aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@tglx.tec.linutronix.de>2005-07-13 10:45:00 +0200
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-07-13 10:45:00 +0200
commit1b3035b7fcc72b6b36f2a3634dad832eb2453ce8 (patch)
tree728174d72943cc9b981a5843553551df62eddc41
parenta98a5d04f400ad112e59cadd739dbabf89417e60 (diff)
parentc32511e2718618f0b53479eb36e07439aa363a74 (diff)
Merge with rsync://fileserver/linux
-rw-r--r--Documentation/acpi-hotkey.txt35
-rw-r--r--Documentation/filesystems/inotify.txt138
-rw-r--r--Documentation/hwmon/adm1021 (renamed from Documentation/i2c/chips/adm1021)0
-rw-r--r--Documentation/hwmon/adm1025 (renamed from Documentation/i2c/chips/adm1025)0
-rw-r--r--Documentation/hwmon/adm1026 (renamed from Documentation/i2c/chips/adm1026)0
-rw-r--r--Documentation/hwmon/adm1031 (renamed from Documentation/i2c/chips/adm1031)0
-rw-r--r--Documentation/hwmon/adm9240 (renamed from Documentation/i2c/chips/adm9240)0
-rw-r--r--Documentation/hwmon/asb100 (renamed from Documentation/i2c/chips/asb100)0
-rw-r--r--Documentation/hwmon/ds1621 (renamed from Documentation/i2c/chips/ds1621)0
-rw-r--r--Documentation/hwmon/fscher (renamed from Documentation/i2c/chips/fscher)0
-rw-r--r--Documentation/hwmon/gl518sm (renamed from Documentation/i2c/chips/gl518sm)0
-rw-r--r--Documentation/hwmon/it87 (renamed from Documentation/i2c/chips/it87)0
-rw-r--r--Documentation/hwmon/lm63 (renamed from Documentation/i2c/chips/lm63)0
-rw-r--r--Documentation/hwmon/lm75 (renamed from Documentation/i2c/chips/lm75)0
-rw-r--r--Documentation/hwmon/lm77 (renamed from Documentation/i2c/chips/lm77)0
-rw-r--r--Documentation/hwmon/lm78 (renamed from Documentation/i2c/chips/lm78)0
-rw-r--r--Documentation/hwmon/lm80 (renamed from Documentation/i2c/chips/lm80)0
-rw-r--r--Documentation/hwmon/lm83 (renamed from Documentation/i2c/chips/lm83)0
-rw-r--r--Documentation/hwmon/lm85 (renamed from Documentation/i2c/chips/lm85)0
-rw-r--r--Documentation/hwmon/lm87 (renamed from Documentation/i2c/chips/lm87)0
-rw-r--r--Documentation/hwmon/lm90 (renamed from Documentation/i2c/chips/lm90)0
-rw-r--r--Documentation/hwmon/lm92 (renamed from Documentation/i2c/chips/lm92)0
-rw-r--r--Documentation/hwmon/max1619 (renamed from Documentation/i2c/chips/max1619)0
-rw-r--r--Documentation/hwmon/pc87360 (renamed from Documentation/i2c/chips/pc87360)0
-rw-r--r--Documentation/hwmon/sis5595 (renamed from Documentation/i2c/chips/sis5595)0
-rw-r--r--Documentation/hwmon/smsc47b397 (renamed from Documentation/i2c/chips/smsc47b397)0
-rw-r--r--Documentation/hwmon/smsc47m1 (renamed from Documentation/i2c/chips/smsc47m1)0
-rw-r--r--Documentation/hwmon/sysfs-interface (renamed from Documentation/i2c/sysfs-interface)0
-rw-r--r--Documentation/hwmon/userspace-tools (renamed from Documentation/i2c/userspace-tools)0
-rw-r--r--Documentation/hwmon/via686a (renamed from Documentation/i2c/chips/via686a)0
-rw-r--r--Documentation/hwmon/w83627hf (renamed from Documentation/i2c/chips/w83627hf)0
-rw-r--r--Documentation/hwmon/w83781d (renamed from Documentation/i2c/chips/w83781d)0
-rw-r--r--Documentation/hwmon/w83l785ts (renamed from Documentation/i2c/chips/w83l785ts)0
-rw-r--r--Documentation/i2c/chips/max687522
-rw-r--r--Documentation/i2c/dev-interface15
-rw-r--r--Documentation/i2c/writing-clients7
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/pcmcia/driver-changes.txt9
-rw-r--r--Documentation/usb/sn9c102.txt4
-rw-r--r--Documentation/usb/usbmon.txt29
-rw-r--r--Documentation/video4linux/CARDLIST.bttv2
-rw-r--r--Documentation/video4linux/CARDLIST.cx882
-rw-r--r--Documentation/video4linux/CARDLIST.saa713414
-rw-r--r--Documentation/video4linux/CARDLIST.tuner4
-rw-r--r--Documentation/video4linux/bttv/Cards74
-rw-r--r--Documentation/video4linux/not-in-cx2388x-datasheet.txt4
-rw-r--r--MAINTAINERS2
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/Kconfig2
-rw-r--r--arch/arm/Kconfig6
-rw-r--r--arch/arm26/Kconfig4
-rw-r--r--arch/cris/Kconfig4
-rw-r--r--arch/frv/Kconfig2
-rw-r--r--arch/frv/mb93090-mb00/pci-irq.c2
-rw-r--r--arch/h8300/Kconfig6
-rw-r--r--arch/i386/Kconfig2
-rw-r--r--arch/i386/kernel/acpi/Makefile4
-rw-r--r--arch/i386/kernel/acpi/cstate.c103
-rw-r--r--arch/i386/kernel/acpi/wakeup.S5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c2
-rw-r--r--arch/i386/kernel/syscall_table.S3
-rw-r--r--arch/i386/pci/irq.c16
-rw-r--r--arch/i386/pci/visws.c2
-rw-r--r--arch/ia64/Kconfig2
-rw-r--r--arch/ia64/kernel/acpi.c54
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/kernel/process.c1
-rw-r--r--arch/ia64/kernel/setup.c3
-rw-r--r--arch/ia64/kernel/topology.c7
-rw-r--r--arch/m32r/Kconfig2
-rw-r--r--arch/m68k/Kconfig2
-rw-r--r--arch/m68knommu/Kconfig2
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/parisc/Kconfig2
-rw-r--r--arch/ppc/Kconfig2
-rw-r--r--arch/ppc/kernel/machine_kexec.c6
-rw-r--r--arch/ppc64/Kconfig2
-rw-r--r--arch/s390/Kconfig4
-rw-r--r--arch/sh/Kconfig2
-rw-r--r--arch/sh64/Kconfig2
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc64/Kconfig6
-rw-r--r--arch/sparc64/kernel/smp.c4
-rw-r--r--arch/um/Kconfig4
-rw-r--r--arch/um/Makefile3
-rw-r--r--arch/v850/Kconfig4
-rw-r--r--arch/x86_64/Kconfig2
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S4
-rw-r--r--arch/xtensa/Kconfig2
-rw-r--r--arch/xtensa/kernel/asm-offsets.c1
-rw-r--r--arch/xtensa/kernel/syscalls.c4
-rw-r--r--arch/xtensa/kernel/syscalls.h6
-rw-r--r--arch/xtensa/kernel/traps.c4
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S6
-rw-r--r--drivers/Kconfig4
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/Kconfig38
-rw-r--r--drivers/acpi/Makefile5
-rw-r--r--drivers/acpi/asus_acpi.c4
-rw-r--r--drivers/acpi/bus.c8
-rw-r--r--drivers/acpi/button.c245
-rw-r--r--drivers/acpi/dispatcher/dsfield.c58
-rw-r--r--drivers/acpi/dispatcher/dsinit.c28
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c11
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c195
-rw-r--r--drivers/acpi/dispatcher/dsobject.c79
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c105
-rw-r--r--drivers/acpi/dispatcher/dsutils.c41
-rw-r--r--drivers/acpi/dispatcher/dswexec.c57
-rw-r--r--drivers/acpi/dispatcher/dswload.c118
-rw-r--r--drivers/acpi/dispatcher/dswscope.c31
-rw-r--r--drivers/acpi/dispatcher/dswstate.c458
-rw-r--r--drivers/acpi/ec.c420
-rw-r--r--drivers/acpi/events/evevent.c33
-rw-r--r--drivers/acpi/events/evgpe.c39
-rw-r--r--drivers/acpi/events/evgpeblk.c63
-rw-r--r--drivers/acpi/events/evmisc.c97
-rw-r--r--drivers/acpi/events/evregion.c35
-rw-r--r--drivers/acpi/events/evrgnini.c14
-rw-r--r--drivers/acpi/events/evsci.c12
-rw-r--r--drivers/acpi/events/evxface.c19
-rw-r--r--drivers/acpi/events/evxfevnt.c25
-rw-r--r--drivers/acpi/executer/exconfig.c31
-rw-r--r--drivers/acpi/executer/exconvrt.c44
-rw-r--r--drivers/acpi/executer/excreate.c50
-rw-r--r--drivers/acpi/executer/exdump.c105
-rw-r--r--drivers/acpi/executer/exfield.c25
-rw-r--r--drivers/acpi/executer/exfldio.c133
-rw-r--r--drivers/acpi/executer/exmisc.c7
-rw-r--r--drivers/acpi/executer/exmutex.c45
-rw-r--r--drivers/acpi/executer/exnames.c70
-rw-r--r--drivers/acpi/executer/exoparg1.c94
-rw-r--r--drivers/acpi/executer/exoparg2.c69
-rw-r--r--drivers/acpi/executer/exoparg3.c25
-rw-r--r--drivers/acpi/executer/exoparg6.c26
-rw-r--r--drivers/acpi/executer/exprep.c104
-rw-r--r--drivers/acpi/executer/exregion.c34
-rw-r--r--drivers/acpi/executer/exresnte.c24
-rw-r--r--drivers/acpi/executer/exresolv.c63
-rw-r--r--drivers/acpi/executer/exresop.c80
-rw-r--r--drivers/acpi/executer/exstore.c260
-rw-r--r--drivers/acpi/executer/exstoren.c20
-rw-r--r--drivers/acpi/executer/exstorob.c9
-rw-r--r--drivers/acpi/executer/exsystem.c48
-rw-r--r--drivers/acpi/executer/exutils.c37
-rw-r--r--drivers/acpi/glue.c360
-rw-r--r--drivers/acpi/hardware/hwacpi.c19
-rw-r--r--drivers/acpi/hardware/hwgpe.c31
-rw-r--r--drivers/acpi/hardware/hwregs.c114
-rw-r--r--drivers/acpi/hardware/hwsleep.c101
-rw-r--r--drivers/acpi/hardware/hwtimer.c4
-rw-r--r--drivers/acpi/hotkey.c1019
-rw-r--r--drivers/acpi/ibm_acpi.c8
-rw-r--r--drivers/acpi/namespace/nsaccess.c5
-rw-r--r--drivers/acpi/namespace/nsalloc.c121
-rw-r--r--drivers/acpi/namespace/nsdump.c109
-rw-r--r--drivers/acpi/namespace/nsdumpdv.c18
-rw-r--r--drivers/acpi/namespace/nseval.c70
-rw-r--r--drivers/acpi/namespace/nsinit.c28
-rw-r--r--drivers/acpi/namespace/nsload.c28
-rw-r--r--drivers/acpi/namespace/nsnames.c12
-rw-r--r--drivers/acpi/namespace/nsobject.c14
-rw-r--r--drivers/acpi/namespace/nssearch.c29
-rw-r--r--drivers/acpi/namespace/nsutils.c167
-rw-r--r--drivers/acpi/namespace/nswalk.c2
-rw-r--r--drivers/acpi/namespace/nsxfeval.c16
-rw-r--r--drivers/acpi/namespace/nsxfname.c8
-rw-r--r--drivers/acpi/namespace/nsxfobj.c4
-rw-r--r--drivers/acpi/osl.c12
-rw-r--r--drivers/acpi/parser/psargs.c55
-rw-r--r--drivers/acpi/parser/psopcode.c298
-rw-r--r--drivers/acpi/parser/psparse.c144
-rw-r--r--drivers/acpi/parser/psscope.c45
-rw-r--r--drivers/acpi/parser/pstree.c159
-rw-r--r--drivers/acpi/parser/psutils.c15
-rw-r--r--drivers/acpi/parser/pswalk.c11
-rw-r--r--drivers/acpi/parser/psxface.c21
-rw-r--r--drivers/acpi/pci_link.c43
-rw-r--r--drivers/acpi/processor_core.c37
-rw-r--r--drivers/acpi/processor_idle.c138
-rw-r--r--drivers/acpi/processor_perflib.c33
-rw-r--r--drivers/acpi/resources/rsaddr.c480
-rw-r--r--drivers/acpi/resources/rscalc.c144
-rw-r--r--drivers/acpi/resources/rscreate.c45
-rw-r--r--drivers/acpi/resources/rsdump.c402
-rw-r--r--drivers/acpi/resources/rsio.c197
-rw-r--r--drivers/acpi/resources/rsirq.c167
-rw-r--r--drivers/acpi/resources/rslist.c68
-rw-r--r--drivers/acpi/resources/rsmemory.c236
-rw-r--r--drivers/acpi/resources/rsmisc.c160
-rw-r--r--drivers/acpi/resources/rsutils.c53
-rw-r--r--drivers/acpi/resources/rsxface.c43
-rw-r--r--drivers/acpi/scan.c12
-rw-r--r--drivers/acpi/sleep/main.c74
-rw-r--r--drivers/acpi/sleep/poweroff.c81
-rw-r--r--drivers/acpi/sleep/proc.c9
-rw-r--r--drivers/acpi/tables/tbconvrt.c105
-rw-r--r--drivers/acpi/tables/tbget.c63
-rw-r--r--drivers/acpi/tables/tbgetall.c45
-rw-r--r--drivers/acpi/tables/tbinstal.c31
-rw-r--r--drivers/acpi/tables/tbrsdt.c19
-rw-r--r--drivers/acpi/tables/tbutils.c97
-rw-r--r--drivers/acpi/tables/tbxface.c39
-rw-r--r--drivers/acpi/tables/tbxfroot.c123
-rw-r--r--drivers/acpi/toshiba_acpi.c8
-rw-r--r--drivers/acpi/utilities/utalloc.c84
-rw-r--r--drivers/acpi/utilities/utcopy.c126
-rw-r--r--drivers/acpi/utilities/utdebug.c106
-rw-r--r--drivers/acpi/utilities/utdelete.c63
-rw-r--r--drivers/acpi/utilities/uteval.c36
-rw-r--r--drivers/acpi/utilities/utglobal.c133
-rw-r--r--drivers/acpi/utilities/utinit.c36
-rw-r--r--drivers/acpi/utilities/utmath.c2
-rw-r--r--drivers/acpi/utilities/utmisc.c187
-rw-r--r--drivers/acpi/utilities/utobject.c68
-rw-r--r--drivers/acpi/utilities/utxface.c61
-rw-r--r--drivers/acpi/video.c15
-rw-r--r--drivers/base/sys.c1
-rw-r--r--drivers/char/tb0219.c19
-rw-r--r--drivers/hwmon/Kconfig420
-rw-r--r--drivers/hwmon/Makefile44
-rw-r--r--drivers/hwmon/adm1021.c (renamed from drivers/i2c/chips/adm1021.c)0
-rw-r--r--drivers/hwmon/adm1025.c (renamed from drivers/i2c/chips/adm1025.c)0
-rw-r--r--drivers/hwmon/adm1026.c (renamed from drivers/i2c/chips/adm1026.c)0
-rw-r--r--drivers/hwmon/adm1031.c (renamed from drivers/i2c/chips/adm1031.c)0
-rw-r--r--drivers/hwmon/adm9240.c (renamed from drivers/i2c/chips/adm9240.c)0
-rw-r--r--drivers/hwmon/asb100.c (renamed from drivers/i2c/chips/asb100.c)0
-rw-r--r--drivers/hwmon/atxp1.c (renamed from drivers/i2c/chips/atxp1.c)0
-rw-r--r--drivers/hwmon/ds1621.c (renamed from drivers/i2c/chips/ds1621.c)0
-rw-r--r--drivers/hwmon/fscher.c (renamed from drivers/i2c/chips/fscher.c)0
-rw-r--r--drivers/hwmon/fscpos.c (renamed from drivers/i2c/chips/fscpos.c)0
-rw-r--r--drivers/hwmon/gl518sm.c (renamed from drivers/i2c/chips/gl518sm.c)0
-rw-r--r--drivers/hwmon/gl520sm.c (renamed from drivers/i2c/chips/gl520sm.c)0
-rw-r--r--drivers/hwmon/it87.c (renamed from drivers/i2c/chips/it87.c)0
-rw-r--r--drivers/hwmon/lm63.c (renamed from drivers/i2c/chips/lm63.c)0
-rw-r--r--drivers/hwmon/lm75.c (renamed from drivers/i2c/chips/lm75.c)0
-rw-r--r--drivers/hwmon/lm75.h (renamed from drivers/i2c/chips/lm75.h)0
-rw-r--r--drivers/hwmon/lm77.c (renamed from drivers/i2c/chips/lm77.c)0
-rw-r--r--drivers/hwmon/lm78.c (renamed from drivers/i2c/chips/lm78.c)0
-rw-r--r--drivers/hwmon/lm80.c (renamed from drivers/i2c/chips/lm80.c)0
-rw-r--r--drivers/hwmon/lm83.c (renamed from drivers/i2c/chips/lm83.c)0
-rw-r--r--drivers/hwmon/lm85.c (renamed from drivers/i2c/chips/lm85.c)0
-rw-r--r--drivers/hwmon/lm87.c (renamed from drivers/i2c/chips/lm87.c)0
-rw-r--r--drivers/hwmon/lm90.c (renamed from drivers/i2c/chips/lm90.c)0
-rw-r--r--drivers/hwmon/lm92.c (renamed from drivers/i2c/chips/lm92.c)0
-rw-r--r--drivers/hwmon/max1619.c (renamed from drivers/i2c/chips/max1619.c)0
-rw-r--r--drivers/hwmon/pc87360.c (renamed from drivers/i2c/chips/pc87360.c)0
-rw-r--r--drivers/hwmon/sis5595.c (renamed from drivers/i2c/chips/sis5595.c)0
-rw-r--r--drivers/hwmon/smsc47b397.c (renamed from drivers/i2c/chips/smsc47b397.c)0
-rw-r--r--drivers/hwmon/smsc47m1.c (renamed from drivers/i2c/chips/smsc47m1.c)0
-rw-r--r--drivers/hwmon/via686a.c (renamed from drivers/i2c/chips/via686a.c)12
-rw-r--r--drivers/hwmon/w83627ehf.c (renamed from drivers/i2c/chips/w83627ehf.c)0
-rw-r--r--drivers/hwmon/w83627hf.c (renamed from drivers/i2c/chips/w83627hf.c)0
-rw-r--r--drivers/hwmon/w83781d.c (renamed from drivers/i2c/chips/w83781d.c)0
-rw-r--r--drivers/hwmon/w83l785ts.c (renamed from drivers/i2c/chips/w83l785ts.c)0
-rw-r--r--drivers/i2c/algos/i2c-algo-ite.c8
-rw-r--r--drivers/i2c/busses/i2c-i801.c4
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/chips/Kconfig413
-rw-r--r--drivers/i2c/chips/Makefile38
-rw-r--r--drivers/i2c/chips/eeprom.c3
-rw-r--r--drivers/i2c/chips/m41t00.c2
-rw-r--r--drivers/i2c/chips/max6875.c6
-rw-r--r--drivers/i2c/chips/tps65010.c59
-rw-r--r--drivers/i2c/i2c-core.c17
-rw-r--r--drivers/ide/ide-cd.c4
-rw-r--r--drivers/md/dm-mpath.c68
-rw-r--r--drivers/md/dm-snap.c6
-rw-r--r--drivers/md/dm-table.c1
-rw-r--r--drivers/md/dm.c27
-rw-r--r--drivers/media/common/ir-common.c255
-rw-r--r--drivers/media/dvb/bt8xx/dst.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c6
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c4
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.c64
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c2
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c2
-rw-r--r--drivers/media/video/Kconfig13
-rw-r--r--drivers/media/video/bt832.c12
-rw-r--r--drivers/media/video/bttv-cards.c110
-rw-r--r--drivers/media/video/bttv-driver.c19
-rw-r--r--drivers/media/video/bttv-i2c.c26
-rw-r--r--drivers/media/video/bttv-risc.c9
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--drivers/media/video/cx88/cx88-core.c48
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c39
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c31
-rw-r--r--drivers/media/video/cx88/cx88-input.c448
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c26
-rw-r--r--drivers/media/video/cx88/cx88-reg.h11
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c76
-rw-r--r--drivers/media/video/cx88/cx88-video.c303
-rw-r--r--drivers/media/video/cx88/cx88.h12
-rw-r--r--drivers/media/video/ir-kbd-i2c.c51
-rw-r--r--drivers/media/video/msp3400.c25
-rw-r--r--drivers/media/video/mt20xx.c16
-rw-r--r--drivers/media/video/mxb.c7
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c2096
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c74
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c423
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c45
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c48
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c19
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c121
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c12
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c54
-rw-r--r--drivers/media/video/saa7134/saa7134.h21
-rw-r--r--drivers/media/video/tda7432.c13
-rw-r--r--drivers/media/video/tda8290.c13
-rw-r--r--drivers/media/video/tda9875.c13
-rw-r--r--drivers/media/video/tda9887.c9
-rw-r--r--drivers/media/video/tea5767.c158
-rw-r--r--drivers/media/video/tuner-3036.c2
-rw-r--r--drivers/media/video/tuner-core.c707
-rw-r--r--drivers/media/video/tuner-simple.c85
-rw-r--r--drivers/media/video/tvaudio.c5
-rw-r--r--drivers/media/video/tveeprom.c9
-rw-r--r--drivers/misc/Kconfig5
-rw-r--r--drivers/net/Kconfig3
-rw-r--r--drivers/net/appletalk/Kconfig27
-rw-r--r--drivers/net/b44.c3
-rw-r--r--drivers/net/myri_sbus.c2
-rw-r--r--drivers/net/ne2k-pci.c3
-rw-r--r--drivers/net/plip.c2
-rw-r--r--drivers/net/wan/farsync.c3
-rw-r--r--drivers/net/wan/hdlc_cisco.c3
-rw-r--r--drivers/net/wan/hdlc_ppp.c3
-rw-r--r--drivers/net/wan/hdlc_raw.c3
-rw-r--r--drivers/pci/pci-acpi.c110
-rw-r--r--drivers/pci/pci.c22
-rw-r--r--drivers/pci/pci.h4
-rw-r--r--drivers/pcmcia/yenta_socket.c163
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c15
-rw-r--r--drivers/pnp/pnpbios/rsparser.c2
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/s390/net/qeth_main.c2
-rw-r--r--drivers/scsi/aacraid/commctrl.c2
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c2
-rw-r--r--drivers/usb/atm/speedtch.c63
-rw-r--r--drivers/usb/class/cdc-acm.c31
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/hcd-pci.c1
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hcd.h8
-rw-r--r--drivers/usb/core/hub.c40
-rw-r--r--drivers/usb/core/message.c2
-rw-r--r--drivers/usb/core/sysfs.c2
-rw-r--r--drivers/usb/core/urb.c4
-rw-r--r--drivers/usb/core/usb.c5
-rw-r--r--drivers/usb/gadget/dummy_hcd.c9
-rw-r--r--drivers/usb/gadget/ether.c22
-rw-r--r--drivers/usb/gadget/goku_udc.c6
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c6
-rw-r--r--drivers/usb/gadget/net2280.c8
-rw-r--r--drivers/usb/gadget/omap_udc.c9
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c6
-rw-r--r--drivers/usb/gadget/zero.c8
-rw-r--r--drivers/usb/host/ehci-hcd.c2
-rw-r--r--drivers/usb/host/ehci-q.c2
-rw-r--r--drivers/usb/host/ehci-sched.c19
-rw-r--r--drivers/usb/host/hc_crisv10.c10
-rw-r--r--drivers/usb/host/isp116x-hcd.c20
-rw-r--r--drivers/usb/host/ohci-hcd.c6
-rw-r--r--drivers/usb/host/ohci-hub.c3
-rw-r--r--drivers/usb/host/ohci-mem.c4
-rw-r--r--drivers/usb/host/ohci-omap.c53
-rw-r--r--drivers/usb/host/sl811-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/input/Kconfig13
-rw-r--r--drivers/usb/input/Makefile1
-rw-r--r--drivers/usb/input/hid-core.c24
-rw-r--r--drivers/usb/input/keyspan_remote.c633
-rw-r--r--drivers/usb/media/Makefile2
-rw-r--r--drivers/usb/media/sn9c102.h2
-rw-r--r--drivers/usb/media/sn9c102_core.c2
-rw-r--r--drivers/usb/media/sn9c102_ov7630.c394
-rw-r--r--drivers/usb/media/sn9c102_sensor.h16
-rw-r--r--drivers/usb/media/sn9c102_tas5110c1b.c21
-rw-r--r--drivers/usb/media/sn9c102_tas5130d1b.c27
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/ldusb.c794
-rw-r--r--drivers/usb/mon/mon_text.c48
-rw-r--r--drivers/usb/net/kaweth.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c756
-rw-r--r--drivers/usb/storage/unusual_devs.h2
-rw-r--r--drivers/w1/w1.c5
-rw-r--r--fs/Kconfig13
-rw-r--r--fs/Makefile1
-rw-r--r--fs/attr.c33
-rw-r--r--fs/char_dev.c3
-rw-r--r--fs/compat.c12
-rw-r--r--fs/exec.c12
-rw-r--r--fs/ext2/ext2.h9
-rw-r--r--fs/ext2/super.c24
-rw-r--r--fs/ext3/super.c70
-rw-r--r--fs/file_table.c3
-rw-r--r--fs/inode.c43
-rw-r--r--fs/inotify.c999
-rw-r--r--fs/namei.c30
-rw-r--r--fs/nfsd/vfs.c6
-rw-r--r--fs/open.c3
-rw-r--r--fs/read_write.c15
-rw-r--r--fs/reiserfs/bitmap.c1842
-rw-r--r--fs/reiserfs/dir.c488
-rw-r--r--fs/reiserfs/do_balan.c3236
-rw-r--r--fs/reiserfs/file.c2564
-rw-r--r--fs/reiserfs/fix_node.c4051
-rw-r--r--fs/reiserfs/hashes.c193
-rw-r--r--fs/reiserfs/ibalance.c1844
-rw-r--r--fs/reiserfs/inode.c4915
-rw-r--r--fs/reiserfs/ioctl.c197
-rw-r--r--fs/reiserfs/item_ops.c979
-rw-r--r--fs/reiserfs/journal.c6855
-rw-r--r--fs/reiserfs/lbalance.c2218
-rw-r--r--fs/reiserfs/namei.c2574
-rw-r--r--fs/reiserfs/objectid.c303
-rw-r--r--fs/reiserfs/prints.c1003
-rw-r--r--fs/reiserfs/procfs.c695
-rw-r--r--fs/reiserfs/resize.c207
-rw-r--r--fs/reiserfs/stree.c3369
-rw-r--r--fs/reiserfs/super.c3623
-rw-r--r--fs/reiserfs/tail_conversion.c463
-rw-r--r--fs/reiserfs/xattr.c2173
-rw-r--r--fs/reiserfs/xattr_acl.c641
-rw-r--r--fs/reiserfs/xattr_security.c54
-rw-r--r--fs/reiserfs/xattr_trusted.c70
-rw-r--r--fs/reiserfs/xattr_user.c89
-rw-r--r--fs/sysfs/file.c7
-rw-r--r--fs/xattr.c5
-rw-r--r--include/acpi/acconfig.h7
-rw-r--r--include/acpi/acdebug.h146
-rw-r--r--include/acpi/acdisasm.h114
-rw-r--r--include/acpi/acdispat.h171
-rw-r--r--include/acpi/acevents.h85
-rw-r--r--include/acpi/acexcep.h5
-rw-r--r--include/acpi/acglobal.h12
-rw-r--r--include/acpi/achware.h52
-rw-r--r--include/acpi/acinterp.h243
-rw-r--r--include/acpi/aclocal.h10
-rw-r--r--include/acpi/acmacros.h10
-rw-r--r--include/acpi/acnames.h84
-rw-r--r--include/acpi/acnamesp.h163
-rw-r--r--include/acpi/acobject.h2
-rw-r--r--include/acpi/acopcode.h325
-rw-r--r--include/acpi/acparser.h134
-rw-r--r--include/acpi/acpi.h1
-rw-r--r--include/acpi/acpi_bus.h21
-rw-r--r--include/acpi/acpi_drivers.h5
-rw-r--r--include/acpi/acpiosxf.h18
-rw-r--r--include/acpi/acpixf.h13
-rw-r--r--include/acpi/acresrc.h67
-rw-r--r--include/acpi/acstruct.h1
-rw-r--r--include/acpi/actables.h70
-rw-r--r--include/acpi/actbl.h2
-rw-r--r--include/acpi/actypes.h2
-rw-r--r--include/acpi/acutils.h274
-rw-r--r--include/acpi/amlcode.h12
-rw-r--r--include/acpi/pdc_intel.h29
-rw-r--r--include/acpi/platform/acenv.h20
-rw-r--r--include/acpi/processor.h34
-rw-r--r--include/asm-alpha/pci.h2
-rw-r--r--include/asm-alpha/pgtable.h4
-rw-r--r--include/asm-arm/pci.h2
-rw-r--r--include/asm-h8300/pci.h2
-rw-r--r--include/asm-i386/acpi.h10
-rw-r--r--include/asm-i386/apicdef.h6
-rw-r--r--include/asm-i386/pci.h2
-rw-r--r--include/asm-i386/unistd.h5
-rw-r--r--include/asm-ia64/acpi.h9
-rw-r--r--include/asm-ia64/pci.h2
-rw-r--r--include/asm-m68k/pci.h2
-rw-r--r--include/asm-mips/pci.h2
-rw-r--r--include/asm-ppc/kexec.h2
-rw-r--r--include/asm-ppc/pci.h2
-rw-r--r--include/asm-ppc64/pci.h2
-rw-r--r--include/asm-sh/pci.h2
-rw-r--r--include/asm-sh64/pci.h2
-rw-r--r--include/asm-sparc/pci.h2
-rw-r--r--include/asm-sparc64/pci.h2
-rw-r--r--include/asm-um/mmu_context.h4
-rw-r--r--include/asm-x86_64/acpi.h8
-rw-r--r--include/asm-x86_64/pci.h2
-rw-r--r--include/linux/acpi.h7
-rw-r--r--include/linux/device.h6
-rw-r--r--include/linux/etherdevice.h2
-rw-r--r--include/linux/ext3_fs.h14
-rw-r--r--include/linux/fddidevice.h2
-rw-r--r--include/linux/fs.h6
-rw-r--r--include/linux/fsnotify.h248
-rw-r--r--include/linux/hardirq.h1
-rw-r--r--include/linux/hdlc.h4
-rw-r--r--include/linux/inotify.h108
-rw-r--r--include/linux/mount.h2
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/pm.h2
-rw-r--r--include/linux/reiserfs_acl.h52
-rw-r--r--include/linux/reiserfs_fs.h1595
-rw-r--r--include/linux/reiserfs_fs_i.h59
-rw-r--r--include/linux/reiserfs_fs_sb.h616
-rw-r--r--include/linux/reiserfs_xattr.h126
-rw-r--r--include/linux/sched.h4
-rw-r--r--include/linux/swap.h2
-rw-r--r--include/linux/sysctl.h11
-rw-r--r--include/linux/usb.h8
-rw-r--r--include/linux/usb_cdc.h13
-rw-r--r--include/linux/usb_gadget.h12
-rw-r--r--include/linux/wanrouter.h3
-rw-r--r--include/media/audiochip.h3
-rw-r--r--include/media/saa6752hs.h49
-rw-r--r--include/media/tuner.h51
-rw-r--r--include/net/sctp/sctp.h3
-rw-r--r--include/net/sctp/sm.h11
-rw-r--r--include/net/sctp/structs.h30
-rw-r--r--include/net/sctp/ulpevent.h16
-rw-r--r--include/net/sctp/ulpqueue.h11
-rw-r--r--include/net/x25device.h3
-rw-r--r--include/pcmcia/ds.h5
-rw-r--r--init/do_mounts.c1
-rw-r--r--init/do_mounts.h1
-rw-r--r--ipc/util.h2
-rw-r--r--kernel/fork.c4
-rw-r--r--kernel/power/disk.c2
-rw-r--r--kernel/power/main.c16
-rw-r--r--kernel/power/swsusp.c3
-rw-r--r--kernel/sys_ni.c3
-rw-r--r--kernel/sysctl.c43
-rw-r--r--kernel/user.c4
-rw-r--r--mm/filemap_xip.c2
-rw-r--r--net/802/fddi.c4
-rw-r--r--net/8021q/Kconfig19
-rw-r--r--net/8021q/vlan.c8
-rw-r--r--net/Kconfig456
-rw-r--r--net/atm/Kconfig74
-rw-r--r--net/atm/br2684.c3
-rw-r--r--net/bridge/Kconfig31
-rw-r--r--net/decnet/Kconfig23
-rw-r--r--net/econet/Kconfig36
-rw-r--r--net/ethernet/eth.c2
-rw-r--r--net/ipv4/Kconfig25
-rw-r--r--net/ipv4/ip_output.c9
-rw-r--r--net/ipv4/ipvs/Kconfig4
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c6
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c9
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c7
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/ipv6/Kconfig22
-rw-r--r--net/ipx/Kconfig33
-rw-r--r--net/lapb/Kconfig22
-rw-r--r--net/packet/Kconfig26
-rw-r--r--net/packet/af_packet.c6
-rw-r--r--net/sched/Kconfig37
-rw-r--r--net/sctp/associola.c13
-rw-r--r--net/sctp/bind_addr.c16
-rw-r--r--net/sctp/chunk.c2
-rw-r--r--net/sctp/endpointola.c6
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/sctp/sm_make_chunk.c15
-rw-r--r--net/sctp/sm_sideeffect.c13
-rw-r--r--net/sctp/ssnmap.c3
-rw-r--r--net/sctp/transport.c5
-rw-r--r--net/sctp/ulpevent.c19
-rw-r--r--net/sctp/ulpqueue.c9
-rw-r--r--net/unix/Kconfig21
-rw-r--r--net/wanrouter/Kconfig29
-rw-r--r--net/wanrouter/wanmain.c6
-rw-r--r--net/x25/Kconfig36
-rw-r--r--net/xfrm/Kconfig15
573 files changed, 40727 insertions, 33107 deletions
diff --git a/Documentation/acpi-hotkey.txt b/Documentation/acpi-hotkey.txt
new file mode 100644
index 00000000000..4c115a7bb82
--- /dev/null
+++ b/Documentation/acpi-hotkey.txt
@@ -0,0 +1,35 @@
+driver/acpi/hotkey.c implement:
+1. /proc/acpi/hotkey/event_config
+(event based hotkey or event config interface):
+a. add a event based hotkey(event) :
+echo "0:bus::action:method:num:num" > event_config
+
+b. delete a event based hotkey(event):
+echo "1:::::num:num" > event_config
+
+c. modify a event based hotkey(event):
+echo "2:bus::action:method:num:num" > event_config
+
+2. /proc/acpi/hotkey/poll_config
+(polling based hotkey or event config interface):
+a.add a polling based hotkey(event) :
+echo "0:bus:method:action:method:num" > poll_config
+this adding command will create a proc file
+/proc/acpi/hotkey/method, which is used to get
+result of polling.
+
+b.delete a polling based hotkey(event):
+echo "1:::::num" > event_config
+
+c.modify a polling based hotkey(event):
+echo "2:bus:method:action:method:num" > poll_config
+
+3./proc/acpi/hotkey/action
+(interface to call aml method associated with a
+specific hotkey(event))
+echo "event_num:event_type:event_argument" >
+ /proc/acpi/hotkey/action.
+The result of the execution of this aml method is
+attached to /proc/acpi/hotkey/poll_method, which is dnyamically
+created. Please use command "cat /proc/acpi/hotkey/polling_method"
+to retrieve it.
diff --git a/Documentation/filesystems/inotify.txt b/Documentation/filesystems/inotify.txt
new file mode 100644
index 00000000000..2c716041f57
--- /dev/null
+++ b/Documentation/filesystems/inotify.txt
@@ -0,0 +1,138 @@
+ inotify
+ a powerful yet simple file change notification system
+
+
+
+Document started 15 Mar 2005 by Robert Love <rml@novell.com>
+
+(i) User Interface
+
+Inotify is controlled by a set of three sys calls
+
+First step in using inotify is to initialise an inotify instance
+
+ int fd = inotify_init ();
+
+Change events are managed by "watches". A watch is an (object,mask) pair where
+the object is a file or directory and the mask is a bit mask of one or more
+inotify events that the application wishes to receive. See <linux/inotify.h>
+for valid events. A watch is referenced by a watch descriptor, or wd.
+
+Watches are added via a path to the file.
+
+Watches on a directory will return events on any files inside of the directory.
+
+Adding a watch is simple,
+
+ int wd = inotify_add_watch (fd, path, mask);
+
+You can add a large number of files via something like
+
+ for each file to watch {
+ int wd = inotify_add_watch (fd, file, mask);
+ }
+
+You can update an existing watch in the same manner, by passing in a new mask.
+
+An existing watch is removed via the INOTIFY_IGNORE ioctl, for example
+
+ inotify_rm_watch (fd, wd);
+
+Events are provided in the form of an inotify_event structure that is read(2)
+from a inotify instance fd. The filename is of dynamic length and follows the
+struct. It is of size len. The filename is padded with null bytes to ensure
+proper alignment. This padding is reflected in len.
+
+You can slurp multiple events by passing a large buffer, for example
+
+ size_t len = read (fd, buf, BUF_LEN);
+
+Will return as many events as are available and fit in BUF_LEN.
+
+each inotify instance fd is also select()- and poll()-able.
+
+You can find the size of the current event queue via the FIONREAD ioctl.
+
+All watches are destroyed and cleaned up on close.
+
+
+(ii) Internal Kernel Implementation
+
+Each open inotify instance is associated with an inotify_device structure.
+
+Each watch is associated with an inotify_watch structure. Watches are chained
+off of each associated device and each associated inode.
+
+See fs/inotify.c for the locking and lifetime rules.
+
+
+(iii) Rationale
+
+Q: What is the design decision behind not tying the watch to the open fd of
+ the watched object?
+
+A: Watches are associated with an open inotify device, not an open file.
+ This solves the primary problem with dnotify: keeping the file open pins
+ the file and thus, worse, pins the mount. Dnotify is therefore infeasible
+ for use on a desktop system with removable media as the media cannot be
+ unmounted.
+
+Q: What is the design decision behind using an-fd-per-device as opposed to
+ an fd-per-watch?
+
+A: An fd-per-watch quickly consumes more file descriptors than are allowed,
+ more fd's than are feasible to manage, and more fd's than are optimally
+ select()-able. Yes, root can bump the per-process fd limit and yes, users
+ can use epoll, but requiring both is a silly and extraneous requirement.
+ A watch consumes less memory than an open file, separating the number
+ spaces is thus sensible. The current design is what user-space developers
+ want: Users initialize inotify, once, and add n watches, requiring but one fd
+ and no twiddling with fd limits. Initializing an inotify instance two
+ thousand times is silly. If we can implement user-space's preferences
+ cleanly--and we can, the idr layer makes stuff like this trivial--then we
+ should.
+
+ There are other good arguments. With a single fd, there is a single
+ item to block on, which is mapped to a single queue of events. The single
+ fd returns all watch events and also any potential out-of-band data. If
+ every fd was a separate watch,
+
+ - There would be no way to get event ordering. Events on file foo and
+ file bar would pop poll() on both fd's, but there would be no way to tell
+ which happened first. A single queue trivially gives you ordering. Such
+ ordering is crucial to existing applications such as Beagle. Imagine
+ "mv a b ; mv b a" events without ordering.
+
+ - We'd have to maintain n fd's and n internal queues with state,
+ versus just one. It is a lot messier in the kernel. A single, linear
+ queue is the data structure that makes sense.
+
+ - User-space developers prefer the current API. The Beagle guys, for
+ example, love it. Trust me, I asked. It is not a surprise: Who'd want
+ to manage and block on 1000 fd's via select?
+
+ - You'd have to manage the fd's, as an example: Call close() when you
+ received a delete event.
+
+ - No way to get out of band data.
+
+ - 1024 is still too low. ;-)
+
+ When you talk about designing a file change notification system that
+ scales to 1000s of directories, juggling 1000s of fd's just does not seem
+ the right interface. It is too heavy.
+
+Q: Why the system call approach?
+
+A: The poor user-space interface is the second biggest problem with dnotify.
+ Signals are a terrible, terrible interface for file notification. Or for
+ anything, for that matter. The ideal solution, from all perspectives, is a
+ file descriptor-based one that allows basic file I/O and poll/select.
+ Obtaining the fd and managing the watches could have been done either via a
+ device file or a family of new system calls. We decided to implement a
+ family of system calls because that is the preffered approach for new kernel
+ features and it means our user interface requirements.
+
+ Additionally, it _is_ possible to more than one instance and
+ juggle more than one queue and thus more than one associated fd.
+
diff --git a/Documentation/i2c/chips/adm1021 b/Documentation/hwmon/adm1021
index 03d02bfb3df..03d02bfb3df 100644
--- a/Documentation/i2c/chips/adm1021
+++ b/Documentation/hwmon/adm1021
diff --git a/Documentation/i2c/chips/adm1025 b/Documentation/hwmon/adm1025
index 39d2b781b5d..39d2b781b5d 100644
--- a/Documentation/i2c/chips/adm1025
+++ b/Documentation/hwmon/adm1025
diff --git a/Documentation/i2c/chips/adm1026 b/Documentation/hwmon/adm1026
index 473c689d792..473c689d792 100644
--- a/Documentation/i2c/chips/adm1026
+++ b/Documentation/hwmon/adm1026
diff --git a/Documentation/i2c/chips/adm1031 b/Documentation/hwmon/adm1031
index 130a38382b9..130a38382b9 100644
--- a/Documentation/i2c/chips/adm1031
+++ b/Documentation/hwmon/adm1031
diff --git a/Documentation/i2c/chips/adm9240 b/Documentation/hwmon/adm9240
index 35f618f3289..35f618f3289 100644
--- a/Documentation/i2c/chips/adm9240
+++ b/Documentation/hwmon/adm9240
diff --git a/Documentation/i2c/chips/asb100 b/Documentation/hwmon/asb100
index ab7365e139b..ab7365e139b 100644
--- a/Documentation/i2c/chips/asb100
+++ b/Documentation/hwmon/asb100
diff --git a/Documentation/i2c/chips/ds1621 b/Documentation/hwmon/ds1621
index 1fee6f1e6bc..1fee6f1e6bc 100644
--- a/Documentation/i2c/chips/ds1621
+++ b/Documentation/hwmon/ds1621
diff --git a/Documentation/i2c/chips/fscher b/Documentation/hwmon/fscher
index 64031659aff..64031659aff 100644
--- a/Documentation/i2c/chips/fscher
+++ b/Documentation/hwmon/fscher
diff --git a/Documentation/i2c/chips/gl518sm b/Documentation/hwmon/gl518sm
index ce0881883bc..ce0881883bc 100644
--- a/Documentation/i2c/chips/gl518sm
+++ b/Documentation/hwmon/gl518sm
diff --git a/Documentation/i2c/chips/it87 b/Documentation/hwmon/it87
index 0d0195040d8..0d0195040d8 100644
--- a/Documentation/i2c/chips/it87
+++ b/Documentation/hwmon/it87
diff --git a/Documentation/i2c/chips/lm63 b/Documentation/hwmon/lm63
index 31660bf9797..31660bf9797 100644
--- a/Documentation/i2c/chips/lm63
+++ b/Documentation/hwmon/lm63
diff --git a/Documentation/i2c/chips/lm75 b/Documentation/hwmon/lm75
index 8e6356fe05d..8e6356fe05d 100644
--- a/Documentation/i2c/chips/lm75
+++ b/Documentation/hwmon/lm75
diff --git a/Documentation/i2c/chips/lm77 b/Documentation/hwmon/lm77
index 57c3a46d637..57c3a46d637 100644
--- a/Documentation/i2c/chips/lm77
+++ b/Documentation/hwmon/lm77
diff --git a/Documentation/i2c/chips/lm78 b/Documentation/hwmon/lm78
index 357086ed7f6..357086ed7f6 100644
--- a/Documentation/i2c/chips/lm78
+++ b/Documentation/hwmon/lm78
diff --git a/Documentation/i2c/chips/lm80 b/Documentation/hwmon/lm80
index cb5b407ba3e..cb5b407ba3e 100644
--- a/Documentation/i2c/chips/lm80
+++ b/Documentation/hwmon/lm80
diff --git a/Documentation/i2c/chips/lm83 b/Documentation/hwmon/lm83
index 061d9ed8ff4..061d9ed8ff4 100644
--- a/Documentation/i2c/chips/lm83
+++ b/Documentation/hwmon/lm83
diff --git a/Documentation/i2c/chips/lm85 b/Documentation/hwmon/lm85
index 9549237530c..9549237530c 100644
--- a/Documentation/i2c/chips/lm85
+++ b/Documentation/hwmon/lm85
diff --git a/Documentation/i2c/chips/lm87 b/Documentation/hwmon/lm87
index c952c57f0e1..c952c57f0e1 100644
--- a/Documentation/i2c/chips/lm87
+++ b/Documentation/hwmon/lm87
diff --git a/Documentation/i2c/chips/lm90 b/Documentation/hwmon/lm90
index 2c4cf39471f..2c4cf39471f 100644
--- a/Documentation/i2c/chips/lm90
+++ b/Documentation/hwmon/lm90
diff --git a/Documentation/i2c/chips/lm92 b/Documentation/hwmon/lm92
index 7705bfaa070..7705bfaa070 100644
--- a/Documentation/i2c/chips/lm92
+++ b/Documentation/hwmon/lm92
diff --git a/Documentation/i2c/chips/max1619 b/Documentation/hwmon/max1619
index d6f8d9cd7d7..d6f8d9cd7d7 100644
--- a/Documentation/i2c/chips/max1619
+++ b/Documentation/hwmon/max1619
diff --git a/Documentation/i2c/chips/pc87360 b/Documentation/hwmon/pc87360
index 89a8fcfa78d..89a8fcfa78d 100644
--- a/Documentation/i2c/chips/pc87360
+++ b/Documentation/hwmon/pc87360
diff --git a/Documentation/i2c/chips/sis5595 b/Documentation/hwmon/sis5595
index b7ae36b8cdf..b7ae36b8cdf 100644
--- a/Documentation/i2c/chips/sis5595
+++ b/Documentation/hwmon/sis5595
diff --git a/Documentation/i2c/chips/smsc47b397 b/Documentation/hwmon/smsc47b397
index da9d80c9643..da9d80c9643 100644
--- a/Documentation/i2c/chips/smsc47b397
+++ b/Documentation/hwmon/smsc47b397
diff --git a/Documentation/i2c/chips/smsc47m1 b/Documentation/hwmon/smsc47m1
index 34e6478c142..34e6478c142 100644
--- a/Documentation/i2c/chips/smsc47m1
+++ b/Documentation/hwmon/smsc47m1
diff --git a/Documentation/i2c/sysfs-interface b/Documentation/hwmon/sysfs-interface
index 346400519d0..346400519d0 100644
--- a/Documentation/i2c/sysfs-interface
+++ b/Documentation/hwmon/sysfs-interface
diff --git a/Documentation/i2c/userspace-tools b/Documentation/hwmon/userspace-tools
index 2622aac6542..2622aac6542 100644
--- a/Documentation/i2c/userspace-tools
+++ b/Documentation/hwmon/userspace-tools
diff --git a/Documentation/i2c/chips/via686a b/Documentation/hwmon/via686a
index b82014cb7c5..b82014cb7c5 100644
--- a/Documentation/i2c/chips/via686a
+++ b/Documentation/hwmon/via686a
diff --git a/Documentation/i2c/chips/w83627hf b/Documentation/hwmon/w83627hf
index 78f37c2d602..78f37c2d602 100644
--- a/Documentation/i2c/chips/w83627hf
+++ b/Documentation/hwmon/w83627hf
diff --git a/Documentation/i2c/chips/w83781d b/Documentation/hwmon/w83781d
index e5459333ba6..e5459333ba6 100644
--- a/Documentation/i2c/chips/w83781d
+++ b/Documentation/hwmon/w83781d
diff --git a/Documentation/i2c/chips/w83l785ts b/Documentation/hwmon/w83l785ts
index 1841cedc25b..1841cedc25b 100644
--- a/Documentation/i2c/chips/w83l785ts
+++ b/Documentation/hwmon/w83l785ts
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875
index b4fb49b4181..b02002898a0 100644
--- a/Documentation/i2c/chips/max6875
+++ b/Documentation/i2c/chips/max6875
@@ -2,10 +2,10 @@ Kernel driver max6875
=====================
Supported chips:
- * Maxim max6874, max6875
- Prefixes: 'max6875'
+ * Maxim MAX6874, MAX6875
+ Prefix: 'max6875'
Addresses scanned: 0x50, 0x52
- Datasheets:
+ Datasheet:
http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
Author: Ben Gardner <bgardner@wabtec.com>
@@ -23,14 +23,26 @@ Module Parameters
Description
-----------
-The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor.
+The Maxim MAX6875 is an EEPROM-programmable power-supply sequencer/supervisor.
It provides timed outputs that can be used as a watchdog, if properly wired.
It also provides 512 bytes of user EEPROM.
-At reset, the max6875 reads the configuration eeprom into its configuration
+At reset, the MAX6875 reads the configuration EEPROM into its configuration
registers. The chip then begins to operate according to the values in the
registers.
+The Maxim MAX6874 is a similar, mostly compatible device, with more intputs
+and outputs:
+
+ vin gpi vout
+MAX6874 6 4 8
+MAX6875 4 3 5
+
+MAX6874 chips can have four different addresses (as opposed to only two for
+the MAX6875). The additional addresses (0x54 and 0x56) are not probed by
+this driver by default, but the probe module parameter can be used if
+needed.
+
See the datasheet for details on how to program the EEPROM.
diff --git a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface
index 09d6cda2a1f..b849ad63658 100644
--- a/Documentation/i2c/dev-interface
+++ b/Documentation/i2c/dev-interface
@@ -14,9 +14,12 @@ C example
=========
So let's say you want to access an i2c adapter from a C program. The
-first thing to do is `#include <linux/i2c.h>" and "#include <linux/i2c-dev.h>.
-Yes, I know, you should never include kernel header files, but until glibc
-knows about i2c, there is not much choice.
+first thing to do is "#include <linux/i2c-dev.h>". Please note that
+there are two files named "i2c-dev.h" out there, one is distributed
+with the Linux kernel and is meant to be included from kernel
+driver code, the other one is distributed with lm_sensors and is
+meant to be included from user-space programs. You obviously want
+the second one here.
Now, you have to decide which adapter you want to access. You should
inspect /sys/class/i2c-dev/ to decide this. Adapter numbers are assigned
@@ -78,7 +81,7 @@ Full interface description
==========================
The following IOCTLs are defined and fully supported
-(see also i2c-dev.h and i2c.h):
+(see also i2c-dev.h):
ioctl(file,I2C_SLAVE,long addr)
Change slave address. The address is passed in the 7 lower bits of the
@@ -97,10 +100,10 @@ ioctl(file,I2C_PEC,long select)
ioctl(file,I2C_FUNCS,unsigned long *funcs)
Gets the adapter functionality and puts it in *funcs.
-ioctl(file,I2C_RDWR,struct i2c_ioctl_rdwr_data *msgset)
+ioctl(file,I2C_RDWR,struct i2c_rdwr_ioctl_data *msgset)
Do combined read/write transaction without stop in between.
- The argument is a pointer to a struct i2c_ioctl_rdwr_data {
+ The argument is a pointer to a struct i2c_rdwr_ioctl_data {
struct i2c_msg *msgs; /* ptr to array of simple messages */
int nmsgs; /* number of messages to exchange */
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index f482dae81de..91664be91ff 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -27,7 +27,6 @@ address.
static struct i2c_driver foo_driver = {
.owner = THIS_MODULE,
.name = "Foo version 2.3 driver",
- .id = I2C_DRIVERID_FOO, /* from i2c-id.h, optional */
.flags = I2C_DF_NOTIFY,
.attach_adapter = &foo_attach_adapter,
.detach_client = &foo_detach_client,
@@ -37,12 +36,6 @@ static struct i2c_driver foo_driver = {
The name can be chosen freely, and may be upto 40 characters long. Please
use something descriptive here.
-If used, the id should be a unique ID. The range 0xf000 to 0xffff is
-reserved for local use, and you can use one of those until you start
-distributing the driver, at which time you should contact the i2c authors
-to get your own ID(s). Note that most of the time you don't need an ID
-at all so you can just omit it.
-
Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This
means that your driver will be notified when new adapters are found.
This is almost always what you want.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 753db6d8b74..a998a8c2f95 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -37,7 +37,7 @@ restrictions referred to are that the relevant option is valid if:
IA-32 IA-32 aka i386 architecture is enabled.
IA-64 IA-64 architecture is enabled.
IOSCHED More than one I/O scheduler is enabled.
- IP_PNP IP DCHP, BOOTP, or RARP is enabled.
+ IP_PNP IP DHCP, BOOTP, or RARP is enabled.
ISAPNP ISA PnP code is enabled.
ISDN Appropriate ISDN support is enabled.
JOY Appropriate joystick support is enabled.
diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt
index 9c315ab48a0..59ccc63838c 100644
--- a/Documentation/pcmcia/driver-changes.txt
+++ b/Documentation/pcmcia/driver-changes.txt
@@ -1,6 +1,13 @@
This file details changes in 2.6 which affect PCMCIA card driver authors:
-* in-kernel device<->driver matching
+* event handler initialization in struct pcmcia_driver (as of 2.6.13)
+ The event handler is notified of all events, and must be initialized
+ as the event() callback in the driver's struct pcmcia_driver.
+
+* pcmcia/version.h should not be used (as of 2.6.13)
+ This file will be removed eventually.
+
+* in-kernel device<->driver matching (as of 2.6.13)
PCMCIA devices and their correct drivers can now be matched in
kernelspace. See 'devicetable.txt' for details.
diff --git a/Documentation/usb/sn9c102.txt b/Documentation/usb/sn9c102.txt
index cf9a1187edc..3f8a119db31 100644
--- a/Documentation/usb/sn9c102.txt
+++ b/Documentation/usb/sn9c102.txt
@@ -297,6 +297,7 @@ Vendor ID Product ID
0x0c45 0x602a
0x0c45 0x602b
0x0c45 0x602c
+0x0c45 0x602d
0x0c45 0x6030
0x0c45 0x6080
0x0c45 0x6082
@@ -333,6 +334,7 @@ Model Manufacturer
----- ------------
HV7131D Hynix Semiconductor, Inc.
MI-0343 Micron Technology, Inc.
+OV7630 OmniVision Technologies, Inc.
PAS106B PixArt Imaging, Inc.
PAS202BCB PixArt Imaging, Inc.
TAS5110C1B Taiwan Advanced Sensor Corporation
@@ -470,9 +472,11 @@ order):
- Luca Capello for the donation of a webcam;
- Joao Rodrigo Fuzaro, Joao Limirio, Claudio Filho and Caio Begotti for the
donation of a webcam;
+- Jon Hollstrom for the donation of a webcam;
- Carlos Eduardo Medaglia Dyonisio, who added the support for the PAS202BCB
image sensor;
- Stefano Mozzi, who donated 45 EU;
+- Andrew Pearce for the donation of a webcam;
- Bertrik Sikken, who reverse-engineered and documented the Huffman compression
algorithm used in the SN9C10x controllers and implemented the first decoder;
- Mizuno Takafumi for the donation of a webcam;
diff --git a/Documentation/usb/usbmon.txt b/Documentation/usb/usbmon.txt
index 2f8431f92b7..f1896ee3bb2 100644
--- a/Documentation/usb/usbmon.txt
+++ b/Documentation/usb/usbmon.txt
@@ -101,6 +101,13 @@ Here is the list of words, from left to right:
or 3 and 2 positions, correspondingly.
- URB Status. This field makes no sense for submissions, but is present
to help scripts with parsing. In error case, it contains the error code.
+ In case of a setup packet, it contains a Setup Tag. If scripts read a number
+ in this field, the proceed to read Data Length. Otherwise, they read
+ the setup packet before reading the Data Length.
+- Setup packet, if present, consists of 5 words: one of each for bmRequestType,
+ bRequest, wValue, wIndex, wLength, as specified by the USB Specification 2.0.
+ These words are safe to decode if Setup Tag was 's'. Otherwise, the setup
+ packet was present, but not captured, and the fields contain filler.
- Data Length. This is the actual length in the URB.
- Data tag. The usbmon may not always capture data, even if length is nonzero.
Only if tag is '=', the data words are present.
@@ -125,25 +132,31 @@ class ParsedLine {
String data_str = st.nextToken();
int len = data_str.length() / 2;
int i;
+ int b; // byte is signed, apparently?! XXX
for (i = 0; i < len; i++) {
- data[data_len] = Byte.parseByte(
- data_str.substring(i*2, i*2 + 2),
- 16);
+ // data[data_len] = Byte.parseByte(
+ // data_str.substring(i*2, i*2 + 2),
+ // 16);
+ b = Integer.parseInt(
+ data_str.substring(i*2, i*2 + 2),
+ 16);
+ if (b >= 128)
+ b *= -1;
+ data[data_len] = (byte) b;
data_len++;
}
}
}
}
-This format is obviously deficient. For example, the setup packet for control
-transfers is not delivered. This will change in the future.
+This format may be changed in the future.
Examples:
-An input control transfer to get a port status:
+An input control transfer to get a port status.
-d74ff9a0 2640288196 S Ci:001:00 -115 4 <
-d74ff9a0 2640288202 C Ci:001:00 0 4 = 01010100
+d5ea89a0 3575914555 S Ci:001:00 s a3 00 0000 0003 0004 4 <
+d5ea89a0 3575914560 C Ci:001:00 0 4 = 01050000
An output bulk transfer to send a SCSI command 0x5E in a 31-byte Bulk wrapper
to a storage device at address 5:
diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv
index aeeafec0594..62a12a08e2a 100644
--- a/Documentation/video4linux/CARDLIST.bttv
+++ b/Documentation/video4linux/CARDLIST.bttv
@@ -1,4 +1,4 @@
-card=0 - *** UNKNOWN/GENERIC ***
+card=0 - *** UNKNOWN/GENERIC ***
card=1 - MIRO PCTV
card=2 - Hauppauge (bt848)
card=3 - STB, Gateway P/N 6000699 (bt848)
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88
index 4377aa11f56..6d44958289d 100644
--- a/Documentation/video4linux/CARDLIST.cx88
+++ b/Documentation/video4linux/CARDLIST.cx88
@@ -27,3 +27,5 @@ card=25 - Digital-Logic MICROSPACE Entertainment Center (MEC)
card=26 - IODATA GV/BCTV7E
card=27 - PixelView PlayTV Ultra Pro (Stereo)
card=28 - DViCO FusionHDTV 3 Gold-T
+card=29 - ADS Tech Instant TV DVB-T PCI
+card=30 - TerraTec Cinergy 1400 DVB-T
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index 735e8ba02d9..1b5a3a9ffbe 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -1,10 +1,10 @@
- 0 -> UNKNOWN/GENERIC
+ 0 -> UNKNOWN/GENERIC
1 -> Proteus Pro [philips reference design] [1131:2001,1131:2001]
2 -> LifeView FlyVIDEO3000 [5168:0138,4e42:0138]
3 -> LifeView FlyVIDEO2000 [5168:0138]
4 -> EMPRESS [1131:6752]
5 -> SKNet Monster TV [1131:4e85]
- 6 -> Tevion MD 9717
+ 6 -> Tevion MD 9717
7 -> KNC One TV-Station RDS / Typhoon TV Tuner RDS [1131:fe01,1894:fe01]
8 -> Terratec Cinergy 400 TV [153B:1142]
9 -> Medion 5044
@@ -34,6 +34,7 @@
33 -> AVerMedia DVD EZMaker [1461:10ff]
34 -> Noval Prime TV 7133
35 -> AverMedia AverTV Studio 305 [1461:2115]
+ 36 -> UPMOST PURPLE TV [12ab:0800]
37 -> Items MuchTV Plus / IT-005
38 -> Terratec Cinergy 200 TV [153B:1152]
39 -> LifeView FlyTV Platinum Mini [5168:0212]
@@ -43,20 +44,21 @@
43 -> :Zolid Xpert TV7134
44 -> Empire PCI TV-Radio LE
45 -> Avermedia AVerTV Studio 307 [1461:9715]
- 46 -> AVerMedia Cardbus TV/Radio [1461:d6ee]
+ 46 -> AVerMedia Cardbus TV/Radio (E500) [1461:d6ee]
47 -> Terratec Cinergy 400 mobile [153b:1162]
48 -> Terratec Cinergy 600 TV MK3 [153B:1158]
49 -> Compro VideoMate Gold+ Pal [185b:c200]
50 -> Pinnacle PCTV 300i DVB-T + PAL [11bd:002d]
51 -> ProVideo PV952 [1540:9524]
52 -> AverMedia AverTV/305 [1461:2108]
+ 53 -> ASUS TV-FM 7135 [1043:4845]
54 -> LifeView FlyTV Platinum FM [5168:0214,1489:0214]
- 55 -> LifeView FlyDVB-T DUO [5168:0306]
+ 55 -> LifeView FlyDVB-T DUO [5168:0502,5168:0306]
56 -> Avermedia AVerTV 307 [1461:a70a]
57 -> Avermedia AVerTV GO 007 FM [1461:f31f]
58 -> ADS Tech Instant TV (saa7135) [1421:0350,1421:0370]
59 -> Kworld/Tevion V-Stream Xpert TV PVR7134
- 60 -> Typhoon DVB-T Duo Digital/Analog Cardbus
- 61 -> Philips TOUGH DVB-T reference design
+ 60 -> Typhoon DVB-T Duo Digital/Analog Cardbus [4e42:0502]
+ 61 -> Philips TOUGH DVB-T reference design [1131:2004]
62 -> Compro VideoMate TV Gold+II
63 -> Kworld Xpert TV PVR7134
diff --git a/Documentation/video4linux/CARDLIST.tuner b/Documentation/video4linux/CARDLIST.tuner
index e78020f68b2..d1b9d21ffd8 100644
--- a/Documentation/video4linux/CARDLIST.tuner
+++ b/Documentation/video4linux/CARDLIST.tuner
@@ -56,9 +56,9 @@ tuner=54 - tda8290+75
tuner=55 - LG PAL (TAPE series)
tuner=56 - Philips PAL/SECAM multi (FQ1216AME MK4)
tuner=57 - Philips FQ1236A MK4
-tuner=58 - Ymec TVision TVF-8531MF
+tuner=58 - Ymec TVision TVF-8531MF/8831MF/8731MF
tuner=59 - Ymec TVision TVF-5533MF
tuner=60 - Thomson DDT 7611 (ATSC/NTSC)
-tuner=61 - Tena TNF9533-D/IF
+tuner=61 - Tena TNF9533-D/IF/TNF9533-B/DF
tuner=62 - Philips TEA5767HN FM Radio
tuner=63 - Philips FMD1216ME MK3 Hybrid Tuner
diff --git a/Documentation/video4linux/bttv/Cards b/Documentation/video4linux/bttv/Cards
index 7f8c7eb70ab..8f1941ede4d 100644
--- a/Documentation/video4linux/bttv/Cards
+++ b/Documentation/video4linux/bttv/Cards
@@ -20,7 +20,7 @@ All other cards only differ by additional components as tuners, sound
decoders, EEPROMs, teletext decoders ...
-Unsupported Cards:
+Unsupported Cards:
------------------
Cards with Zoran (ZR) or Philips (SAA) or ISA are not supported by
@@ -50,11 +50,11 @@ Bt848a/Bt849 single crytal operation support possible!!!
Miro/Pinnacle PCTV
------------------
-- Bt848
- some (all??) come with 2 crystals for PAL/SECAM and NTSC
+- Bt848
+ some (all??) come with 2 crystals for PAL/SECAM and NTSC
- PAL, SECAM or NTSC TV tuner (Philips or TEMIC)
- MSP34xx sound decoder on add on board
- decoder is supported but AFAIK does not yet work
+ decoder is supported but AFAIK does not yet work
(other sound MUX setting in GPIO port needed??? somebody who fixed this???)
- 1 tuner, 1 composite and 1 S-VHS input
- tuner type is autodetected
@@ -70,7 +70,7 @@ in 1997!
Hauppauge Win/TV pci
--------------------
-There are many different versions of the Hauppauge cards with different
+There are many different versions of the Hauppauge cards with different
tuners (TV+Radio ...), teletext decoders.
Note that even cards with same model numbers have (depending on the revision)
different chips on it.
@@ -80,22 +80,22 @@ different chips on it.
- PAL, SECAM, NTSC or tuner with or without Radio support
e.g.:
- PAL:
+ PAL:
TDA5737: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
TSA5522: 1.4 GHz I2C-bus controlled synthesizer, I2C 0xc2-0xc3
-
+
NTSC:
TDA5731: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
TSA5518: no datasheet available on Philips site
-- Philips SAA5246 or SAA5284 ( or no) Teletext decoder chip
+- Philips SAA5246 or SAA5284 ( or no) Teletext decoder chip
with buffer RAM (e.g. Winbond W24257AS-35: 32Kx8 CMOS static RAM)
SAA5246 (I2C 0x22) is supported
-- 256 bytes EEPROM: Microchip 24LC02B or Philips 8582E2Y
+- 256 bytes EEPROM: Microchip 24LC02B or Philips 8582E2Y
with configuration information
I2C address 0xa0 (24LC02B also responds to 0xa2-0xaf)
- 1 tuner, 1 composite and (depending on model) 1 S-VHS input
- 14052B: mux for selection of sound source
-- sound decoder: TDA9800, MSP34xx (stereo cards)
+- sound decoder: TDA9800, MSP34xx (stereo cards)
Askey CPH-Series
@@ -108,17 +108,17 @@ Developed by TelSignal(?), OEMed by many vendors (Typhoon, Anubis, Dynalink)
CPH05x: BT878 with FM
CPH06x: BT878 (w/o FM)
CPH07x: BT878 capture only
-
+
TV standards:
CPH0x0: NTSC-M/M
CPH0x1: PAL-B/G
CPH0x2: PAL-I/I
CPH0x3: PAL-D/K
- CPH0x4: SECAM-L/L
- CPH0x5: SECAM-B/G
- CPH0x6: SECAM-D/K
- CPH0x7: PAL-N/N
- CPH0x8: PAL-B/H
+ CPH0x4: SECAM-L/L
+ CPH0x5: SECAM-B/G
+ CPH0x6: SECAM-D/K
+ CPH0x7: PAL-N/N
+ CPH0x8: PAL-B/H
CPH0x9: PAL-M/M
CPH03x was often sold as "TV capturer".
@@ -174,7 +174,7 @@ Lifeview Flyvideo Series:
"The FlyVideo2000 and FlyVideo2000s product name have renamed to FlyVideo98."
Their Bt8x8 cards are listed as discontinued.
Flyvideo 2000S was probably sold as Flyvideo 3000 in some contries(Europe?).
- The new Flyvideo 2000/3000 are SAA7130/SAA7134 based.
+ The new Flyvideo 2000/3000 are SAA7130/SAA7134 based.
"Flyvideo II" had been the name for the 848 cards, nowadays (in Germany)
this name is re-used for LR50 Rev.W.
@@ -235,12 +235,12 @@ Prolink
Multimedia TV packages (card + software pack):
PixelView Play TV Theater - (Model: PV-M4200) = PixelView Play TV pro + Software
PixelView Play TV PAK - (Model: PV-BT878P+ REV 4E)
- PixelView Play TV/VCR - (Model: PV-M3200 REV 4C / 8D / 10A )
+ PixelView Play TV/VCR - (Model: PV-M3200 REV 4C / 8D / 10A )
PixelView Studio PAK - (Model: M2200 REV 4C / 8D / 10A )
PixelView PowerStudio PAK - (Model: PV-M3600 REV 4E)
PixelView DigitalVCR PAK - (Model: PV-M2400 REV 4C / 8D / 10A )
- PixelView PlayTV PAK II (TV/FM card + usb camera) PV-M3800
+ PixelView PlayTV PAK II (TV/FM card + usb camera) PV-M3800
PixelView PlayTV XP PV-M4700,PV-M4700(w/FM)
PixelView PlayTV DVR PV-M4600 package contents:PixelView PlayTV pro, windvr & videoMail s/w
@@ -254,7 +254,7 @@ Prolink
DTV3000 PV-DTV3000P+ DVB-S CI = Twinhan VP-1030
DTV2000 DVB-S = Twinhan VP-1020
-
+
Video Conferencing:
PixelView Meeting PAK - (Model: PV-BT878P)
PixelView Meeting PAK Lite - (Model: PV-BT878P)
@@ -308,7 +308,7 @@ KNC One
newer Cards have saa7134, but model name stayed the same?
-Provideo
+Provideo
--------
PV951 or PV-951 (also are sold as:
Boeder TV-FM Video Capture Card
@@ -353,7 +353,7 @@ AVerMedia
AVerTV
AVerTV Stereo
AVerTV Studio (w/FM)
- AVerMedia TV98 with Remote
+ AVerMedia TV98 with Remote
AVerMedia TV/FM98 Stereo
AVerMedia TVCAM98
TVCapture (Bt848)
@@ -373,7 +373,7 @@ AVerMedia
(1) Daughterboard MB68-A with TDA9820T and TDA9840T
(2) Sony NE41S soldered (stereo sound?)
(3) Daughterboard M118-A w/ pic 16c54 and 4 MHz quartz
-
+
US site has different drivers for (as of 09/2002):
EZ Capture/InterCam PCI (BT-848 chip)
EZ Capture/InterCam PCI (BT-878 chip)
@@ -437,7 +437,7 @@ Terratec
Terra TValueRadio, "LR102 Rev.C" printed on the PCB
Terra TV/Radio+ Version 1.0, "80-CP2830100-0" TTTV3 printed on the PCB,
"CPH010-E83" on the back, SAA6588T, TDA9873H
- Terra TValue Version BT878, "80-CP2830110-0 TTTV4" printed on the PCB,
+ Terra TValue Version BT878, "80-CP2830110-0 TTTV4" printed on the PCB,
"CPH011-D83" on back
Terra TValue Version 1.0 "ceb105.PCB" (really identical to Terra TV+ Version 1.0)
Terra TValue New Revision "LR102 Rec.C"
@@ -528,7 +528,7 @@ Koutech
KW-606RSF
KW-607A (capture only)
KW-608 (Zoran capture only)
-
+
IODATA (jp)
------
GV-BCTV/PCI
@@ -542,15 +542,15 @@ Canopus (jp)
-------
WinDVR = Kworld "KW-TVL878RF"
-www.sigmacom.co.kr
+www.sigmacom.co.kr
------------------
- Sigma Cyber TV II
+ Sigma Cyber TV II
www.sasem.co.kr
---------------
Litte OnAir TV
-hama
+hama
----
TV/Radio-Tuner Card, PCI (Model 44677) = CPH051
@@ -638,7 +638,7 @@ Media-Surfer (esc-kathrein.de)
Jetway (www.jetway.com.tw)
--------------------------
- JW-TV 878M
+ JW-TV 878M
JW-TV 878 = KWorld KW-TV878RF
Galaxis
@@ -715,7 +715,7 @@ Hauppauge
809 MyVideo
872 MyTV2Go FM
-
+
546 WinTV Nova-S CI
543 WinTV Nova
907 Nova-S USB
@@ -739,7 +739,7 @@ Hauppauge
832 MyTV2Go
869 MyTV2Go-FM
805 MyVideo (USB)
-
+
Matrix-Vision
-------------
@@ -764,7 +764,7 @@ Gallant (www.gallantcom.com) www.minton.com.tw
Intervision IV-550 (bt8x8)
Intervision IV-100 (zoran)
Intervision IV-1000 (bt8x8)
-
+
Asonic (www.asonic.com.cn) (website down)
-----------------------------------------
SkyEye tv 878
@@ -804,11 +804,11 @@ Kworld (www.kworld.com.tw)
JTT/ Justy Corp.http://www.justy.co.jp/ (www.jtt.com.jp website down)
---------------------------------------------------------------------
- JTT-02 (JTT TV) "TV watchmate pro" (bt848)
+ JTT-02 (JTT TV) "TV watchmate pro" (bt848)
ADS www.adstech.com
-------------------
- Channel Surfer TV ( CHX-950 )
+ Channel Surfer TV ( CHX-950 )
Channel Surfer TV+FM ( CHX-960FM )
AVEC www.prochips.com
@@ -874,7 +874,7 @@ www.ids-imaging.de
------------------
Falcon Series (capture only)
In USA: http://www.theimagingsource.com/
- DFG/LC1
+ DFG/LC1
www.sknet-web.co.jp
-------------------
@@ -890,7 +890,7 @@ Cybertainment
CyberMail Xtreme
These are Flyvideo
-VCR (http://www.vcrinc.com/)
+VCR (http://www.vcrinc.com/)
---
Video Catcher 16
@@ -920,7 +920,7 @@ Sdisilk www.sdisilk.com/
SDI Silk 200 SDI Input Card
www.euresys.com
- PICOLO series
+ PICOLO series
PMC/Pace
www.pacecom.co.uk website closed
diff --git a/Documentation/video4linux/not-in-cx2388x-datasheet.txt b/Documentation/video4linux/not-in-cx2388x-datasheet.txt
index 96b638b5ba1..edbfe744d21 100644
--- a/Documentation/video4linux/not-in-cx2388x-datasheet.txt
+++ b/Documentation/video4linux/not-in-cx2388x-datasheet.txt
@@ -34,4 +34,8 @@ MO_OUTPUT_FORMAT (0x310164)
2: HACTEXT
1: HSFMT
+0x47 is the sync byte for MPEG-2 transport stream packets.
+Datasheet incorrectly states to use 47 decimal. 188 is the length.
+All DVB compliant frontends output packets with this start code.
+
=================================================================================
diff --git a/MAINTAINERS b/MAINTAINERS
index 37fb1e2ec68..5d014725901 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1240,7 +1240,7 @@ S: Maintained
IRDA SUBSYSTEM
P: Jean Tourrilhes
-L: irda-users@lists.sourceforge.net
+L: irda-users@lists.sourceforge.net (subscribers-only)
W: http://irda.sourceforge.net/
S: Maintained
diff --git a/Makefile b/Makefile
index 9cf07e7b9f8..cf34a6b5c6e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 13
-EXTRAVERSION =-rc2
+EXTRAVERSION =-rc3
NAME=Woozy Numbat
# *DOCUMENTATION*
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index c5739d6309d..083c5df42d3 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -596,6 +596,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8752751f998..7bc4a583f4e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -700,6 +700,8 @@ config APM
endmenu
+source "net/Kconfig"
+
menu "Device Drivers"
source "drivers/base/Kconfig"
@@ -732,7 +734,7 @@ source "drivers/ieee1394/Kconfig"
source "drivers/message/i2o/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/isdn/Kconfig"
@@ -744,6 +746,8 @@ source "drivers/char/Kconfig"
source "drivers/i2c/Kconfig"
+source "drivers/hwmon/Kconfig"
+
#source "drivers/l3/Kconfig"
source "drivers/misc/Kconfig"
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index dc0c1936969..1f037326730 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -183,6 +183,8 @@ source "mm/Kconfig"
endmenu
+source "net/Kconfig"
+
source "drivers/base/Kconfig"
source "drivers/parport/Kconfig"
@@ -193,7 +195,7 @@ source "drivers/block/Kconfig"
source "drivers/md/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/ide/Kconfig"
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index f848e376149..e5979d68e35 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -122,6 +122,8 @@ source arch/cris/arch-v10/Kconfig
endmenu
+source "net/Kconfig"
+
# bring in ETRAX built-in drivers
menu "Drivers for built-in interfaces"
source arch/cris/arch-v10/drivers/Kconfig
@@ -149,7 +151,7 @@ source "drivers/ieee1394/Kconfig"
source "drivers/message/i2o/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/isdn/Kconfig"
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index c93f95146cc..ec85c0d6c6d 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -346,6 +346,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/frv/mb93090-mb00/pci-irq.c b/arch/frv/mb93090-mb00/pci-irq.c
index 24622d89b1c..af981bda015 100644
--- a/arch/frv/mb93090-mb00/pci-irq.c
+++ b/arch/frv/mb93090-mb00/pci-irq.c
@@ -60,7 +60,7 @@ void __init pcibios_fixup_irqs(void)
}
}
-void __init pcibios_penalize_isa_irq(int irq)
+void __init pcibios_penalize_isa_irq(int irq, int active)
{
}
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 62a89e812e3..26698a49f15 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -55,6 +55,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/base/Kconfig"
source "drivers/mtd/Kconfig"
@@ -65,7 +67,7 @@ source "drivers/ide/Kconfig"
source "arch/h8300/Kconfig.ide"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
#
# input - input/joystick depends on it. As does USB.
@@ -179,6 +181,8 @@ source "drivers/serial/Kconfig"
source "drivers/i2c/Kconfig"
+source "drivers/hwmon/Kconfig"
+
source "drivers/usb/Kconfig"
endmenu
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 6c02336fe2e..a801d9d4860 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1285,6 +1285,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile
index ee75cb286cf..5e291a20c03 100644
--- a/arch/i386/kernel/acpi/Makefile
+++ b/arch/i386/kernel/acpi/Makefile
@@ -2,3 +2,7 @@ obj-$(CONFIG_ACPI_BOOT) := boot.o
obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
+ifneq ($(CONFIG_ACPI_PROCESSOR),)
+obj-y += cstate.o
+endif
+
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
new file mode 100644
index 00000000000..4c3036ba65d
--- /dev/null
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -0,0 +1,103 @@
+/*
+ * arch/i386/kernel/acpi/cstate.c
+ *
+ * Copyright (C) 2005 Intel Corporation
+ * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
+ * - Added _PDC for SMP C-states on Intel CPUs
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/acpi.h>
+
+#include <acpi/processor.h>
+#include <asm/acpi.h>
+
+static void acpi_processor_power_init_intel_pdc(struct acpi_processor_power
+ *pow)
+{
+ struct acpi_object_list *obj_list;
+ union acpi_object *obj;
+ u32 *buf;
+
+ /* allocate and initialize pdc. It will be used later. */
+ obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
+ if (!obj_list) {
+ printk(KERN_ERR "Memory allocation error\n");
+ return;
+ }
+
+ obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+ if (!obj) {
+ printk(KERN_ERR "Memory allocation error\n");
+ kfree(obj_list);
+ return;
+ }
+
+ buf = kmalloc(12, GFP_KERNEL);
+ if (!buf) {
+ printk(KERN_ERR "Memory allocation error\n");
+ kfree(obj);
+ kfree(obj_list);
+ return;
+ }
+
+ buf[0] = ACPI_PDC_REVISION_ID;
+ buf[1] = 1;
+ buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
+
+ obj->type = ACPI_TYPE_BUFFER;
+ obj->buffer.length = 12;
+ obj->buffer.pointer = (u8 *) buf;
+ obj_list->count = 1;
+ obj_list->pointer = obj;
+ pow->pdc = obj_list;
+
+ return;
+}
+
+/* Initialize _PDC data based on the CPU vendor */
+void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
+ unsigned int cpu)
+{
+ struct cpuinfo_x86 *c = cpu_data + cpu;
+
+ pow->pdc = NULL;
+ if (c->x86_vendor == X86_VENDOR_INTEL)
+ acpi_processor_power_init_intel_pdc(pow);
+
+ return;
+}
+
+EXPORT_SYMBOL(acpi_processor_power_init_pdc);
+
+/*
+ * Initialize bm_flags based on the CPU cache properties
+ * On SMP it depends on cache configuration
+ * - When cache is not shared among all CPUs, we flush cache
+ * before entering C3.
+ * - When cache is shared among all CPUs, we use bm_check
+ * mechanism as in UP case
+ *
+ * This routine is called only after all the CPUs are online
+ */
+void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
+ unsigned int cpu)
+{
+ struct cpuinfo_x86 *c = cpu_data + cpu;
+
+ flags->bm_check = 0;
+ if (num_online_cpus() == 1)
+ flags->bm_check = 1;
+ else if (c->x86_vendor == X86_VENDOR_INTEL) {
+ /*
+ * Today all CPUs that support C3 share cache.
+ * TBD: This needs to look at cache shared map, once
+ * multi-core detection patch makes to the base.
+ */
+ flags->bm_check = 1;
+ }
+}
+
+EXPORT_SYMBOL(acpi_processor_power_init_bm_check);
diff --git a/arch/i386/kernel/acpi/wakeup.S b/arch/i386/kernel/acpi/wakeup.S
index 39d32484f6f..44d886c745e 100644
--- a/arch/i386/kernel/acpi/wakeup.S
+++ b/arch/i386/kernel/acpi/wakeup.S
@@ -74,8 +74,9 @@ wakeup_code:
movw %ax,%fs
movw $0x0e00 + 'i', %fs:(0x12)
- # need a gdt
- lgdt real_save_gdt - wakeup_code
+ # need a gdt -- use lgdtl to force 32-bit operands, in case
+ # the GDT is located past 16 megabytes.
+ lgdtl real_save_gdt - wakeup_code
movl real_save_cr0 - wakeup_code, %eax
movl %eax, %cr0
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index 7dcbf70fc16..327a55d4d1c 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -375,7 +375,7 @@ static int centrino_cpu_init_acpi(struct cpufreq_policy *policy)
arg0.buffer.pointer = (u8 *) arg0_buf;
arg0_buf[0] = ACPI_PDC_REVISION_ID;
arg0_buf[1] = 1;
- arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP | ACPI_PDC_EST_CAPABILITY_MSR;
+ arg0_buf[2] = ACPI_PDC_EST_CAPABILITY_SMP_MSR;
p.pdc = &arg_list;
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 3db9a04aec6..468500a7e89 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -291,3 +291,6 @@ ENTRY(sys_call_table)
.long sys_keyctl
.long sys_ioprio_set
.long sys_ioprio_get /* 290 */
+ .long sys_inotify_init
+ .long sys_inotify_add_watch
+ .long sys_inotify_rm_watch
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index 78ca1ecbb90..766b104ac1a 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -1051,24 +1051,28 @@ static int __init pcibios_irq_init(void)
subsys_initcall(pcibios_irq_init);
-static void pirq_penalize_isa_irq(int irq)
+static void pirq_penalize_isa_irq(int irq, int active)
{
/*
* If any ISAPnP device reports an IRQ in its list of possible
* IRQ's, we try to avoid assigning it to PCI devices.
*/
- if (irq < 16)
- pirq_penalty[irq] += 100;
+ if (irq < 16) {
+ if (active)
+ pirq_penalty[irq] += 1000;
+ else
+ pirq_penalty[irq] += 100;
+ }
}
-void pcibios_penalize_isa_irq(int irq)
+void pcibios_penalize_isa_irq(int irq, int active)
{
#ifdef CONFIG_ACPI_PCI
if (!acpi_noirq)
- acpi_penalize_isa_irq(irq);
+ acpi_penalize_isa_irq(irq, active);
else
#endif
- pirq_penalize_isa_irq(irq);
+ pirq_penalize_isa_irq(irq, active);
}
static int pirq_enable_irq(struct pci_dev *dev)
diff --git a/arch/i386/pci/visws.c b/arch/i386/pci/visws.c
index 6a924878443..314c933b6b8 100644
--- a/arch/i386/pci/visws.c
+++ b/arch/i386/pci/visws.c
@@ -21,7 +21,7 @@ static int pci_visws_enable_irq(struct pci_dev *dev) { return 0; }
int (*pcibios_enable_irq)(struct pci_dev *dev) = &pci_visws_enable_irq;
-void __init pcibios_penalize_isa_irq(int irq) {}
+void __init pcibios_penalize_isa_irq(int irq, int active) {}
unsigned int pci_bus0, pci_bus1;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 01b78e7f992..2e08942339a 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -423,6 +423,8 @@ endmenu
endif
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 542256e98e6..9609f243e5d 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -11,6 +11,7 @@
* Copyright (C) 2001 Jenna Hall <jenna.s.hall@intel.com>
* Copyright (C) 2001 Takayoshi Kochi <t-kochi@bq.jp.nec.com>
* Copyright (C) 2002 Erich Focht <efocht@ess.nec.de>
+ * Copyright (C) 2004 Ashok Raj <ashok.raj@intel.com>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
@@ -67,6 +68,11 @@ EXPORT_SYMBOL(pm_power_off);
unsigned char acpi_kbd_controller_present = 1;
unsigned char acpi_legacy_devices;
+static unsigned int __initdata acpi_madt_rev;
+
+unsigned int acpi_cpei_override;
+unsigned int acpi_cpei_phys_cpuid;
+
#define MAX_SAPICS 256
u16 ia64_acpiid_to_sapicid[MAX_SAPICS] =
{ [0 ... MAX_SAPICS - 1] = -1 };
@@ -265,10 +271,56 @@ acpi_parse_plat_int_src (
(plintsrc->flags.trigger == 1) ? IOSAPIC_EDGE : IOSAPIC_LEVEL);
platform_intr_list[plintsrc->type] = vector;
+ if (acpi_madt_rev > 1) {
+ acpi_cpei_override = plintsrc->plint_flags.cpei_override_flag;
+ }
+
+ /*
+ * Save the physical id, so we can check when its being removed
+ */
+ acpi_cpei_phys_cpuid = ((plintsrc->id << 8) | (plintsrc->eid)) & 0xffff;
+
return 0;
}
+unsigned int can_cpei_retarget(void)
+{
+ extern int cpe_vector;
+
+ /*
+ * Only if CPEI is supported and the override flag
+ * is present, otherwise return that its re-targettable
+ * if we are in polling mode.
+ */
+ if (cpe_vector > 0 && !acpi_cpei_override)
+ return 0;
+ else
+ return 1;
+}
+
+unsigned int is_cpu_cpei_target(unsigned int cpu)
+{
+ unsigned int logical_id;
+
+ logical_id = cpu_logical_id(acpi_cpei_phys_cpuid);
+
+ if (logical_id == cpu)
+ return 1;
+ else
+ return 0;
+}
+
+void set_cpei_target_cpu(unsigned int cpu)
+{
+ acpi_cpei_phys_cpuid = cpu_physical_id(cpu);
+}
+
+unsigned int get_cpei_target_cpu(void)
+{
+ return acpi_cpei_phys_cpuid;
+}
+
static int __init
acpi_parse_int_src_ovr (
acpi_table_entry_header *header, const unsigned long end)
@@ -326,6 +378,8 @@ acpi_parse_madt (unsigned long phys_addr, unsigned long size)
acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
+ acpi_madt_rev = acpi_madt->header.revision;
+
/* remember the value for reference after free_initmem() */
#ifdef CONFIG_ITANIUM
has_8259 = 1; /* Firmware on old Itanium systems is broken */
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 736e328b5e6..4ebbf397438 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -271,7 +271,7 @@ ia64_mca_log_sal_error_record(int sal_info_type)
#ifdef CONFIG_ACPI
-static int cpe_vector = -1;
+int cpe_vector = -1;
static irqreturn_t
ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs)
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 6e35bff05d5..e484910246a 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -196,6 +196,7 @@ update_pal_halt_status(int status)
void
default_idle (void)
{
+ local_irq_enable();
while (!need_resched())
if (can_do_pal_halt)
safe_halt();
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 2693e1522d7..5c7c95737bb 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -40,6 +40,8 @@
#include <linux/serial_core.h>
#include <linux/efi.h>
#include <linux/initrd.h>
+#include <linux/platform.h>
+#include <linux/pm.h>
#include <asm/ia32.h>
#include <asm/machvec.h>
@@ -783,6 +785,7 @@ cpu_init (void)
/* size of physical stacked register partition plus 8 bytes: */
__get_cpu_var(ia64_phys_stacked_size_p8) = num_phys_stacked*8 + 8;
platform_cpu_init();
+ pm_idle = default_idle;
}
void
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index f1aafd4c05f..d8030f3bd86 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -36,6 +36,13 @@ int arch_register_cpu(int num)
parent = &sysfs_nodes[cpu_to_node(num)];
#endif /* CONFIG_NUMA */
+ /*
+ * If CPEI cannot be re-targetted, and this is
+ * CPEI target, then dont create the control file
+ */
+ if (!can_cpei_retarget() && is_cpu_cpei_target(num))
+ sysfs_cpus[num].cpu.no_control = 1;
+
return register_cpu(&sysfs_cpus[num].cpu, num, parent);
}
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 42ca8a39798..7772951df31 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -359,6 +359,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 691a2469ff3..178c4a3fbb7 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -450,6 +450,8 @@ source "drivers/zorro/Kconfig"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
menu "Character devices"
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index dbfcdc8e608..117f183f0b4 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -575,6 +575,8 @@ config PM
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index bd9de7b00c0..b578239146b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1640,6 +1640,8 @@ config PM
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index ce327c799b4..1c2d8743523 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -190,6 +190,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 23b0d2f662c..b833cbcd77f 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -1355,6 +1355,8 @@ config PIN_TLB
depends on ADVANCED_OPTIONS && 8xx
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/ppc/kernel/machine_kexec.c b/arch/ppc/kernel/machine_kexec.c
index 84d65a87191..a72787747df 100644
--- a/arch/ppc/kernel/machine_kexec.c
+++ b/arch/ppc/kernel/machine_kexec.c
@@ -28,6 +28,12 @@ typedef NORET_TYPE void (*relocate_new_kernel_t)(
const extern unsigned char relocate_new_kernel[];
const extern unsigned int relocate_new_kernel_size;
+/*
+ * Provide a dummy crash_notes definition while crash dump arrives to ppc.
+ * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
+ */
+void *crash_notes = NULL;
+
void machine_shutdown(void)
{
if (ppc_md.machine_shutdown)
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index f804f25232a..fdd8afba715 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -429,6 +429,8 @@ config CMDLINE
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 6600ee87f89..477ac2758bd 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -465,6 +465,8 @@ config KEXEC
endmenu
+source "net/Kconfig"
+
config PCMCIA
bool
default n
@@ -475,7 +477,7 @@ source "drivers/scsi/Kconfig"
source "drivers/s390/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "fs/Kconfig"
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index a7c8bfc1160..adc8109f8b7 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -784,6 +784,8 @@ config EMBEDDED_RAMDISK_IMAGE
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index 708e59736a4..4c3e5334adb 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -268,6 +268,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 7a117ef473c..aca028aa29b 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -268,6 +268,8 @@ source "mm/Kconfig"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
if !SUN4
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 6a4733683f0..9afd28e2c4d 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -525,6 +525,8 @@ source "mm/Kconfig"
endmenu
+source "net/Kconfig"
+
source "drivers/base/Kconfig"
source "drivers/video/Kconfig"
@@ -551,7 +553,7 @@ endif
source "drivers/ieee1394/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/isdn/Kconfig"
@@ -647,6 +649,8 @@ source "drivers/input/Kconfig"
source "drivers/i2c/Kconfig"
+source "drivers/hwmon/Kconfig"
+
source "fs/Kconfig"
source "drivers/media/Kconfig"
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 441fc2e52ce..7e8e2919e18 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -45,8 +45,8 @@ extern void calibrate_delay(void);
/* Please don't make this stuff initdata!!! --DaveM */
static unsigned char boot_cpu_id;
-cpumask_t cpu_online_map = CPU_MASK_NONE __read_mostly;
-cpumask_t phys_cpu_present_map = CPU_MASK_NONE __read_mostly;
+cpumask_t cpu_online_map __read_mostly = CPU_MASK_NONE;
+cpumask_t phys_cpu_present_map __read_mostly = CPU_MASK_NONE;
static cpumask_t smp_commenced_mask;
static cpumask_t cpu_callout_map;
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index 6682c788364..f945444df49 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -275,6 +275,8 @@ endmenu
source "init/Kconfig"
+source "net/Kconfig"
+
source "drivers/base/Kconfig"
source "arch/um/Kconfig_char"
@@ -287,7 +289,7 @@ config NETDEVICES
source "arch/um/Kconfig_net"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "fs/Kconfig"
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 3f073902351..4a375bbac10 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -140,7 +140,8 @@ endef
#When cleaning we don't include .config, so we don't include
#TT or skas makefiles and don't clean skas_ptregs.h.
CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
- $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h
+ $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \
+ $(ARCH_DIR)/include/user_constants.h
MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
$(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os \
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig
index 27febd6ffa8..89c053b6c2c 100644
--- a/arch/v850/Kconfig
+++ b/arch/v850/Kconfig
@@ -250,6 +250,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
#############################################################################
source "drivers/base/Kconfig"
@@ -283,7 +285,7 @@ source "drivers/ieee1394/Kconfig"
source "drivers/message/i2o/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/isdn/Kconfig"
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index d09437b5c48..4b8326177c5 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -515,6 +515,8 @@ config UID16
endmenu
+source "net/Kconfig"
+
source drivers/Kconfig
source "drivers/firmware/Kconfig"
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 61c12758ca7..2a94f9b60b2 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -62,8 +62,8 @@ SECTIONS
}
#define VSYSCALL_ADDR (-10*1024*1024)
-#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095))
-#define VSYSCALL_VIRT_ADDR ((ADDR(.data.cacheline_aligned) + SIZEOF(.data.cacheline_aligned) + 4095) & ~(4095))
+#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
+#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + SIZEOF(.data.read_mostly) + 4095) & ~(4095))
#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index c9b5d298e3c..2b6257bec4c 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -228,6 +228,8 @@ source "fs/Kconfig.binfmt"
endmenu
+source "net/Kconfig"
+
source "drivers/Kconfig"
source "fs/Kconfig"
diff --git a/arch/xtensa/kernel/asm-offsets.c b/arch/xtensa/kernel/asm-offsets.c
index 840cd9a1d3d..7cd1d7f8f60 100644
--- a/arch/xtensa/kernel/asm-offsets.c
+++ b/arch/xtensa/kernel/asm-offsets.c
@@ -15,7 +15,6 @@
#include <asm/processor.h>
#include <linux/types.h>
-#include <linux/sched.h>
#include <linux/stddef.h>
#include <linux/thread_info.h>
#include <linux/ptrace.h>
diff --git a/arch/xtensa/kernel/syscalls.c b/arch/xtensa/kernel/syscalls.c
index 7270509c44d..f20c6494c51 100644
--- a/arch/xtensa/kernel/syscalls.c
+++ b/arch/xtensa/kernel/syscalls.c
@@ -69,8 +69,8 @@ int sys_pipe(int __user *userfds)
/*
* Common code for old and new mmaps.
*/
-long sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
- unsigned long flags, unsigned long fd, unsigned long pgoff)
+long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot,
+ unsigned long flags, unsigned long fd, unsigned long pgoff)
{
int error = -EBADF;
struct file * file = NULL;
diff --git a/arch/xtensa/kernel/syscalls.h b/arch/xtensa/kernel/syscalls.h
index 07580696b60..216c10a3150 100644
--- a/arch/xtensa/kernel/syscalls.h
+++ b/arch/xtensa/kernel/syscalls.h
@@ -42,7 +42,7 @@ SYSCALL(sys_mknod, 3)
SYSCALL(sys_chmod, 2) /* 15 */
SYSCALL(sys_lchown, 3)
SYSCALL(sys_ni_syscall, 0)
-SYSCALL(sys_stat, 2)
+SYSCALL(sys_newstat, 2)
SYSCALL(sys_lseek, 3)
SYSCALL(sys_getpid, 0) /* 20 */
SYSCALL(sys_mount, 5)
@@ -52,7 +52,7 @@ SYSCALL(sys_getuid, 0)
SYSCALL(sys_ni_syscall, 1) /* 25 */
SYSCALL(sys_ptrace, 4)
SYSCALL(sys_ni_syscall, 1)
-SYSCALL(sys_fstat, 2)
+SYSCALL(sys_newfstat, 2)
SYSCALL(sys_ni_syscall, 0)
SYSCALL(sys_utime, 2) /* 30 */
SYSCALL(sys_ni_syscall, 0)
@@ -108,7 +108,7 @@ SYSCALL(sys_getgroups, 2) /* 80 */
SYSCALL(sys_setgroups, 2)
SYSCALL(sys_ni_syscall, 0)
SYSCALL(sys_symlink, 2)
-SYSCALL(sys_lstat, 2)
+SYSCALL(sys_newlstat, 2)
SYSCALL(sys_readlink, 3) /* 85 */
SYSCALL(sys_uselib, 1)
SYSCALL(sys_swapon, 2)
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index 804246e743b..225d64d73f0 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -29,6 +29,7 @@
#include <linux/module.h>
#include <linux/stringify.h>
#include <linux/kallsyms.h>
+#include <linux/delay.h>
#include <asm/ptrace.h>
#include <asm/timex.h>
@@ -488,8 +489,7 @@ void die(const char * str, struct pt_regs * regs, long err)
if (panic_on_oops) {
printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(5 * HZ);
+ ssleep(5);
panic("Fatal exception");
}
do_exit(err);
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index 476b2b53cd0..5ed71dfc811 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -90,10 +90,10 @@ SECTIONS
*(.literal .text)
*(.srom.text)
VMLINUX_SYMBOL(__sched_text_start) = .;
- *(.sched.text.literal .sched.text)
+ *(.sched.literal .sched.text)
VMLINUX_SYMBOL(__sched_text_end) = .;
VMLINUX_SYMBOL(__lock_text_start) = .;
- *(.spinlock.text.literal .spinlock.text)
+ *(.spinlock.literal .spinlock.text)
VMLINUX_SYMBOL(__lock_text_end) = .;
}
@@ -164,7 +164,7 @@ SECTIONS
__init_begin = .;
.init.text : {
_sinittext = .;
- *(.init.text.literal) *(.init.text)
+ *(.init.literal) *(.init.text)
_einittext = .;
}
diff --git a/drivers/Kconfig b/drivers/Kconfig
index aed4a9b97c1..cecab0acc3f 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -28,7 +28,7 @@ source "drivers/message/i2o/Kconfig"
source "drivers/macintosh/Kconfig"
-source "net/Kconfig"
+source "drivers/net/Kconfig"
source "drivers/isdn/Kconfig"
@@ -44,6 +44,8 @@ source "drivers/i2c/Kconfig"
source "drivers/w1/Kconfig"
+source "drivers/hwmon/Kconfig"
+
source "drivers/misc/Kconfig"
source "drivers/media/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index 3167be54fed..126a851d565 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_INPUT) += input/
obj-$(CONFIG_I2O) += message/
obj-$(CONFIG_I2C) += i2c/
obj-$(CONFIG_W1) += w1/
+obj-$(CONFIG_HWMON) += hwmon/
obj-$(CONFIG_PHONE) += telephony/
obj-$(CONFIG_MD) += md/
obj-$(CONFIG_BT) += bluetooth/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 86c52520ed3..986410e7b48 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -3,6 +3,7 @@
#
menu "ACPI (Advanced Configuration and Power Interface) Support"
+ depends on PM
depends on !X86_VISWS
depends on !IA64_HP_SIM
depends on IA64 || X86
@@ -48,7 +49,6 @@ config ACPI_BOOT
config ACPI_INTERPRETER
bool
- depends on !IA64_SGI_SN
default y
if ACPI_INTERPRETER
@@ -79,6 +79,14 @@ config ACPI_SLEEP_PROC_FS
depends on ACPI_SLEEP && PROC_FS
default y
+config ACPI_SLEEP_PROC_SLEEP
+ bool "/proc/acpi/sleep (deprecated)"
+ depends on ACPI_SLEEP_PROC_FS
+ default n
+ ---help---
+ Create /proc/acpi/sleep
+ Deprecated by /sys/power/state
+
config ACPI_AC
tristate "AC Adapter"
depends on X86
@@ -99,7 +107,6 @@ config ACPI_BATTERY
config ACPI_BUTTON
tristate "Button"
- depends on !IA64_SGI_SN
default m
help
This driver registers for events based on buttons, such as the
@@ -111,7 +118,6 @@ config ACPI_BUTTON
config ACPI_VIDEO
tristate "Video"
depends on EXPERIMENTAL
- depends on !IA64_SGI_SN
default m
help
This driver implement the ACPI Extensions For Display Adapters
@@ -122,9 +128,17 @@ config ACPI_VIDEO
Note that this is an ref. implementation only. It may or may not work
for your integrated video device.
+config ACPI_HOTKEY
+ tristate "Generic Hotkey"
+ depends on ACPI_INTERPRETER
+ depends on EXPERIMENTAL
+ depends on !IA64_SGI_SN
+ default m
+ help
+ ACPI generic hotkey
+
config ACPI_FAN
tristate "Fan"
- depends on !IA64_SGI_SN
default m
help
This driver adds support for ACPI fan devices, allowing user-mode
@@ -132,7 +146,6 @@ config ACPI_FAN
config ACPI_PROCESSOR
tristate "Processor"
- depends on !IA64_SGI_SN
default m
help
This driver installs ACPI as the idle handler for Linux, and uses
@@ -142,7 +155,6 @@ config ACPI_PROCESSOR
config ACPI_HOTPLUG_CPU
bool "Processor Hotplug (EXPERIMENTAL)"
depends on ACPI_PROCESSOR && HOTPLUG_CPU && EXPERIMENTAL
- depends on !IA64_SGI_SN
select ACPI_CONTAINER
default n
---help---
@@ -262,7 +274,6 @@ config ACPI_BLACKLIST_YEAR
config ACPI_DEBUG
bool "Debug Statements"
- depends on !IA64_SGI_SN
default n
help
The ACPI driver can optionally report errors with a great deal
@@ -271,7 +282,6 @@ config ACPI_DEBUG
config ACPI_BUS
bool
- depends on !IA64_SGI_SN
default y
config ACPI_EC
@@ -285,17 +295,14 @@ config ACPI_EC
config ACPI_POWER
bool
- depends on !IA64_SGI_SN
default y
config ACPI_PCI
bool
- depends on !IA64_SGI_SN
default PCI
config ACPI_SYSTEM
bool
- depends on !IA64_SGI_SN
default y
help
This driver will enable your system to shut down using ACPI, and
@@ -327,8 +334,13 @@ config ACPI_CONTAINER
depends on EXPERIMENTAL
default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU || ACPI_HOTPLUG_IO)
---help---
- This is the ACPI generic container driver which supports
- ACPI0004, PNP0A05 and PNP0A06 devices
+ This allows _physical_ insertion and removal of CPUs and memory.
+ This can be useful, for example, on NUMA machines that support
+ ACPI based physical hotplug of nodes, or non-NUMA machines that
+ support physical cpu/memory hot-plug.
+
+ If one selects "m", this driver can be loaded with
+ "modprobe acpi_container".
config ACPI_HOTPLUG_MEMORY
tristate "Memory Hotplug"
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 65c92e20566..ad67e8f61e6 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -36,13 +36,14 @@ processor-objs += processor_perflib.o
endif
obj-$(CONFIG_ACPI_BUS) += sleep/
-obj-$(CONFIG_ACPI_BUS) += bus.o
+obj-$(CONFIG_ACPI_BUS) += bus.o glue.o
obj-$(CONFIG_ACPI_AC) += ac.o
obj-$(CONFIG_ACPI_BATTERY) += battery.o
obj-$(CONFIG_ACPI_BUTTON) += button.o
obj-$(CONFIG_ACPI_EC) += ec.o
obj-$(CONFIG_ACPI_FAN) += fan.o
-obj-$(CONFIG_ACPI_VIDEO) += video.o
+obj-$(CONFIG_ACPI_VIDEO) += video.o
+obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
obj-$(CONFIG_ACPI_PCI) += pci_root.o pci_link.o pci_irq.o pci_bind.o
obj-$(CONFIG_ACPI_POWER) += power.o
obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index a75cb565cae..a560b1e2da7 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -1204,6 +1204,10 @@ static int __init asus_acpi_init(void)
if (acpi_disabled)
return -ENODEV;
+ if (!acpi_specific_hotkey_enabled){
+ printk(KERN_ERR "Using generic hotkey driver\n");
+ return -ENODEV;
+ }
asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
if (!asus_proc_dir) {
printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 4edff173857..d77c2307883 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -212,6 +212,12 @@ acpi_bus_set_power (
ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device is not power manageable\n"));
return_VALUE(-ENODEV);
}
+ /*
+ * Get device's current power state if it's unknown
+ * This means device power state isn't initialized or previous setting failed
+ */
+ if (device->power.state == ACPI_STATE_UNKNOWN)
+ acpi_bus_get_power(device->handle, &device->power.state);
if (state == device->power.state) {
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", state));
return_VALUE(0);
@@ -231,7 +237,7 @@ acpi_bus_set_power (
* On transitions to a high-powered state we first apply power (via
* power resources) then evalute _PSx. Conversly for transitions to
* a lower-powered state.
- */
+ */
if (state < device->power.state) {
if (device->power.flags.power_resources) {
result = acpi_power_transition(device, state);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index ec4430e3053..0f45d45f05a 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -26,9 +26,6 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
@@ -36,9 +33,6 @@
#define ACPI_BUTTON_COMPONENT 0x00080000
#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver"
#define ACPI_BUTTON_CLASS "button"
-#define ACPI_BUTTON_FILE_INFO "info"
-#define ACPI_BUTTON_FILE_STATE "state"
-#define ACPI_BUTTON_TYPE_UNKNOWN 0x00
#define ACPI_BUTTON_NOTIFY_STATUS 0x80
#define ACPI_BUTTON_SUBCLASS_POWER "power"
@@ -70,8 +64,6 @@ MODULE_LICENSE("GPL");
static int acpi_button_add (struct acpi_device *device);
static int acpi_button_remove (struct acpi_device *device, int type);
-static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
-static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
static struct acpi_driver acpi_button_driver = {
.name = ACPI_BUTTON_DRIVER_NAME,
@@ -90,187 +82,6 @@ struct acpi_button {
unsigned long pushed;
};
-static struct file_operations acpi_button_info_fops = {
- .open = acpi_button_info_open_fs,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static struct file_operations acpi_button_state_fops = {
- .open = acpi_button_state_open_fs,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-/* --------------------------------------------------------------------------
- FS Interface (/proc)
- -------------------------------------------------------------------------- */
-
-static struct proc_dir_entry *acpi_button_dir;
-
-static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
-{
- struct acpi_button *button = (struct acpi_button *) seq->private;
-
- ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
-
- if (!button || !button->device)
- return_VALUE(0);
-
- seq_printf(seq, "type: %s\n",
- acpi_device_name(button->device));
-
- return_VALUE(0);
-}
-
-static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
-{
- return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
-}
-
-static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
-{
- struct acpi_button *button = (struct acpi_button *) seq->private;
- acpi_status status;
- unsigned long state;
-
- ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
-
- if (!button || !button->device)
- return_VALUE(0);
-
- status = acpi_evaluate_integer(button->handle,"_LID",NULL,&state);
- if (ACPI_FAILURE(status)) {
- seq_printf(seq, "state: unsupported\n");
- }
- else{
- seq_printf(seq, "state: %s\n", (state ? "open" : "closed"));
- }
-
- return_VALUE(0);
-}
-
-static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
-{
- return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
-}
-
-static int
-acpi_button_add_fs (
- struct acpi_device *device)
-{
- struct proc_dir_entry *entry = NULL;
- struct acpi_button *button = NULL;
-
- ACPI_FUNCTION_TRACE("acpi_button_add_fs");
-
- if (!device || !acpi_driver_data(device))
- return_VALUE(-EINVAL);
-
- button = acpi_driver_data(device);
-
- switch (button->type) {
- case ACPI_BUTTON_TYPE_POWER:
- case ACPI_BUTTON_TYPE_POWERF:
- entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER,
- acpi_button_dir);
- break;
- case ACPI_BUTTON_TYPE_SLEEP:
- case ACPI_BUTTON_TYPE_SLEEPF:
- entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
- acpi_button_dir);
- break;
- case ACPI_BUTTON_TYPE_LID:
- entry = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
- acpi_button_dir);
- break;
- }
-
- if (!entry)
- return_VALUE(-ENODEV);
- entry->owner = THIS_MODULE;
-
- acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
- if (!acpi_device_dir(device))
- return_VALUE(-ENODEV);
- acpi_device_dir(device)->owner = THIS_MODULE;
-
- /* 'info' [R] */
- entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
- S_IRUGO, acpi_device_dir(device));
- if (!entry)
- ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
- "Unable to create '%s' fs entry\n",
- ACPI_BUTTON_FILE_INFO));
- else {
- entry->proc_fops = &acpi_button_info_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
-
- /* show lid state [R] */
- if (button->type == ACPI_BUTTON_TYPE_LID) {
- entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
- S_IRUGO, acpi_device_dir(device));
- if (!entry)
- ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
- "Unable to create '%s' fs entry\n",
- ACPI_BUTTON_FILE_INFO));
- else {
- entry->proc_fops = &acpi_button_state_fops;
- entry->data = acpi_driver_data(device);
- entry->owner = THIS_MODULE;
- }
- }
-
- return_VALUE(0);
-}
-
-
-static int
-acpi_button_remove_fs (
- struct acpi_device *device)
-{
- struct acpi_button *button = NULL;
-
- ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
-
- button = acpi_driver_data(device);
- if (acpi_device_dir(device)) {
- if (button->type == ACPI_BUTTON_TYPE_LID)
- remove_proc_entry(ACPI_BUTTON_FILE_STATE,
- acpi_device_dir(device));
- remove_proc_entry(ACPI_BUTTON_FILE_INFO,
- acpi_device_dir(device));
-
- remove_proc_entry(acpi_device_bid(device),
- acpi_device_dir(device)->parent);
-
-
- switch (button->type) {
- case ACPI_BUTTON_TYPE_POWER:
- case ACPI_BUTTON_TYPE_POWERF:
- remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER,
- acpi_button_dir);
- break;
- case ACPI_BUTTON_TYPE_SLEEP:
- case ACPI_BUTTON_TYPE_SLEEPF:
- remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP,
- acpi_button_dir);
- break;
- case ACPI_BUTTON_TYPE_LID:
- remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID,
- acpi_button_dir);
- break;
- }
- acpi_device_dir(device) = NULL;
- }
-
- return_VALUE(0);
-}
-
-
/* --------------------------------------------------------------------------
Driver Interface
-------------------------------------------------------------------------- */
@@ -310,8 +121,7 @@ acpi_button_notify_fixed (
ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
- if (!button)
- return_ACPI_STATUS(AE_BAD_PARAMETER);
+ BUG_ON(!button);
acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
@@ -327,10 +137,6 @@ acpi_button_add (
acpi_status status = AE_OK;
struct acpi_button *button = NULL;
- static struct acpi_device *power_button;
- static struct acpi_device *sleep_button;
- static struct acpi_device *lid_button;
-
ACPI_FUNCTION_TRACE("acpi_button_add");
if (!device)
@@ -391,42 +197,6 @@ acpi_button_add (
goto end;
}
- /*
- * Ensure only one button of each type is used.
- */
- switch (button->type) {
- case ACPI_BUTTON_TYPE_POWER:
- case ACPI_BUTTON_TYPE_POWERF:
- if (!power_button)
- power_button = device;
- else {
- kfree(button);
- return_VALUE(-ENODEV);
- }
- break;
- case ACPI_BUTTON_TYPE_SLEEP:
- case ACPI_BUTTON_TYPE_SLEEPF:
- if (!sleep_button)
- sleep_button = device;
- else {
- kfree(button);
- return_VALUE(-ENODEV);
- }
- break;
- case ACPI_BUTTON_TYPE_LID:
- if (!lid_button)
- lid_button = device;
- else {
- kfree(button);
- return_VALUE(-ENODEV);
- }
- break;
- }
-
- result = acpi_button_add_fs(device);
- if (result)
- goto end;
-
switch (button->type) {
case ACPI_BUTTON_TYPE_POWERF:
status = acpi_install_fixed_event_handler (
@@ -470,7 +240,6 @@ acpi_button_add (
end:
if (result) {
- acpi_button_remove_fs(device);
kfree(button);
}
@@ -511,8 +280,6 @@ acpi_button_remove (struct acpi_device *device, int type)
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Error removing notify handler\n"));
- acpi_button_remove_fs(device);
-
kfree(button);
return_VALUE(0);
@@ -526,21 +293,14 @@ acpi_button_init (void)
ACPI_FUNCTION_TRACE("acpi_button_init");
- acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
- if (!acpi_button_dir)
- return_VALUE(-ENODEV);
- acpi_button_dir->owner = THIS_MODULE;
-
result = acpi_bus_register_driver(&acpi_button_driver);
if (result < 0) {
- remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
return_VALUE(-ENODEV);
}
return_VALUE(0);
}
-
static void __exit
acpi_button_exit (void)
{
@@ -548,11 +308,8 @@ acpi_button_exit (void)
acpi_bus_unregister_driver(&acpi_button_driver);
- remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
-
return_VOID;
}
-
module_init(acpi_button_init);
module_exit(acpi_button_exit);
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/dispatcher/dsfield.c
index 2779211be75..84193983d6b 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/dispatcher/dsfield.c
@@ -53,13 +53,20 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsfield")
+/* Local prototypes */
+
+static acpi_status
+acpi_ds_get_field_names (
+ struct acpi_create_field_info *info,
+ struct acpi_walk_state *walk_state,
+ union acpi_parse_object *arg);
+
/*******************************************************************************
*
* FUNCTION: acpi_ds_create_buffer_field
*
- * PARAMETERS: Opcode - The opcode to be executed
- * Operands - List of operands for the opcode
+ * PARAMETERS: Op - Current parse op (create_xXField)
* walk_state - Current state
*
* RETURN: Status
@@ -70,7 +77,7 @@
* create_word_field_op,
* create_dword_field_op,
* create_qword_field_op,
- * create_field_op (all of which define fields in buffers)
+ * create_field_op (all of which define a field in a buffer)
*
******************************************************************************/
@@ -119,7 +126,8 @@ acpi_ds_create_buffer_field (
flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE;
}
else {
- flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND;
+ flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
+ ACPI_NS_ERROR_IF_FOUND;
}
/*
@@ -134,16 +142,16 @@ acpi_ds_create_buffer_field (
}
}
- /* We could put the returned object (Node) on the object stack for later, but
- * for now, we will put it in the "op" object that the parser uses, so we
- * can get it again at the end of this scope
+ /* We could put the returned object (Node) on the object stack for later,
+ * but for now, we will put it in the "op" object that the parser uses,
+ * so we can get it again at the end of this scope
*/
op->common.node = node;
/*
- * If there is no object attached to the node, this node was just created and
- * we need to create the field object. Otherwise, this was a lookup of an
- * existing node and we don't want to create the field object again.
+ * If there is no object attached to the node, this node was just created
+ * and we need to create the field object. Otherwise, this was a lookup
+ * of an existing node and we don't want to create the field object again.
*/
obj_desc = acpi_ns_get_attached_object (node);
if (obj_desc) {
@@ -205,7 +213,7 @@ cleanup:
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_get_field_names (
struct acpi_create_field_info *info,
struct acpi_walk_state *walk_state,
@@ -238,7 +246,8 @@ acpi_ds_get_field_names (
+ (acpi_integer) arg->common.value.size;
if (position > ACPI_UINT32_MAX) {
- ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n"));
+ ACPI_REPORT_ERROR ((
+ "Bit offset within field too large (> 0xFFFFFFFF)\n"));
return_ACPI_STATUS (AE_SUPPORT);
}
@@ -250,12 +259,15 @@ acpi_ds_get_field_names (
/*
* Get a new access_type and access_attribute -- to be used for all
- * field units that follow, until field end or another access_as keyword.
+ * field units that follow, until field end or another access_as
+ * keyword.
*
- * In field_flags, preserve the flag bits other than the ACCESS_TYPE bits
+ * In field_flags, preserve the flag bits other than the
+ * ACCESS_TYPE bits
*/
- info->field_flags = (u8) ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
- ((u8) ((u32) arg->common.value.integer >> 8)));
+ info->field_flags = (u8)
+ ((info->field_flags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
+ ((u8) ((u32) arg->common.value.integer >> 8)));
info->attribute = (u8) (arg->common.value.integer);
break;
@@ -267,7 +279,8 @@ acpi_ds_get_field_names (
status = acpi_ns_lookup (walk_state->scope_info,
(char *) &arg->named.name,
- info->field_type, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
+ info->field_type, ACPI_IMODE_EXECUTE,
+ ACPI_NS_DONT_OPEN_SCOPE,
walk_state, &info->field_node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
@@ -295,8 +308,9 @@ acpi_ds_get_field_names (
+ (acpi_integer) arg->common.value.size;
if (position > ACPI_UINT32_MAX) {
- ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
- (char *) &info->field_node->name));
+ ACPI_REPORT_ERROR ((
+ "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n",
+ (char *) &info->field_node->name));
return_ACPI_STATUS (AE_SUPPORT);
}
@@ -306,7 +320,8 @@ acpi_ds_get_field_names (
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Invalid opcode in field list: %X\n",
arg->common.aml_opcode));
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
}
@@ -435,7 +450,8 @@ acpi_ds_init_field_objects (
status = acpi_ns_lookup (walk_state->scope_info,
(char *) &arg->named.name,
type, ACPI_IMODE_LOAD_PASS1,
- ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND,
+ ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
+ ACPI_NS_ERROR_IF_FOUND,
walk_state, &node);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_NSERROR ((char *) &arg->named.name, status);
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index b4d264dbbf6..d7790db5017 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -49,12 +49,21 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsinit")
+/* Local prototypes */
+
+static acpi_status
+acpi_ds_init_one_object (
+ acpi_handle obj_handle,
+ u32 level,
+ void *context,
+ void **return_value);
+
/*******************************************************************************
*
* FUNCTION: acpi_ds_init_one_object
*
- * PARAMETERS: obj_handle - Node
+ * PARAMETERS: obj_handle - Node for the object
* Level - Current nesting level
* Context - Points to a init info struct
* return_value - Not used
@@ -70,7 +79,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_init_one_object (
acpi_handle obj_handle,
u32 level,
@@ -105,7 +114,8 @@ acpi_ds_init_one_object (
status = acpi_ds_initialize_region (obj_handle);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Region %p [%4.4s] - Init failure, %s\n",
obj_handle, acpi_ut_get_node_name (obj_handle),
acpi_format_exception (status)));
}
@@ -118,8 +128,10 @@ acpi_ds_init_one_object (
info->method_count++;
- /* Print a dot for each method unless we are going to print the entire pathname */
-
+ /*
+ * Print a dot for each method unless we are going to print
+ * the entire pathname
+ */
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
}
@@ -140,7 +152,8 @@ acpi_ds_init_one_object (
*/
status = acpi_ds_parse_method (obj_handle);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Method %p [%4.4s] - parse failure, %s\n",
obj_handle, acpi_ut_get_node_name (obj_handle),
acpi_format_exception (status)));
@@ -154,7 +167,8 @@ acpi_ds_init_one_object (
* for every execution since there isn't much overhead
*/
acpi_ns_delete_namespace_subtree (obj_handle);
- acpi_ns_delete_namespace_by_owner (((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
+ acpi_ns_delete_namespace_by_owner (
+ ((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
break;
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 9f0456cb9bb..9fc3f4c033e 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -153,12 +153,11 @@ acpi_ds_parse_method (
/*
* Parse the method, first pass
*
- * The first pass load is where newly declared named objects are
- * added into the namespace. Actual evaluation of
- * the named objects (what would be called a "second
- * pass") happens during the actual execution of the
- * method so that operands to the named objects can
- * take on dynamic run-time values.
+ * The first pass load is where newly declared named objects are added into
+ * the namespace. Actual evaluation of the named objects (what would be
+ * called a "second pass") happens during the actual execution of the
+ * method so that operands to the named objects can take on dynamic
+ * run-time values.
*/
status = acpi_ps_parse_aml (walk_state);
if (ACPI_FAILURE (status)) {
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index f31d095f983..f7998306f75 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -52,6 +52,29 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsmthdat")
+/* Local prototypes */
+
+static void
+acpi_ds_method_data_delete_value (
+ u16 opcode,
+ u32 index,
+ struct acpi_walk_state *walk_state);
+
+static acpi_status
+acpi_ds_method_data_set_value (
+ u16 opcode,
+ u32 index,
+ union acpi_operand_object *object,
+ struct acpi_walk_state *walk_state);
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+acpi_object_type
+acpi_ds_method_data_get_type (
+ u16 opcode,
+ u32 index,
+ struct acpi_walk_state *walk_state);
+#endif
+
/*******************************************************************************
*
@@ -62,8 +85,8 @@
* RETURN: Status
*
* DESCRIPTION: Initialize the data structures that hold the method's arguments
- * and locals. The data struct is an array of NTEs for each.
- * This allows ref_of and de_ref_of to work properly for these
+ * and locals. The data struct is an array of namespace nodes for
+ * each - this allows ref_of and de_ref_of to work properly for these
* special data types.
*
* NOTES: walk_state fields are initialized to zero by the
@@ -92,7 +115,8 @@ acpi_ds_method_data_init (
walk_state->arguments[i].name.integer |= (i << 24);
walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->arguments[i].type = ACPI_TYPE_ANY;
- walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
+ walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
+ ANOBJ_METHOD_ARG;
}
/* Init the method locals */
@@ -104,7 +128,8 @@ acpi_ds_method_data_init (
walk_state->local_variables[i].name.integer |= (i << 24);
walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED;
walk_state->local_variables[i].type = ACPI_TYPE_ANY;
- walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
+ walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
+ ANOBJ_METHOD_LOCAL;
}
return_VOID;
@@ -198,15 +223,18 @@ acpi_ds_method_data_init_args (
return_ACPI_STATUS (AE_OK);
}
- /* Copy passed parameters into the new method stack frame */
+ /* Copy passed parameters into the new method stack frame */
- while ((index < ACPI_METHOD_NUM_ARGS) && (index < max_param_count) && params[index]) {
+ while ((index < ACPI_METHOD_NUM_ARGS) &&
+ (index < max_param_count) &&
+ params[index]) {
/*
* A valid parameter.
* Store the argument in the method/walk descriptor.
* Do not copy the arg in order to implement call by reference
*/
- status = acpi_ds_method_data_set_value (AML_ARG_OP, index, params[index], walk_state);
+ status = acpi_ds_method_data_set_value (AML_ARG_OP, index,
+ params[index], walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -224,11 +252,13 @@ acpi_ds_method_data_init_args (
* FUNCTION: acpi_ds_method_data_get_node
*
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
- * Index - which local_var or argument whose type
- * to get
+ * Index - Which Local or Arg whose type to get
* walk_state - Current walk state object
+ * Node - Where the node is returned.
*
- * RETURN: Get the Node associated with a local or arg.
+ * RETURN: Status and node
+ *
+ * DESCRIPTION: Get the Node associated with a local or arg.
*
******************************************************************************/
@@ -249,7 +279,8 @@ acpi_ds_method_data_get_node (
case AML_LOCAL_OP:
if (index > ACPI_METHOD_MAX_LOCAL) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Local index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_LOCAL));
return_ACPI_STATUS (AE_AML_INVALID_INDEX);
}
@@ -262,7 +293,8 @@ acpi_ds_method_data_get_node (
case AML_ARG_OP:
if (index > ACPI_METHOD_MAX_ARG) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Arg index %d is invalid (max %d)\n",
index, ACPI_METHOD_MAX_ARG));
return_ACPI_STATUS (AE_AML_INVALID_INDEX);
}
@@ -286,7 +318,7 @@ acpi_ds_method_data_get_node (
* FUNCTION: acpi_ds_method_data_set_value
*
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
- * Index - which local_var or argument to get
+ * Index - Which Local or Arg to get
* Object - Object to be inserted into the stack entry
* walk_state - Current walk state object
*
@@ -297,7 +329,7 @@ acpi_ds_method_data_get_node (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_method_data_set_value (
u16 opcode,
u32 index,
@@ -340,68 +372,16 @@ acpi_ds_method_data_set_value (
/*******************************************************************************
*
- * FUNCTION: acpi_ds_method_data_get_type
- *
- * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
- * Index - which local_var or argument whose type
- * to get
- * walk_state - Current walk state object
- *
- * RETURN: Data type of current value of the selected Arg or Local
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
-acpi_object_type
-acpi_ds_method_data_get_type (
- u16 opcode,
- u32 index,
- struct acpi_walk_state *walk_state)
-{
- acpi_status status;
- struct acpi_namespace_node *node;
- union acpi_operand_object *object;
-
-
- ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
-
-
- /* Get the namespace node for the arg/local */
-
- status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
- if (ACPI_FAILURE (status)) {
- return_VALUE ((ACPI_TYPE_NOT_FOUND));
- }
-
- /* Get the object */
-
- object = acpi_ns_get_attached_object (node);
- if (!object) {
- /* Uninitialized local/arg, return TYPE_ANY */
-
- return_VALUE (ACPI_TYPE_ANY);
- }
-
- /* Get the object type */
-
- return_VALUE (ACPI_GET_OBJECT_TYPE (object));
-}
-#endif /* ACPI_FUTURE_USAGE */
-
-
-/*******************************************************************************
- *
* FUNCTION: acpi_ds_method_data_get_value
*
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
* Index - which local_var or argument to get
* walk_state - Current walk state object
- * *dest_desc - Ptr to Descriptor into which selected Arg
- * or Local value should be copied
+ * dest_desc - Where Arg or Local value is returned
*
* RETURN: Status
*
- * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame
- * at the current top of the method stack.
+ * DESCRIPTION: Retrieve value of selected Arg or Local for this method
* Used only in acpi_ex_resolve_to_value().
*
******************************************************************************/
@@ -467,14 +447,16 @@ acpi_ds_method_data_get_value (
else switch (opcode) {
case AML_ARG_OP:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Uninitialized Arg[%d] at node %p\n",
index, node));
return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
case AML_LOCAL_OP:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Uninitialized Local[%d] at node %p\n",
index, node));
return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
@@ -506,12 +488,12 @@ acpi_ds_method_data_get_value (
*
* RETURN: None
*
- * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts
+ * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
* a null into the stack slot after the object is deleted.
*
******************************************************************************/
-void
+static void
acpi_ds_method_data_delete_value (
u16 opcode,
u32 index,
@@ -562,7 +544,7 @@ acpi_ds_method_data_delete_value (
* FUNCTION: acpi_ds_store_object_to_local
*
* PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
- * Index - which local_var or argument to set
+ * Index - Which Local or Arg to set
* obj_desc - Value to be stored
* walk_state - Current walk state
*
@@ -651,19 +633,20 @@ acpi_ds_store_object_to_local (
*/
if (opcode == AML_ARG_OP) {
/*
- * Make sure that the object is the correct type. This may be overkill, but
- * it is here because references were NS nodes in the past. Now they are
- * operand objects of type Reference.
+ * Make sure that the object is the correct type. This may be
+ * overkill, butit is here because references were NS nodes in
+ * the past. Now they are operand objects of type Reference.
*/
if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
- ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: [%s]\n",
- acpi_ut_get_descriptor_name (current_obj_desc)));
+ ACPI_REPORT_ERROR ((
+ "Invalid descriptor type while storing to method arg: [%s]\n",
+ acpi_ut_get_descriptor_name (current_obj_desc)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
/*
- * If we have a valid reference object that came from ref_of(), do the
- * indirect store
+ * If we have a valid reference object that came from ref_of(),
+ * do the indirect store
*/
if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
(current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
@@ -713,3 +696,55 @@ acpi_ds_store_object_to_local (
}
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ds_method_data_get_type
+ *
+ * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
+ * Index - Which Local or Arg whose type to get
+ * walk_state - Current walk state object
+ *
+ * RETURN: Data type of current value of the selected Arg or Local
+ *
+ * DESCRIPTION: Get the type of the object stored in the Local or Arg
+ *
+ ******************************************************************************/
+
+acpi_object_type
+acpi_ds_method_data_get_type (
+ u16 opcode,
+ u32 index,
+ struct acpi_walk_state *walk_state)
+{
+ acpi_status status;
+ struct acpi_namespace_node *node;
+ union acpi_operand_object *object;
+
+
+ ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
+
+
+ /* Get the namespace node for the arg/local */
+
+ status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
+ if (ACPI_FAILURE (status)) {
+ return_VALUE ((ACPI_TYPE_NOT_FOUND));
+ }
+
+ /* Get the object */
+
+ object = acpi_ns_get_attached_object (node);
+ if (!object) {
+ /* Uninitialized local/arg, return TYPE_ANY */
+
+ return_VALUE (ACPI_TYPE_ANY);
+ }
+
+ /* Get the object type */
+
+ return_VALUE (ACPI_GET_OBJECT_TYPE (object));
+}
+#endif
+
+
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index eb8af4785bc..bfbae4e4c66 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -52,9 +52,15 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsobject")
+static acpi_status
+acpi_ds_build_internal_object (
+ struct acpi_walk_state *walk_state,
+ union acpi_parse_object *op,
+ union acpi_operand_object **obj_desc_ptr);
+
#ifndef ACPI_NO_METHOD_EXECUTION
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_build_internal_object
*
@@ -67,9 +73,9 @@
* DESCRIPTION: Translate a parser Op object to the equivalent namespace object
* Simple objects are any objects other than a package object!
*
- ****************************************************************************/
+ ******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_build_internal_object (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
@@ -90,9 +96,11 @@ acpi_ds_build_internal_object (
* Otherwise, go ahead and look it up now
*/
if (!op->common.node) {
- status = acpi_ns_lookup (walk_state->scope_info, op->common.value.string,
+ status = acpi_ns_lookup (walk_state->scope_info,
+ op->common.value.string,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+ NULL,
(struct acpi_namespace_node **) &(op->common.node));
if (ACPI_FAILURE (status)) {
@@ -104,12 +112,14 @@ acpi_ds_build_internal_object (
/* Create and init the internal ACPI object */
- obj_desc = acpi_ut_create_internal_object ((acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type);
+ obj_desc = acpi_ut_create_internal_object (
+ (acpi_ps_get_opcode_info (op->common.aml_opcode))->object_type);
if (!obj_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
- status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode, &obj_desc);
+ status = acpi_ds_init_object_from_op (walk_state, op, op->common.aml_opcode,
+ &obj_desc);
if (ACPI_FAILURE (status)) {
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
@@ -120,7 +130,7 @@ acpi_ds_build_internal_object (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_build_internal_buffer_obj
*
@@ -134,7 +144,7 @@ acpi_ds_build_internal_object (
* DESCRIPTION: Translate a parser Op package object to the equivalent
* namespace object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_build_internal_buffer_obj (
@@ -229,7 +239,7 @@ acpi_ds_build_internal_buffer_obj (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_build_internal_package_obj
*
@@ -243,7 +253,7 @@ acpi_ds_build_internal_buffer_obj (
* DESCRIPTION: Translate a parser Op package object to the equivalent
* namespace object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_build_internal_package_obj (
@@ -331,11 +341,12 @@ acpi_ds_build_internal_package_obj (
if (arg->common.aml_opcode == AML_INT_RETURN_VALUE_OP) {
/* Object (package or buffer) is already built */
- obj_desc->package.elements[i] = ACPI_CAST_PTR (union acpi_operand_object, arg->common.node);
+ obj_desc->package.elements[i] =
+ ACPI_CAST_PTR (union acpi_operand_object, arg->common.node);
}
else {
status = acpi_ds_build_internal_object (walk_state, arg,
- &obj_desc->package.elements[i]);
+ &obj_desc->package.elements[i]);
}
i++;
@@ -348,7 +359,7 @@ acpi_ds_build_internal_package_obj (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_create_node
*
@@ -360,7 +371,7 @@ acpi_ds_build_internal_package_obj (
*
* DESCRIPTION: Create the object to be associated with a namespace node
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_create_node (
@@ -392,7 +403,8 @@ acpi_ds_create_node (
/* Build an internal object for the argument(s) */
- status = acpi_ds_build_internal_object (walk_state, op->common.value.arg, &obj_desc);
+ status = acpi_ds_build_internal_object (walk_state, op->common.value.arg,
+ &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -414,7 +426,7 @@ acpi_ds_create_node (
#endif /* ACPI_NO_METHOD_EXECUTION */
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_init_object_from_op
*
@@ -429,7 +441,7 @@ acpi_ds_create_node (
* associated arguments. The namespace object is a more compact
* representation of the Op and its arguments.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_init_object_from_op (
@@ -462,7 +474,8 @@ acpi_ds_init_object_from_op (
/*
* Defer evaluation of Buffer term_arg operand
*/
- obj_desc->buffer.node = (struct acpi_namespace_node *) walk_state->operands[0];
+ obj_desc->buffer.node = (struct acpi_namespace_node *)
+ walk_state->operands[0];
obj_desc->buffer.aml_start = op->named.data;
obj_desc->buffer.aml_length = op->named.length;
break;
@@ -473,7 +486,8 @@ acpi_ds_init_object_from_op (
/*
* Defer evaluation of Package term_arg operand
*/
- obj_desc->package.node = (struct acpi_namespace_node *) walk_state->operands[0];
+ obj_desc->package.node = (struct acpi_namespace_node *)
+ walk_state->operands[0];
obj_desc->package.aml_start = op->named.data;
obj_desc->package.aml_length = op->named.length;
break;
@@ -486,9 +500,10 @@ acpi_ds_init_object_from_op (
/*
* Resolve AML Constants here - AND ONLY HERE!
* All constants are integers.
- * We mark the integer with a flag that indicates that it started life
- * as a constant -- so that stores to constants will perform as expected (noop).
- * (zero_op is used as a placeholder for optional target operands.)
+ * We mark the integer with a flag that indicates that it started
+ * life as a constant -- so that stores to constants will perform
+ * as expected (noop). zero_op is used as a placeholder for optional
+ * target operands.
*/
obj_desc->common.flags = AOPOBJ_AML_CONSTANT;
@@ -521,7 +536,8 @@ acpi_ds_init_object_from_op (
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", opcode));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Unknown constant opcode %X\n", opcode));
status = AE_AML_OPERAND_TYPE;
break;
}
@@ -535,7 +551,8 @@ acpi_ds_init_object_from_op (
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", op_info->type));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n",
+ op_info->type));
status = AE_AML_OPERAND_TYPE;
break;
}
@@ -570,8 +587,10 @@ acpi_ds_init_object_from_op (
obj_desc->reference.offset = opcode - AML_LOCAL_OP;
#ifndef ACPI_NO_METHOD_EXECUTION
- status = acpi_ds_method_data_get_node (AML_LOCAL_OP, obj_desc->reference.offset,
- walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object);
+ status = acpi_ds_method_data_get_node (AML_LOCAL_OP,
+ obj_desc->reference.offset,
+ walk_state,
+ (struct acpi_namespace_node **) &obj_desc->reference.object);
#endif
break;
@@ -584,8 +603,10 @@ acpi_ds_init_object_from_op (
obj_desc->reference.offset = opcode - AML_ARG_OP;
#ifndef ACPI_NO_METHOD_EXECUTION
- status = acpi_ds_method_data_get_node (AML_ARG_OP, obj_desc->reference.offset,
- walk_state, (struct acpi_namespace_node **) &obj_desc->reference.object);
+ status = acpi_ds_method_data_get_node (AML_ARG_OP,
+ obj_desc->reference.offset,
+ walk_state,
+ (struct acpi_namespace_node **) &obj_desc->reference.object);
#endif
break;
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 5c987a0e7b7..ba13bca28be 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -54,12 +54,31 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dsopcode")
+/* Local prototypes */
-/*****************************************************************************
+static acpi_status
+acpi_ds_execute_arguments (
+ struct acpi_namespace_node *node,
+ struct acpi_namespace_node *scope_node,
+ u32 aml_length,
+ u8 *aml_start);
+
+static acpi_status
+acpi_ds_init_buffer_field (
+ u16 aml_opcode,
+ union acpi_operand_object *obj_desc,
+ union acpi_operand_object *buffer_desc,
+ union acpi_operand_object *offset_desc,
+ union acpi_operand_object *length_desc,
+ union acpi_operand_object *result_desc);
+
+
+/*******************************************************************************
*
* FUNCTION: acpi_ds_execute_arguments
*
- * PARAMETERS: Node - Parent NS node
+ * PARAMETERS: Node - Object NS node
+ * scope_node - Parent NS node
* aml_length - Length of executable AML
* aml_start - Pointer to the AML
*
@@ -67,9 +86,9 @@
*
* DESCRIPTION: Late (deferred) execution of region or field arguments
*
- ****************************************************************************/
+ ******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_execute_arguments (
struct acpi_namespace_node *node,
struct acpi_namespace_node *scope_node,
@@ -162,7 +181,7 @@ acpi_ds_execute_arguments (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_get_buffer_field_arguments
*
@@ -173,7 +192,7 @@ acpi_ds_execute_arguments (
* DESCRIPTION: Get buffer_field Buffer and Index. This implements the late
* evaluation of these field attributes.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_get_buffer_field_arguments (
@@ -208,7 +227,7 @@ acpi_ds_get_buffer_field_arguments (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_get_buffer_arguments
*
@@ -219,7 +238,7 @@ acpi_ds_get_buffer_field_arguments (
* DESCRIPTION: Get Buffer length and initializer byte list. This implements
* the late evaluation of these attributes.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_get_buffer_arguments (
@@ -255,7 +274,7 @@ acpi_ds_get_buffer_arguments (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_get_package_arguments
*
@@ -266,7 +285,7 @@ acpi_ds_get_buffer_arguments (
* DESCRIPTION: Get Package length and initializer byte list. This implements
* the late evaluation of these attributes.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_get_package_arguments (
@@ -353,17 +372,17 @@ acpi_ds_get_region_arguments (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_initialize_region
*
- * PARAMETERS: Op - A valid region Op object
+ * PARAMETERS: obj_handle - Region namespace node
*
* RETURN: Status
*
* DESCRIPTION: Front end to ev_initialize_region
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_initialize_region (
@@ -382,7 +401,7 @@ acpi_ds_initialize_region (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_init_buffer_field
*
@@ -390,16 +409,16 @@ acpi_ds_initialize_region (
* obj_desc - buffer_field object
* buffer_desc - Host Buffer
* offset_desc - Offset into buffer
- * Length - Length of field (CREATE_FIELD_OP only)
- * Result - Where to store the result
+ * length_desc - Length of field (CREATE_FIELD_OP only)
+ * result_desc - Where to store the result
*
* RETURN: Status
*
* DESCRIPTION: Perform actual initialization of a buffer field
*
- ****************************************************************************/
+ ******************************************************************************/
-acpi_status
+static acpi_status
acpi_ds_init_buffer_field (
u16 aml_opcode,
union acpi_operand_object *obj_desc,
@@ -435,8 +454,10 @@ acpi_ds_init_buffer_field (
* after resolution in acpi_ex_resolve_operands().
*/
if (ACPI_GET_DESCRIPTOR_TYPE (result_desc) != ACPI_DESC_TYPE_NAMED) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n",
- acpi_ps_get_opcode_name (aml_opcode), acpi_ut_get_descriptor_name (result_desc)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(%s) destination not a NS Node [%s]\n",
+ acpi_ps_get_opcode_name (aml_opcode),
+ acpi_ut_get_descriptor_name (result_desc)));
status = AE_AML_OPERAND_TYPE;
goto cleanup;
@@ -452,9 +473,18 @@ acpi_ds_init_buffer_field (
/* Offset is in bits, count is in bits */
+ field_flags = AML_FIELD_ACCESS_BYTE;
bit_offset = offset;
bit_count = (u32) length_desc->integer.value;
- field_flags = AML_FIELD_ACCESS_BYTE;
+
+ /* Must have a valid (>0) bit count */
+
+ if (bit_count == 0) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Attempt to create_field of length 0\n"));
+ status = AE_AML_OPERAND_VALUE;
+ goto cleanup;
+ }
break;
case AML_CREATE_BIT_FIELD_OP:
@@ -527,7 +557,8 @@ acpi_ds_init_buffer_field (
/*
* Initialize areas of the field object that are common to all fields
- * For field_flags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE)
+ * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
+ * UPDATE_RULE = 0 (UPDATE_PRESERVE)
*/
status = acpi_ex_prep_common_field_object (obj_desc, field_flags, 0,
bit_offset, bit_count);
@@ -539,8 +570,8 @@ acpi_ds_init_buffer_field (
/* Reference count for buffer_desc inherits obj_desc count */
- buffer_desc->common.reference_count = (u16) (buffer_desc->common.reference_count +
- obj_desc->common.reference_count);
+ buffer_desc->common.reference_count = (u16)
+ (buffer_desc->common.reference_count + obj_desc->common.reference_count);
cleanup:
@@ -569,7 +600,7 @@ cleanup:
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_eval_buffer_field_operands
*
@@ -581,7 +612,7 @@ cleanup:
* DESCRIPTION: Get buffer_field Buffer and Index
* Called from acpi_ds_exec_end_op during buffer_field parse tree walk
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_eval_buffer_field_operands (
@@ -656,7 +687,7 @@ acpi_ds_eval_buffer_field_operands (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_eval_region_operands
*
@@ -668,7 +699,7 @@ acpi_ds_eval_buffer_field_operands (
* DESCRIPTION: Get region address and length
* Called from acpi_ds_exec_end_op during op_region parse tree walk
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_eval_region_operands (
@@ -686,7 +717,8 @@ acpi_ds_eval_region_operands (
/*
- * This is where we evaluate the address and length fields of the op_region declaration
+ * This is where we evaluate the address and length fields of the
+ * op_region declaration
*/
node = op->common.node;
@@ -707,7 +739,8 @@ acpi_ds_eval_region_operands (
/* Resolve the length and address operands to numbers */
- status = acpi_ex_resolve_operands (op->common.aml_opcode, ACPI_WALK_OPERANDS, walk_state);
+ status = acpi_ex_resolve_operands (op->common.aml_opcode,
+ ACPI_WALK_OPERANDS, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -736,7 +769,8 @@ acpi_ds_eval_region_operands (
*/
operand_desc = walk_state->operands[walk_state->num_operands - 2];
- obj_desc->region.address = (acpi_physical_address) operand_desc->integer.value;
+ obj_desc->region.address = (acpi_physical_address)
+ operand_desc->integer.value;
acpi_ut_remove_reference (operand_desc);
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "rgn_obj %p Addr %8.8X%8.8X Len %X\n",
@@ -752,7 +786,7 @@ acpi_ds_eval_region_operands (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ds_eval_data_object_operands
*
@@ -765,7 +799,7 @@ acpi_ds_eval_region_operands (
* DESCRIPTION: Get the operands and complete the following data object types:
* Buffer, Package.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ds_eval_data_object_operands (
@@ -830,7 +864,7 @@ acpi_ds_eval_data_object_operands (
if (ACPI_SUCCESS (status)) {
/*
- * Return the object in the walk_state, unless the parent is a package --
+ * Return the object in the walk_state, unless the parent is a package -
* in this case, the return object will be stored in the parse tree
* for the package.
*/
@@ -988,7 +1022,8 @@ acpi_ds_exec_end_control_op (
status = AE_CTRL_PENDING;
}
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "[WHILE_OP] termination! Op=%p\n",op));
/* Pop this control state and free it */
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/dispatcher/dsutils.c
index 462c5d83e74..9613349ac31 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/dispatcher/dsutils.c
@@ -100,7 +100,6 @@ acpi_ds_clear_implicit_return (
#ifndef ACPI_NO_METHOD_EXECUTION
-
/*******************************************************************************
*
* FUNCTION: acpi_ds_do_implicit_return
@@ -205,7 +204,7 @@ acpi_ds_is_result_used (
* NOTE: this is optional because the ASL language does not actually
* support this behavior.
*/
- acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE);
+ (void) acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE);
/*
* Now determine if the parent will use the result
@@ -219,8 +218,9 @@ acpi_ds_is_result_used (
(op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
/* No parent, the return value cannot possibly be used */
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "At Method level, result of [%s] not used\n",
- acpi_ps_get_opcode_name (op->common.aml_opcode)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "At Method level, result of [%s] not used\n",
+ acpi_ps_get_opcode_name (op->common.aml_opcode)));
return_VALUE (FALSE);
}
@@ -228,7 +228,8 @@ acpi_ds_is_result_used (
parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
if (parent_info->class == AML_CLASS_UNKNOWN) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Unknown parent opcode. Op=%p\n", op));
return_VALUE (FALSE);
}
@@ -309,17 +310,19 @@ acpi_ds_is_result_used (
result_used:
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
- acpi_ps_get_opcode_name (op->common.aml_opcode),
- acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "Result of [%s] used by Parent [%s] Op=%p\n",
+ acpi_ps_get_opcode_name (op->common.aml_opcode),
+ acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
return_VALUE (TRUE);
result_not_used:
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
- acpi_ps_get_opcode_name (op->common.aml_opcode),
- acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "Result of [%s] not used by Parent [%s] Op=%p\n",
+ acpi_ps_get_opcode_name (op->common.aml_opcode),
+ acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
return_VALUE (FALSE);
}
@@ -522,7 +525,8 @@ acpi_ds_create_operand (
if ((walk_state->deferred_node) &&
(walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) &&
(arg_index != 0)) {
- obj_desc = ACPI_CAST_PTR (union acpi_operand_object, walk_state->deferred_node);
+ obj_desc = ACPI_CAST_PTR (
+ union acpi_operand_object, walk_state->deferred_node);
status = AE_OK;
}
else /* All other opcodes */ {
@@ -565,7 +569,8 @@ acpi_ds_create_operand (
* indicate this to the interpreter, set the
* object to the root
*/
- obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node);
+ obj_desc = ACPI_CAST_PTR (
+ union acpi_operand_object, acpi_gbl_root_node);
status = AE_OK;
}
else {
@@ -612,7 +617,8 @@ acpi_ds_create_operand (
*/
opcode = AML_ZERO_OP; /* Has no arguments! */
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "Null namepath: Arg=%p\n", arg));
}
else {
opcode = arg->common.aml_opcode;
@@ -642,7 +648,8 @@ acpi_ds_create_operand (
* Only error is underflow, and this indicates
* a missing or null operand!
*/
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Missing or null operand, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
}
@@ -657,8 +664,8 @@ acpi_ds_create_operand (
/* Initialize the new object */
- status = acpi_ds_init_object_from_op (walk_state, arg,
- opcode, &obj_desc);
+ status = acpi_ds_init_object_from_op (
+ walk_state, arg, opcode, &obj_desc);
if (ACPI_FAILURE (status)) {
acpi_ut_delete_object_desc (obj_desc);
return_ACPI_STATUS (status);
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index 2071a0d2bbb..10f71318e23 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -73,11 +73,13 @@ static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch [] = {
acpi_ex_opcode_3A_1T_1R,
acpi_ex_opcode_6A_0T_1R};
+
/*****************************************************************************
*
* FUNCTION: acpi_ds_get_predicate_value
*
* PARAMETERS: walk_state - Current state of the parse tree walk
+ * result_obj - if non-zero, pop result from result stack
*
* RETURN: Status
*
@@ -124,7 +126,8 @@ acpi_ds_get_predicate_value (
}
if (!obj_desc) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate obj_desc=%p State=%p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "No predicate obj_desc=%p State=%p\n",
obj_desc, walk_state));
return_ACPI_STATUS (AE_AML_NO_OPERAND);
@@ -197,7 +200,7 @@ cleanup:
* FUNCTION: acpi_ds_exec_begin_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * out_op - Return op if a new one is created
+ * out_op - Where to return op if a new one is created
*
* RETURN: Status
*
@@ -233,7 +236,8 @@ acpi_ds_exec_begin_op (
walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
if (acpi_ns_opens_scope (walk_state->op_info->object_type)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name (walk_state->op_info->object_type), op));
status = acpi_ds_scope_stack_pop (walk_state);
@@ -297,11 +301,10 @@ acpi_ds_exec_begin_op (
if (walk_state->walk_type == ACPI_WALK_METHOD) {
/*
- * Found a named object declaration during method
- * execution; we must enter this object into the
- * namespace. The created object is temporary and
- * will be deleted upon completion of the execution
- * of this method.
+ * Found a named object declaration during method execution;
+ * we must enter this object into the namespace. The created
+ * object is temporary and will be deleted upon completion of
+ * the execution of this method.
*/
status = acpi_ds_load2_begin_op (walk_state, NULL);
}
@@ -338,8 +341,6 @@ acpi_ds_exec_begin_op (
* FUNCTION: acpi_ds_exec_end_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * Op - Op that has been just been completed in the
- * walk; Arguments have now been evaluated.
*
* RETURN: Status
*
@@ -389,7 +390,7 @@ acpi_ds_exec_end_op (
/* Decode the Opcode Class */
switch (op_class) {
- case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */
+ case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */
break;
@@ -417,12 +418,12 @@ acpi_ds_exec_end_op (
/* Resolve all operands */
status = acpi_ex_resolve_operands (walk_state->opcode,
- &(walk_state->operands [walk_state->num_operands -1]),
- walk_state);
+ &(walk_state->operands [walk_state->num_operands -1]),
+ walk_state);
if (ACPI_SUCCESS (status)) {
ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE,
- acpi_ps_get_opcode_name (walk_state->opcode),
- walk_state->num_operands, "after ex_resolve_operands");
+ acpi_ps_get_opcode_name (walk_state->opcode),
+ walk_state->num_operands, "after ex_resolve_operands");
}
}
@@ -506,7 +507,8 @@ acpi_ds_exec_end_op (
if ((op->asl.parent) &&
((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP) ||
(op->asl.parent->asl.aml_opcode == AML_VAR_PACKAGE_OP))) {
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method Reference in a Package, Op=%p\n", op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "Method Reference in a Package, Op=%p\n", op));
op->common.node = (struct acpi_namespace_node *) op->asl.value.arg->asl.node->object;
acpi_ut_add_reference (op->asl.value.arg->asl.node->object);
return_ACPI_STATUS (AE_OK);
@@ -583,13 +585,15 @@ acpi_ds_exec_end_op (
case AML_NAME_OP:
/*
- * Put the Node on the object stack (Contains the ACPI Name of
- * this object)
+ * Put the Node on the object stack (Contains the ACPI Name
+ * of this object)
*/
walk_state->operands[0] = (void *) op->common.parent->common.node;
walk_state->num_operands = 1;
- status = acpi_ds_create_node (walk_state, op->common.parent->common.node, op->common.parent);
+ status = acpi_ds_create_node (walk_state,
+ op->common.parent->common.node,
+ op->common.parent);
if (ACPI_FAILURE (status)) {
break;
}
@@ -600,7 +604,7 @@ acpi_ds_exec_end_op (
case AML_INT_EVAL_SUBTREE_OP:
status = acpi_ds_eval_data_object_operands (walk_state, op,
- acpi_ns_get_attached_object (op->common.parent->common.node));
+ acpi_ns_get_attached_object (op->common.parent->common.node));
break;
default:
@@ -609,7 +613,7 @@ acpi_ds_exec_end_op (
break;
}
- /* Done with this result state (Now that operand stack is built) */
+ /* Done with result state (Now that operand stack is built) */
status = acpi_ds_result_stack_pop (walk_state);
if (ACPI_FAILURE (status)) {
@@ -620,8 +624,7 @@ acpi_ds_exec_end_op (
* If a result object was returned from above, push it on the
* current result stack
*/
- if (ACPI_SUCCESS (status) &&
- walk_state->result_obj) {
+ if (walk_state->result_obj) {
status = acpi_ds_result_push (walk_state->result_obj, walk_state);
}
break;
@@ -654,7 +657,8 @@ acpi_ds_exec_end_op (
case AML_TYPE_UNDEFINED:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", op));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Undefined opcode type Op=%p\n", op));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
@@ -709,13 +713,14 @@ cleanup:
status = acpi_gbl_exception_handler (status,
walk_state->method_node->name.integer, walk_state->opcode,
walk_state->aml_offset, NULL);
- acpi_ex_enter_interpreter ();
+ (void) acpi_ex_enter_interpreter ();
}
if (walk_state->result_obj) {
/* Break to debugger to display result */
- ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj, walk_state));
+ ACPI_DEBUGGER_EXEC (acpi_db_display_result_object (walk_state->result_obj,
+ walk_state));
/*
* Delete the result op if and only if:
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 06d75867958..1ac197ccfc8 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -79,20 +79,23 @@ acpi_ds_init_callbacks (
switch (pass_number) {
case 1:
- walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
+ walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
+ ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_load1_begin_op;
walk_state->ascending_callback = acpi_ds_load1_end_op;
break;
case 2:
- walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE;
+ walk_state->parse_flags = ACPI_PARSE_LOAD_PASS1 |
+ ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_load2_begin_op;
walk_state->ascending_callback = acpi_ds_load2_end_op;
break;
case 3:
#ifndef ACPI_NO_METHOD_EXECUTION
- walk_state->parse_flags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE;
+ walk_state->parse_flags |= ACPI_PARSE_EXECUTE |
+ ACPI_PARSE_DELETE_TREE;
walk_state->descending_callback = acpi_ds_exec_begin_op;
walk_state->ascending_callback = acpi_ds_exec_end_op;
#endif
@@ -111,8 +114,7 @@ acpi_ds_init_callbacks (
* FUNCTION: acpi_ds_load1_begin_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * Op - Op that has been just been reached in the
- * walk; Arguments have not been evaluated yet.
+ * out_op - Where to return op if a new one is created
*
* RETURN: Status
*
@@ -146,7 +148,8 @@ acpi_ds_load1_begin_op (
#if 0
if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
(walk_state->op_info->class == AML_CLASS_CONTROL)) {
- acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n", walk_state->op_info->name);
+ acpi_os_printf ("\n\n***EXECUTABLE OPCODE %s***\n\n",
+ walk_state->op_info->name);
*out_op = op;
return (AE_CTRL_SKIP);
}
@@ -191,7 +194,8 @@ acpi_ds_load1_begin_op (
*/
acpi_dm_add_to_external_list (path);
status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
- ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+ ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
+ walk_state, &(node));
}
#endif
if (ACPI_FAILURE (status)) {
@@ -224,10 +228,12 @@ acpi_ds_load1_begin_op (
* Name (DEB, 0)
* Scope (DEB) { ... }
*
- * Note: silently change the type here. On the second pass, we will report a warning
+ * Note: silently change the type here. On the second pass, we will report
+ * a warning
*/
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
path, acpi_ut_get_type_name (node->type)));
node->type = ACPI_TYPE_ANY;
@@ -238,7 +244,8 @@ acpi_ds_load1_begin_op (
/* All other types are an error */
- ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
+ ACPI_REPORT_ERROR ((
+ "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n",
acpi_ut_get_type_name (node->type), path));
return (AE_AML_OPERAND_TYPE);
@@ -249,7 +256,8 @@ acpi_ds_load1_begin_op (
default:
/*
- * For all other named opcodes, we will enter the name into the namespace.
+ * For all other named opcodes, we will enter the name into
+ * the namespace.
*
* Setup the search flags.
* Since we are entering a name into the namespace, we do not want to
@@ -279,14 +287,16 @@ acpi_ds_load1_begin_op (
acpi_ut_get_type_name (object_type)));
}
else {
- ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "[%s] Both Find or Create allowed\n",
acpi_ut_get_type_name (object_type)));
}
/*
* Enter the named type into the internal namespace. We enter the name
- * as we go downward in the parse tree. Any necessary subobjects that involve
- * arguments to the opcode must be created as we go back up the parse tree later.
+ * as we go downward in the parse tree. Any necessary subobjects that
+ * involve arguments to the opcode must be created as we go back up the
+ * parse tree later.
*/
status = acpi_ns_lookup (walk_state->scope_info, path, object_type,
ACPI_IMODE_LOAD_PASS1, flags, walk_state, &(node));
@@ -335,8 +345,6 @@ acpi_ds_load1_begin_op (
* FUNCTION: acpi_ds_load1_end_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * Op - Op that has been just been completed in the
- * walk; Arguments have now been evaluated.
*
* RETURN: Status
*
@@ -383,7 +391,9 @@ acpi_ds_load1_end_op (
if (op->common.aml_opcode == AML_REGION_OP) {
status = acpi_ex_create_region (op->named.data, op->named.length,
- (acpi_adr_space_type) ((op->common.value.arg)->common.value.integer), walk_state);
+ (acpi_adr_space_type)
+ ((op->common.value.arg)->common.value.integer),
+ walk_state);
if (ACPI_FAILURE (status)) {
return (status);
}
@@ -394,7 +404,8 @@ acpi_ds_load1_end_op (
/* For Name opcode, get the object type from the argument */
if (op->common.value.arg) {
- object_type = (acpi_ps_get_opcode_info ((op->common.value.arg)->common.aml_opcode))->object_type;
+ object_type = (acpi_ps_get_opcode_info (
+ (op->common.value.arg)->common.aml_opcode))->object_type;
op->common.node->type = (u8) object_type;
}
}
@@ -448,8 +459,7 @@ acpi_ds_load1_end_op (
* FUNCTION: acpi_ds_load2_begin_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * Op - Op that has been just been reached in the
- * walk; Arguments have not been evaluated yet.
+ * out_op - Wher to return op if a new one is created
*
* RETURN: Status
*
@@ -478,14 +488,20 @@ acpi_ds_load2_begin_op (
if (op) {
/* We only care about Namespace opcodes here */
- if ((!(walk_state->op_info->flags & AML_NSOPCODE) && (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
+ if ((!(walk_state->op_info->flags & AML_NSOPCODE) &&
+ (walk_state->opcode != AML_INT_NAMEPATH_OP)) ||
(!(walk_state->op_info->flags & AML_NAMED))) {
+ if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
+ (walk_state->op_info->class == AML_CLASS_CONTROL)) {
+ ACPI_REPORT_WARNING ((
+ "Encountered executable code at module level, [%s]\n",
+ acpi_ps_get_opcode_name (walk_state->opcode)));
+ }
return_ACPI_STATUS (AE_OK);
}
- /*
- * Get the name we are going to enter or lookup in the namespace
- */
+ /* Get the name we are going to enter or lookup in the namespace */
+
if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
/* For Namepath op, get the path string */
@@ -528,21 +544,25 @@ acpi_ds_load2_begin_op (
case AML_INT_NAMEPATH_OP:
/*
- * The name_path is an object reference to an existing object. Don't enter the
- * name into the namespace, but look it up for use later
+ * The name_path is an object reference to an existing object.
+ * Don't enter the name into the namespace, but look it up
+ * for use later.
*/
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
- ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+ ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
+ walk_state, &(node));
break;
case AML_SCOPE_OP:
/*
- * The Path is an object reference to an existing object. Don't enter the
- * name into the namespace, but look it up for use later
+ * The Path is an object reference to an existing object.
+ * Don't enter the name into the namespace, but look it up
+ * for use later.
*/
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
- ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, walk_state, &(node));
+ ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT,
+ walk_state, &(node));
if (ACPI_FAILURE (status)) {
#ifdef _ACPI_ASL_COMPILER
if (status == AE_NOT_FOUND) {
@@ -582,7 +602,8 @@ acpi_ds_load2_begin_op (
* Scope (DEB) { ... }
*/
- ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
+ ACPI_REPORT_WARNING ((
+ "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
buffer_ptr, acpi_ut_get_type_name (node->type)));
node->type = ACPI_TYPE_ANY;
@@ -593,7 +614,8 @@ acpi_ds_load2_begin_op (
/* All other types are an error */
- ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n",
+ ACPI_REPORT_ERROR ((
+ "Invalid type (%s) for target of Scope operator [%4.4s]\n",
acpi_ut_get_type_name (node->type), buffer_ptr));
return (AE_AML_OPERAND_TYPE);
@@ -621,8 +643,9 @@ acpi_ds_load2_begin_op (
/*
* Enter the named type into the internal namespace. We enter the name
- * as we go downward in the parse tree. Any necessary subobjects that involve
- * arguments to the opcode must be created as we go back up the parse tree later.
+ * as we go downward in the parse tree. Any necessary subobjects that
+ * involve arguments to the opcode must be created as we go back up the
+ * parse tree later.
*
* Note: Name may already exist if we are executing a deferred opcode.
*/
@@ -635,7 +658,8 @@ acpi_ds_load2_begin_op (
}
status = acpi_ns_lookup (walk_state->scope_info, buffer_ptr, object_type,
- ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, walk_state, &(node));
+ ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH,
+ walk_state, &(node));
break;
}
@@ -678,8 +702,6 @@ acpi_ds_load2_begin_op (
* FUNCTION: acpi_ds_load2_end_op
*
* PARAMETERS: walk_state - Current state of the parse tree walk
- * Op - Op that has been just been completed in the
- * walk; Arguments have now been evaluated.
*
* RETURN: Status
*
@@ -738,7 +760,8 @@ acpi_ds_load2_end_op (
/* Pop the scope stack */
- if (acpi_ns_opens_scope (object_type) && (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
+ if (acpi_ns_opens_scope (object_type) &&
+ (op->common.aml_opcode != AML_INT_METHODCALL_OP)) {
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n",
acpi_ut_get_type_name (object_type), op));
@@ -803,7 +826,7 @@ acpi_ds_load2_end_op (
case AML_INDEX_FIELD_OP:
status = acpi_ds_create_index_field (op, (acpi_handle) arg->common.node,
- walk_state);
+ walk_state);
break;
case AML_BANK_FIELD_OP:
@@ -884,14 +907,16 @@ acpi_ds_load2_end_op (
#ifndef ACPI_NO_METHOD_EXECUTION
case AML_REGION_OP:
/*
- * The op_region is not fully parsed at this time. Only valid argument is the space_id.
- * (We must save the address of the AML of the address and length operands)
+ * The op_region is not fully parsed at this time. Only valid
+ * argument is the space_id. (We must save the address of the
+ * AML of the address and length operands)
*/
/*
* If we have a valid region, initialize it
* Namespace is NOT locked at this point.
*/
- status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node), FALSE);
+ status = acpi_ev_initialize_region (acpi_ns_get_attached_object (node),
+ FALSE);
if (ACPI_FAILURE (status)) {
/*
* If AE_NOT_EXIST is returned, it is not fatal
@@ -942,15 +967,16 @@ acpi_ds_load2_end_op (
if (ACPI_SUCCESS (status)) {
/*
* Make sure that what we found is indeed a method
- * We didn't search for a method on purpose, to see if the name would resolve
+ * We didn't search for a method on purpose, to see if the name
+ * would resolve
*/
if (new_node->type != ACPI_TYPE_METHOD) {
status = AE_AML_OPERAND_TYPE;
}
- /* We could put the returned object (Node) on the object stack for later, but
- * for now, we will put it in the "op" object that the parser uses, so we
- * can get it again at the end of this scope
+ /* We could put the returned object (Node) on the object stack for
+ * later, but for now, we will put it in the "op" object that the
+ * parser uses, so we can get it again at the end of this scope
*/
op->common.node = new_node;
}
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/dispatcher/dswscope.c
index 65f456151e2..21f4548ff32 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/dispatcher/dswscope.c
@@ -50,14 +50,13 @@
ACPI_MODULE_NAME ("dswscope")
-#define STACK_POP(head) head
-
-
/****************************************************************************
*
* FUNCTION: acpi_ds_scope_stack_clear
*
- * PARAMETERS: None
+ * PARAMETERS: walk_state - Current state
+ *
+ * RETURN: None
*
* DESCRIPTION: Pop (and free) everything on the scope stack except the
* root scope object (which remains at the stack top.)
@@ -80,7 +79,8 @@ acpi_ds_scope_stack_clear (
walk_state->scope_info = scope_info->scope.next;
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Popped object type (%s)\n", acpi_ut_get_type_name (scope_info->common.value)));
+ "Popped object type (%s)\n",
+ acpi_ut_get_type_name (scope_info->common.value)));
acpi_ut_delete_generic_state (scope_info);
}
}
@@ -90,8 +90,11 @@ acpi_ds_scope_stack_clear (
*
* FUNCTION: acpi_ds_scope_stack_push
*
- * PARAMETERS: *Node, - Name to be made current
- * Type, - Type of frame being pushed
+ * PARAMETERS: Node - Name to be made current
+ * Type - Type of frame being pushed
+ * walk_state - Current state
+ *
+ * RETURN: Status
*
* DESCRIPTION: Push the current scope on the scope stack, and make the
* passed Node current.
@@ -121,7 +124,8 @@ acpi_ds_scope_stack_push (
/* Make sure object type is valid */
if (!acpi_ut_valid_object_type (type)) {
- ACPI_REPORT_WARNING (("ds_scope_stack_push: Invalid object type: 0x%X\n", type));
+ ACPI_REPORT_WARNING ((
+ "ds_scope_stack_push: Invalid object type: 0x%X\n", type));
}
/* Allocate a new scope object */
@@ -170,16 +174,11 @@ acpi_ds_scope_stack_push (
*
* FUNCTION: acpi_ds_scope_stack_pop
*
- * PARAMETERS: Type - The type of frame to be found
+ * PARAMETERS: walk_state - Current state
*
- * DESCRIPTION: Pop the scope stack until a frame of the requested type
- * is found.
+ * RETURN: Status
*
- * RETURN: Count of frames popped. If no frame of the requested type
- * was found, the count is returned as a negative number and
- * the scope stack is emptied (which sets the current scope
- * to the root). If the scope stack was empty at entry, the
- * function is a no-op and returns 0.
+ * DESCRIPTION: Pop the scope stack once.
*
***************************************************************************/
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/dispatcher/dswstate.c
index e555b3fbd5e..9cd3db652b3 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/dispatcher/dswstate.c
@@ -50,67 +50,31 @@
#define _COMPONENT ACPI_DISPATCHER
ACPI_MODULE_NAME ("dswstate")
+/* Local prototypes */
-#ifdef ACPI_FUTURE_USAGE
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ds_result_insert
- *
- * PARAMETERS: Object - Object to push
- * Index - Where to insert the object
- * walk_state - Current Walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Insert an object onto this walk's result stack
- *
- ******************************************************************************/
-
+#ifdef ACPI_OBSOLETE_FUNCTIONS
acpi_status
acpi_ds_result_insert (
void *object,
u32 index,
- struct acpi_walk_state *walk_state)
-{
- union acpi_generic_state *state;
-
+ struct acpi_walk_state *walk_state);
- ACPI_FUNCTION_NAME ("ds_result_insert");
-
-
- state = walk_state->results;
- if (!state) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
- walk_state));
- return (AE_NOT_EXIST);
- }
-
- if (index >= ACPI_OBJ_NUM_OPERANDS) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Index out of range: %X Obj=%p State=%p Num=%X\n",
- index, object, walk_state, state->results.num_results));
- return (AE_BAD_PARAMETER);
- }
-
- if (!object) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
- index, object, walk_state, state->results.num_results));
- return (AE_BAD_PARAMETER);
- }
-
- state->results.obj_desc [index] = object;
- state->results.num_results++;
+acpi_status
+acpi_ds_obj_stack_delete_all (
+ struct acpi_walk_state *walk_state);
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
- object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
- walk_state, state->results.num_results, walk_state->current_result));
+acpi_status
+acpi_ds_obj_stack_pop_object (
+ union acpi_operand_object **object,
+ struct acpi_walk_state *walk_state);
- return (AE_OK);
-}
+void *
+acpi_ds_obj_stack_get_value (
+ u32 index,
+ struct acpi_walk_state *walk_state);
+#endif
+#ifdef ACPI_FUTURE_USAGE
/*******************************************************************************
*
@@ -178,7 +142,6 @@ acpi_ds_result_remove (
#endif /* ACPI_FUTURE_USAGE */
-
/*******************************************************************************
*
* FUNCTION: acpi_ds_result_pop
@@ -227,15 +190,18 @@ acpi_ds_result_pop (
*object = state->results.obj_desc [index -1];
state->results.obj_desc [index -1] = NULL;
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n",
- *object, (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj=%p [%s] Index=%X State=%p Num=%X\n",
+ *object,
+ (*object) ? acpi_ut_get_object_type_name (*object) : "NULL",
(u32) index -1, walk_state, state->results.num_results));
return (AE_OK);
}
}
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "No result objects! State=%p\n", walk_state));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -274,7 +240,8 @@ acpi_ds_result_pop_from_bottom (
}
if (!state->results.num_results) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", walk_state));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n",
+ walk_state));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -293,7 +260,8 @@ acpi_ds_result_pop_from_bottom (
/* Check for a valid result object */
if (!*object) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null operand! State=%p #Ops=%X, Index=%X\n",
walk_state, state->results.num_results, (u32) index));
return (AE_AML_NO_RETURN_VALUE);
}
@@ -344,7 +312,8 @@ acpi_ds_result_push (
}
if (!object) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null Object! Obj=%p State=%p Num=%X\n",
object, walk_state, state->results.num_results));
return (AE_BAD_PARAMETER);
}
@@ -439,43 +408,6 @@ acpi_ds_result_stack_pop (
/*******************************************************************************
*
- * FUNCTION: acpi_ds_obj_stack_delete_all
- *
- * PARAMETERS: walk_state - Current Walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
- * Should be used with great care, if at all!
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
-acpi_status
-acpi_ds_obj_stack_delete_all (
- struct acpi_walk_state *walk_state)
-{
- u32 i;
-
-
- ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
-
-
- /* The stack size is configurable, but fixed */
-
- for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
- if (walk_state->operands[i]) {
- acpi_ut_remove_reference (walk_state->operands[i]);
- walk_state->operands[i] = NULL;
- }
- }
-
- return_ACPI_STATUS (AE_OK);
-}
-#endif /* ACPI_FUTURE_USAGE */
-
-
-/*******************************************************************************
- *
* FUNCTION: acpi_ds_obj_stack_push
*
* PARAMETERS: Object - Object to push
@@ -517,67 +449,6 @@ acpi_ds_obj_stack_push (
}
-#if 0
-/*******************************************************************************
- *
- * FUNCTION: acpi_ds_obj_stack_pop_object
- *
- * PARAMETERS: pop_count - Number of objects/entries to pop
- * walk_state - Current Walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
- * deleted by this routine.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ds_obj_stack_pop_object (
- union acpi_operand_object **object,
- struct acpi_walk_state *walk_state)
-{
- ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
-
-
- /* Check for stack underflow */
-
- if (walk_state->num_operands == 0) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Missing operand/stack empty! State=%p #Ops=%X\n",
- walk_state, walk_state->num_operands));
- *object = NULL;
- return (AE_AML_NO_OPERAND);
- }
-
- /* Pop the stack */
-
- walk_state->num_operands--;
-
- /* Check for a valid operand */
-
- if (!walk_state->operands [walk_state->num_operands]) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Null operand! State=%p #Ops=%X\n",
- walk_state, walk_state->num_operands));
- *object = NULL;
- return (AE_AML_NO_OPERAND);
- }
-
- /* Get operand and set stack entry to null */
-
- *object = walk_state->operands [walk_state->num_operands];
- walk_state->operands [walk_state->num_operands] = NULL;
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
- *object, acpi_ut_get_object_type_name (*object),
- walk_state, walk_state->num_operands));
-
- return (AE_OK);
-}
-#endif
-
-
/*******************************************************************************
*
* FUNCTION: acpi_ds_obj_stack_pop
@@ -680,48 +551,6 @@ acpi_ds_obj_stack_pop_and_delete (
/*******************************************************************************
*
- * FUNCTION: acpi_ds_obj_stack_get_value
- *
- * PARAMETERS: Index - Stack index whose value is desired. Based
- * on the top of the stack (index=0 == top)
- * walk_state - Current Walk state
- *
- * RETURN: Status
- *
- * DESCRIPTION: Retrieve an object from this walk's object stack. Index must
- * be within the range of the current stack pointer.
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
-void *
-acpi_ds_obj_stack_get_value (
- u32 index,
- struct acpi_walk_state *walk_state)
-{
-
- ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
-
-
- /* Can't do it if the stack is empty */
-
- if (walk_state->num_operands == 0) {
- return_PTR (NULL);
- }
-
- /* or if the index is past the top of the stack */
-
- if (index > (walk_state->num_operands - (u32) 1)) {
- return_PTR (NULL);
- }
-
- return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
- index]);
-}
-#endif /* ACPI_FUTURE_USAGE */
-
-
-/*******************************************************************************
- *
* FUNCTION: acpi_ds_get_current_walk_state
*
* PARAMETERS: Thread - Get current active state for this Thread
@@ -757,11 +586,11 @@ acpi_ds_get_current_walk_state (
* FUNCTION: acpi_ds_push_walk_state
*
* PARAMETERS: walk_state - State to push
- * walk_list - The list that owns the walk stack
+ * Thread - Thread state object
*
* RETURN: None
*
- * DESCRIPTION: Place the walk_state at the head of the state list.
+ * DESCRIPTION: Place the Thread state at the head of the state list.
*
******************************************************************************/
@@ -784,9 +613,9 @@ acpi_ds_push_walk_state (
*
* FUNCTION: acpi_ds_pop_walk_state
*
- * PARAMETERS: walk_list - The list that owns the walk stack
+ * PARAMETERS: Thread - Current thread state
*
- * RETURN: A walk_state object popped from the stack
+ * RETURN: A walk_state object popped from the thread's stack
*
* DESCRIPTION: Remove and return the walkstate object that is at the head of
* the walk stack for the given walk list. NULL indicates that
@@ -814,7 +643,7 @@ acpi_ds_pop_walk_state (
/*
* Don't clear the NEXT field, this serves as an indicator
* that there is a parent WALK STATE
- * NO: walk_state->Next = NULL;
+ * Do Not: walk_state->Next = NULL;
*/
}
@@ -826,7 +655,9 @@ acpi_ds_pop_walk_state (
*
* FUNCTION: acpi_ds_create_walk_state
*
- * PARAMETERS: Origin - Starting point for this walk
+ * PARAMETERS: owner_id - ID for object creation
+ * Origin - Starting point for this walk
+ * mth_desc - Method object
* Thread - Current thread state
*
* RETURN: Pointer to the new walk state.
@@ -896,8 +727,7 @@ acpi_ds_create_walk_state (
* method_node - Control method NS node, if any
* aml_start - Start of AML
* aml_length - Length of AML
- * Params - Method args, if any
- * return_obj_desc - Where to store a return object, if any
+ * Info - Method info block (params, etc.)
* pass_number - 1, 2, or 3
*
* RETURN: Status
@@ -931,7 +761,7 @@ acpi_ds_init_aml_walk (
/* The next_op of the next_walk will be the beginning of the method */
- walk_state->next_op = NULL;
+ walk_state->next_op = NULL;
if (info) {
if (info->parameter_type == ACPI_PARAM_GPE) {
@@ -939,8 +769,8 @@ acpi_ds_init_aml_walk (
info->parameters);
}
else {
- walk_state->params = info->parameters;
- walk_state->caller_return_desc = &info->return_object;
+ walk_state->params = info->parameters;
+ walk_state->caller_return_desc = &info->return_object;
}
}
@@ -964,7 +794,8 @@ acpi_ds_init_aml_walk (
/* Init the method arguments */
- status = acpi_ds_method_data_init_args (walk_state->params, ACPI_METHOD_NUM_ARGS, walk_state);
+ status = acpi_ds_method_data_init_args (walk_state->params,
+ ACPI_METHOD_NUM_ARGS, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -1031,12 +862,14 @@ acpi_ds_delete_walk_state (
}
if (walk_state->data_type != ACPI_DESC_TYPE_WALK) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", walk_state));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n",
+ walk_state));
return;
}
if (walk_state->parser_state.scope) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", walk_state));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n",
+ walk_state));
}
/* Always must free any linked control states */
@@ -1078,7 +911,7 @@ acpi_ds_delete_walk_state (
*
* PARAMETERS: None
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Purge the global state object cache. Used during subsystem
* termination.
@@ -1098,3 +931,200 @@ acpi_ds_delete_walk_state_cache (
#endif
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ds_result_insert
+ *
+ * PARAMETERS: Object - Object to push
+ * Index - Where to insert the object
+ * walk_state - Current Walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Insert an object onto this walk's result stack
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_result_insert (
+ void *object,
+ u32 index,
+ struct acpi_walk_state *walk_state)
+{
+ union acpi_generic_state *state;
+
+
+ ACPI_FUNCTION_NAME ("ds_result_insert");
+
+
+ state = walk_state->results;
+ if (!state) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n",
+ walk_state));
+ return (AE_NOT_EXIST);
+ }
+
+ if (index >= ACPI_OBJ_NUM_OPERANDS) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Index out of range: %X Obj=%p State=%p Num=%X\n",
+ index, object, walk_state, state->results.num_results));
+ return (AE_BAD_PARAMETER);
+ }
+
+ if (!object) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
+ index, object, walk_state, state->results.num_results));
+ return (AE_BAD_PARAMETER);
+ }
+
+ state->results.obj_desc [index] = object;
+ state->results.num_results++;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
+ object, object ? acpi_ut_get_object_type_name ((union acpi_operand_object *) object) : "NULL",
+ walk_state, state->results.num_results, walk_state->current_result));
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ds_obj_stack_delete_all
+ *
+ * PARAMETERS: walk_state - Current Walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clear the object stack by deleting all objects that are on it.
+ * Should be used with great care, if at all!
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_obj_stack_delete_all (
+ struct acpi_walk_state *walk_state)
+{
+ u32 i;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_delete_all", walk_state);
+
+
+ /* The stack size is configurable, but fixed */
+
+ for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) {
+ if (walk_state->operands[i]) {
+ acpi_ut_remove_reference (walk_state->operands[i]);
+ walk_state->operands[i] = NULL;
+ }
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ds_obj_stack_pop_object
+ *
+ * PARAMETERS: Object - Where to return the popped object
+ * walk_state - Current Walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT
+ * deleted by this routine.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ds_obj_stack_pop_object (
+ union acpi_operand_object **object,
+ struct acpi_walk_state *walk_state)
+{
+ ACPI_FUNCTION_NAME ("ds_obj_stack_pop_object");
+
+
+ /* Check for stack underflow */
+
+ if (walk_state->num_operands == 0) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Missing operand/stack empty! State=%p #Ops=%X\n",
+ walk_state, walk_state->num_operands));
+ *object = NULL;
+ return (AE_AML_NO_OPERAND);
+ }
+
+ /* Pop the stack */
+
+ walk_state->num_operands--;
+
+ /* Check for a valid operand */
+
+ if (!walk_state->operands [walk_state->num_operands]) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null operand! State=%p #Ops=%X\n",
+ walk_state, walk_state->num_operands));
+ *object = NULL;
+ return (AE_AML_NO_OPERAND);
+ }
+
+ /* Get operand and set stack entry to null */
+
+ *object = walk_state->operands [walk_state->num_operands];
+ walk_state->operands [walk_state->num_operands] = NULL;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n",
+ *object, acpi_ut_get_object_type_name (*object),
+ walk_state, walk_state->num_operands));
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ds_obj_stack_get_value
+ *
+ * PARAMETERS: Index - Stack index whose value is desired. Based
+ * on the top of the stack (index=0 == top)
+ * walk_state - Current Walk state
+ *
+ * RETURN: Pointer to the requested operand
+ *
+ * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must
+ * be within the range of the current stack pointer.
+ *
+ ******************************************************************************/
+
+void *
+acpi_ds_obj_stack_get_value (
+ u32 index,
+ struct acpi_walk_state *walk_state)
+{
+
+ ACPI_FUNCTION_TRACE_PTR ("ds_obj_stack_get_value", walk_state);
+
+
+ /* Can't do it if the stack is empty */
+
+ if (walk_state->num_operands == 0) {
+ return_PTR (NULL);
+ }
+
+ /* or if the index is past the top of the stack */
+
+ if (index > (walk_state->num_operands - (u32) 1)) {
+ return_PTR (NULL);
+ }
+
+ return_PTR (walk_state->operands[(acpi_native_uint)(walk_state->num_operands - 1) -
+ index]);
+}
+#endif
+
+
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index fdf143b405b..8e665f2e313 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -31,6 +31,7 @@
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/interrupt.h>
#include <asm/io.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
@@ -49,17 +50,19 @@ ACPI_MODULE_NAME ("acpi_ec")
#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
+#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */
#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */
-#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
-#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
+#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
#define ACPI_EC_COMMAND_READ 0x80
#define ACPI_EC_COMMAND_WRITE 0x81
+#define ACPI_EC_BURST_ENABLE 0x82
+#define ACPI_EC_BURST_DISABLE 0x83
#define ACPI_EC_COMMAND_QUERY 0x84
static int acpi_ec_add (struct acpi_device *device);
@@ -87,7 +90,11 @@ struct acpi_ec {
struct acpi_generic_address command_addr;
struct acpi_generic_address data_addr;
unsigned long global_lock;
- spinlock_t lock;
+ unsigned int expect_event;
+ atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/
+ atomic_t pending_gpe;
+ struct semaphore sem;
+ wait_queue_head_t wait;
};
/* If we find an EC via the ECDT, we need to keep a ptr to its context */
@@ -100,42 +107,122 @@ static struct acpi_device *first_ec;
Transaction Management
-------------------------------------------------------------------------- */
-static int
-acpi_ec_wait (
- struct acpi_ec *ec,
- u8 event)
+static inline u32 acpi_ec_read_status(struct acpi_ec *ec)
{
- u32 acpi_ec_status = 0;
- u32 i = ACPI_EC_UDELAY_COUNT;
+ u32 status = 0;
- if (!ec)
- return -EINVAL;
+ acpi_hw_low_level_read(8, &status, &ec->status_addr);
+ return status;
+}
+
+static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event)
+{
+ int result = 0;
+
+ ACPI_FUNCTION_TRACE("acpi_ec_wait");
- /* Poll the EC status register waiting for the event to occur. */
+ ec->expect_event = event;
+ smp_mb();
+
+ result = wait_event_interruptible_timeout(ec->wait,
+ !ec->expect_event,
+ msecs_to_jiffies(ACPI_EC_DELAY));
+
+ ec->expect_event = 0;
+ smp_mb();
+
+ if (result < 0){
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR," result = %d ", result));
+ return_VALUE(result);
+ }
+
+ /*
+ * Verify that the event in question has actually happened by
+ * querying EC status. Do the check even if operation timed-out
+ * to make sure that we did not miss interrupt.
+ */
switch (event) {
case ACPI_EC_EVENT_OBF:
- do {
- acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
- if (acpi_ec_status & ACPI_EC_FLAG_OBF)
- return 0;
- udelay(ACPI_EC_UDELAY);
- } while (--i>0);
+ if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
+ return_VALUE(0);
break;
+
case ACPI_EC_EVENT_IBE:
- do {
- acpi_hw_low_level_read(8, &acpi_ec_status, &ec->status_addr);
- if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
- return 0;
- udelay(ACPI_EC_UDELAY);
- } while (--i>0);
+ if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
+ return_VALUE(0);
break;
- default:
- return -EINVAL;
}
- return -ETIME;
+ return_VALUE(-ETIME);
+}
+
+
+
+static int
+acpi_ec_enter_burst_mode (
+ struct acpi_ec *ec)
+{
+ u32 tmp = 0;
+ int status = 0;
+
+ ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
+
+ status = acpi_ec_read_status(ec);
+ if (status != -EINVAL &&
+ !(status & ACPI_EC_FLAG_BURST)){
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n"));
+ acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+ if (status){
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status));
+ return_VALUE(-EINVAL);
+ }
+ acpi_hw_low_level_read(8, &tmp, &ec->data_addr);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ if(tmp != 0x90 ) {/* Burst ACK byte*/
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n"));
+ return_VALUE(-EINVAL);
+ }
+ } else
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n"));
+ atomic_set(&ec->leaving_burst , 0);
+ return_VALUE(0);
}
+static int
+acpi_ec_leave_burst_mode (
+ struct acpi_ec *ec)
+{
+ int status =0;
+
+ ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
+
+ atomic_set(&ec->leaving_burst , 1);
+ status = acpi_ec_read_status(ec);
+ if (status != -EINVAL &&
+ (status & ACPI_EC_FLAG_BURST)){
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
+ acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr);
+ status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
+ if (status){
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
+ return_VALUE(-EINVAL);
+ }
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ status = acpi_ec_read_status(ec);
+ if (status != -EINVAL &&
+ (status & ACPI_EC_FLAG_BURST)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n"));
+ return_VALUE(-EINVAL);
+ }
+ }else
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n"));
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
+
+ return_VALUE(0);
+}
static int
acpi_ec_read (
@@ -143,16 +230,15 @@ acpi_ec_read (
u8 address,
u32 *data)
{
- acpi_status status = AE_OK;
- int result = 0;
- unsigned long flags = 0;
- u32 glk = 0;
+ int status = 0;
+ u32 glk;
ACPI_FUNCTION_TRACE("acpi_ec_read");
if (!ec || !data)
return_VALUE(-EINVAL);
+retry:
*data = 0;
if (ec->global_lock) {
@@ -160,32 +246,50 @@ acpi_ec_read (
if (ACPI_FAILURE(status))
return_VALUE(-ENODEV);
}
-
- spin_lock_irqsave(&ec->lock, flags);
+
+ WARN_ON(in_interrupt());
+ down(&ec->sem);
+
+ if(acpi_ec_enter_burst_mode(ec))
+ goto end;
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
- if (result)
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ if (status) {
goto end;
+ }
acpi_hw_low_level_write(8, address, &ec->data_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
- if (result)
+ status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+ if (status){
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
goto end;
-
+ }
acpi_hw_low_level_read(8, data, &ec->data_addr);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
*data, address));
-
+
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ acpi_ec_leave_burst_mode(ec);
+ up(&ec->sem);
if (ec->global_lock)
acpi_release_global_lock(glk);
- return_VALUE(result);
+ if(atomic_read(&ec->leaving_burst) == 2){
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
+ while(atomic_read(&ec->pending_gpe)){
+ msleep(1);
+ }
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ goto retry;
+ }
+
+ return_VALUE(status);
}
@@ -195,49 +299,80 @@ acpi_ec_write (
u8 address,
u8 data)
{
- int result = 0;
- acpi_status status = AE_OK;
- unsigned long flags = 0;
- u32 glk = 0;
+ int status = 0;
+ u32 glk;
+ u32 tmp;
ACPI_FUNCTION_TRACE("acpi_ec_write");
if (!ec)
return_VALUE(-EINVAL);
-
+retry:
if (ec->global_lock) {
status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
if (ACPI_FAILURE(status))
return_VALUE(-ENODEV);
}
- spin_lock_irqsave(&ec->lock, flags);
+ WARN_ON(in_interrupt());
+ down(&ec->sem);
+
+ if(acpi_ec_enter_burst_mode(ec))
+ goto end;
+
+ status = acpi_ec_read_status(ec);
+ if (status != -EINVAL &&
+ !(status & ACPI_EC_FLAG_BURST)){
+ acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+ if (status)
+ goto end;
+ acpi_hw_low_level_read(8, &tmp, &ec->data_addr);
+ if(tmp != 0x90 ) /* Burst ACK byte*/
+ goto end;
+ }
+ /*Now we are in burst mode*/
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
- if (result)
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ if (status){
goto end;
+ }
acpi_hw_low_level_write(8, address, &ec->data_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
- if (result)
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+ if (status){
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
goto end;
+ }
acpi_hw_low_level_write(8, data, &ec->data_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
- if (result)
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ if (status)
goto end;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
data, address));
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ acpi_ec_leave_burst_mode(ec);
+ up(&ec->sem);
if (ec->global_lock)
acpi_release_global_lock(glk);
- return_VALUE(result);
+ if(atomic_read(&ec->leaving_burst) == 2){
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
+ while(atomic_read(&ec->pending_gpe)){
+ msleep(1);
+ }
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ goto retry;
+ }
+
+ return_VALUE(status);
}
/*
@@ -289,16 +424,13 @@ acpi_ec_query (
struct acpi_ec *ec,
u32 *data)
{
- int result = 0;
- acpi_status status = AE_OK;
- unsigned long flags = 0;
- u32 glk = 0;
+ int status = 0;
+ u32 glk;
ACPI_FUNCTION_TRACE("acpi_ec_query");
if (!ec || !data)
return_VALUE(-EINVAL);
-
*data = 0;
if (ec->global_lock) {
@@ -307,29 +439,39 @@ acpi_ec_query (
return_VALUE(-ENODEV);
}
+ down(&ec->sem);
+ if(acpi_ec_enter_burst_mode(ec))
+ goto end;
/*
* Query the EC to find out which _Qxx method we need to evaluate.
* Note that successful completion of the query causes the ACPI_EC_SCI
* bit to be cleared (and thus clearing the interrupt source).
*/
- spin_lock_irqsave(&ec->lock, flags);
-
acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr);
- result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
- if (result)
+ status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
+ if (status){
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
goto end;
-
+ }
+
acpi_hw_low_level_read(8, data, &ec->data_addr);
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
if (!*data)
- result = -ENODATA;
+ status = -ENODATA;
end:
- spin_unlock_irqrestore(&ec->lock, flags);
+ acpi_ec_leave_burst_mode(ec);
+ up(&ec->sem);
if (ec->global_lock)
acpi_release_global_lock(glk);
- return_VALUE(result);
+ if(atomic_read(&ec->leaving_burst) == 2){
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+ status = -ENODATA;
+ }
+ return_VALUE(status);
}
@@ -347,42 +489,29 @@ acpi_ec_gpe_query (
void *ec_cxt)
{
struct acpi_ec *ec = (struct acpi_ec *) ec_cxt;
- u32 value = 0;
- unsigned long flags = 0;
+ u32 value;
+ int result = -ENODATA;
static char object_name[5] = {'_','Q','0','0','\0'};
const char hex[] = {'0','1','2','3','4','5','6','7',
'8','9','A','B','C','D','E','F'};
ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
- if (!ec_cxt)
- goto end;
-
- spin_lock_irqsave(&ec->lock, flags);
- acpi_hw_low_level_read(8, &value, &ec->command_addr);
- spin_unlock_irqrestore(&ec->lock, flags);
+ if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
+ result = acpi_ec_query(ec, &value);
- /* TBD: Implement asynch events!
- * NOTE: All we care about are EC-SCI's. Other EC events are
- * handled via polling (yuck!). This is because some systems
- * treat EC-SCIs as level (versus EDGE!) triggered, preventing
- * a purely interrupt-driven approach (grumble, grumble).
- */
- if (!(value & ACPI_EC_FLAG_SCI))
+ if (result)
goto end;
- if (acpi_ec_query(ec, &value))
- goto end;
-
object_name[2] = hex[((value >> 4) & 0x0F)];
object_name[3] = hex[(value & 0x0F)];
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
-
-end:
- acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
+end:
+ atomic_dec(&ec->pending_gpe);
+ return;
}
static u32
@@ -390,6 +519,7 @@ acpi_ec_gpe_handler (
void *data)
{
acpi_status status = AE_OK;
+ u32 value;
struct acpi_ec *ec = (struct acpi_ec *) data;
if (!ec)
@@ -397,13 +527,41 @@ acpi_ec_gpe_handler (
acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
- status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
- acpi_ec_gpe_query, ec);
+ value = acpi_ec_read_status(ec);
- if (status == AE_OK)
- return ACPI_INTERRUPT_HANDLED;
- else
- return ACPI_INTERRUPT_NOT_HANDLED;
+ if((value & ACPI_EC_FLAG_IBF) &&
+ !(value & ACPI_EC_FLAG_BURST) &&
+ (atomic_read(&ec->leaving_burst) == 0)) {
+ /*
+ * the embedded controller disables
+ * burst mode for any reason other
+ * than the burst disable command
+ * to process critical event.
+ */
+ atomic_set(&ec->leaving_burst , 2); /* block current pending transaction
+ and retry */
+ wake_up(&ec->wait);
+ }else {
+ if ((ec->expect_event == ACPI_EC_EVENT_OBF &&
+ (value & ACPI_EC_FLAG_OBF)) ||
+ (ec->expect_event == ACPI_EC_EVENT_IBE &&
+ !(value & ACPI_EC_FLAG_IBF))) {
+ ec->expect_event = 0;
+ wake_up(&ec->wait);
+ return ACPI_INTERRUPT_HANDLED;
+ }
+ }
+
+ if (value & ACPI_EC_FLAG_SCI){
+ atomic_add(1, &ec->pending_gpe) ;
+ status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
+ acpi_ec_gpe_query, ec);
+ return status == AE_OK ?
+ ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
+ }
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
+ return status == AE_OK ?
+ ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
}
/* --------------------------------------------------------------------------
@@ -421,10 +579,8 @@ acpi_ec_space_setup (
* The EC object is in the handler context and is needed
* when calling the acpi_ec_space_handler.
*/
- if(function == ACPI_REGION_DEACTIVATE)
- *return_context = NULL;
- else
- *return_context = handler_context;
+ *return_context = (function != ACPI_REGION_DEACTIVATE) ?
+ handler_context : NULL;
return AE_OK;
}
@@ -441,7 +597,7 @@ acpi_ec_space_handler (
{
int result = 0;
struct acpi_ec *ec = NULL;
- u32 temp = 0;
+ u64 temp = *value;
acpi_integer f_v = 0;
int i = 0;
@@ -450,10 +606,9 @@ acpi_ec_space_handler (
if ((address > 0xFF) || !value || !handler_context)
return_VALUE(AE_BAD_PARAMETER);
- if(bit_width != 8) {
+ if (bit_width != 8 && acpi_strict) {
printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n");
- if (acpi_strict)
- return_VALUE(AE_BAD_PARAMETER);
+ return_VALUE(AE_BAD_PARAMETER);
}
ec = (struct acpi_ec *) handler_context;
@@ -461,11 +616,11 @@ acpi_ec_space_handler (
next_byte:
switch (function) {
case ACPI_READ:
- result = acpi_ec_read(ec, (u8) address, &temp);
- *value = (acpi_integer) temp;
+ temp = 0;
+ result = acpi_ec_read(ec, (u8) address, (u32 *)&temp);
break;
case ACPI_WRITE:
- result = acpi_ec_write(ec, (u8) address, (u8) *value);
+ result = acpi_ec_write(ec, (u8) address, (u8) temp);
break;
default:
result = -EINVAL;
@@ -474,19 +629,18 @@ next_byte:
}
bit_width -= 8;
- if(bit_width){
-
- if(function == ACPI_READ)
- f_v |= (acpi_integer) (*value) << 8*i;
- if(function == ACPI_WRITE)
- (*value) >>=8;
+ if (bit_width) {
+ if (function == ACPI_READ)
+ f_v |= temp << 8 * i;
+ if (function == ACPI_WRITE)
+ temp >>= 8;
i++;
+ address++;
goto next_byte;
}
-
- if(function == ACPI_READ){
- f_v |= (acpi_integer) (*value) << 8*i;
+ if (function == ACPI_READ) {
+ f_v |= temp << 8 * i;
*value = f_v;
}
@@ -505,8 +659,6 @@ out:
default:
return_VALUE(AE_OK);
}
-
-
}
@@ -533,6 +685,7 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
(u32) ec->status_addr.address, (u32) ec->data_addr.address);
seq_printf(seq, "use global lock: %s\n",
ec->global_lock?"yes":"no");
+ acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
end:
return_VALUE(0);
@@ -555,7 +708,7 @@ static int
acpi_ec_add_fs (
struct acpi_device *device)
{
- struct proc_dir_entry *entry = NULL;
+ struct proc_dir_entry *entry;
ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
@@ -606,9 +759,9 @@ static int
acpi_ec_add (
struct acpi_device *device)
{
- int result = 0;
- acpi_status status = AE_OK;
- struct acpi_ec *ec = NULL;
+ int result;
+ acpi_status status;
+ struct acpi_ec *ec;
unsigned long uid;
ACPI_FUNCTION_TRACE("acpi_ec_add");
@@ -623,7 +776,10 @@ acpi_ec_add (
ec->handle = device->handle;
ec->uid = -1;
- spin_lock_init(&ec->lock);
+ atomic_set(&ec->pending_gpe, 0);
+ atomic_set(&ec->leaving_burst , 1);
+ init_MUTEX(&ec->sem);
+ init_waitqueue_head(&ec->wait);
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
acpi_driver_data(device) = ec;
@@ -637,7 +793,7 @@ acpi_ec_add (
if (ec_ecdt && ec_ecdt->uid == uid) {
acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
-
+
acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler);
kfree(ec_ecdt);
@@ -677,7 +833,7 @@ acpi_ec_remove (
struct acpi_device *device,
int type)
{
- struct acpi_ec *ec = NULL;
+ struct acpi_ec *ec;
ACPI_FUNCTION_TRACE("acpi_ec_remove");
@@ -732,8 +888,8 @@ static int
acpi_ec_start (
struct acpi_device *device)
{
- acpi_status status = AE_OK;
- struct acpi_ec *ec = NULL;
+ acpi_status status;
+ struct acpi_ec *ec;
ACPI_FUNCTION_TRACE("acpi_ec_start");
@@ -789,8 +945,8 @@ acpi_ec_stop (
struct acpi_device *device,
int type)
{
- acpi_status status = AE_OK;
- struct acpi_ec *ec = NULL;
+ acpi_status status;
+ struct acpi_ec *ec;
ACPI_FUNCTION_TRACE("acpi_ec_stop");
@@ -832,7 +988,6 @@ acpi_fake_ecdt_callback (
status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit);
if (ACPI_FAILURE(status))
return status;
- spin_lock_init(&ec_ecdt->lock);
ec_ecdt->global_lock = TRUE;
ec_ecdt->handle = handle;
@@ -890,7 +1045,7 @@ acpi_ec_get_real_ecdt(void)
acpi_status status;
struct acpi_table_ecdt *ecdt_ptr;
- status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
+ status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
(struct acpi_table_header **) &ecdt_ptr);
if (ACPI_FAILURE(status))
return -ENODEV;
@@ -905,11 +1060,12 @@ acpi_ec_get_real_ecdt(void)
return -ENOMEM;
memset(ec_ecdt, 0, sizeof(struct acpi_ec));
+ init_MUTEX(&ec_ecdt->sem);
+ init_waitqueue_head(&ec_ecdt->wait);
ec_ecdt->command_addr = ecdt_ptr->ec_control;
ec_ecdt->status_addr = ecdt_ptr->ec_control;
ec_ecdt->data_addr = ecdt_ptr->ec_data;
ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
- spin_lock_init(&ec_ecdt->lock);
/* use the GL just to be safe */
ec_ecdt->global_lock = TRUE;
ec_ecdt->uid = ecdt_ptr->uid;
@@ -978,7 +1134,7 @@ error:
static int __init acpi_ec_init (void)
{
- int result = 0;
+ int result;
ACPI_FUNCTION_TRACE("acpi_ec_init");
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 2a213604ae5..dd3a72a869f 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -47,6 +47,16 @@
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evevent")
+/* Local prototypes */
+
+static acpi_status
+acpi_ev_fixed_event_initialize (
+ void);
+
+static u32
+acpi_ev_fixed_event_dispatch (
+ u32 event);
+
/*******************************************************************************
*
@@ -56,7 +66,7 @@
*
* RETURN: Status
*
- * DESCRIPTION: Initialize global data structures for events.
+ * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE)
*
******************************************************************************/
@@ -78,9 +88,9 @@ acpi_ev_initialize_events (
}
/*
- * Initialize the Fixed and General Purpose Events. This is
- * done prior to enabling SCIs to prevent interrupts from
- * occurring before handers are installed.
+ * Initialize the Fixed and General Purpose Events. This is done prior to
+ * enabling SCIs to prevent interrupts from occurring before the handlers are
+ * installed.
*/
status = acpi_ev_fixed_event_initialize ();
if (ACPI_FAILURE (status)) {
@@ -161,7 +171,7 @@ acpi_ev_install_xrupt_handlers (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ev_fixed_event_initialize (
void)
{
@@ -180,7 +190,8 @@ acpi_ev_fixed_event_initialize (
/* Enable the fixed event */
if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
- status = acpi_set_register (acpi_gbl_fixed_event_info[i].enable_register_id,
+ status = acpi_set_register (
+ acpi_gbl_fixed_event_info[i].enable_register_id,
0, ACPI_MTX_LOCK);
if (ACPI_FAILURE (status)) {
return (status);
@@ -200,7 +211,7 @@ acpi_ev_fixed_event_initialize (
*
* RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
*
- * DESCRIPTION: Checks the PM status register for fixed events
+ * DESCRIPTION: Checks the PM status register for active fixed events
*
******************************************************************************/
@@ -221,8 +232,10 @@ acpi_ev_fixed_event_detect (
* Read the fixed feature status and enable registers, as all the cases
* depend on their values. Ignore errors here.
*/
- (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, &fixed_status);
- (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
+ (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
+ &fixed_status);
+ (void) acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE,
+ &fixed_enable);
ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
"Fixed Event Block: Enable %08X Status %08X\n",
@@ -259,7 +272,7 @@ acpi_ev_fixed_event_detect (
*
******************************************************************************/
-u32
+static u32
acpi_ev_fixed_event_dispatch (
u32 event)
{
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index 118d72ac7c7..081120b109b 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -48,6 +48,12 @@
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evgpe")
+/* Local prototypes */
+
+static void ACPI_SYSTEM_XFACE
+acpi_ev_asynch_execute_gpe_method (
+ void *context);
+
/*******************************************************************************
*
@@ -335,8 +341,10 @@ acpi_ev_get_gpe_event_info (
gpe_block = acpi_gbl_gpe_fadt_blocks[i];
if (gpe_block) {
if ((gpe_number >= gpe_block->block_base_number) &&
- (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
- return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
+ (gpe_number < gpe_block->block_base_number +
+ (gpe_block->register_count * 8))) {
+ return (&gpe_block->event_info[gpe_number -
+ gpe_block->block_base_number]);
}
}
}
@@ -437,7 +445,7 @@ acpi_ev_gpe_detect (
"Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
gpe_register_info->base_gpe_number, status_reg, enable_reg));
- /* First check if there is anything active at all in this register */
+ /* Check if there is anything active at all in this register */
enabled_status_byte = (u8) (status_reg & enable_reg);
if (!enabled_status_byte) {
@@ -457,8 +465,8 @@ acpi_ev_gpe_detect (
* or method.
*/
int_status |= acpi_ev_gpe_dispatch (
- &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
- (u32) j + gpe_register_info->base_gpe_number);
+ &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
+ (u32) j + gpe_register_info->base_gpe_number);
}
}
}
@@ -523,7 +531,8 @@ acpi_ev_asynch_execute_gpe_method (
* Take a snapshot of the GPE info for this level - we copy the
* info to prevent a race condition with remove_handler/remove_block.
*/
- ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info, sizeof (struct acpi_gpe_event_info));
+ ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info,
+ sizeof (struct acpi_gpe_event_info));
status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
if (ACPI_FAILURE (status)) {
@@ -534,7 +543,8 @@ acpi_ev_asynch_execute_gpe_method (
* Must check for control method type dispatch one more
* time to avoid race with ev_gpe_install_handler
*/
- if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) {
+ if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
+ ACPI_GPE_DISPATCH_METHOD) {
/*
* Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
* control method that corresponds to this GPE
@@ -553,7 +563,8 @@ acpi_ev_asynch_execute_gpe_method (
}
}
- if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) {
+ if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
+ ACPI_GPE_LEVEL_TRIGGERED) {
/*
* GPE is level-triggered, we clear the GPE status bit after
* handling the event.
@@ -575,7 +586,7 @@ acpi_ev_asynch_execute_gpe_method (
*
* FUNCTION: acpi_ev_gpe_dispatch
*
- * PARAMETERS: gpe_event_info - info for this GPE
+ * PARAMETERS: gpe_event_info - Info for this GPE
* gpe_number - Number relative to the parent GPE block
*
* RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
@@ -602,10 +613,12 @@ acpi_ev_gpe_dispatch (
* If edge-triggered, clear the GPE status bit now. Note that
* level-triggered events are cleared after the GPE is serviced.
*/
- if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_EDGE_TRIGGERED) {
+ if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
+ ACPI_GPE_EDGE_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
+ ACPI_REPORT_ERROR ((
+ "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
acpi_format_exception (status), gpe_number));
return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
}
@@ -639,7 +652,8 @@ acpi_ev_gpe_dispatch (
/* It is now safe to clear level-triggered events. */
- if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) {
+ if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
+ ACPI_GPE_LEVEL_TRIGGERED) {
status = acpi_hw_clear_gpe (gpe_event_info);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
@@ -704,7 +718,6 @@ acpi_ev_gpe_dispatch (
#ifdef ACPI_GPE_NOTIFY_CHECK
-
/*******************************************************************************
* TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
*
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 00d981f53c6..84186a7d17b 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -48,6 +48,39 @@
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evgpeblk")
+/* Local prototypes */
+
+static acpi_status
+acpi_ev_save_method_info (
+ acpi_handle obj_handle,
+ u32 level,
+ void *obj_desc,
+ void **return_value);
+
+static acpi_status
+acpi_ev_match_prw_and_gpe (
+ acpi_handle obj_handle,
+ u32 level,
+ void *info,
+ void **return_value);
+
+static struct acpi_gpe_xrupt_info *
+acpi_ev_get_gpe_xrupt_block (
+ u32 interrupt_level);
+
+static acpi_status
+acpi_ev_delete_gpe_xrupt (
+ struct acpi_gpe_xrupt_info *gpe_xrupt);
+
+static acpi_status
+acpi_ev_install_gpe_block (
+ struct acpi_gpe_block_info *gpe_block,
+ u32 interrupt_level);
+
+static acpi_status
+acpi_ev_create_gpe_info_blocks (
+ struct acpi_gpe_block_info *gpe_block);
+
/*******************************************************************************
*
@@ -155,7 +188,7 @@ unlock_and_exit:
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ev_delete_gpe_handlers
*
@@ -190,7 +223,8 @@ acpi_ev_delete_gpe_handlers (
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
gpe_event_info = &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j];
- if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) {
+ if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
+ ACPI_GPE_DISPATCH_HANDLER) {
ACPI_MEM_FREE (gpe_event_info->dispatch.handler);
gpe_event_info->dispatch.handler = NULL;
gpe_event_info->flags &= ~ACPI_GPE_DISPATCH_MASK;
@@ -471,7 +505,7 @@ acpi_ev_get_gpe_xrupt_block (
ACPI_FUNCTION_TRACE ("ev_get_gpe_xrupt_block");
- /* No need for spin lock since we are not changing any list elements here */
+ /* No need for lock since we are not changing any list elements here */
next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
while (next_gpe_xrupt) {
@@ -619,7 +653,7 @@ acpi_ev_install_gpe_block (
goto unlock_and_exit;
}
- /* Install the new block at the end of the list for this interrupt with lock */
+ /* Install the new block at the end of the list with lock */
acpi_os_acquire_lock (acpi_gbl_gpe_lock, ACPI_NOT_ISR);
if (gpe_xrupt_block->gpe_block_list_head) {
@@ -756,10 +790,12 @@ acpi_ev_create_gpe_info_blocks (
* per register. Initialization to zeros is sufficient.
*/
gpe_event_info = ACPI_MEM_CALLOCATE (
- ((acpi_size) gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH) *
+ ((acpi_size) gpe_block->register_count *
+ ACPI_GPE_REGISTER_WIDTH) *
sizeof (struct acpi_gpe_event_info));
if (!gpe_event_info) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the gpe_event_info table\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not allocate the gpe_event_info table\n"));
status = AE_NO_MEMORY;
goto error_exit;
}
@@ -899,7 +935,8 @@ acpi_ev_create_gpe_block (
gpe_block->block_base_number = gpe_block_base_number;
gpe_block->node = gpe_device;
- ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address, sizeof (struct acpi_generic_address));
+ ACPI_MEMCPY (&gpe_block->block_address, gpe_block_address,
+ sizeof (struct acpi_generic_address));
/* Create the register_info and event_info sub-structures */
@@ -1061,8 +1098,9 @@ acpi_ev_gpe_initialize (
/* Install GPE Block 0 */
- status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, &acpi_gbl_FADT->xgpe0_blk,
- register_count0, 0, acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]);
+ status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device,
+ &acpi_gbl_FADT->xgpe0_blk, register_count0, 0,
+ acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[0]);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR ((
@@ -1094,8 +1132,9 @@ acpi_ev_gpe_initialize (
else {
/* Install GPE Block 1 */
- status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device, &acpi_gbl_FADT->xgpe1_blk,
- register_count1, acpi_gbl_FADT->gpe1_base,
+ status = acpi_ev_create_gpe_block (acpi_gbl_fadt_gpe_device,
+ &acpi_gbl_FADT->xgpe1_blk, register_count1,
+ acpi_gbl_FADT->gpe1_base,
acpi_gbl_FADT->sci_int, &acpi_gbl_gpe_fadt_blocks[1]);
if (ACPI_FAILURE (status)) {
@@ -1109,7 +1148,7 @@ acpi_ev_gpe_initialize (
* space. However, GPE0 always starts at GPE number zero.
*/
gpe_number_max = acpi_gbl_FADT->gpe1_base +
- ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
+ ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
}
}
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 2548efa7a45..659e9095611 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -50,6 +50,35 @@
ACPI_MODULE_NAME ("evmisc")
+#ifdef ACPI_DEBUG_OUTPUT
+static const char *acpi_notify_value_names[] =
+{
+ "Bus Check",
+ "Device Check",
+ "Device Wake",
+ "Eject request",
+ "Device Check Light",
+ "Frequency Mismatch",
+ "Bus Mode Mismatch",
+ "Power Fault"
+};
+#endif
+
+/* Local prototypes */
+
+static void ACPI_SYSTEM_XFACE
+acpi_ev_notify_dispatch (
+ void *context);
+
+static void ACPI_SYSTEM_XFACE
+acpi_ev_global_lock_thread (
+ void *context);
+
+static u32
+acpi_ev_global_lock_handler (
+ void *context);
+
+
/*******************************************************************************
*
* FUNCTION: acpi_ev_is_notify_object
@@ -98,20 +127,6 @@ acpi_ev_is_notify_object (
*
******************************************************************************/
-#ifdef ACPI_DEBUG_OUTPUT
-static const char *acpi_notify_value_names[] =
-{
- "Bus Check",
- "Device Check",
- "Device Wake",
- "Eject request",
- "Device Check Light",
- "Frequency Mismatch",
- "Bus Mode Mismatch",
- "Power Fault"
-};
-#endif
-
acpi_status
acpi_ev_queue_notify_request (
struct acpi_namespace_node *node,
@@ -128,9 +143,10 @@ acpi_ev_queue_notify_request (
/*
* For value 3 (Ejection Request), some device method may need to be run.
- * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run.
+ * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need
+ * to be run.
* For value 0x80 (Status Change) on the power button or sleep button,
- * initiate soft-off or sleep operation?
+ * initiate soft-off or sleep operation?
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Dispatching Notify(%X) on node %p\n", notify_value, node));
@@ -140,8 +156,9 @@ acpi_ev_queue_notify_request (
acpi_notify_value_names[notify_value]));
}
else {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: 0x%2.2X **Device Specific**\n",
- notify_value));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Notify value: 0x%2.2X **Device Specific**\n",
+ notify_value));
}
/* Get the notify object attached to the NS Node */
@@ -210,7 +227,7 @@ acpi_ev_queue_notify_request (
*
* FUNCTION: acpi_ev_notify_dispatch
*
- * PARAMETERS: Context - To be passsed to the notify handler
+ * PARAMETERS: Context - To be passed to the notify handler
*
* RETURN: None.
*
@@ -219,7 +236,7 @@ acpi_ev_queue_notify_request (
*
******************************************************************************/
-void ACPI_SYSTEM_XFACE
+static void ACPI_SYSTEM_XFACE
acpi_ev_notify_dispatch (
void *context)
{
@@ -234,7 +251,8 @@ acpi_ev_notify_dispatch (
/*
* We will invoke a global notify handler if installed.
- * This is done _before_ we invoke the per-device handler attached to the device.
+ * This is done _before_ we invoke the per-device handler attached
+ * to the device.
*/
if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
/* Global system notification handler */
@@ -256,15 +274,17 @@ acpi_ev_notify_dispatch (
/* Invoke the system handler first, if present */
if (global_handler) {
- global_handler (notify_info->notify.node, notify_info->notify.value, global_context);
+ global_handler (notify_info->notify.node, notify_info->notify.value,
+ global_context);
}
/* Now invoke the per-device handler, if present */
handler_obj = notify_info->notify.handler_obj;
if (handler_obj) {
- handler_obj->notify.handler (notify_info->notify.node, notify_info->notify.value,
- handler_obj->notify.context);
+ handler_obj->notify.handler (notify_info->notify.node,
+ notify_info->notify.value,
+ handler_obj->notify.context);
}
/* All done with the info object */
@@ -370,7 +390,8 @@ acpi_ev_global_lock_handler (
******************************************************************************/
acpi_status
-acpi_ev_init_global_lock_handler (void)
+acpi_ev_init_global_lock_handler (
+ void)
{
acpi_status status;
@@ -380,7 +401,7 @@ acpi_ev_init_global_lock_handler (void)
acpi_gbl_global_lock_present = TRUE;
status = acpi_install_fixed_event_handler (ACPI_EVENT_GLOBAL,
- acpi_ev_global_lock_handler, NULL);
+ acpi_ev_global_lock_handler, NULL);
/*
* If the global lock does not exist on this platform, the attempt
@@ -433,8 +454,10 @@ acpi_ev_acquire_global_lock (
acpi_gbl_global_lock_thread_count++;
- /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */
-
+ /*
+ * If we (OS side vs. BIOS side) have the hardware lock already,
+ * we are done
+ */
if (acpi_gbl_global_lock_acquired) {
return_ACPI_STATUS (AE_OK);
}
@@ -480,7 +503,8 @@ acpi_ev_acquire_global_lock (
******************************************************************************/
acpi_status
-acpi_ev_release_global_lock (void)
+acpi_ev_release_global_lock (
+ void)
{
u8 pending = FALSE;
acpi_status status = AE_OK;
@@ -490,7 +514,8 @@ acpi_ev_release_global_lock (void)
if (!acpi_gbl_global_lock_thread_count) {
- ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n"));
+ ACPI_REPORT_WARNING((
+ "Cannot release HW Global Lock, it has not been acquired\n"));
return_ACPI_STATUS (AE_NOT_ACQUIRED);
}
@@ -515,7 +540,8 @@ acpi_ev_release_global_lock (void)
* register
*/
if (pending) {
- status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK);
+ status = acpi_set_register (ACPI_BITREG_GLOBAL_LOCK_RELEASE,
+ 1, ACPI_MTX_LOCK);
}
return_ACPI_STATUS (status);
@@ -535,7 +561,8 @@ acpi_ev_release_global_lock (void)
******************************************************************************/
void
-acpi_ev_terminate (void)
+acpi_ev_terminate (
+ void)
{
acpi_native_uint i;
acpi_status status;
@@ -555,7 +582,8 @@ acpi_ev_terminate (void)
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
status = acpi_disable_event ((u32) i, 0);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (u32) i));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not disable fixed event %d\n", (u32) i));
}
}
@@ -567,7 +595,8 @@ acpi_ev_terminate (void)
status = acpi_ev_remove_sci_handler ();
if (ACPI_FAILURE(status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not remove SCI handler\n"));
}
}
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/events/evregion.c
index 772342708a7..a1d7276c574 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/events/evregion.c
@@ -58,6 +58,22 @@ static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPA
ACPI_ADR_SPACE_PCI_CONFIG,
ACPI_ADR_SPACE_DATA_TABLE};
+/* Local prototypes */
+
+static acpi_status
+acpi_ev_reg_run (
+ acpi_handle obj_handle,
+ u32 level,
+ void *context,
+ void **return_value);
+
+static acpi_status
+acpi_ev_install_handler (
+ acpi_handle obj_handle,
+ u32 level,
+ void *context,
+ void **return_value);
+
/*******************************************************************************
*
@@ -179,8 +195,8 @@ acpi_ev_initialize_op_regions (
*
* FUNCTION: acpi_ev_execute_reg_method
*
- * PARAMETERS: region_obj - Object structure
- * Function - Passed to _REG: On (1) or Off (0)
+ * PARAMETERS: region_obj - Region object
+ * Function - Passed to _REG: On (1) or Off (0)
*
* RETURN: Status
*
@@ -323,14 +339,16 @@ acpi_ev_address_space_dispatch (
if (!region_setup) {
/* No initialization routine, exit with error */
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "No init routine for region(%p) [%s]\n",
region_obj, acpi_ut_get_region_name (region_obj->region.space_id)));
return_ACPI_STATUS (AE_NOT_EXIST);
}
/*
- * We must exit the interpreter because the region setup will potentially
- * execute control methods (e.g., _REG method for this region)
+ * We must exit the interpreter because the region
+ * setup will potentially execute control methods
+ * (e.g., _REG method for this region)
*/
acpi_ex_exit_interpreter ();
@@ -621,7 +639,7 @@ acpi_ev_attach_region (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ev_install_handler (
acpi_handle obj_handle,
u32 level,
@@ -848,7 +866,8 @@ acpi_ev_install_space_handler (
if (handler_obj->address_space.handler == handler) {
/*
* It is (relatively) OK to attempt to install the SAME
- * handler twice. This can easily happen with PCI_Config space.
+ * handler twice. This can easily happen
+ * with PCI_Config space.
*/
status = AE_SAME_HANDLER;
goto unlock_and_exit;
@@ -1011,7 +1030,7 @@ acpi_ev_execute_reg_methods (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ev_reg_run (
acpi_handle obj_handle,
u32 level,
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 4983a3378be..95bc09c73a6 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -61,7 +61,7 @@
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling, a nop for now
+ * DESCRIPTION: Setup a system_memory operation region
*
******************************************************************************/
@@ -115,7 +115,7 @@ acpi_ev_system_memory_region_setup (
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling
+ * DESCRIPTION: Setup a IO operation region
*
******************************************************************************/
@@ -144,14 +144,14 @@ acpi_ev_io_space_region_setup (
*
* FUNCTION: acpi_ev_pci_config_region_setup
*
- * PARAMETERS: Handle - Region we are interested in
+ * PARAMETERS: Handle - Region we are interested in
* Function - Start or stop
* handler_context - Address space handler context
* region_context - Region specific context
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling
+ * DESCRIPTION: Setup a PCI_Config operation region
*
* MUTEX: Assumes namespace is not locked
*
@@ -324,7 +324,7 @@ acpi_ev_pci_config_region_setup (
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling
+ * DESCRIPTION: Setup a pci_bAR operation region
*
* MUTEX: Assumes namespace is not locked
*
@@ -355,7 +355,7 @@ acpi_ev_pci_bar_region_setup (
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling
+ * DESCRIPTION: Setup a CMOS operation region
*
* MUTEX: Assumes namespace is not locked
*
@@ -386,7 +386,7 @@ acpi_ev_cmos_region_setup (
*
* RETURN: Status
*
- * DESCRIPTION: Do any prep work for region handling
+ * DESCRIPTION: Default region initialization
*
******************************************************************************/
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/events/evsci.c
index 46b31995c82..f3123c26ae9 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/events/evsci.c
@@ -49,6 +49,12 @@
#define _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evsci")
+/* Local prototypes */
+
+static u32 ACPI_SYSTEM_XFACE
+acpi_ev_sci_xrupt_handler (
+ void *context);
+
/*******************************************************************************
*
@@ -146,7 +152,8 @@ acpi_ev_gpe_xrupt_handler (
******************************************************************************/
u32
-acpi_ev_install_sci_handler (void)
+acpi_ev_install_sci_handler (
+ void)
{
u32 status = AE_OK;
@@ -180,7 +187,8 @@ acpi_ev_install_sci_handler (void)
******************************************************************************/
acpi_status
-acpi_ev_remove_sci_handler (void)
+acpi_ev_remove_sci_handler (
+ void)
{
acpi_status status;
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 0bfec10a5f1..4092d47f675 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -64,6 +64,7 @@
* DESCRIPTION: Saves the pointer to the handler function
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_install_exception_handler (
@@ -457,7 +458,8 @@ acpi_remove_notify_handler (
/* Root Object */
if (device == ACPI_ROOT_OBJECT) {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Removing notify handler for ROOT object.\n"));
if (((handler_type & ACPI_SYSTEM_NOTIFY) &&
!acpi_gbl_system_notify.handler) ||
@@ -564,8 +566,9 @@ EXPORT_SYMBOL(acpi_remove_notify_handler);
*
* FUNCTION: acpi_install_gpe_handler
*
- * PARAMETERS: gpe_number - The GPE number within the GPE block
- * gpe_block - GPE block (NULL == FADT GPEs)
+ * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
+ * defined GPEs)
+ * gpe_number - The GPE number within the GPE block
* Type - Whether this GPE should be treated as an
* edge- or level-triggered interrupt.
* Address - Address of the handler
@@ -662,8 +665,9 @@ EXPORT_SYMBOL(acpi_install_gpe_handler);
*
* FUNCTION: acpi_remove_gpe_handler
*
- * PARAMETERS: gpe_number - The event to remove a handler
- * gpe_block - GPE block (NULL == FADT GPEs)
+ * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
+ * defined GPEs)
+ * gpe_number - The event to remove a handler
* Address - Address of the handler
*
* RETURN: Status
@@ -766,7 +770,8 @@ EXPORT_SYMBOL(acpi_remove_gpe_handler);
* FUNCTION: acpi_acquire_global_lock
*
* PARAMETERS: Timeout - How long the caller is willing to wait
- * out_handle - A handle to the lock if acquired
+ * Handle - Where the handle to the lock is returned
+ * (if acquired)
*
* RETURN: Status
*
@@ -812,7 +817,7 @@ EXPORT_SYMBOL(acpi_acquire_global_lock);
*
* RETURN: Status
*
- * DESCRIPTION: Release the ACPI Global Lock
+ * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
*
******************************************************************************/
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index fa8d5f25be6..f337dc2cc56 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -64,7 +64,8 @@
******************************************************************************/
acpi_status
-acpi_enable (void)
+acpi_enable (
+ void)
{
acpi_status status = AE_OK;
@@ -91,7 +92,8 @@ acpi_enable (void)
return_ACPI_STATUS (status);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+ "Transition to ACPI mode successful\n"));
}
return_ACPI_STATUS (status);
@@ -106,12 +108,13 @@ acpi_enable (void)
*
* RETURN: Status
*
- * DESCRIPTION: Transfers the system into LEGACY mode.
+ * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
*
******************************************************************************/
acpi_status
-acpi_disable (void)
+acpi_disable (
+ void)
{
acpi_status status = AE_OK;
@@ -125,7 +128,8 @@ acpi_disable (void)
}
if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+ "System is already in legacy (non-ACPI) mode\n"));
}
else {
/* Transition to LEGACY mode */
@@ -133,7 +137,8 @@ acpi_disable (void)
status = acpi_hw_set_mode (ACPI_SYS_MODE_LEGACY);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not exit ACPI mode to legacy mode"));
return_ACPI_STATUS (status);
}
@@ -214,7 +219,7 @@ EXPORT_SYMBOL(acpi_enable_event);
*
* RETURN: Status
*
- * DESCRIPTION: Enable an ACPI event (general purpose)
+ * DESCRIPTION: Set the type of an individual GPE
*
******************************************************************************/
@@ -519,13 +524,12 @@ unlock_and_exit:
#ifdef ACPI_FUTURE_USAGE
-
/*******************************************************************************
*
* FUNCTION: acpi_get_event_status
*
* PARAMETERS: Event - The fixed event
- * Event Status - Where the current status of the event will
+ * event_status - Where the current status of the event will
* be returned
*
* RETURN: Status
@@ -571,7 +575,7 @@ acpi_get_event_status (
* PARAMETERS: gpe_device - Parent GPE Device
* gpe_number - GPE level within the GPE block
* Flags - Called from an ISR or not
- * Event Status - Where the current status of the event will
+ * event_status - Where the current status of the event will
* be returned
*
* RETURN: Status
@@ -775,4 +779,5 @@ unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (status);
}
+
EXPORT_SYMBOL(acpi_remove_gpe_block);
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index ac3c061967f..734b2f24af4 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -54,6 +54,14 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exconfig")
+/* Local prototypes */
+
+static acpi_status
+acpi_ex_add_table (
+ struct acpi_table_header *table,
+ struct acpi_namespace_node *parent_node,
+ union acpi_operand_object **ddb_handle);
+
/*******************************************************************************
*
@@ -70,7 +78,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_add_table (
struct acpi_table_header *table,
struct acpi_namespace_node *parent_node,
@@ -95,10 +103,10 @@ acpi_ex_add_table (
ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc));
- table_info.type = ACPI_TABLE_SSDT;
- table_info.pointer = table;
- table_info.length = (acpi_size) table->length;
- table_info.allocation = ACPI_MEM_ALLOCATED;
+ table_info.type = ACPI_TABLE_SSDT;
+ table_info.pointer = table;
+ table_info.length = (acpi_size) table->length;
+ table_info.allocation = ACPI_MEM_ALLOCATED;
status = acpi_tb_install_table (&table_info);
if (ACPI_FAILURE (status)) {
@@ -226,11 +234,10 @@ acpi_ex_load_table_op (
start_node = parent_node;
}
- /*
- * Find the node referenced by the parameter_path_string
- */
+ /* Find the node referenced by the parameter_path_string */
+
status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
- ACPI_NS_SEARCH_PARENT, &parameter_node);
+ ACPI_NS_SEARCH_PARENT, &parameter_node);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -248,7 +255,8 @@ acpi_ex_load_table_op (
if (parameter_node) {
/* Store the parameter data into the optional parameter object */
- status = acpi_ex_store (operand[5], ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
+ status = acpi_ex_store (operand[5],
+ ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
walk_state);
if (ACPI_FAILURE (status)) {
(void) acpi_ex_unload_table (ddb_handle);
@@ -371,7 +379,8 @@ acpi_ex_load_op (
goto cleanup;
}
- table_ptr = ACPI_CAST_PTR (struct acpi_table_header, buffer_desc->buffer.pointer);
+ table_ptr = ACPI_CAST_PTR (struct acpi_table_header,
+ buffer_desc->buffer.pointer);
/* Sanity check the table length */
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index df7ba1219bf..97856c48bd7 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -50,6 +50,15 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exconvrt")
+/* Local prototypes */
+
+static u32
+acpi_ex_convert_to_ascii (
+ acpi_integer integer,
+ u16 base,
+ u8 *string,
+ u8 max_length);
+
/*******************************************************************************
*
@@ -115,9 +124,8 @@ acpi_ex_convert_to_integer (
*/
result = 0;
- /*
- * String conversion is different than Buffer conversion
- */
+ /* String conversion is different than Buffer conversion */
+
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_STRING:
@@ -168,9 +176,8 @@ acpi_ex_convert_to_integer (
break;
}
- /*
- * Create a new integer
- */
+ /* Create a new integer */
+
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
@@ -251,7 +258,8 @@ acpi_ex_convert_to_buffer (
* ASL/AML code that depends on the null being transferred to the new
* buffer.
*/
- return_desc = acpi_ut_create_buffer_object ((acpi_size) obj_desc->string.length + 1);
+ return_desc = acpi_ut_create_buffer_object (
+ (acpi_size) obj_desc->string.length + 1);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
@@ -291,7 +299,7 @@ acpi_ex_convert_to_buffer (
*
******************************************************************************/
-u32
+static u32
acpi_ex_convert_to_ascii (
acpi_integer integer,
u16 base,
@@ -357,8 +365,9 @@ acpi_ex_convert_to_ascii (
case 16:
- hex_length = ACPI_MUL_2 (data_width); /* 2 ascii hex chars per data byte */
+ /* hex_length: 2 ascii hex chars per data byte */
+ hex_length = ACPI_MUL_2 (data_width);
for (i = 0, j = (hex_length-1); i < hex_length; i++, j--) {
/* Get one hex digit, most significant digits first */
@@ -475,7 +484,7 @@ acpi_ex_convert_to_string (
/* Setup string length, base, and separator */
switch (type) {
- case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string operator */
+ case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
/*
* From ACPI: "If Data is a buffer, it is converted to a string of
* decimal values separated by commas."
@@ -509,7 +518,7 @@ acpi_ex_convert_to_string (
string_length = (obj_desc->buffer.length * 3);
break;
- case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string operator */
+ case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
/*
* From ACPI: "If Data is a buffer, it is converted to a string of
* hexadecimal values separated by commas."
@@ -530,9 +539,8 @@ acpi_ex_convert_to_string (
return_ACPI_STATUS (AE_AML_STRING_LIMIT);
}
- /*
- * Create a new string object and string buffer
- */
+ /* Create a new string object and string buffer */
+
return_desc = acpi_ut_create_string_object ((acpi_size) string_length);
if (!return_desc) {
return_ACPI_STATUS (AE_NO_MEMORY);
@@ -551,8 +559,10 @@ acpi_ex_convert_to_string (
*new_buf++ = separator; /* each separated by a comma or space */
}
- /* Null terminate the string (overwrites final comma/space from above) */
-
+ /*
+ * Null terminate the string
+ * (overwrites final comma/space from above)
+ */
new_buf--;
*new_buf = 0;
break;
@@ -645,7 +655,6 @@ acpi_ex_convert_to_target_type (
case ACPI_TYPE_STRING:
-
/*
* The operand must be a String. We can convert an
* Integer or Buffer if necessary
@@ -656,7 +665,6 @@ acpi_ex_convert_to_target_type (
case ACPI_TYPE_BUFFER:
-
/*
* The operand must be a Buffer. We can convert an
* Integer or String if necessary
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index d94c260dac6..812cdcb2e37 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -55,7 +55,7 @@
#ifndef ACPI_NO_METHOD_EXECUTION
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_alias
*
@@ -65,7 +65,7 @@
*
* DESCRIPTION: Create a new named alias
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_alias (
@@ -140,8 +140,7 @@ acpi_ex_create_alias (
* target node or the alias Node
*/
status = acpi_ns_attach_object (alias_node,
- acpi_ns_get_attached_object (target_node),
- target_node->type);
+ acpi_ns_get_attached_object (target_node), target_node->type);
break;
}
@@ -151,7 +150,7 @@ acpi_ex_create_alias (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_event
*
@@ -161,7 +160,7 @@ acpi_ex_create_alias (
*
* DESCRIPTION: Create a new event object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_event (
@@ -185,7 +184,7 @@ acpi_ex_create_event (
* that the event is created in an unsignalled state
*/
status = acpi_os_create_semaphore (ACPI_NO_UNIT_LIMIT, 0,
- &obj_desc->event.semaphore);
+ &obj_desc->event.semaphore);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -193,7 +192,7 @@ acpi_ex_create_event (
/* Attach object to the Node */
status = acpi_ns_attach_object ((struct acpi_namespace_node *) walk_state->operands[0],
- obj_desc, ACPI_TYPE_EVENT);
+ obj_desc, ACPI_TYPE_EVENT);
cleanup:
/*
@@ -205,7 +204,7 @@ cleanup:
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_mutex
*
@@ -217,7 +216,7 @@ cleanup:
*
* Mutex (Name[0], sync_level[1])
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_mutex (
@@ -267,20 +266,20 @@ cleanup:
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_region
*
* PARAMETERS: aml_start - Pointer to the region declaration AML
* aml_length - Max length of the declaration AML
- * Operands - List of operands for the opcode
+ * region_space - space_iD for the region
* walk_state - Current state
*
* RETURN: Status
*
* DESCRIPTION: Create a new operation region object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_region (
@@ -321,7 +320,7 @@ acpi_ex_create_region (
}
ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n",
- acpi_ut_get_region_name (region_space), region_space));
+ acpi_ut_get_region_name (region_space), region_space));
/* Create the region descriptor */
@@ -360,7 +359,7 @@ cleanup:
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_table_region
*
@@ -370,7 +369,7 @@ cleanup:
*
* DESCRIPTION: Create a new data_table_region object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_table_region (
@@ -455,7 +454,7 @@ cleanup:
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_processor
*
@@ -467,7 +466,7 @@ cleanup:
*
* Processor (Name[0], cpu_iD[1], pblock_addr[2], pblock_length[3])
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_processor (
@@ -488,9 +487,8 @@ acpi_ex_create_processor (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /*
- * Initialize the processor object from the operands
- */
+ /* Initialize the processor object from the operands */
+
obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
obj_desc->processor.address = (acpi_io_address) operand[2]->integer.value;
obj_desc->processor.length = (u8) operand[3]->integer.value;
@@ -507,7 +505,7 @@ acpi_ex_create_processor (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_power_resource
*
@@ -519,7 +517,7 @@ acpi_ex_create_processor (
*
* power_resource (Name[0], system_level[1], resource_order[2])
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_power_resource (
@@ -555,10 +553,10 @@ acpi_ex_create_power_resource (
acpi_ut_remove_reference (obj_desc);
return_ACPI_STATUS (status);
}
-
#endif
-/*****************************************************************************
+
+/*******************************************************************************
*
* FUNCTION: acpi_ex_create_method
*
@@ -570,7 +568,7 @@ acpi_ex_create_power_resource (
*
* DESCRIPTION: Create a new method object
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
acpi_ex_create_method (
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index e2f7c32f28d..40850064811 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -51,23 +51,48 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exdump")
+/* Local prototypes */
+
+#ifdef ACPI_FUTURE_USAGE
+static void
+acpi_ex_out_string (
+ char *title,
+ char *value);
+
+static void
+acpi_ex_out_pointer (
+ char *title,
+ void *value);
+
+static void
+acpi_ex_out_integer (
+ char *title,
+ u32 value);
+
+static void
+acpi_ex_out_address (
+ char *title,
+ acpi_physical_address value);
+#endif /* ACPI_FUTURE_USAGE */
+
/*
* The following routines are used for debug output only
*/
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_operand
*
- * PARAMETERS: *obj_desc - Pointer to entry to be dumped
+ * PARAMETERS: *obj_desc - Pointer to entry to be dumped
+ * Depth - Current nesting depth
*
* RETURN: None
*
* DESCRIPTION: Dump an operand object
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ex_dump_operand (
@@ -86,9 +111,8 @@ acpi_ex_dump_operand (
}
if (!obj_desc) {
- /*
- * This could be a null element of a package
- */
+ /* This could be a null element of a package */
+
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
return;
}
@@ -117,6 +141,8 @@ acpi_ex_dump_operand (
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", obj_desc));
}
+ /* Decode object type */
+
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_LOCAL_REFERENCE:
@@ -274,7 +300,9 @@ acpi_ex_dump_operand (
case ACPI_TYPE_STRING:
acpi_os_printf ("String length %X @ %p ",
- obj_desc->string.length, obj_desc->string.pointer);
+ obj_desc->string.length,
+ obj_desc->string.pointer);
+
acpi_ut_print_string (obj_desc->string.pointer, ACPI_UINT8_MAX);
acpi_os_printf ("\n");
break;
@@ -290,10 +318,13 @@ acpi_ex_dump_operand (
acpi_os_printf (
"region_field: Bits=%X acc_width=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n",
- obj_desc->field.bit_length, obj_desc->field.access_byte_width,
+ obj_desc->field.bit_length,
+ obj_desc->field.access_byte_width,
obj_desc->field.field_flags & AML_FIELD_LOCK_RULE_MASK,
obj_desc->field.field_flags & AML_FIELD_UPDATE_RULE_MASK,
- obj_desc->field.base_byte_offset, obj_desc->field.start_field_bit_offset);
+ obj_desc->field.base_byte_offset,
+ obj_desc->field.start_field_bit_offset);
+
acpi_ex_dump_operand (obj_desc->field.region_obj, depth+1);
break;
@@ -308,13 +339,15 @@ acpi_ex_dump_operand (
acpi_os_printf (
"buffer_field: %X bits at byte %X bit %X of \n",
- obj_desc->buffer_field.bit_length, obj_desc->buffer_field.base_byte_offset,
+ obj_desc->buffer_field.bit_length,
+ obj_desc->buffer_field.base_byte_offset,
obj_desc->buffer_field.start_field_bit_offset);
if (!obj_desc->buffer_field.buffer_obj) {
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n"));
}
- else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) != ACPI_TYPE_BUFFER) {
+ else if (ACPI_GET_OBJECT_TYPE (obj_desc->buffer_field.buffer_obj) !=
+ ACPI_TYPE_BUFFER) {
acpi_os_printf ("*not a Buffer* \n");
}
else {
@@ -331,10 +364,10 @@ acpi_ex_dump_operand (
case ACPI_TYPE_METHOD:
- acpi_os_printf (
- "Method(%X) @ %p:%X\n",
+ acpi_os_printf ("Method(%X) @ %p:%X\n",
obj_desc->method.param_count,
- obj_desc->method.aml_start, obj_desc->method.aml_length);
+ obj_desc->method.aml_start,
+ obj_desc->method.aml_length);
break;
@@ -379,7 +412,7 @@ acpi_ex_dump_operand (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_operands
*
@@ -393,7 +426,7 @@ acpi_ex_dump_operand (
*
* DESCRIPTION: Dump the object stack
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ex_dump_operands (
@@ -441,10 +474,9 @@ acpi_ex_dump_operands (
#ifdef ACPI_FUTURE_USAGE
-
-/*****************************************************************************
+/*******************************************************************************
*
- * FUNCTION: acpi_ex_out*
+ * FUNCTION: acpi_ex_out* functions
*
* PARAMETERS: Title - Descriptive text
* Value - Value to be displayed
@@ -453,9 +485,9 @@ acpi_ex_dump_operands (
* reduce the number of format strings required and keeps them
* all in one place for easy modification.
*
- ****************************************************************************/
+ ******************************************************************************/
-void
+static void
acpi_ex_out_string (
char *title,
char *value)
@@ -463,7 +495,7 @@ acpi_ex_out_string (
acpi_os_printf ("%20s : %s\n", title, value);
}
-void
+static void
acpi_ex_out_pointer (
char *title,
void *value)
@@ -471,7 +503,7 @@ acpi_ex_out_pointer (
acpi_os_printf ("%20s : %p\n", title, value);
}
-void
+static void
acpi_ex_out_integer (
char *title,
u32 value)
@@ -479,7 +511,7 @@ acpi_ex_out_integer (
acpi_os_printf ("%20s : %X\n", title, value);
}
-void
+static void
acpi_ex_out_address (
char *title,
acpi_physical_address value)
@@ -493,16 +525,16 @@ acpi_ex_out_address (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_node
*
* PARAMETERS: *Node - Descriptor to dump
- * Flags - Force display
+ * Flags - Force display if TRUE
*
* DESCRIPTION: Dumps the members of the given.Node
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ex_dump_node (
@@ -531,16 +563,16 @@ acpi_ex_dump_node (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ex_dump_object_descriptor
*
* PARAMETERS: *Object - Descriptor to dump
- * Flags - Force display
+ * Flags - Force display if TRUE
*
* DESCRIPTION: Dumps the members of the object descriptor given.
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ex_dump_object_descriptor (
@@ -553,6 +585,10 @@ acpi_ex_dump_object_descriptor (
ACPI_FUNCTION_TRACE ("ex_dump_object_descriptor");
+ if (!obj_desc) {
+ return_VOID;
+ }
+
if (!flags) {
if (!((ACPI_LV_OBJECTS & acpi_dbg_level) && (_COMPONENT & acpi_dbg_layer))) {
return_VOID;
@@ -747,11 +783,17 @@ acpi_ex_dump_object_descriptor (
case ACPI_TYPE_LOCAL_REFERENCE:
acpi_ex_out_integer ("target_type", obj_desc->reference.target_type);
- acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info (obj_desc->reference.opcode))->name);
+ acpi_ex_out_string ("Opcode", (acpi_ps_get_opcode_info (
+ obj_desc->reference.opcode))->name);
acpi_ex_out_integer ("Offset", obj_desc->reference.offset);
acpi_ex_out_pointer ("obj_desc", obj_desc->reference.object);
acpi_ex_out_pointer ("Node", obj_desc->reference.node);
acpi_ex_out_pointer ("Where", obj_desc->reference.where);
+
+ if (obj_desc->reference.object) {
+ acpi_os_printf ("\nReferenced Object:\n");
+ acpi_ex_dump_object_descriptor (obj_desc->reference.object, flags);
+ }
break;
@@ -788,6 +830,5 @@ acpi_ex_dump_object_descriptor (
}
#endif /* ACPI_FUTURE_USAGE */
-
#endif
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/executer/exfield.c
index be7f2124fa0..22c8fa480f6 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/executer/exfield.c
@@ -120,8 +120,8 @@ acpi_ex_read_data_from_field (
* Note: Smbus protocol value is passed in upper 16-bits of Function
*/
status = acpi_ex_access_region (obj_desc, 0,
- ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
- ACPI_READ | (obj_desc->field.attribute << 16));
+ ACPI_CAST_PTR (acpi_integer, buffer_desc->buffer.pointer),
+ ACPI_READ | (obj_desc->field.attribute << 16));
acpi_ex_release_global_lock (locked);
goto exit;
}
@@ -196,6 +196,7 @@ exit:
*
* PARAMETERS: source_desc - Contains data to write
* obj_desc - The named field
+ * result_desc - Where the return value is returned, if any
*
* RETURN: Status
*
@@ -250,12 +251,15 @@ acpi_ex_write_data_to_field (
if (ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) {
ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n",
acpi_ut_get_object_type_name (source_desc)));
+
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (source_desc->buffer.length < ACPI_SMBUS_BUFFER_SIZE) {
- ACPI_REPORT_ERROR (("SMBus write requires Buffer of length %X, found length %X\n",
+ ACPI_REPORT_ERROR ((
+ "SMBus write requires Buffer of length %X, found length %X\n",
ACPI_SMBUS_BUFFER_SIZE, source_desc->buffer.length));
+
return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
}
@@ -265,14 +269,16 @@ acpi_ex_write_data_to_field (
}
buffer = buffer_desc->buffer.pointer;
- ACPI_MEMCPY (buffer, source_desc->buffer.pointer, ACPI_SMBUS_BUFFER_SIZE);
+ ACPI_MEMCPY (buffer, source_desc->buffer.pointer,
+ ACPI_SMBUS_BUFFER_SIZE);
/* Lock entire transaction if requested */
locked = acpi_ex_acquire_global_lock (obj_desc->common_field.field_flags);
/*
- * Perform the write (returns status and perhaps data in the same buffer)
+ * Perform the write (returns status and perhaps data in the
+ * same buffer)
* Note: SMBus protocol type is passed in upper 16-bits of Function.
*/
status = acpi_ex_access_region (obj_desc, 0,
@@ -284,9 +290,8 @@ acpi_ex_write_data_to_field (
return_ACPI_STATUS (status);
}
- /*
- * Get a pointer to the data to be written
- */
+ /* Get a pointer to the data to be written */
+
switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
case ACPI_TYPE_INTEGER:
buffer = &source_desc->integer.value;
@@ -314,7 +319,8 @@ acpi_ex_write_data_to_field (
* the ACPI specification.
*/
new_buffer = NULL;
- required_length = ACPI_ROUND_BITS_UP_TO_BYTES (obj_desc->common_field.bit_length);
+ required_length = ACPI_ROUND_BITS_UP_TO_BYTES (
+ obj_desc->common_field.bit_length);
if (length < required_length) {
/* We need to create a new buffer */
@@ -338,6 +344,7 @@ acpi_ex_write_data_to_field (
"field_write [FROM]: Obj %p (%s:%X), Buf %p, byte_len %X\n",
source_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (source_desc)),
ACPI_GET_OBJECT_TYPE (source_desc), buffer, length));
+
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"field_write [TO]: Obj %p (%s:%X), bit_len %X, bit_off %X, byte_off %X\n",
obj_desc, acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)),
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 9d0f9d2e906..3c2f89e00f7 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -52,12 +52,31 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exfldio")
+/* Local prototypes */
+
+static acpi_status
+acpi_ex_field_datum_io (
+ union acpi_operand_object *obj_desc,
+ u32 field_datum_byte_offset,
+ acpi_integer *value,
+ u32 read_write);
+
+static u8
+acpi_ex_register_overflow (
+ union acpi_operand_object *obj_desc,
+ acpi_integer value);
+
+static acpi_status
+acpi_ex_setup_region (
+ union acpi_operand_object *obj_desc,
+ u32 field_datum_byte_offset);
+
/*******************************************************************************
*
* FUNCTION: acpi_ex_setup_region
*
- * PARAMETERS: *obj_desc - Field to be read or written
+ * PARAMETERS: obj_desc - Field to be read or written
* field_datum_byte_offset - Byte offset of this datum within the
* parent field
*
@@ -69,7 +88,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_setup_region (
union acpi_operand_object *obj_desc,
u32 field_datum_byte_offset)
@@ -127,9 +146,9 @@ acpi_ex_setup_region (
* length of one field datum (access width) must fit within the region.
* (Region length is specified in bytes)
*/
- if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset
- + field_datum_byte_offset
- + obj_desc->common_field.access_byte_width)) {
+ if (rgn_desc->region.length < (obj_desc->common_field.base_byte_offset +
+ field_datum_byte_offset +
+ obj_desc->common_field.access_byte_width)) {
if (acpi_gbl_enable_interpreter_slack) {
/*
* Slack mode only: We will go ahead and allow access to this
@@ -155,7 +174,8 @@ acpi_ex_setup_region (
"Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
acpi_ut_get_node_name (obj_desc->common_field.node),
obj_desc->common_field.access_byte_width,
- acpi_ut_get_node_name (rgn_desc->region.node), rgn_desc->region.length));
+ acpi_ut_get_node_name (rgn_desc->region.node),
+ rgn_desc->region.length));
}
/*
@@ -167,7 +187,8 @@ acpi_ex_setup_region (
acpi_ut_get_node_name (obj_desc->common_field.node),
obj_desc->common_field.base_byte_offset,
field_datum_byte_offset, obj_desc->common_field.access_byte_width,
- acpi_ut_get_node_name (rgn_desc->region.node), rgn_desc->region.length));
+ acpi_ut_get_node_name (rgn_desc->region.node),
+ rgn_desc->region.length));
return_ACPI_STATUS (AE_AML_REGION_LIMIT);
}
@@ -180,10 +201,10 @@ acpi_ex_setup_region (
*
* FUNCTION: acpi_ex_access_region
*
- * PARAMETERS: *obj_desc - Field to be read
+ * PARAMETERS: obj_desc - Field to be read
* field_datum_byte_offset - Byte offset of this datum within the
* parent field
- * *Value - Where to store value (must at least
+ * Value - Where to store value (must at least
* the size of acpi_integer)
* Function - Read or Write flag plus other region-
* dependent flags
@@ -226,9 +247,9 @@ acpi_ex_access_region (
* 3) The current offset into the field
*/
rgn_desc = obj_desc->common_field.region_obj;
- address = rgn_desc->region.address
- + obj_desc->common_field.base_byte_offset
- + field_datum_byte_offset;
+ address = rgn_desc->region.address +
+ obj_desc->common_field.base_byte_offset +
+ field_datum_byte_offset;
if ((function & ACPI_IO_MASK) == ACPI_READ) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
@@ -249,7 +270,8 @@ acpi_ex_access_region (
/* Invoke the appropriate address_space/op_region handler */
status = acpi_ev_address_space_dispatch (rgn_desc, function,
- address, ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value);
+ address,
+ ACPI_MUL_8 (obj_desc->common_field.access_byte_width), value);
if (ACPI_FAILURE (status)) {
if (status == AE_NOT_IMPLEMENTED) {
@@ -274,7 +296,7 @@ acpi_ex_access_region (
*
* FUNCTION: acpi_ex_register_overflow
*
- * PARAMETERS: *obj_desc - Register(Field) to be written
+ * PARAMETERS: obj_desc - Register(Field) to be written
* Value - Value to be stored
*
* RETURN: TRUE if value overflows the field, FALSE otherwise
@@ -287,7 +309,7 @@ acpi_ex_access_region (
*
******************************************************************************/
-u8
+static u8
acpi_ex_register_overflow (
union acpi_operand_object *obj_desc,
acpi_integer value)
@@ -319,10 +341,10 @@ acpi_ex_register_overflow (
*
* FUNCTION: acpi_ex_field_datum_io
*
- * PARAMETERS: *obj_desc - Field to be read
+ * PARAMETERS: obj_desc - Field to be read
* field_datum_byte_offset - Byte offset of this datum within the
* parent field
- * *Value - Where to store value (must be 64 bits)
+ * Value - Where to store value (must be 64 bits)
* read_write - Read or Write flag
*
* RETURN: Status
@@ -333,7 +355,7 @@ acpi_ex_register_overflow (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_field_datum_io (
union acpi_operand_object *obj_desc,
u32 field_datum_byte_offset,
@@ -350,7 +372,9 @@ acpi_ex_field_datum_io (
if (read_write == ACPI_READ) {
if (!value) {
local_value = 0;
- value = &local_value; /* To support reads without saving return value */
+
+ /* To support reads without saving return value */
+ value = &local_value;
}
/* Clear the entire return buffer first, [Very Important!] */
@@ -363,8 +387,10 @@ acpi_ex_field_datum_io (
*
* buffer_field - Read/write from/to a Buffer
* region_field - Read/write from/to a Operation Region.
- * bank_field - Write to a Bank Register, then read/write from/to an op_region
- * index_field - Write to an Index Register, then read/write from/to a Data Register
+ * bank_field - Write to a Bank Register, then read/write from/to an
+ * operation_region
+ * index_field - Write to an Index Register, then read/write from/to a
+ * Data Register
*/
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_BUFFER_FIELD:
@@ -384,19 +410,20 @@ acpi_ex_field_datum_io (
* Copy the data from the source buffer.
* Length is the field width in bytes.
*/
- ACPI_MEMCPY (value, (obj_desc->buffer_field.buffer_obj)->buffer.pointer
- + obj_desc->buffer_field.base_byte_offset
- + field_datum_byte_offset,
- obj_desc->common_field.access_byte_width);
+ ACPI_MEMCPY (value,
+ (obj_desc->buffer_field.buffer_obj)->buffer.pointer +
+ obj_desc->buffer_field.base_byte_offset +
+ field_datum_byte_offset,
+ obj_desc->common_field.access_byte_width);
}
else {
/*
* Copy the data to the target buffer.
* Length is the field width in bytes.
*/
- ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer
- + obj_desc->buffer_field.base_byte_offset
- + field_datum_byte_offset,
+ ACPI_MEMCPY ((obj_desc->buffer_field.buffer_obj)->buffer.pointer +
+ obj_desc->buffer_field.base_byte_offset +
+ field_datum_byte_offset,
value, obj_desc->common_field.access_byte_width);
}
@@ -406,8 +433,10 @@ acpi_ex_field_datum_io (
case ACPI_TYPE_LOCAL_BANK_FIELD:
- /* Ensure that the bank_value is not beyond the capacity of the register */
-
+ /*
+ * Ensure that the bank_value is not beyond the capacity of
+ * the register
+ */
if (acpi_ex_register_overflow (obj_desc->bank_field.bank_obj,
(acpi_integer) obj_desc->bank_field.value)) {
return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
@@ -445,8 +474,10 @@ acpi_ex_field_datum_io (
case ACPI_TYPE_LOCAL_INDEX_FIELD:
- /* Ensure that the index_value is not beyond the capacity of the register */
-
+ /*
+ * Ensure that the index_value is not beyond the capacity of
+ * the register
+ */
if (acpi_ex_register_overflow (obj_desc->index_field.index_obj,
(acpi_integer) obj_desc->index_field.value)) {
return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
@@ -496,14 +527,16 @@ acpi_ex_field_datum_io (
if (ACPI_SUCCESS (status)) {
if (read_write == ACPI_READ) {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read %8.8X%8.8X, Width %d\n",
- ACPI_FORMAT_UINT64 (*value),
- obj_desc->common_field.access_byte_width));
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Read %8.8X%8.8X, Width %d\n",
+ ACPI_FORMAT_UINT64 (*value),
+ obj_desc->common_field.access_byte_width));
}
else {
- ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written %8.8X%8.8X, Width %d\n",
- ACPI_FORMAT_UINT64 (*value),
- obj_desc->common_field.access_byte_width));
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Value Written %8.8X%8.8X, Width %d\n",
+ ACPI_FORMAT_UINT64 (*value),
+ obj_desc->common_field.access_byte_width));
}
}
@@ -515,8 +548,10 @@ acpi_ex_field_datum_io (
*
* FUNCTION: acpi_ex_write_with_update_rule
*
- * PARAMETERS: *obj_desc - Field to be set
- * Value - Value to store
+ * PARAMETERS: obj_desc - Field to be written
+ * Mask - bitmask within field datum
+ * field_value - Value to write
+ * field_datum_byte_offset - Offset of datum within field
*
* RETURN: Status
*
@@ -689,7 +724,8 @@ acpi_ex_extract_from_field (
/* Merge with previous datum if necessary */
merged_datum |= raw_datum <<
- (obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset);
+ (obj_desc->common_field.access_bit_width -
+ obj_desc->common_field.start_field_bit_offset);
if (i == datum_count) {
break;
@@ -707,7 +743,8 @@ acpi_ex_extract_from_field (
/* Mask off any extra bits in the last datum */
- buffer_tail_bits = obj_desc->common_field.bit_length % obj_desc->common_field.access_bit_width;
+ buffer_tail_bits = obj_desc->common_field.bit_length %
+ obj_desc->common_field.access_bit_width;
if (buffer_tail_bits) {
merged_datum &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
}
@@ -791,7 +828,8 @@ acpi_ex_insert_into_field (
/* Write merged datum to the target field */
merged_datum &= mask;
- status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset);
+ status = acpi_ex_write_with_update_rule (obj_desc, mask,
+ merged_datum, field_offset);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -800,7 +838,8 @@ acpi_ex_insert_into_field (
field_offset += obj_desc->common_field.access_byte_width;
merged_datum = raw_datum >>
- (obj_desc->common_field.access_bit_width - obj_desc->common_field.start_field_bit_offset);
+ (obj_desc->common_field.access_bit_width -
+ obj_desc->common_field.start_field_bit_offset);
mask = ACPI_INTEGER_MAX;
if (i == datum_count) {
@@ -819,7 +858,8 @@ acpi_ex_insert_into_field (
/* Mask off any extra bits in the last datum */
buffer_tail_bits = (obj_desc->common_field.bit_length +
- obj_desc->common_field.start_field_bit_offset) % obj_desc->common_field.access_bit_width;
+ obj_desc->common_field.start_field_bit_offset) %
+ obj_desc->common_field.access_bit_width;
if (buffer_tail_bits) {
mask &= ACPI_MASK_BITS_ABOVE (buffer_tail_bits);
}
@@ -827,7 +867,8 @@ acpi_ex_insert_into_field (
/* Write the last datum to the field */
merged_datum &= mask;
- status = acpi_ex_write_with_update_rule (obj_desc, mask, merged_datum, field_offset);
+ status = acpi_ex_write_with_update_rule (obj_desc,
+ mask, merged_datum, field_offset);
return_ACPI_STATUS (status);
}
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index b542dcd58c0..022f281345b 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -139,8 +139,9 @@ acpi_ex_get_object_reference (
reference_obj->reference.object = referenced_obj;
*return_desc = reference_obj;
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n",
- obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Object %p Type [%s], returning Reference %p\n",
+ obj_desc, acpi_ut_get_object_type_name (obj_desc), *return_desc));
return_ACPI_STATUS (AE_OK);
}
@@ -456,7 +457,7 @@ acpi_ex_do_math_op (
return (integer0 * integer1);
- case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result) */
+ case AML_SHIFT_LEFT_OP: /* shift_left (Operand, shift_count, Result)*/
return (integer0 << integer1);
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index 68c4bb1970a..c3cb714d2cb 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -49,6 +49,13 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exmutex")
+/* Local prototypes */
+
+static void
+acpi_ex_link_mutex (
+ union acpi_operand_object *obj_desc,
+ struct acpi_thread_state *thread);
+
/*******************************************************************************
*
@@ -56,7 +63,7 @@
*
* PARAMETERS: obj_desc - The mutex to be unlinked
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Remove a mutex from the "acquired_mutex" list
*
@@ -92,16 +99,16 @@ acpi_ex_unlink_mutex (
*
* FUNCTION: acpi_ex_link_mutex
*
- * PARAMETERS: obj_desc - The mutex to be linked
- * list_head - head of the "acquired_mutex" list
+ * PARAMETERS: obj_desc - The mutex to be linked
+ * Thread - Current executing thread object
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Add a mutex to the "acquired_mutex" list for this walk
*
******************************************************************************/
-void
+static void
acpi_ex_link_mutex (
union acpi_operand_object *obj_desc,
struct acpi_thread_state *thread)
@@ -132,8 +139,9 @@ acpi_ex_link_mutex (
*
* FUNCTION: acpi_ex_acquire_mutex
*
- * PARAMETERS: time_desc - The 'time to delay' object descriptor
- * obj_desc - The object descriptor for this op
+ * PARAMETERS: time_desc - Timeout integer
+ * obj_desc - Mutex object
+ * walk_state - Current method execution state
*
* RETURN: Status
*
@@ -161,7 +169,7 @@ acpi_ex_acquire_mutex (
if (!walk_state->thread) {
ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n",
- acpi_ut_get_node_name (obj_desc->mutex.node)));
+ acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
@@ -170,8 +178,9 @@ acpi_ex_acquire_mutex (
* mutex. This mechanism provides some deadlock prevention
*/
if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
- ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect sync_level\n",
- acpi_ut_get_node_name (obj_desc->mutex.node)));
+ ACPI_REPORT_ERROR ((
+ "Cannot acquire Mutex [%4.4s], incorrect sync_level\n",
+ acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
}
@@ -180,8 +189,10 @@ acpi_ex_acquire_mutex (
if (obj_desc->mutex.owner_thread) {
/* Special case for Global Lock, allow all threads */
- if ((obj_desc->mutex.owner_thread->thread_id == walk_state->thread->thread_id) ||
- (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore)) {
+ if ((obj_desc->mutex.owner_thread->thread_id ==
+ walk_state->thread->thread_id) ||
+ (obj_desc->mutex.semaphore ==
+ acpi_gbl_global_lock_semaphore)) {
/*
* The mutex is already owned by this thread,
* just increment the acquisition depth
@@ -221,6 +232,7 @@ acpi_ex_acquire_mutex (
* FUNCTION: acpi_ex_release_mutex
*
* PARAMETERS: obj_desc - The object descriptor for this op
+ * walk_state - Current method execution state
*
* RETURN: Status
*
@@ -278,8 +290,9 @@ acpi_ex_release_mutex (
* equal to the current sync level
*/
if (obj_desc->mutex.sync_level > walk_state->thread->current_sync_level) {
- ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect sync_level\n",
- acpi_ut_get_node_name (obj_desc->mutex.node)));
+ ACPI_REPORT_ERROR ((
+ "Cannot release Mutex [%4.4s], incorrect sync_level\n",
+ acpi_ut_get_node_name (obj_desc->mutex.node)));
return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
}
@@ -313,11 +326,11 @@ acpi_ex_release_mutex (
*
* FUNCTION: acpi_ex_release_all_mutexes
*
- * PARAMETERS: mutex_list - Head of the mutex list
+ * PARAMETERS: Thread - Current executing thread object
*
* RETURN: Status
*
- * DESCRIPTION: Release all mutexes in the list
+ * DESCRIPTION: Release all mutexes held by this thread
*
******************************************************************************/
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index 7911c533c26..639f0bd3f6d 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -50,13 +50,17 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exnames")
+/* Local prototypes */
-/* AML Package Length encodings */
+static char *
+acpi_ex_allocate_name_string (
+ u32 prefix_count,
+ u32 num_name_segs);
-#define ACPI_AML_PACKAGE_TYPE1 0x40
-#define ACPI_AML_PACKAGE_TYPE2 0x4000
-#define ACPI_AML_PACKAGE_TYPE3 0x400000
-#define ACPI_AML_PACKAGE_TYPE4 0x40000000
+static acpi_status
+acpi_ex_name_segment (
+ u8 **in_aml_address,
+ char *name_string);
/*******************************************************************************
@@ -64,7 +68,7 @@
* FUNCTION: acpi_ex_allocate_name_string
*
* PARAMETERS: prefix_count - Count of parent levels. Special cases:
- * (-1) = root, 0 = none
+ * (-1)==root, 0==none
* num_name_segs - count of 4-character name segments
*
* RETURN: A pointer to the allocated string segment. This segment must
@@ -75,7 +79,7 @@
*
******************************************************************************/
-char *
+static char *
acpi_ex_allocate_name_string (
u32 prefix_count,
u32 num_name_segs)
@@ -88,7 +92,7 @@ acpi_ex_allocate_name_string (
/*
- * Allow room for all \ and ^ prefixes, all segments, and a multi_name_prefix.
+ * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
* Also, one byte for the null terminator.
* This may actually be somewhat longer than needed.
*/
@@ -107,7 +111,8 @@ acpi_ex_allocate_name_string (
*/
name_string = ACPI_MEM_ALLOCATE (size_needed);
if (!name_string) {
- ACPI_REPORT_ERROR (("ex_allocate_name_string: Could not allocate size %d\n", size_needed));
+ ACPI_REPORT_ERROR ((
+ "ex_allocate_name_string: Could not allocate size %d\n", size_needed));
return_PTR (NULL);
}
@@ -152,15 +157,17 @@ acpi_ex_allocate_name_string (
*
* FUNCTION: acpi_ex_name_segment
*
- * PARAMETERS: interpreter_mode - Current running mode (load1/Load2/Exec)
+ * PARAMETERS: in_aml_address - Pointer to the name in the AML code
+ * name_string - Where to return the name. The name is appended
+ * to any existing string to form a namepath
*
* RETURN: Status
*
- * DESCRIPTION: Execute a name segment (4 bytes)
+ * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_name_segment (
u8 **in_aml_address,
char *name_string)
@@ -223,10 +230,13 @@ acpi_ex_name_segment (
status = AE_CTRL_PENDING;
}
else {
- /* Segment started with one or more valid characters, but fewer than 4 */
-
+ /*
+ * Segment started with one or more valid characters, but fewer than
+ * the required 4
+ */
status = AE_AML_BAD_NAME;
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Bad character %02x in name, at %p\n",
*aml_address, aml_address));
}
@@ -239,11 +249,16 @@ acpi_ex_name_segment (
*
* FUNCTION: acpi_ex_get_name_string
*
- * PARAMETERS: data_type - Data type to be associated with this name
+ * PARAMETERS: data_type - Object type to be associated with this
+ * name
+ * in_aml_address - Pointer to the namestring in the AML code
+ * out_name_string - Where the namestring is returned
+ * out_name_length - Length of the returned string
*
- * RETURN: Status
+ * RETURN: Status, namestring and length
*
- * DESCRIPTION: Get a name, including any prefixes.
+ * DESCRIPTION: Extract a full namepath from the AML byte stream,
+ * including any prefixes.
*
******************************************************************************/
@@ -286,7 +301,8 @@ acpi_ex_get_name_string (
switch (*aml_address) {
case AML_ROOT_PREFIX:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", aml_address));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n",
+ aml_address));
/*
* Remember that we have a root_prefix --
@@ -303,7 +319,8 @@ acpi_ex_get_name_string (
/* Increment past possibly multiple parent prefixes */
do {
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", aml_address));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n",
+ aml_address));
aml_address++;
prefix_count++;
@@ -321,13 +338,13 @@ acpi_ex_get_name_string (
break;
}
-
/* Examine first character of name for name segment prefix operator */
switch (*aml_address) {
case AML_DUAL_NAME_PREFIX:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", aml_address));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n",
+ aml_address));
aml_address++;
name_string = acpi_ex_allocate_name_string (prefix_count, 2);
@@ -349,7 +366,8 @@ acpi_ex_get_name_string (
case AML_MULTI_NAME_PREFIX_OP:
- ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", aml_address));
+ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n",
+ aml_address));
/* Fetch count of segments remaining in name path */
@@ -368,7 +386,8 @@ acpi_ex_get_name_string (
has_prefix = TRUE;
while (num_segments &&
- (status = acpi_ex_name_segment (&aml_address, name_string)) == AE_OK) {
+ (status = acpi_ex_name_segment (&aml_address, name_string)) ==
+ AE_OK) {
num_segments--;
}
@@ -380,7 +399,8 @@ acpi_ex_get_name_string (
/* null_name valid as of 8-12-98 ASL/AML Grammar Update */
if (prefix_count == ACPI_UINT32_MAX) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "name_seg is \"\\\" followed by NULL\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "name_seg is \"\\\" followed by NULL\n"));
}
/* Consume the NULL byte */
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 8482aefaf38..dbdf8262ba0 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -97,7 +97,8 @@ acpi_ex_opcode_0A_0T_1R (
union acpi_operand_object *return_desc = NULL;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_0A_0T_1R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
@@ -161,7 +162,8 @@ acpi_ex_opcode_1A_0T_0R (
acpi_status status = AE_OK;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_0R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
@@ -236,7 +238,8 @@ acpi_ex_opcode_1A_1T_0R (
union acpi_operand_object **operand = &walk_state->operands[0];
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_0R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
@@ -289,7 +292,8 @@ acpi_ex_opcode_1A_1T_1R (
acpi_integer digit;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_1T_1R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
@@ -409,8 +413,10 @@ acpi_ex_opcode_1A_1T_1R (
for (i = 0; (i < acpi_gbl_integer_nybble_width) && (digit > 0); i++) {
(void) acpi_ut_short_divide (digit, 10, &digit, &temp32);
- /* Insert the BCD digit that resides in the remainder from above */
-
+ /*
+ * Insert the BCD digit that resides in the
+ * remainder from above
+ */
return_desc->integer.value |= (((acpi_integer) temp32) <<
ACPI_MUL_4 (i));
}
@@ -445,7 +451,8 @@ acpi_ex_opcode_1A_1T_1R (
/* Get the object reference, store it, and remove our reference */
- status = acpi_ex_get_object_reference (operand[0], &return_desc2, walk_state);
+ status = acpi_ex_get_object_reference (operand[0],
+ &return_desc2, walk_state);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -482,10 +489,10 @@ acpi_ex_opcode_1A_1T_1R (
if (!walk_state->result_obj) {
/*
- * Normally, we would remove a reference on the Operand[0] parameter;
- * But since it is being used as the internal return object
- * (meaning we would normally increment it), the two cancel out,
- * and we simply don't do anything.
+ * Normally, we would remove a reference on the Operand[0]
+ * parameter; But since it is being used as the internal return
+ * object (meaning we would normally increment it), the two
+ * cancel out, and we simply don't do anything.
*/
walk_state->result_obj = operand[0];
walk_state->operands[0] = NULL; /* Prevent deletion */
@@ -549,9 +556,8 @@ acpi_ex_opcode_1A_1T_1R (
case AML_SHIFT_LEFT_BIT_OP: /* shift_left_bit (Source, bit_num) */
case AML_SHIFT_RIGHT_BIT_OP: /* shift_right_bit (Source, bit_num) */
- /*
- * These are two obsolete opcodes
- */
+ /* These are two obsolete opcodes */
+
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"%s is obsolete and not implemented\n",
acpi_ps_get_opcode_name (walk_state->opcode)));
@@ -568,9 +574,8 @@ acpi_ex_opcode_1A_1T_1R (
}
if (ACPI_SUCCESS (status)) {
- /*
- * Store the return value computed above into the target object
- */
+ /* Store the return value computed above into the target object */
+
status = acpi_ex_store (return_desc, operand[1], walk_state);
}
@@ -615,7 +620,8 @@ acpi_ex_opcode_1A_0T_1R (
acpi_integer value;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_1A_0T_1R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
/* Examine the AML opcode */
@@ -706,9 +712,9 @@ acpi_ex_opcode_1A_0T_1R (
/*
* Note: The operand is not resolved at this point because we want to
- * get the associated object, not its value. For example, we don't want
- * to resolve a field_unit to its value, we want the actual field_unit
- * object.
+ * get the associated object, not its value. For example, we don't
+ * want to resolve a field_unit to its value, we want the actual
+ * field_unit object.
*/
/* Get the type of the base object */
@@ -738,7 +744,8 @@ acpi_ex_opcode_1A_0T_1R (
/* Get the base object */
- status = acpi_ex_resolve_multiple (walk_state, operand[0], &type, &temp_desc);
+ status = acpi_ex_resolve_multiple (walk_state,
+ operand[0], &type, &temp_desc);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -818,8 +825,10 @@ acpi_ex_opcode_1A_0T_1R (
/* Set Operand[0] to the value of the local/arg */
- status = acpi_ds_method_data_get_value (operand[0]->reference.opcode,
- operand[0]->reference.offset, walk_state, &temp_desc);
+ status = acpi_ds_method_data_get_value (
+ operand[0]->reference.opcode,
+ operand[0]->reference.offset,
+ walk_state, &temp_desc);
if (ACPI_FAILURE (status)) {
goto cleanup;
}
@@ -852,21 +861,26 @@ acpi_ex_opcode_1A_0T_1R (
case ACPI_TYPE_STRING:
/*
- * This is a deref_of (String). The string is a reference to a named ACPI object.
+ * This is a deref_of (String). The string is a reference
+ * to a named ACPI object.
*
* 1) Find the owning Node
- * 2) Dereference the node to an actual object. Could be a Field, so we nee
- * to resolve the node to a value.
+ * 2) Dereference the node to an actual object. Could be a
+ * Field, so we need to resolve the node to a value.
*/
status = acpi_ns_get_node_by_path (operand[0]->string.pointer,
- walk_state->scope_info->scope.node, ACPI_NS_SEARCH_PARENT,
- ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc));
+ walk_state->scope_info->scope.node,
+ ACPI_NS_SEARCH_PARENT,
+ ACPI_CAST_INDIRECT_PTR (
+ struct acpi_namespace_node, &return_desc));
if (ACPI_FAILURE (status)) {
goto cleanup;
}
status = acpi_ex_resolve_node_to_value (
- ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &return_desc), walk_state);
+ ACPI_CAST_INDIRECT_PTR (
+ struct acpi_namespace_node, &return_desc),
+ walk_state);
goto cleanup;
@@ -883,14 +897,16 @@ acpi_ex_opcode_1A_0T_1R (
/*
* This is a deref_of (object_reference)
* Get the actual object from the Node (This is the dereference).
- * -- This case may only happen when a local_x or arg_x is dereferenced above.
+ * This case may only happen when a local_x or arg_x is
+ * dereferenced above.
*/
- return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) operand[0]);
+ return_desc = acpi_ns_get_attached_object (
+ (struct acpi_namespace_node *) operand[0]);
}
else {
/*
- * This must be a reference object produced by either the Index() or
- * ref_of() operator
+ * This must be a reference object produced by either the
+ * Index() or ref_of() operator
*/
switch (operand[0]->reference.opcode) {
case AML_INDEX_OP:
@@ -931,8 +947,8 @@ acpi_ex_opcode_1A_0T_1R (
case ACPI_TYPE_PACKAGE:
/*
- * Return the referenced element of the package. We must add
- * another reference to the referenced object, however.
+ * Return the referenced element of the package. We must
+ * add another reference to the referenced object, however.
*/
return_desc = *(operand[0]->reference.where);
if (!return_desc) {
@@ -967,9 +983,11 @@ acpi_ex_opcode_1A_0T_1R (
return_desc = operand[0]->reference.object;
- if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) == ACPI_DESC_TYPE_NAMED) {
+ if (ACPI_GET_DESCRIPTOR_TYPE (return_desc) ==
+ ACPI_DESC_TYPE_NAMED) {
- return_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) return_desc);
+ return_desc = acpi_ns_get_attached_object (
+ (struct acpi_namespace_node *) return_desc);
}
/* Add another reference to the object! */
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8be4d80ceed..7429032c2b6 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -118,7 +118,7 @@ acpi_ex_opcode_2A_0T_0R (
value = (u32) operand[1]->integer.value;
- /* Notifies allowed on this object? */
+ /* Are notifies allowed on this object? */
if (!acpi_ev_is_notify_object (node)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
@@ -203,11 +203,12 @@ acpi_ex_opcode_2A_2T_1R (
acpi_ps_get_opcode_name (walk_state->opcode));
- /*
- * Execute the opcode
- */
+ /* Execute the opcode */
+
switch (walk_state->opcode) {
- case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, remainder_result quotient_result) */
+ case AML_DIVIDE_OP:
+
+ /* Divide (Dividend, Divisor, remainder_result quotient_result) */
return_desc1 = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
if (!return_desc1) {
@@ -241,7 +242,6 @@ acpi_ex_opcode_2A_2T_1R (
goto cleanup;
}
-
/* Store the results to the target reference operands */
status = acpi_ex_store (return_desc2, operand[2], walk_state);
@@ -295,7 +295,7 @@ acpi_ex_opcode_2A_1T_1R (
{
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
- u32 index;
+ acpi_integer index;
acpi_status status = AE_OK;
acpi_size length;
@@ -304,9 +304,8 @@ acpi_ex_opcode_2A_1T_1R (
acpi_ps_get_opcode_name (walk_state->opcode));
- /*
- * Execute the opcode
- */
+ /* Execute the opcode */
+
if (walk_state->op_info->flags & AML_MATH) {
/* All simple math opcodes (add, etc.) */
@@ -322,9 +321,8 @@ acpi_ex_opcode_2A_1T_1R (
goto store_result_to_target;
}
-
switch (walk_state->opcode) {
- case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
+ case AML_MOD_OP: /* Mod (Dividend, Divisor, remainder_result (ACPI 2.0) */
return_desc = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
if (!return_desc) {
@@ -341,18 +339,19 @@ acpi_ex_opcode_2A_1T_1R (
break;
- case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
+ case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */
status = acpi_ex_do_concatenate (operand[0], operand[1],
&return_desc, walk_state);
break;
- case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
+ case AML_TO_STRING_OP: /* to_string (Buffer, Length, Result) (ACPI 2.0) */
/*
* Input object is guaranteed to be a buffer at this point (it may have
- * been converted.) Copy the raw buffer data to a new object of type String.
+ * been converted.) Copy the raw buffer data to a new object of
+ * type String.
*/
/*
@@ -383,14 +382,16 @@ acpi_ex_opcode_2A_1T_1R (
goto cleanup;
}
- /* Copy the raw buffer data with no transform. NULL terminated already. */
+ /* Copy the raw buffer data with no transform. NULL terminated already*/
ACPI_MEMCPY (return_desc->string.pointer,
operand[0]->buffer.pointer, length);
break;
- case AML_CONCAT_RES_OP: /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
+ case AML_CONCAT_RES_OP:
+
+ /* concatenate_res_template (Buffer, Buffer, Result) (ACPI 2.0) */
status = acpi_ex_concat_template (operand[0], operand[1],
&return_desc, walk_state);
@@ -407,33 +408,33 @@ acpi_ex_opcode_2A_1T_1R (
goto cleanup;
}
- index = (u32) operand[1]->integer.value;
+ index = operand[1]->integer.value;
+
+ /* At this point, the Source operand is a Package, Buffer, or String */
- /*
- * At this point, the Source operand is a Package, Buffer, or String
- */
if (ACPI_GET_OBJECT_TYPE (operand[0]) == ACPI_TYPE_PACKAGE) {
/* Object to be indexed is a Package */
if (index >= operand[0]->package.count) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Index value (%X) beyond package end (%X)\n",
- index, operand[0]->package.count));
+ "Index value (%X%8.8X) beyond package end (%X)\n",
+ ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
status = AE_AML_PACKAGE_LIMIT;
goto cleanup;
}
return_desc->reference.target_type = ACPI_TYPE_PACKAGE;
return_desc->reference.object = operand[0];
- return_desc->reference.where = &operand[0]->package.elements [index];
+ return_desc->reference.where = &operand[0]->package.elements [
+ index];
}
else {
/* Object to be indexed is a Buffer/String */
if (index >= operand[0]->buffer.length) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Index value (%X) beyond end of buffer (%X)\n",
- index, operand[0]->buffer.length));
+ "Index value (%X%8.8X) beyond end of buffer (%X)\n",
+ ACPI_FORMAT_UINT64 (index), operand[0]->buffer.length));
status = AE_AML_BUFFER_LIMIT;
goto cleanup;
}
@@ -451,7 +452,7 @@ acpi_ex_opcode_2A_1T_1R (
/* Complete the Index reference object */
return_desc->reference.opcode = AML_INDEX_OP;
- return_desc->reference.offset = index;
+ return_desc->reference.offset = (u32) index;
/* Store the reference to the Target */
@@ -536,22 +537,24 @@ acpi_ex_opcode_2A_0T_1R (
goto cleanup;
}
- /*
- * Execute the Opcode
- */
- if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) /* logical_op (Operand0, Operand1) */ {
+ /* Execute the Opcode */
+
+ if (walk_state->op_info->flags & AML_LOGICAL_NUMERIC) {
+ /* logical_op (Operand0, Operand1) */
+
status = acpi_ex_do_logical_numeric_op (walk_state->opcode,
operand[0]->integer.value, operand[1]->integer.value,
&logical_result);
goto store_logical_result;
}
- else if (walk_state->op_info->flags & AML_LOGICAL) /* logical_op (Operand0, Operand1) */ {
+ else if (walk_state->op_info->flags & AML_LOGICAL) {
+ /* logical_op (Operand0, Operand1) */
+
status = acpi_ex_do_logical_op (walk_state->opcode, operand[0],
operand[1], &logical_result);
goto store_logical_result;
}
-
switch (walk_state->opcode) {
case AML_ACQUIRE_OP: /* Acquire (mutex_object, Timeout) */
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/executer/exoparg3.c
index 29d0b167745..23b068adbf5 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/executer/exoparg3.c
@@ -97,11 +97,12 @@ acpi_ex_opcode_3A_0T_0R (
acpi_status status = AE_OK;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_0T_0R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
switch (walk_state->opcode) {
- case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
+ case AML_FATAL_OP: /* Fatal (fatal_type fatal_code fatal_arg) */
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"fatal_op: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
@@ -116,9 +117,8 @@ acpi_ex_opcode_3A_0T_0R (
fatal->argument = (u32) operand[2]->integer.value;
}
- /*
- * Always signal the OS!
- */
+ /* Always signal the OS! */
+
status = acpi_os_signal (ACPI_SIGNAL_FATAL, fatal);
/* Might return while OS is shutting down, just continue */
@@ -162,21 +162,23 @@ acpi_ex_opcode_3A_1T_1R (
union acpi_operand_object *return_desc = NULL;
char *buffer;
acpi_status status = AE_OK;
- acpi_native_uint index;
+ acpi_integer index;
acpi_size length;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_3A_1T_1R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
switch (walk_state->opcode) {
- case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
+ case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */
/*
* Create the return object. The Source operand is guaranteed to be
* either a String or a Buffer, so just use its type.
*/
- return_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (operand[0]));
+ return_desc = acpi_ut_create_internal_object (
+ ACPI_GET_OBJECT_TYPE (operand[0]));
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
@@ -184,7 +186,7 @@ acpi_ex_opcode_3A_1T_1R (
/* Get the Integer values from the objects */
- index = (acpi_native_uint) operand[1]->integer.value;
+ index = operand[1]->integer.value;
length = (acpi_size) operand[2]->integer.value;
/*
@@ -197,7 +199,8 @@ acpi_ex_opcode_3A_1T_1R (
if ((index + length) >
operand[0]->string.length) {
- length = (acpi_size) operand[0]->string.length - index;
+ length = (acpi_size) operand[0]->string.length -
+ (acpi_size) index;
}
/* Allocate a new buffer for the String/Buffer */
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/executer/exoparg6.c
index d3262433162..17f81d42ee4 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/executer/exoparg6.c
@@ -75,6 +75,14 @@
* fully resolved operands.
!*/
+/* Local prototypes */
+
+static u8
+acpi_ex_do_match (
+ u32 match_op,
+ union acpi_operand_object *package_obj,
+ union acpi_operand_object *match_obj);
+
/*******************************************************************************
*
@@ -92,7 +100,7 @@
*
******************************************************************************/
-u8
+static u8
acpi_ex_do_match (
u32 match_op,
union acpi_operand_object *package_obj,
@@ -216,11 +224,12 @@ acpi_ex_opcode_6A_0T_1R (
union acpi_operand_object **operand = &walk_state->operands[0];
union acpi_operand_object *return_desc = NULL;
acpi_status status = AE_OK;
- u32 index;
+ acpi_integer index;
union acpi_operand_object *this_element;
- ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R", acpi_ps_get_opcode_name (walk_state->opcode));
+ ACPI_FUNCTION_TRACE_STR ("ex_opcode_6A_0T_1R",
+ acpi_ps_get_opcode_name (walk_state->opcode));
switch (walk_state->opcode) {
@@ -241,9 +250,11 @@ acpi_ex_opcode_6A_0T_1R (
/* Get the package start_index, validate against the package length */
- index = (u32) operand[5]->integer.value;
- if (index >= (u32) operand[0]->package.count) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n"));
+ index = operand[5]->integer.value;
+ if (index >= operand[0]->package.count) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Index (%X%8.8X) beyond package end (%X)\n",
+ ACPI_FORMAT_UINT64 (index), operand[0]->package.count));
status = AE_AML_PACKAGE_LIMIT;
goto cleanup;
}
@@ -314,13 +325,12 @@ acpi_ex_opcode_6A_0T_1R (
default:
- ACPI_REPORT_ERROR (("acpi_ex_opcode_3A_0T_0R: Unknown opcode %X\n",
+ ACPI_REPORT_ERROR (("acpi_ex_opcode_6A_0T_1R: Unknown opcode %X\n",
walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
-
walk_state->result_obj = return_desc;
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/executer/exprep.c
index 264ef3bba31..c9e3c68b554 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/executer/exprep.c
@@ -52,8 +52,23 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exprep")
+/* Local prototypes */
+
+static u32
+acpi_ex_decode_field_access (
+ union acpi_operand_object *obj_desc,
+ u8 field_flags,
+ u32 *return_byte_alignment);
+
#ifdef ACPI_UNDER_DEVELOPMENT
+
+static u32
+acpi_ex_generate_access (
+ u32 field_bit_offset,
+ u32 field_bit_length,
+ u32 region_length);
+
/*******************************************************************************
*
* FUNCTION: acpi_ex_generate_access
@@ -99,12 +114,14 @@ acpi_ex_generate_access (
/* Round Field start offset and length to "minimal" byte boundaries */
field_byte_offset = ACPI_DIV_8 (ACPI_ROUND_DOWN (field_bit_offset, 8));
- field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length + field_bit_offset, 8));
+ field_byte_end_offset = ACPI_DIV_8 (ACPI_ROUND_UP (field_bit_length +
+ field_bit_offset, 8));
field_byte_length = field_byte_end_offset - field_byte_offset;
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Bit length %d, Bit offset %d\n",
field_bit_length, field_bit_offset));
+
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Byte Length %d, Byte Offset %d, End Offset %d\n",
field_byte_length, field_byte_offset, field_byte_end_offset));
@@ -117,20 +134,26 @@ acpi_ex_generate_access (
*/
for (access_byte_width = 1; access_byte_width <= 8; access_byte_width <<= 1) {
/*
- * 1) Round end offset up to next access boundary and make sure that this
- * does not go beyond the end of the parent region.
- * 2) When the Access width is greater than the field_byte_length, we are done.
- * (This does not optimize for the perfectly aligned case yet).
+ * 1) Round end offset up to next access boundary and make sure that
+ * this does not go beyond the end of the parent region.
+ * 2) When the Access width is greater than the field_byte_length, we
+ * are done. (This does not optimize for the perfectly aligned
+ * case yet).
*/
if (ACPI_ROUND_UP (field_byte_end_offset, access_byte_width) <= region_length) {
- field_start_offset = ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) /
- access_byte_width;
- field_end_offset = ACPI_ROUND_UP ((field_byte_length + field_byte_offset),
- access_byte_width) / access_byte_width;
- accesses = field_end_offset - field_start_offset;
+ field_start_offset =
+ ACPI_ROUND_DOWN (field_byte_offset, access_byte_width) /
+ access_byte_width;
+
+ field_end_offset =
+ ACPI_ROUND_UP ((field_byte_length + field_byte_offset),
+ access_byte_width) / access_byte_width;
+
+ accesses = field_end_offset - field_start_offset;
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"access_width %d end is within region\n", access_byte_width));
+
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Field Start %d, Field End %d -- requires %d accesses\n",
field_start_offset, field_end_offset, accesses));
@@ -139,8 +162,8 @@ acpi_ex_generate_access (
if (accesses <= 1) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "Entire field can be accessed with one operation of size %d\n",
- access_byte_width));
+ "Entire field can be accessed with one operation of size %d\n",
+ access_byte_width));
return_VALUE (access_byte_width);
}
@@ -155,15 +178,20 @@ acpi_ex_generate_access (
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
- "access_width %d end is NOT within region\n", access_byte_width));
+ "access_width %d end is NOT within region\n", access_byte_width));
if (access_byte_width == 1) {
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Field goes beyond end-of-region!\n"));
- return_VALUE (0); /* Field does not fit in the region at all */
- }
- /* This width goes beyond the end-of-region, back off to previous access */
+ /* Field does not fit in the region at all */
+ return_VALUE (0);
+ }
+
+ /*
+ * This width goes beyond the end-of-region, back off to
+ * previous access
+ */
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Backing off to previous optimal access width of %d\n",
minimum_access_width));
@@ -171,8 +199,10 @@ acpi_ex_generate_access (
}
}
- /* Could not read/write field with one operation, just use max access width */
-
+ /*
+ * Could not read/write field with one operation,
+ * just use max access width
+ */
ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
"Cannot access field in one operation, using width 8\n"));
return_VALUE (8);
@@ -184,8 +214,9 @@ acpi_ex_generate_access (
*
* FUNCTION: acpi_ex_decode_field_access
*
- * PARAMETERS: Access - Encoded field access bits
- * Length - Field length.
+ * PARAMETERS: obj_desc - Field object
+ * field_flags - Encoded fieldflags (contains access bits)
+ * return_byte_alignment - Where the byte alignment is returned
*
* RETURN: Field granularity (8, 16, 32 or 64) and
* byte_alignment (1, 2, 3, or 4)
@@ -214,9 +245,10 @@ acpi_ex_decode_field_access (
case AML_FIELD_ACCESS_ANY:
#ifdef ACPI_UNDER_DEVELOPMENT
- byte_alignment = acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset,
- obj_desc->common_field.bit_length,
- 0xFFFFFFFF /* Temp until we pass region_length as param */);
+ byte_alignment =
+ acpi_ex_generate_access (obj_desc->common_field.start_field_bit_offset,
+ obj_desc->common_field.bit_length,
+ 0xFFFFFFFF /* Temp until we pass region_length as parameter */);
bit_length = byte_alignment * 8;
#endif
@@ -276,6 +308,7 @@ acpi_ex_decode_field_access (
* field_flags - Access, lock_rule, and update_rule.
* The format of a field_flag is described
* in the ACPI specification
+ * field_attribute - Special attributes (not used)
* field_bit_position - Field start position
* field_bit_length - Field length in number of bits
*
@@ -337,7 +370,7 @@ acpi_ex_prep_common_field_object (
/* Setup width (access granularity) fields */
obj_desc->common_field.access_byte_width = (u8)
- ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */
+ ACPI_DIV_8 (access_bit_width); /* 1, 2, 4, 8 */
obj_desc->common_field.access_bit_width = (u8) access_bit_width;
@@ -380,11 +413,7 @@ acpi_ex_prep_common_field_object (
*
* FUNCTION: acpi_ex_prep_field_value
*
- * PARAMETERS: Node - Owning Node
- * region_node - Region in which field is being defined
- * field_flags - Access, lock_rule, and update_rule.
- * field_bit_position - Field start position
- * field_bit_length - Field length in number of bits
+ * PARAMETERS: Info - Contains all field creation info
*
* RETURN: Status
*
@@ -445,7 +474,7 @@ acpi_ex_prep_field_value (
switch (info->field_type) {
case ACPI_TYPE_LOCAL_REGION_FIELD:
- obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node);
+ obj_desc->field.region_obj = acpi_ns_get_attached_object (info->region_node);
/* An additional reference for the container */
@@ -461,8 +490,10 @@ acpi_ex_prep_field_value (
case ACPI_TYPE_LOCAL_BANK_FIELD:
obj_desc->bank_field.value = info->bank_value;
- obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (info->region_node);
- obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (info->register_node);
+ obj_desc->bank_field.region_obj = acpi_ns_get_attached_object (
+ info->region_node);
+ obj_desc->bank_field.bank_obj = acpi_ns_get_attached_object (
+ info->register_node);
/* An additional reference for the attached objects */
@@ -481,10 +512,13 @@ acpi_ex_prep_field_value (
case ACPI_TYPE_LOCAL_INDEX_FIELD:
- obj_desc->index_field.index_obj = acpi_ns_get_attached_object (info->register_node);
- obj_desc->index_field.data_obj = acpi_ns_get_attached_object (info->data_register_node);
+ obj_desc->index_field.index_obj = acpi_ns_get_attached_object (
+ info->register_node);
+ obj_desc->index_field.data_obj = acpi_ns_get_attached_object (
+ info->data_register_node);
obj_desc->index_field.value = (u32)
- (info->field_bit_position / ACPI_MUL_8 (obj_desc->field.access_byte_width));
+ (info->field_bit_position / ACPI_MUL_8 (
+ obj_desc->field.access_byte_width));
if (!obj_desc->index_field.data_obj || !obj_desc->index_field.index_obj) {
ACPI_REPORT_ERROR (("Null Index Object during field prep\n"));
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 7cfd0684c70..723aaef4bb4 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -115,7 +115,6 @@ acpi_ex_system_memory_space_handler (
return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
}
-
#ifndef ACPI_MISALIGNED_TRANSFERS
/*
* Hardware does not support non-aligned data transfers, we must verify
@@ -134,7 +133,8 @@ acpi_ex_system_memory_space_handler (
*/
if ((address < mem_info->mapped_physical_address) ||
(((acpi_integer) address + length) >
- ((acpi_integer) mem_info->mapped_physical_address + mem_info->mapped_length))) {
+ ((acpi_integer)
+ mem_info->mapped_physical_address + mem_info->mapped_length))) {
/*
* The request cannot be resolved by the current memory mapping;
* Delete the existing mapping and create a new one.
@@ -150,7 +150,9 @@ acpi_ex_system_memory_space_handler (
* Don't attempt to map memory beyond the end of the region, and
* constrain the maximum mapping size to something reasonable.
*/
- window_size = (acpi_size) ((mem_info->address + mem_info->length) - address);
+ window_size = (acpi_size)
+ ((mem_info->address + mem_info->length) - address);
+
if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
}
@@ -160,8 +162,9 @@ acpi_ex_system_memory_space_handler (
status = acpi_os_map_memory (address, window_size,
(void **) &mem_info->mapped_logical_address);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n",
- ACPI_FORMAT_UINT64 (address), (u32) window_size));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not map memory at %8.8X%8.8X, size %X\n",
+ ACPI_FORMAT_UINT64 (address), (u32) window_size));
mem_info->mapped_length = 0;
return_ACPI_STATUS (status);
}
@@ -177,10 +180,12 @@ acpi_ex_system_memory_space_handler (
* access
*/
logical_addr_ptr = mem_info->mapped_logical_address +
- ((acpi_integer) address - (acpi_integer) mem_info->mapped_physical_address);
+ ((acpi_integer) address -
+ (acpi_integer) mem_info->mapped_physical_address);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "system_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
+ "system_memory %d (%d width) Address=%8.8X%8.8X\n",
+ function, bit_width,
ACPI_FORMAT_UINT64 (address)));
/*
@@ -298,13 +303,15 @@ acpi_ex_system_io_space_handler (
switch (function) {
case ACPI_READ:
- status = acpi_os_read_port ((acpi_io_address) address, &value32, bit_width);
+ status = acpi_os_read_port ((acpi_io_address) address,
+ &value32, bit_width);
*value = value32;
break;
case ACPI_WRITE:
- status = acpi_os_write_port ((acpi_io_address) address, (u32) *value, bit_width);
+ status = acpi_os_write_port ((acpi_io_address) address,
+ (u32) *value, bit_width);
break;
default:
@@ -375,12 +382,14 @@ acpi_ex_pci_config_space_handler (
case ACPI_READ:
*value = 0;
- status = acpi_os_read_pci_configuration (pci_id, pci_register, value, bit_width);
+ status = acpi_os_read_pci_configuration (pci_id, pci_register,
+ value, bit_width);
break;
case ACPI_WRITE:
- status = acpi_os_write_pci_configuration (pci_id, pci_register, *value, bit_width);
+ status = acpi_os_write_pci_configuration (pci_id, pci_register,
+ *value, bit_width);
break;
default:
@@ -505,8 +514,7 @@ acpi_ex_data_table_space_handler (
logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
-
- /* Perform the memory read or write */
+ /* Perform the memory read or write */
switch (function) {
case ACPI_READ:
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index 7936329a0e3..21d5c74fa30 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -210,15 +210,15 @@ acpi_ex_resolve_node_to_value (
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "field_read Node=%p source_desc=%p Type=%X\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "field_read Node=%p source_desc=%p Type=%X\n",
node, source_desc, entry_type));
status = acpi_ex_read_data_from_field (walk_state, source_desc, &obj_desc);
break;
- /*
- * For these objects, just return the object attached to the Node
- */
+ /* For these objects, just return the object attached to the Node */
+
case ACPI_TYPE_MUTEX:
case ACPI_TYPE_METHOD:
case ACPI_TYPE_POWER:
@@ -233,12 +233,12 @@ acpi_ex_resolve_node_to_value (
acpi_ut_add_reference (obj_desc);
break;
-
/* TYPE_ANY is untyped, and thus there is no object associated with it */
case ACPI_TYPE_ANY:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Untyped entry %p, no attached object!\n",
node));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */
@@ -259,7 +259,8 @@ acpi_ex_resolve_node_to_value (
default:
/* No named references are allowed here */
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X (%s)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Unsupported Reference opcode %X (%s)\n",
source_desc->reference.opcode,
acpi_ps_get_opcode_name (source_desc->reference.opcode)));
@@ -268,11 +269,12 @@ acpi_ex_resolve_node_to_value (
break;
- /* Default case is for unknown types */
-
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n",
+ /* Default case is for unknown types */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Node %p - Unknown object type %X\n",
node, entry_type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
@@ -280,7 +282,7 @@ acpi_ex_resolve_node_to_value (
} /* switch (entry_type) */
- /* Put the object descriptor on the stack */
+ /* Return the object descriptor */
*object_ptr = (void *) obj_desc;
return_ACPI_STATUS (status);
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index 7be60491115..3de45672379 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -54,6 +54,13 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresolv")
+/* Local prototypes */
+
+static acpi_status
+acpi_ex_resolve_object_to_value (
+ union acpi_operand_object **stack_ptr,
+ struct acpi_walk_state *walk_state);
+
/*******************************************************************************
*
@@ -96,6 +103,11 @@ acpi_ex_resolve_to_value (
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
+
+ if (!*stack_ptr) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n"));
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
}
/*
@@ -120,18 +132,17 @@ acpi_ex_resolve_to_value (
*
* FUNCTION: acpi_ex_resolve_object_to_value
*
- * PARAMETERS: stack_ptr - Pointer to a stack location that contains a
- * ptr to an internal object.
+ * PARAMETERS: stack_ptr - Pointer to an internal object
* walk_state - Current method state
*
* RETURN: Status
*
- * DESCRIPTION: Retrieve the value from an internal object. The Reference type
+ * DESCRIPTION: Retrieve the value from an internal object. The Reference type
* uses the associated AML opcode to determine the value.
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_resolve_object_to_value (
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state)
@@ -159,7 +170,7 @@ acpi_ex_resolve_object_to_value (
case AML_NAME_OP:
/*
- * Convert indirect name ptr to a direct name ptr.
+ * Convert name reference to a namespace node
* Then, acpi_ex_resolve_node_to_value can be used to get the value
*/
temp_node = stack_desc->reference.object;
@@ -168,7 +179,7 @@ acpi_ex_resolve_object_to_value (
acpi_ut_remove_reference (stack_desc);
- /* Put direct name pointer onto stack and exit */
+ /* Return the namespace node */
(*stack_ptr) = temp_node;
break;
@@ -255,10 +266,19 @@ acpi_ex_resolve_object_to_value (
break;
+ case AML_INT_NAMEPATH_OP: /* Reference to a named object */
+
+ /* Get the object pointed to by the namespace node */
+
+ *stack_ptr = (stack_desc->reference.node)->object;
+ acpi_ut_add_reference (*stack_ptr);
+ acpi_ut_remove_reference (stack_desc);
+ break;
default:
- ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n",
+ ACPI_REPORT_ERROR ((
+ "During resolve, Unknown Reference opcode %X (%s) in %p\n",
opcode, acpi_ps_get_opcode_name (opcode), stack_desc));
status = AE_AML_INTERNAL;
break;
@@ -278,9 +298,8 @@ acpi_ex_resolve_object_to_value (
break;
- /*
- * These cases may never happen here, but just in case..
- */
+ /* These cases may never happen here, but just in case.. */
+
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
@@ -333,9 +352,8 @@ acpi_ex_resolve_multiple (
ACPI_FUNCTION_TRACE ("acpi_ex_resolve_multiple");
- /*
- * Operand can be either a namespace node or an operand descriptor
- */
+ /* Operand can be either a namespace node or an operand descriptor */
+
switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
case ACPI_DESC_TYPE_OPERAND:
type = obj_desc->common.type;
@@ -357,10 +375,8 @@ acpi_ex_resolve_multiple (
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
+ /* If type is anything other than a reference, we are done */
- /*
- * If type is anything other than a reference, we are done
- */
if (type != ACPI_TYPE_LOCAL_REFERENCE) {
goto exit;
}
@@ -382,8 +398,9 @@ acpi_ex_resolve_multiple (
/* All "References" point to a NS node */
if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
- ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
- node, acpi_ut_get_descriptor_name (node)));
+ ACPI_REPORT_ERROR ((
+ "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
+ node, acpi_ut_get_descriptor_name (node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
@@ -440,8 +457,9 @@ acpi_ex_resolve_multiple (
/* All "References" point to a NS node */
if (ACPI_GET_DESCRIPTOR_TYPE (node) != ACPI_DESC_TYPE_NAMED) {
- ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
- node, acpi_ut_get_descriptor_name (node)));
+ ACPI_REPORT_ERROR ((
+ "acpi_ex_resolve_multiple: Not a NS node %p [%s]\n",
+ node, acpi_ut_get_descriptor_name (node)));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
@@ -468,7 +486,7 @@ acpi_ex_resolve_multiple (
if (return_desc) {
status = acpi_ds_method_data_get_value (obj_desc->reference.opcode,
- obj_desc->reference.offset, walk_state, &obj_desc);
+ obj_desc->reference.offset, walk_state, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -500,7 +518,8 @@ acpi_ex_resolve_multiple (
default:
- ACPI_REPORT_ERROR (("acpi_ex_resolve_multiple: Unknown Reference subtype %X\n",
+ ACPI_REPORT_ERROR ((
+ "acpi_ex_resolve_multiple: Unknown Reference subtype %X\n",
obj_desc->reference.opcode));
return_ACPI_STATUS (AE_AML_INTERNAL);
}
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index c92890220c3..d8b470eefe7 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -52,6 +52,14 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exresop")
+/* Local prototypes */
+
+static acpi_status
+acpi_ex_check_object_type (
+ acpi_object_type type_needed,
+ acpi_object_type this_type,
+ void *object);
+
/*******************************************************************************
*
@@ -67,7 +75,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_check_object_type (
acpi_object_type type_needed,
acpi_object_type this_type,
@@ -142,6 +150,7 @@ acpi_ex_resolve_operands (
const struct acpi_opcode_info *op_info;
u32 this_arg_type;
acpi_object_type type_needed;
+ u16 target_op = 0;
ACPI_FUNCTION_TRACE_U32 ("ex_resolve_operands", opcode);
@@ -160,7 +169,8 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (AE_AML_INTERNAL);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] required_operand_types=%8.8X \n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Opcode %X [%s] required_operand_types=%8.8X \n",
opcode, op_info->name, arg_types));
/*
@@ -187,7 +197,7 @@ acpi_ex_resolve_operands (
switch (ACPI_GET_DESCRIPTOR_TYPE (obj_desc)) {
case ACPI_DESC_TYPE_NAMED:
- /* Node */
+ /* Namespace Node */
object_type = ((struct acpi_namespace_node *) obj_desc)->type;
break;
@@ -202,16 +212,16 @@ acpi_ex_resolve_operands (
/* Check for bad acpi_object_type */
if (!acpi_ut_valid_object_type (object_type)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Bad operand object type [%X]\n",
object_type));
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
- /*
- * Decode the Reference
- */
+ /* Decode the Reference */
+
op_info = acpi_ps_get_opcode_info (opcode);
if (op_info->class == AML_CLASS_UNKNOWN) {
return_ACPI_STATUS (AE_AML_BAD_OPCODE);
@@ -219,12 +229,17 @@ acpi_ex_resolve_operands (
switch (obj_desc->reference.opcode) {
case AML_DEBUG_OP:
+ target_op = AML_DEBUG_OP;
+
+ /*lint -fallthrough */
+
case AML_NAME_OP:
case AML_INDEX_OP:
case AML_REF_OF_OP:
case AML_ARG_OP:
case AML_LOCAL_OP:
- case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
+ case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
+ case AML_INT_NAMEPATH_OP: /* Reference to a named object */
ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
"Operand is a Reference, ref_opcode [%s]\n",
@@ -254,10 +269,8 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
}
+ /* Get one argument type, point to the next */
- /*
- * Get one argument type, point to the next
- */
this_arg_type = GET_CURRENT_ARG_TYPE (arg_types);
INCREMENT_ARG_LIST (arg_types);
@@ -271,26 +284,31 @@ acpi_ex_resolve_operands (
if ((ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) &&
(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_STRING)) {
/*
- * String found - the string references a named object and must be
- * resolved to a node
+ * String found - the string references a named object and
+ * must be resolved to a node
*/
goto next_operand;
}
- /* Else not a string - fall through to the normal Reference case below */
+ /*
+ * Else not a string - fall through to the normal Reference
+ * case below
+ */
/*lint -fallthrough */
case ARGI_REFERENCE: /* References: */
case ARGI_INTEGER_REF:
case ARGI_OBJECT_REF:
case ARGI_DEVICE_REF:
- case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
- case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
- case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
-
- /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */
+ case ARGI_TARGETREF: /* Allows implicit conversion rules before store */
+ case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */
+ case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */
- if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ {
+ /*
+ * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE
+ * A Namespace Node is OK as-is
+ */
+ if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_NAMED) {
goto next_operand;
}
@@ -300,11 +318,9 @@ acpi_ex_resolve_operands (
return_ACPI_STATUS (status);
}
- if (AML_NAME_OP == obj_desc->reference.opcode) {
- /*
- * Convert an indirect name ptr to direct name ptr and put
- * it on the stack
- */
+ if (obj_desc->reference.opcode == AML_NAME_OP) {
+ /* Convert a named reference to the actual named object */
+
temp_node = obj_desc->reference.object;
acpi_ut_remove_reference (obj_desc);
(*stack_ptr) = temp_node;
@@ -332,7 +348,6 @@ acpi_ex_resolve_operands (
break;
}
-
/*
* Resolve this object to a value
*/
@@ -392,7 +407,7 @@ acpi_ex_resolve_operands (
/*
* The more complex cases allow multiple resolved object types
*/
- case ARGI_INTEGER: /* Number */
+ case ARGI_INTEGER:
/*
* Need an operand of type ACPI_TYPE_INTEGER,
@@ -563,7 +578,7 @@ acpi_ex_resolve_operands (
case ARGI_REGION_OR_FIELD:
- /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */
+ /* Need an operand of type REGION or a FIELD in a region */
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_REGION:
@@ -614,6 +629,12 @@ acpi_ex_resolve_operands (
break;
}
+ if (target_op == AML_DEBUG_OP) {
+ /* Allow store of any object to the Debug object */
+
+ break;
+ }
+
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n",
acpi_ut_get_object_type_name (obj_desc), obj_desc));
@@ -652,8 +673,7 @@ next_operand:
if (GET_CURRENT_ARG_TYPE (arg_types)) {
stack_ptr--;
}
-
- } /* while (*Types) */
+ }
return_ACPI_STATUS (status);
}
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index e0fc6aba125..2725db0901b 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -48,11 +48,171 @@
#include <acpi/acinterp.h>
#include <acpi/amlcode.h>
#include <acpi/acnamesp.h>
+#include <acpi/acparser.h>
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exstore")
+/* Local prototypes */
+
+static void
+acpi_ex_do_debug_object (
+ union acpi_operand_object *source_desc,
+ u32 level,
+ u32 index);
+
+static acpi_status
+acpi_ex_store_object_to_index (
+ union acpi_operand_object *val_desc,
+ union acpi_operand_object *dest_desc,
+ struct acpi_walk_state *walk_state);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ex_do_debug_object
+ *
+ * PARAMETERS: source_desc - Value to be stored
+ * Level - Indentation level (used for packages)
+ * Index - Current package element, zero if not pkg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Handles stores to the Debug Object.
+ *
+ ******************************************************************************/
+
+static void
+acpi_ex_do_debug_object (
+ union acpi_operand_object *source_desc,
+ u32 level,
+ u32 index)
+{
+ u32 i;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("ex_do_debug_object", source_desc);
+
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
+ level, " "));
+
+ /* Display index for package output only */
+
+ if (index > 0) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
+ "(%.2u) ", index -1));
+ }
+
+ if (!source_desc) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n"));
+ return_VOID;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_OPERAND) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ",
+ acpi_ut_get_object_type_name (source_desc)));
+
+ if (!acpi_ut_valid_internal_object (source_desc)) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
+ "%p, Invalid Internal Object!\n", source_desc));
+ return_VOID;
+ }
+ }
+ else if (ACPI_GET_DESCRIPTOR_TYPE (source_desc) == ACPI_DESC_TYPE_NAMED) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
+ acpi_ut_get_type_name (((struct acpi_namespace_node *) source_desc)->type),
+ source_desc));
+ return_VOID;
+ }
+ else {
+ return_VOID;
+ }
+
+ switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
+ case ACPI_TYPE_INTEGER:
+
+ /* Output correct integer width */
+
+ if (acpi_gbl_integer_byte_width == 4) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
+ (u32) source_desc->integer.value));
+ }
+ else {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
+ ACPI_FORMAT_UINT64 (source_desc->integer.value)));
+ }
+ break;
+
+ case ACPI_TYPE_BUFFER:
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
+ (u32) source_desc->buffer.length));
+ ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
+ (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
+ source_desc->string.length, source_desc->string.pointer));
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X Elements]\n",
+ source_desc->package.count));
+
+ /* Output the entire contents of the package */
+
+ for (i = 0; i < source_desc->package.count; i++) {
+ acpi_ex_do_debug_object (source_desc->package.elements[i],
+ level+4, i+1);
+ }
+ break;
+
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ if (source_desc->reference.opcode == AML_INDEX_OP) {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n",
+ acpi_ps_get_opcode_name (source_desc->reference.opcode),
+ source_desc->reference.offset));
+ }
+ else {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n",
+ acpi_ps_get_opcode_name (source_desc->reference.opcode)));
+ }
+
+
+ if (source_desc->reference.object) {
+ if (ACPI_GET_DESCRIPTOR_TYPE (source_desc->reference.object) ==
+ ACPI_DESC_TYPE_NAMED) {
+ acpi_ex_do_debug_object (((struct acpi_namespace_node *)
+ source_desc->reference.object)->object,
+ level+4, 0);
+ }
+ else {
+ acpi_ex_do_debug_object (source_desc->reference.object, level+4, 0);
+ }
+ }
+ else if (source_desc->reference.node) {
+ acpi_ex_do_debug_object ((source_desc->reference.node)->object,
+ level+4, 0);
+ }
+ break;
+
+ default:
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n",
+ source_desc, acpi_ut_get_object_type_name (source_desc)));
+ break;
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
+ return_VOID;
+}
+
/*******************************************************************************
*
@@ -154,8 +314,9 @@ acpi_ex_store (
/* Storing an object into a Name "container" */
- status = acpi_ex_store_object_to_node (source_desc, ref_desc->reference.object,
- walk_state, ACPI_IMPLICIT_CONVERSION);
+ status = acpi_ex_store_object_to_node (source_desc,
+ ref_desc->reference.object,
+ walk_state, ACPI_IMPLICIT_CONVERSION);
break;
@@ -173,7 +334,7 @@ acpi_ex_store (
/* Store to a method local/arg */
status = acpi_ds_store_object_to_local (ref_desc->reference.opcode,
- ref_desc->reference.offset, source_desc, walk_state);
+ ref_desc->reference.offset, source_desc, walk_state);
break;
@@ -187,60 +348,7 @@ acpi_ex_store (
"**** Write to Debug Object: Object %p %s ****:\n\n",
source_desc, acpi_ut_get_object_type_name (source_desc)));
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ",
- acpi_ut_get_object_type_name (source_desc)));
-
- if (!acpi_ut_valid_internal_object (source_desc)) {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT,
- "%p, Invalid Internal Object!\n", source_desc));
- break;
- }
-
- switch (ACPI_GET_OBJECT_TYPE (source_desc)) {
- case ACPI_TYPE_INTEGER:
-
- if (acpi_gbl_integer_byte_width == 4) {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
- (u32) source_desc->integer.value));
- }
- else {
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (source_desc->integer.value)));
- }
- break;
-
-
- case ACPI_TYPE_BUFFER:
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]",
- (u32) source_desc->buffer.length));
- ACPI_DUMP_BUFFER (source_desc->buffer.pointer,
- (source_desc->buffer.length < 32) ? source_desc->buffer.length : 32);
- break;
-
-
- case ACPI_TYPE_STRING:
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
- source_desc->string.length, source_desc->string.pointer));
- break;
-
-
- case ACPI_TYPE_PACKAGE:
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] Elements Ptr - %p\n",
- source_desc->package.count, source_desc->package.elements));
- break;
-
-
- default:
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n",
- source_desc));
- break;
- }
-
- ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
+ acpi_ex_do_debug_object (source_desc, 0, 0);
break;
@@ -272,7 +380,7 @@ acpi_ex_store (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ex_store_object_to_index (
union acpi_operand_object *source_desc,
union acpi_operand_object *index_desc,
@@ -313,16 +421,22 @@ acpi_ex_store_object_to_index (
if (obj_desc) {
/* Decrement reference count by the ref count of the parent package */
- for (i = 0; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) {
+ for (i = 0;
+ i < ((union acpi_operand_object *)
+ index_desc->reference.object)->common.reference_count;
+ i++) {
acpi_ut_remove_reference (obj_desc);
}
}
*(index_desc->reference.where) = new_desc;
- /* Increment reference count by the ref count of the parent package -1 */
+ /* Increment ref count by the ref count of the parent package-1 */
- for (i = 1; i < ((union acpi_operand_object *) index_desc->reference.object)->common.reference_count; i++) {
+ for (i = 1;
+ i < ((union acpi_operand_object *)
+ index_desc->reference.object)->common.reference_count;
+ i++) {
acpi_ut_add_reference (new_desc);
}
@@ -440,9 +554,8 @@ acpi_ex_store_object_to_node (
ACPI_FUNCTION_TRACE_PTR ("ex_store_object_to_node", source_desc);
- /*
- * Get current type of the node, and object attached to Node
- */
+ /* Get current type of the node, and object attached to Node */
+
target_type = acpi_ns_get_type (node);
target_desc = acpi_ns_get_attached_object (node);
@@ -467,19 +580,18 @@ acpi_ex_store_object_to_node (
target_type = ACPI_TYPE_ANY;
}
- /*
- * Do the actual store operation
- */
+ /* Do the actual store operation */
+
switch (target_type) {
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
- /*
- * For fields, copy the source data to the target field.
- */
- status = acpi_ex_write_data_to_field (source_desc, target_desc, &walk_state->result_obj);
+ /* For fields, copy the source data to the target field. */
+
+ status = acpi_ex_write_data_to_field (source_desc, target_desc,
+ &walk_state->result_obj);
break;
@@ -493,7 +605,8 @@ acpi_ex_store_object_to_node (
*
* Copy and/or convert the source object to a new target object
*/
- status = acpi_ex_store_object_to_object (source_desc, target_desc, &new_desc, walk_state);
+ status = acpi_ex_store_object_to_object (source_desc, target_desc,
+ &new_desc, walk_state);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -526,7 +639,8 @@ acpi_ex_store_object_to_node (
/* No conversions for all other types. Just attach the source object */
- status = acpi_ns_attach_object (node, source_desc, ACPI_GET_OBJECT_TYPE (source_desc));
+ status = acpi_ns_attach_object (node, source_desc,
+ ACPI_GET_OBJECT_TYPE (source_desc));
break;
}
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index d3677feb07f..120f30ed0bd 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -81,9 +81,8 @@ acpi_ex_resolve_object (
ACPI_FUNCTION_TRACE ("ex_resolve_object");
- /*
- * Ensure we have a Target that can be stored to
- */
+ /* Ensure we have a Target that can be stored to */
+
switch (target_type) {
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
@@ -118,16 +117,14 @@ acpi_ex_resolve_object (
break;
}
- /*
- * Must have a Integer, Buffer, or String
- */
+ /* Must have a Integer, Buffer, or String */
+
if ((ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_INTEGER) &&
(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_BUFFER) &&
(ACPI_GET_OBJECT_TYPE (source_desc) != ACPI_TYPE_STRING) &&
!((ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_LOCAL_REFERENCE) && (source_desc->reference.opcode == AML_LOAD_OP))) {
- /*
- * Conversion successful but still not a valid type
- */
+ /* Conversion successful but still not a valid type */
+
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Cannot assign type %s to %s (must be type Int/Str/Buf)\n",
acpi_ut_get_object_type_name (source_desc),
@@ -140,9 +137,8 @@ acpi_ex_resolve_object (
case ACPI_TYPE_LOCAL_ALIAS:
case ACPI_TYPE_LOCAL_METHOD_ALIAS:
- /*
- * Aliases are resolved by acpi_ex_prep_operands
- */
+ /* Aliases are resolved by acpi_ex_prep_operands */
+
ACPI_REPORT_ERROR (("Store into Alias - should never happen\n"));
status = AE_AML_INTERNAL;
break;
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index 05e1ecae8d9..12d1527669c 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -128,7 +128,8 @@ acpi_ex_store_buffer_to_buffer (
else {
/* Truncate the source, copy only what will fit */
- ACPI_MEMCPY (target_desc->buffer.pointer, buffer, target_desc->buffer.length);
+ ACPI_MEMCPY (target_desc->buffer.pointer, buffer,
+ target_desc->buffer.length);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Truncating source buffer from %X to %X\n",
@@ -183,7 +184,8 @@ acpi_ex_store_string_to_string (
* String will fit in existing non-static buffer.
* Clear old string and copy in the new one
*/
- ACPI_MEMSET (target_desc->string.pointer, 0, (acpi_size) target_desc->string.length + 1);
+ ACPI_MEMSET (target_desc->string.pointer, 0,
+ (acpi_size) target_desc->string.length + 1);
ACPI_MEMCPY (target_desc->string.pointer, buffer, length);
}
else {
@@ -198,7 +200,8 @@ acpi_ex_store_string_to_string (
ACPI_MEM_FREE (target_desc->string.pointer);
}
- target_desc->string.pointer = ACPI_MEM_CALLOCATE ((acpi_size) length + 1);
+ target_desc->string.pointer = ACPI_MEM_CALLOCATE (
+ (acpi_size) length + 1);
if (!target_desc->string.pointer) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index f92efc51289..cafa702108d 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -55,8 +55,8 @@
*
* FUNCTION: acpi_ex_system_wait_semaphore
*
- * PARAMETERS: Semaphore - OSD semaphore to wait on
- * Timeout - Max time to wait
+ * PARAMETERS: Semaphore - Semaphore to wait on
+ * Timeout - Max time to wait
*
* RETURN: Status
*
@@ -90,7 +90,8 @@ acpi_ex_system_wait_semaphore (
status = acpi_os_wait_semaphore (semaphore, 1, timeout);
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "*** Thread awake after blocking, %s\n",
acpi_format_exception (status)));
/* Reacquire the interpreter */
@@ -111,8 +112,8 @@ acpi_ex_system_wait_semaphore (
*
* FUNCTION: acpi_ex_system_do_stall
*
- * PARAMETERS: how_long - The amount of time to stall,
- * in microseconds
+ * PARAMETERS: how_long - The amount of time to stall,
+ * in microseconds
*
* RETURN: Status
*
@@ -141,7 +142,8 @@ acpi_ex_system_do_stall (
* (ACPI specifies 100 usec as max, but this gives some slack in
* order to support existing BIOSs)
*/
- ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", how_long));
+ ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n",
+ how_long));
status = AE_AML_OPERAND_VALUE;
}
else {
@@ -156,8 +158,8 @@ acpi_ex_system_do_stall (
*
* FUNCTION: acpi_ex_system_do_suspend
*
- * PARAMETERS: how_long - The amount of time to suspend,
- * in milliseconds
+ * PARAMETERS: how_long - The amount of time to suspend,
+ * in milliseconds
*
* RETURN: None
*
@@ -192,8 +194,8 @@ acpi_ex_system_do_suspend (
*
* FUNCTION: acpi_ex_system_acquire_mutex
*
- * PARAMETERS: *time_desc - The 'time to delay' object descriptor
- * *obj_desc - The object descriptor for this op
+ * PARAMETERS: time_desc - The 'time to delay' object descriptor
+ * obj_desc - The object descriptor for this op
*
* RETURN: Status
*
@@ -218,16 +220,15 @@ acpi_ex_system_acquire_mutex (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- /*
- * Support for the _GL_ Mutex object -- go get the global lock
- */
+ /* Support for the _GL_ Mutex object -- go get the global lock */
+
if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
status = acpi_ev_acquire_global_lock ((u16) time_desc->integer.value);
return_ACPI_STATUS (status);
}
status = acpi_ex_system_wait_semaphore (obj_desc->mutex.semaphore,
- (u16) time_desc->integer.value);
+ (u16) time_desc->integer.value);
return_ACPI_STATUS (status);
}
@@ -236,7 +237,7 @@ acpi_ex_system_acquire_mutex (
*
* FUNCTION: acpi_ex_system_release_mutex
*
- * PARAMETERS: *obj_desc - The object descriptor for this op
+ * PARAMETERS: obj_desc - The object descriptor for this op
*
* RETURN: Status
*
@@ -261,9 +262,8 @@ acpi_ex_system_release_mutex (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- /*
- * Support for the _GL_ Mutex object -- release the global lock
- */
+ /* Support for the _GL_ Mutex object -- release the global lock */
+
if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) {
status = acpi_ev_release_global_lock ();
return_ACPI_STATUS (status);
@@ -278,9 +278,9 @@ acpi_ex_system_release_mutex (
*
* FUNCTION: acpi_ex_system_signal_event
*
- * PARAMETERS: *obj_desc - The object descriptor for this op
+ * PARAMETERS: obj_desc - The object descriptor for this op
*
- * RETURN: AE_OK
+ * RETURN: Status
*
* DESCRIPTION: Provides an access point to perform synchronization operations
* within the AML.
@@ -309,8 +309,8 @@ acpi_ex_system_signal_event (
*
* FUNCTION: acpi_ex_system_wait_event
*
- * PARAMETERS: *time_desc - The 'time to delay' object descriptor
- * *obj_desc - The object descriptor for this op
+ * PARAMETERS: time_desc - The 'time to delay' object descriptor
+ * obj_desc - The object descriptor for this op
*
* RETURN: Status
*
@@ -333,7 +333,7 @@ acpi_ex_system_wait_event (
if (obj_desc) {
status = acpi_ex_system_wait_semaphore (obj_desc->event.semaphore,
- (u16) time_desc->integer.value);
+ (u16) time_desc->integer.value);
}
return_ACPI_STATUS (status);
@@ -344,7 +344,7 @@ acpi_ex_system_wait_event (
*
* FUNCTION: acpi_ex_system_reset_event
*
- * PARAMETERS: *obj_desc - The object descriptor for this op
+ * PARAMETERS: obj_desc - The object descriptor for this op
*
* RETURN: Status
*
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/executer/exutils.c
index 40c6abb8b49..5c7ec0c0417 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/executer/exutils.c
@@ -67,22 +67,31 @@
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exutils")
+/* Local prototypes */
-#ifndef ACPI_NO_METHOD_EXECUTION
+static u32
+acpi_ex_digits_needed (
+ acpi_integer value,
+ u32 base);
+
+#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
*
* FUNCTION: acpi_ex_enter_interpreter
*
* PARAMETERS: None
*
+ * RETURN: Status
+ *
* DESCRIPTION: Enter the interpreter execution region. Failure to enter
* the interpreter region is a fatal system error
*
******************************************************************************/
acpi_status
-acpi_ex_enter_interpreter (void)
+acpi_ex_enter_interpreter (
+ void)
{
acpi_status status;
@@ -104,6 +113,8 @@ acpi_ex_enter_interpreter (void)
*
* PARAMETERS: None
*
+ * RETURN: None
+ *
* DESCRIPTION: Exit the interpreter execution region
*
* Cases where the interpreter is unlocked:
@@ -119,7 +130,8 @@ acpi_ex_enter_interpreter (void)
******************************************************************************/
void
-acpi_ex_exit_interpreter (void)
+acpi_ex_exit_interpreter (
+ void)
{
acpi_status status;
@@ -212,7 +224,8 @@ acpi_ex_acquire_global_lock (
locked = TRUE;
}
else {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not acquire Global Lock, %s\n",
acpi_format_exception (status)));
}
}
@@ -228,7 +241,7 @@ acpi_ex_acquire_global_lock (
* PARAMETERS: locked_by_me - Return value from corresponding call to
* acquire_global_lock.
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Release the global lock if it is locked.
*
@@ -269,11 +282,14 @@ acpi_ex_release_global_lock (
* PARAMETERS: Value - Value to be represented
* Base - Base of representation
*
- * RETURN: the number of digits needed to represent Value in Base
+ * RETURN: The number of digits.
+ *
+ * DESCRIPTION: Calculate the number of digits needed to represent the Value
+ * in the given Base (Radix)
*
******************************************************************************/
-u32
+static u32
acpi_ex_digits_needed (
acpi_integer value,
u32 base)
@@ -312,6 +328,8 @@ acpi_ex_digits_needed (
* PARAMETERS: numeric_id - EISA ID to be converted
* out_string - Where to put the converted string (8 bytes)
*
+ * RETURN: None
+ *
* DESCRIPTION: Convert a numeric EISA ID to string representation
*
******************************************************************************/
@@ -349,7 +367,10 @@ acpi_ex_eisa_id_to_string (
* PARAMETERS: Value - Value to be converted
* out_string - Where to put the converted string (8 bytes)
*
- * RETURN: Convert a number to string representation
+ * RETURN: None, string
+ *
+ * DESCRIPTOIN: Convert a number to string representation. Assumes string
+ * buffer is large enough to hold the string.
*
******************************************************************************/
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
new file mode 100644
index 00000000000..770cfc8b17e
--- /dev/null
+++ b/drivers/acpi/glue.c
@@ -0,0 +1,360 @@
+/*
+ * Link physical devices with ACPI devices support
+ *
+ * Copyright (c) 2005 David Shaohua Li <shaohua.li@intel.com>
+ * Copyright (c) 2005 Intel Corp.
+ *
+ * This file is released under the GPLv2.
+ */
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/device.h>
+#include <linux/rwsem.h>
+#include <linux/acpi.h>
+
+#define ACPI_GLUE_DEBUG 0
+#if ACPI_GLUE_DEBUG
+#define DBG(x...) printk(PREFIX x)
+#else
+#define DBG(x...)
+#endif
+static LIST_HEAD(bus_type_list);
+static DECLARE_RWSEM(bus_type_sem);
+
+int register_acpi_bus_type(struct acpi_bus_type *type)
+{
+ if (acpi_disabled)
+ return -ENODEV;
+ if (type && type->bus && type->find_device) {
+ down_write(&bus_type_sem);
+ list_add_tail(&type->list, &bus_type_list);
+ up_write(&bus_type_sem);
+ printk(KERN_INFO PREFIX "bus type %s registered\n", type->bus->name);
+ return 0;
+ }
+ return -ENODEV;
+}
+
+EXPORT_SYMBOL(register_acpi_bus_type);
+
+int unregister_acpi_bus_type(struct acpi_bus_type *type)
+{
+ if (acpi_disabled)
+ return 0;
+ if (type) {
+ down_write(&bus_type_sem);
+ list_del_init(&type->list);
+ up_write(&bus_type_sem);
+ printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", type->bus->name);
+ return 0;
+ }
+ return -ENODEV;
+}
+
+EXPORT_SYMBOL(unregister_acpi_bus_type);
+
+static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
+{
+ struct acpi_bus_type *tmp, *ret = NULL;
+
+ down_read(&bus_type_sem);
+ list_for_each_entry(tmp, &bus_type_list, list) {
+ if (tmp->bus == type) {
+ ret = tmp;
+ break;
+ }
+ }
+ up_read(&bus_type_sem);
+ return ret;
+}
+
+static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
+{
+ struct acpi_bus_type *tmp;
+ int ret = -ENODEV;
+
+ down_read(&bus_type_sem);
+ list_for_each_entry(tmp, &bus_type_list, list) {
+ if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
+ ret = 0;
+ break;
+ }
+ }
+ up_read(&bus_type_sem);
+ return ret;
+}
+
+/* Get PCI root bridge's handle from its segment and bus number */
+struct acpi_find_pci_root {
+ unsigned int seg;
+ unsigned int bus;
+ acpi_handle handle;
+};
+
+static acpi_status
+do_root_bridge_busnr_callback(struct acpi_resource *resource, void *data)
+{
+ int *busnr = (int *)data;
+ struct acpi_resource_address64 address;
+
+ if (resource->id != ACPI_RSTYPE_ADDRESS16 &&
+ resource->id != ACPI_RSTYPE_ADDRESS32 &&
+ resource->id != ACPI_RSTYPE_ADDRESS64)
+ return AE_OK;
+
+ acpi_resource_to_address64(resource, &address);
+ if ((address.address_length > 0) &&
+ (address.resource_type == ACPI_BUS_NUMBER_RANGE))
+ *busnr = address.min_address_range;
+
+ return AE_OK;
+}
+
+static int get_root_bridge_busnr(acpi_handle handle)
+{
+ acpi_status status;
+ int bus, bbn;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+ status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL,
+ (unsigned long *)&bbn);
+ if (status == AE_NOT_FOUND) {
+ /* Assume bus = 0 */
+ printk(KERN_INFO PREFIX
+ "Assume root bridge [%s] bus is 0\n",
+ (char *)buffer.pointer);
+ status = AE_OK;
+ bbn = 0;
+ }
+ if (ACPI_FAILURE(status)) {
+ bbn = -ENODEV;
+ goto exit;
+ }
+ if (bbn > 0)
+ goto exit;
+
+ /* _BBN in some systems return 0 for all root bridges */
+ bus = -1;
+ status = acpi_walk_resources(handle, METHOD_NAME__CRS,
+ do_root_bridge_busnr_callback, &bus);
+ /* If _CRS failed, we just use _BBN */
+ if (ACPI_FAILURE(status) || (bus == -1))
+ goto exit;
+ /* We select _CRS */
+ if (bbn != bus) {
+ printk(KERN_INFO PREFIX
+ "_BBN and _CRS returns different value for %s. Select _CRS\n",
+ (char *)buffer.pointer);
+ bbn = bus;
+ }
+ exit:
+ acpi_os_free(buffer.pointer);
+ return bbn;
+}
+
+static acpi_status
+find_pci_rootbridge(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ struct acpi_find_pci_root *find = (struct acpi_find_pci_root *)context;
+ unsigned long seg, bus;
+ acpi_status status;
+ int tmp;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+ status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &seg);
+ if (status == AE_NOT_FOUND) {
+ /* Assume seg = 0 */
+ printk(KERN_INFO PREFIX
+ "Assume root bridge [%s] segment is 0\n",
+ (char *)buffer.pointer);
+ status = AE_OK;
+ seg = 0;
+ }
+ if (ACPI_FAILURE(status)) {
+ status = AE_CTRL_DEPTH;
+ goto exit;
+ }
+
+ tmp = get_root_bridge_busnr(handle);
+ if (tmp < 0) {
+ printk(KERN_ERR PREFIX
+ "Find root bridge failed for %s\n",
+ (char *)buffer.pointer);
+ status = AE_CTRL_DEPTH;
+ goto exit;
+ }
+ bus = tmp;
+
+ if (seg == find->seg && bus == find->bus)
+ find->handle = handle;
+ status = AE_OK;
+ exit:
+ acpi_os_free(buffer.pointer);
+ return status;
+}
+
+acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
+{
+ struct acpi_find_pci_root find = { seg, bus, NULL };
+
+ acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL);
+ return find.handle;
+}
+
+/* Get device's handler per its address under its parent */
+struct acpi_find_child {
+ acpi_handle handle;
+ acpi_integer address;
+};
+
+static acpi_status
+do_acpi_find_child(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ acpi_status status;
+ struct acpi_device_info *info;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct acpi_find_child *find = (struct acpi_find_child *)context;
+
+ status = acpi_get_object_info(handle, &buffer);
+ if (ACPI_SUCCESS(status)) {
+ info = buffer.pointer;
+ if (info->address == find->address)
+ find->handle = handle;
+ acpi_os_free(buffer.pointer);
+ }
+ return AE_OK;
+}
+
+acpi_handle acpi_get_child(acpi_handle parent, acpi_integer address)
+{
+ struct acpi_find_child find = { NULL, address };
+
+ if (!parent)
+ return NULL;
+ acpi_walk_namespace(ACPI_TYPE_DEVICE, parent,
+ 1, do_acpi_find_child, &find, NULL);
+ return find.handle;
+}
+
+EXPORT_SYMBOL(acpi_get_child);
+
+/* Link ACPI devices with physical devices */
+static void acpi_glue_data_handler(acpi_handle handle,
+ u32 function, void *context)
+{
+ /* we provide an empty handler */
+}
+
+/* Note: a success call will increase reference count by one */
+struct device *acpi_get_physical_device(acpi_handle handle)
+{
+ acpi_status status;
+ struct device *dev;
+
+ status = acpi_get_data(handle, acpi_glue_data_handler, (void **)&dev);
+ if (ACPI_SUCCESS(status))
+ return get_device(dev);
+ return NULL;
+}
+
+EXPORT_SYMBOL(acpi_get_physical_device);
+
+static int acpi_bind_one(struct device *dev, acpi_handle handle)
+{
+ acpi_status status;
+
+ if (dev->firmware_data) {
+ printk(KERN_WARNING PREFIX
+ "Drivers changed 'firmware_data' for %s\n", dev->bus_id);
+ return -EINVAL;
+ }
+ get_device(dev);
+ status = acpi_attach_data(handle, acpi_glue_data_handler, dev);
+ if (ACPI_FAILURE(status)) {
+ put_device(dev);
+ return -EINVAL;
+ }
+ dev->firmware_data = handle;
+
+ return 0;
+}
+
+static int acpi_unbind_one(struct device *dev)
+{
+ if (!dev->firmware_data)
+ return 0;
+ if (dev == acpi_get_physical_device(dev->firmware_data)) {
+ /* acpi_get_physical_device increase refcnt by one */
+ put_device(dev);
+ acpi_detach_data(dev->firmware_data, acpi_glue_data_handler);
+ dev->firmware_data = NULL;
+ /* acpi_bind_one increase refcnt by one */
+ put_device(dev);
+ } else {
+ printk(KERN_ERR PREFIX
+ "Oops, 'firmware_data' corrupt for %s\n", dev->bus_id);
+ }
+ return 0;
+}
+
+static int acpi_platform_notify(struct device *dev)
+{
+ struct acpi_bus_type *type;
+ acpi_handle handle;
+ int ret = -EINVAL;
+
+ if (!dev->bus || !dev->parent) {
+ /* bridge devices genernally haven't bus or parent */
+ ret = acpi_find_bridge_device(dev, &handle);
+ goto end;
+ }
+ type = acpi_get_bus_type(dev->bus);
+ if (!type) {
+ DBG("No ACPI bus support for %s\n", dev->bus_id);
+ ret = -EINVAL;
+ goto end;
+ }
+ if ((ret = type->find_device(dev, &handle)) != 0)
+ DBG("Can't get handler for %s\n", dev->bus_id);
+ end:
+ if (!ret)
+ acpi_bind_one(dev, handle);
+
+#if ACPI_GLUE_DEBUG
+ if (!ret) {
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ acpi_get_name(dev->firmware_data, ACPI_FULL_PATHNAME, &buffer);
+ DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer);
+ acpi_os_free(buffer.pointer);
+ } else
+ DBG("Device %s -> No ACPI support\n", dev->bus_id);
+#endif
+
+ return ret;
+}
+
+static int acpi_platform_notify_remove(struct device *dev)
+{
+ acpi_unbind_one(dev);
+ return 0;
+}
+
+static int __init init_acpi_device_notify(void)
+{
+ if (acpi_disabled)
+ return 0;
+ if (platform_notify || platform_notify_remove) {
+ printk(KERN_ERR PREFIX "Can't use platform_notify\n");
+ return 0;
+ }
+ platform_notify = acpi_platform_notify;
+ platform_notify_remove = acpi_platform_notify_remove;
+ return 0;
+}
+
+arch_initcall(init_acpi_device_notify);
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/hardware/hwacpi.c
index 529e922bdc8..b51001e74ee 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/hardware/hwacpi.c
@@ -58,7 +58,8 @@
*
* RETURN: Status
*
- * DESCRIPTION: Initialize and validate various ACPI registers
+ * DESCRIPTION: Initialize and validate the various ACPI registers defined in
+ * the FADT.
*
******************************************************************************/
@@ -75,7 +76,7 @@ acpi_hw_initialize (
/* We must have the ACPI tables by the time we get here */
if (!acpi_gbl_FADT) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n"));
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
@@ -131,7 +132,8 @@ acpi_hw_set_mode (
* transitions are not supported.
*/
if (!acpi_gbl_FADT->acpi_enable && !acpi_gbl_FADT->acpi_disable) {
- ACPI_REPORT_ERROR (("No ACPI mode transition supported in this system (enable/disable both zero)\n"));
+ ACPI_REPORT_ERROR ((
+ "No ACPI mode transition supported in this system (enable/disable both zero)\n"));
return_ACPI_STATUS (AE_OK);
}
@@ -162,7 +164,8 @@ acpi_hw_set_mode (
}
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("Could not write mode change, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Could not write mode change, %s\n",
+ acpi_format_exception (status)));
return_ACPI_STATUS (status);
}
@@ -173,7 +176,8 @@ acpi_hw_set_mode (
retry = 3000;
while (retry) {
if (acpi_hw_get_mode() == mode) {
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", mode));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n",
+ mode));
return_ACPI_STATUS (AE_OK);
}
acpi_os_stall(1000);
@@ -185,7 +189,7 @@ acpi_hw_set_mode (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_hw_get_mode
*
@@ -199,7 +203,8 @@ acpi_hw_set_mode (
******************************************************************************/
u32
-acpi_hw_get_mode (void)
+acpi_hw_get_mode (
+ void)
{
acpi_status status;
u32 value;
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/hardware/hwgpe.c
index 9ac1d639bf5..8daeabb2fc7 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/hardware/hwgpe.c
@@ -48,6 +48,13 @@
#define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME ("hwgpe")
+/* Local prototypes */
+
+static acpi_status
+acpi_hw_enable_wakeup_gpe_block (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block);
+
/******************************************************************************
*
@@ -135,6 +142,7 @@ acpi_hw_clear_gpe (
* DESCRIPTION: Return the status of a single GPE.
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_hw_get_gpe_status (
@@ -206,7 +214,7 @@ unlock_and_exit:
*
* RETURN: Status
*
- * DESCRIPTION: Disable all GPEs within a GPE block
+ * DESCRIPTION: Disable all GPEs within a single GPE block
*
******************************************************************************/
@@ -244,7 +252,7 @@ acpi_hw_disable_gpe_block (
*
* RETURN: Status
*
- * DESCRIPTION: Clear status bits for all GPEs within a GPE block
+ * DESCRIPTION: Clear status bits for all GPEs within a single GPE block
*
******************************************************************************/
@@ -282,8 +290,8 @@ acpi_hw_clear_gpe_block (
*
* RETURN: Status
*
- * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes
- * combination wake/run GPEs.)
+ * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes
+ * combination wake/run GPEs.
*
******************************************************************************/
@@ -327,12 +335,12 @@ acpi_hw_enable_runtime_gpe_block (
*
* RETURN: Status
*
- * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes
- * combination wake/run GPEs.)
+ * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes
+ * combination wake/run GPEs.
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_hw_enable_wakeup_gpe_block (
struct acpi_gpe_xrupt_info *gpe_xrupt_info,
struct acpi_gpe_block_info *gpe_block)
@@ -350,7 +358,8 @@ acpi_hw_enable_wakeup_gpe_block (
/* Enable all "wake" GPEs in this register */
- status = acpi_hw_low_level_write (8, gpe_block->register_info[i].enable_for_wake,
+ status = acpi_hw_low_level_write (8,
+ gpe_block->register_info[i].enable_for_wake,
&gpe_block->register_info[i].enable_address);
if (ACPI_FAILURE (status)) {
return (status);
@@ -369,7 +378,7 @@ acpi_hw_enable_wakeup_gpe_block (
*
* RETURN: Status
*
- * DESCRIPTION: Disable and clear all GPEs
+ * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
*
******************************************************************************/
@@ -397,7 +406,7 @@ acpi_hw_disable_all_gpes (
*
* RETURN: Status
*
- * DESCRIPTION: Enable all GPEs of the given type
+ * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
*
******************************************************************************/
@@ -424,7 +433,7 @@ acpi_hw_enable_all_runtime_gpes (
*
* RETURN: Status
*
- * DESCRIPTION: Enable all GPEs of the given type
+ * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks
*
******************************************************************************/
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 91af0c2ddcf..6d9e4eb8483 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -87,8 +87,9 @@ acpi_hw_clear_acpi_status (
}
}
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
- ACPI_BITMASK_ALL_FIXED_STATUS);
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1_STATUS,
+ ACPI_BITMASK_ALL_FIXED_STATUS);
if (ACPI_FAILURE (status)) {
goto unlock_and_exit;
}
@@ -138,28 +139,30 @@ acpi_get_sleep_type_data (
{
acpi_status status = AE_OK;
struct acpi_parameter_info info;
+ char *sleep_state_name;
ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
- /*
- * Validate parameters
- */
+ /* Validate parameters */
+
if ((sleep_state > ACPI_S_STATES_MAX) ||
!sleep_type_a || !sleep_type_b) {
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- /*
- * Evaluate the namespace object containing the values for this state
- */
+ /* Evaluate the namespace object containing the values for this state */
+
info.parameters = NULL;
- status = acpi_ns_evaluate_by_name ((char *) acpi_gbl_sleep_state_names[sleep_state],
- &info);
+ info.return_object = NULL;
+ sleep_state_name = (char *) acpi_gbl_sleep_state_names[sleep_state];
+
+ status = acpi_ns_evaluate_by_name (sleep_state_name, &info);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating sleep_state [%s]\n",
- acpi_format_exception (status), acpi_gbl_sleep_state_names[sleep_state]));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "%s while evaluating sleep_state [%s]\n",
+ acpi_format_exception (status), sleep_state_name));
return_ACPI_STATUS (status);
}
@@ -167,45 +170,57 @@ acpi_get_sleep_type_data (
/* Must have a return object */
if (!info.return_object) {
- ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
+ ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n",
+ sleep_state_name));
status = AE_NOT_EXIST;
}
/* It must be of type Package */
else if (ACPI_GET_OBJECT_TYPE (info.return_object) != ACPI_TYPE_PACKAGE) {
- ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
+ ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n"));
status = AE_AML_OPERAND_TYPE;
}
- /* The package must have at least two elements */
-
+ /*
+ * The package must have at least two elements. NOTE (March 2005): This
+ * goes against the current ACPI spec which defines this object as a
+ * package with one encoded DWORD element. However, existing practice
+ * by BIOS vendors seems to be to have 2 or more elements, at least
+ * one per sleep type (A/B).
+ */
else if (info.return_object->package.count < 2) {
- ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
+ ACPI_REPORT_ERROR ((
+ "Sleep State return package does not have at least two elements\n"));
status = AE_AML_NO_OPERAND;
}
/* The first two elements must both be of type Integer */
- else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0]) != ACPI_TYPE_INTEGER) ||
- (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1]) != ACPI_TYPE_INTEGER)) {
- ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
+ else if ((ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[0])
+ != ACPI_TYPE_INTEGER) ||
+ (ACPI_GET_OBJECT_TYPE (info.return_object->package.elements[1])
+ != ACPI_TYPE_INTEGER)) {
+ ACPI_REPORT_ERROR ((
+ "Sleep State return package elements are not both Integers (%s, %s)\n",
acpi_ut_get_object_type_name (info.return_object->package.elements[0]),
acpi_ut_get_object_type_name (info.return_object->package.elements[1])));
status = AE_AML_OPERAND_TYPE;
}
else {
- /*
- * Valid _Sx_ package size, type, and value
- */
- *sleep_type_a = (u8) (info.return_object->package.elements[0])->integer.value;
- *sleep_type_b = (u8) (info.return_object->package.elements[1])->integer.value;
+ /* Valid _Sx_ package size, type, and value */
+
+ *sleep_type_a = (u8)
+ (info.return_object->package.elements[0])->integer.value;
+ *sleep_type_b = (u8)
+ (info.return_object->package.elements[1])->integer.value;
}
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
- acpi_gbl_sleep_state_names[sleep_state], info.return_object,
+ "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
+ acpi_format_exception (status),
+ sleep_state_name, info.return_object,
acpi_ut_get_object_type_name (info.return_object)));
}
@@ -221,9 +236,9 @@ EXPORT_SYMBOL(acpi_get_sleep_type_data);
*
* PARAMETERS: register_id - Index of ACPI Register to access
*
- * RETURN: The bit mask to be used when accessing the register
+ * RETURN: The bitmask to be used when accessing the register
*
- * DESCRIPTION: Map register_id into a register bit mask.
+ * DESCRIPTION: Map register_id into a register bitmask.
*
******************************************************************************/
@@ -359,7 +374,7 @@ acpi_set_register (
/* Always do a register read first so we can insert the new bits */
status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
- bit_reg_info->parent_register, &register_value);
+ bit_reg_info->parent_register, &register_value);
if (ACPI_FAILURE (status)) {
goto unlock_and_exit;
}
@@ -396,7 +411,7 @@ acpi_set_register (
bit_reg_info->access_bit_mask, value);
status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
- ACPI_REGISTER_PM1_ENABLE, (u16) register_value);
+ ACPI_REGISTER_PM1_ENABLE, (u16) register_value);
break;
@@ -413,7 +428,7 @@ acpi_set_register (
bit_reg_info->access_bit_mask, value);
status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
- ACPI_REGISTER_PM1_CONTROL, (u16) register_value);
+ ACPI_REGISTER_PM1_CONTROL, (u16) register_value);
break;
@@ -427,17 +442,19 @@ acpi_set_register (
ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
register_value,
- ACPI_FORMAT_UINT64 (acpi_gbl_FADT->xpm2_cnt_blk.address)));
+ ACPI_FORMAT_UINT64 (
+ acpi_gbl_FADT->xpm2_cnt_blk.address)));
ACPI_REGISTER_INSERT_VALUE (register_value, bit_reg_info->bit_position,
bit_reg_info->access_bit_mask, value);
ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
register_value,
- ACPI_FORMAT_UINT64 (acpi_gbl_FADT->xpm2_cnt_blk.address)));
+ ACPI_FORMAT_UINT64 (
+ acpi_gbl_FADT->xpm2_cnt_blk.address)));
status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
- ACPI_REGISTER_PM2_CONTROL, (u8) (register_value));
+ ACPI_REGISTER_PM2_CONTROL, (u8) (register_value));
break;
@@ -454,7 +471,9 @@ unlock_and_exit:
/* Normalize the value that was read */
- ACPI_DEBUG_EXEC (register_value = ((register_value & bit_reg_info->access_bit_mask) >> bit_reg_info->bit_position));
+ ACPI_DEBUG_EXEC (register_value =
+ ((register_value & bit_reg_info->access_bit_mask) >>
+ bit_reg_info->bit_position));
ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n",
value, register_value, bit_reg_info->parent_register));
@@ -469,7 +488,7 @@ EXPORT_SYMBOL(acpi_set_register);
*
* PARAMETERS: use_lock - Mutex hw access
* register_id - register_iD + Offset
- * return_value - Value that was read from the register
+ * return_value - Where the register value is returned
*
* RETURN: Status and the value read.
*
@@ -557,7 +576,8 @@ acpi_hw_register_read (
break;
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", register_id));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n",
+ register_id));
status = AE_BAD_PARAMETER;
break;
}
@@ -763,10 +783,11 @@ acpi_hw_low_level_read (
return (AE_BAD_PARAMETER);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
- *value, width,
- ACPI_FORMAT_UINT64 (address),
- acpi_ut_get_region_name (reg->address_space_id)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
+ *value, width,
+ ACPI_FORMAT_UINT64 (address),
+ acpi_ut_get_region_name (reg->address_space_id)));
return (status);
}
@@ -841,10 +862,11 @@ acpi_hw_low_level_write (
return (AE_BAD_PARAMETER);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
- value, width,
- ACPI_FORMAT_UINT64 (address),
- acpi_ut_get_region_name (reg->address_space_id)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO,
+ "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
+ value, width,
+ ACPI_FORMAT_UINT64 (address),
+ acpi_ut_get_region_name (reg->address_space_id)));
return (status);
}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 77b3e9a8550..415d342aeab 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -43,27 +43,13 @@
*/
#include <linux/module.h>
-
#include <acpi/acpi.h>
#define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME ("hwsleep")
-#define METHOD_NAME__BFS "\\_BFS"
-#define METHOD_NAME__GTS "\\_GTS"
-#define METHOD_NAME__PTS "\\_PTS"
-#define METHOD_NAME__SST "\\_SI._SST"
-#define METHOD_NAME__WAK "\\_WAK"
-
-#define ACPI_SST_INDICATOR_OFF 0
-#define ACPI_SST_WORKING 1
-#define ACPI_SST_WAKING 2
-#define ACPI_SST_SLEEPING 3
-#define ACPI_SST_SLEEP_CONTEXT 4
-
-
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_set_firmware_waking_vector
*
@@ -72,7 +58,7 @@
*
* RETURN: Status
*
- * DESCRIPTION: access function for d_firmware_waking_vector field in FACS
+ * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
*
******************************************************************************/
@@ -99,19 +85,20 @@ acpi_set_firmware_waking_vector (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_get_firmware_waking_vector
*
- * PARAMETERS: *physical_address - Output buffer where contents of
+ * PARAMETERS: *physical_address - Where the contents of
* the firmware_waking_vector field of
- * the FACS will be stored.
+ * the FACS will be returned.
*
- * RETURN: Status
+ * RETURN: Status, vector
*
- * DESCRIPTION: Access function for firmware_waking_vector field in FACS
+ * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_get_firmware_waking_vector (
@@ -141,7 +128,7 @@ acpi_get_firmware_waking_vector (
#endif
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_enter_sleep_state_prep
*
@@ -215,7 +202,7 @@ acpi_enter_sleep_state_prep (
break;
default:
- arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is indicator off */
+ arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
break;
}
@@ -223,14 +210,15 @@ acpi_enter_sleep_state_prep (
status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
- ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
+ acpi_format_exception (status)));
}
return_ACPI_STATUS (AE_OK);
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_enter_sleep_state
*
@@ -299,15 +287,18 @@ acpi_enter_sleep_state (
/* Get current value of PM1A control */
- status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
+ status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", sleep_state));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+ "Entering sleep state [S%d]\n", sleep_state));
/* Clear SLP_EN and SLP_TYP fields */
- PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | sleep_enable_reg_info->access_bit_mask);
+ PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
+ sleep_enable_reg_info->access_bit_mask);
PM1Bcontrol = PM1Acontrol;
/* Insert SLP_TYP bits */
@@ -322,12 +313,14 @@ acpi_enter_sleep_state (
/* Write #1: fill in SLP_TYP data */
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -341,22 +334,25 @@ acpi_enter_sleep_state (
ACPI_FLUSH_CPU_CACHE ();
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
if (sleep_state > ACPI_STATE_S3) {
/*
- * We wanted to sleep > S3, but it didn't happen (by virtue of the fact that
- * we are still executing!)
+ * We wanted to sleep > S3, but it didn't happen (by virtue of the
+ * fact that we are still executing!)
*
- * Wait ten seconds, then try again. This is to get S4/S5 to work on all machines.
+ * Wait ten seconds, then try again. This is to get S4/S5 to work on
+ * all machines.
*
* We wait so long to allow chipsets that poll this reg very slowly to
* still read the right value. Ideally, this block would go
@@ -364,7 +360,8 @@ acpi_enter_sleep_state (
*/
acpi_os_stall (10000000);
- status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL,
+ status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1_CONTROL,
sleep_enable_reg_info->access_bit_mask);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
@@ -374,7 +371,8 @@ acpi_enter_sleep_state (
/* Wait until we enter sleep state */
do {
- status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK);
+ status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value,
+ ACPI_MTX_DO_NOT_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -388,7 +386,7 @@ acpi_enter_sleep_state (
EXPORT_SYMBOL(acpi_enter_sleep_state);
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_enter_sleep_state_s4bios
*
@@ -439,11 +437,13 @@ acpi_enter_sleep_state_s4bios (
ACPI_FLUSH_CPU_CACHE ();
- status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, (u32) acpi_gbl_FADT->S4bios_req, 8);
+ status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd,
+ (u32) acpi_gbl_FADT->S4bios_req, 8);
do {
acpi_os_stall(1000);
- status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, ACPI_MTX_DO_NOT_LOCK);
+ status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value,
+ ACPI_MTX_DO_NOT_LOCK);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -454,7 +454,7 @@ acpi_enter_sleep_state_s4bios (
EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_leave_sleep_state
*
@@ -534,18 +534,21 @@ acpi_leave_sleep_state (
arg.integer.value = ACPI_SST_WAKING;
status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
- ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
+ acpi_format_exception (status)));
}
arg.integer.value = sleep_state;
status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL);
if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
- ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Method _BFS failed, %s\n",
+ acpi_format_exception (status)));
}
status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL);
if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
- ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Method _WAK failed, %s\n",
+ acpi_format_exception (status)));
}
/* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
@@ -567,15 +570,19 @@ acpi_leave_sleep_state (
/* Enable power button */
- (void) acpi_set_register(acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id,
+ (void) acpi_set_register(
+ acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id,
1, ACPI_MTX_DO_NOT_LOCK);
- (void) acpi_set_register(acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id,
+
+ (void) acpi_set_register(
+ acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id,
1, ACPI_MTX_DO_NOT_LOCK);
arg.integer.value = ACPI_SST_WORKING;
status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL);
if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) {
- ACPI_REPORT_ERROR (("Method _SST failed, %s\n", acpi_format_exception (status)));
+ ACPI_REPORT_ERROR (("Method _SST failed, %s\n",
+ acpi_format_exception (status)));
}
return_ACPI_STATUS (status);
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/hardware/hwtimer.c
index 1906167d729..49d7b395322 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/hardware/hwtimer.c
@@ -43,7 +43,6 @@
*/
#include <linux/module.h>
-
#include <acpi/acpi.h>
#define _COMPONENT ACPI_HARDWARE
@@ -90,7 +89,7 @@ acpi_get_timer_resolution (
*
* PARAMETERS: Ticks - Where the timer value is returned
*
- * RETURN: Status and current ticks
+ * RETURN: Status and current timer value (ticks)
*
* DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks).
*
@@ -199,5 +198,6 @@ acpi_get_timer_duration (
*time_elapsed = (u32) quotient;
return_ACPI_STATUS (status);
}
+
EXPORT_SYMBOL(acpi_get_timer_duration);
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
new file mode 100644
index 00000000000..babdf762ead
--- /dev/null
+++ b/drivers/acpi/hotkey.c
@@ -0,0 +1,1019 @@
+/*
+ * hotkey.c - ACPI Hotkey Driver ($Revision:$)
+ *
+ * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <linux/sched.h>
+#include <linux/kmod.h>
+#include <linux/seq_file.h>
+#include <acpi/acpi_drivers.h>
+#include <acpi/acpi_bus.h>
+#include <asm/uaccess.h>
+
+#define HOTKEY_ACPI_VERSION "0.1"
+
+#define HOTKEY_PROC "hotkey"
+#define HOTKEY_EV_CONFIG "event_config"
+#define HOTKEY_PL_CONFIG "poll_config"
+#define HOTKEY_ACTION "action"
+#define HOTKEY_INFO "info"
+
+#define ACPI_HOTK_NAME "Generic Hotkey Driver"
+#define ACPI_HOTK_CLASS "Hotkey"
+#define ACPI_HOTK_DEVICE_NAME "Hotkey"
+#define ACPI_HOTK_HID "Unknown?"
+#define ACPI_HOTKEY_COMPONENT 0x20000000
+
+#define ACPI_HOTKEY_EVENT 0x1
+#define ACPI_HOTKEY_POLLING 0x2
+#define ACPI_UNDEFINED_EVENT 0xf
+
+#define MAX_CONFIG_RECORD_LEN 80
+#define MAX_NAME_PATH_LEN 80
+#define MAX_CALL_PARM 80
+
+#define IS_EVENT(e) 0xff /* ((e) & 0x40000000) */
+#define IS_POLL(e) 0xff /* (~((e) & 0x40000000)) */
+
+#define _COMPONENT ACPI_HOTKEY_COMPONENT
+ACPI_MODULE_NAME("acpi_hotkey")
+
+ MODULE_AUTHOR("luming.yu@intel.com");
+MODULE_DESCRIPTION(ACPI_HOTK_NAME);
+MODULE_LICENSE("GPL");
+
+/* standardized internal hotkey number/event */
+enum {
+ /* Video Extension event */
+ HK_EVENT_CYCLE_OUTPUT_DEVICE = 0x80,
+ HK_EVENT_OUTPUT_DEVICE_STATUS_CHANGE,
+ HK_EVENT_CYCLE_DISPLAY_OUTPUT,
+ HK_EVENT_NEXT_DISPLAY_OUTPUT,
+ HK_EVENT_PREVIOUS_DISPLAY_OUTPUT,
+ HK_EVENT_CYCLE_BRIGHTNESS,
+ HK_EVENT_INCREASE_BRIGHTNESS,
+ HK_EVENT_DECREASE_BRIGHTNESS,
+ HK_EVENT_ZERO_BRIGHTNESS,
+ HK_EVENT_DISPLAY_DEVICE_OFF,
+
+ /* Snd Card event */
+ HK_EVENT_VOLUME_MUTE,
+ HK_EVENT_VOLUME_INCLREASE,
+ HK_EVENT_VOLUME_DECREASE,
+
+ /* running state control */
+ HK_EVENT_ENTERRING_S3,
+ HK_EVENT_ENTERRING_S4,
+ HK_EVENT_ENTERRING_S5,
+};
+
+/* procdir we use */
+static struct proc_dir_entry *hotkey_proc_dir;
+static struct proc_dir_entry *hotkey_config;
+static struct proc_dir_entry *hotkey_poll_config;
+static struct proc_dir_entry *hotkey_action;
+static struct proc_dir_entry *hotkey_info;
+
+/* linkage for all type of hotkey */
+struct acpi_hotkey_link {
+ struct list_head entries;
+ int hotkey_type; /* event or polling based hotkey */
+ int hotkey_standard_num; /* standardized hotkey(event) number */
+};
+
+/* event based hotkey */
+struct acpi_event_hotkey {
+ struct acpi_hotkey_link hotkey_link;
+ int flag;
+ acpi_handle bus_handle; /* bus to install notify handler */
+ int external_hotkey_num; /* external hotkey/event number */
+ acpi_handle action_handle; /* acpi handle attached aml action method */
+ char *action_method; /* action method */
+};
+
+/*
+ * There are two ways to poll status
+ * 1. directy call read_xxx method, without any arguments passed in
+ * 2. call write_xxx method, with arguments passed in, you need
+ * the result is saved in acpi_polling_hotkey.poll_result.
+ * anthoer read command through polling interface.
+ *
+ */
+
+/* polling based hotkey */
+struct acpi_polling_hotkey {
+ struct acpi_hotkey_link hotkey_link;
+ int flag;
+ acpi_handle poll_handle; /* acpi handle attached polling method */
+ char *poll_method; /* poll method */
+ acpi_handle action_handle; /* acpi handle attached action method */
+ char *action_method; /* action method */
+ void *poll_result; /* polling_result */
+ struct proc_dir_entry *proc;
+};
+
+/* hotkey object union */
+union acpi_hotkey {
+ struct list_head entries;
+ struct acpi_hotkey_link link;
+ struct acpi_event_hotkey event_hotkey;
+ struct acpi_polling_hotkey poll_hotkey;
+};
+
+/* hotkey object list */
+struct acpi_hotkey_list {
+ struct list_head *entries;
+ int count;
+};
+
+static int auto_hotkey_add(struct acpi_device *device);
+static int auto_hotkey_remove(struct acpi_device *device, int type);
+
+static struct acpi_driver hotkey_driver = {
+ .name = ACPI_HOTK_NAME,
+ .class = ACPI_HOTK_CLASS,
+ .ids = ACPI_HOTK_HID,
+ .ops = {
+ .add = auto_hotkey_add,
+ .remove = auto_hotkey_remove,
+ },
+};
+
+static int hotkey_open_config(struct inode *inode, struct file *file);
+static ssize_t hotkey_write_config(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data);
+static ssize_t hotkey_write_poll_config(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data);
+static int hotkey_info_open_fs(struct inode *inode, struct file *file);
+static int hotkey_action_open_fs(struct inode *inode, struct file *file);
+static ssize_t hotkey_execute_aml_method(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data);
+static int hotkey_config_seq_show(struct seq_file *seq, void *offset);
+static int hotkey_polling_open_fs(struct inode *inode, struct file *file);
+
+/* event based config */
+static struct file_operations hotkey_config_fops = {
+ .open = hotkey_open_config,
+ .read = seq_read,
+ .write = hotkey_write_config,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/* polling based config */
+static struct file_operations hotkey_poll_config_fops = {
+ .open = hotkey_open_config,
+ .read = seq_read,
+ .write = hotkey_write_poll_config,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/* hotkey driver info */
+static struct file_operations hotkey_info_fops = {
+ .open = hotkey_info_open_fs,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/* action */
+static struct file_operations hotkey_action_fops = {
+ .open = hotkey_action_open_fs,
+ .read = seq_read,
+ .write = hotkey_execute_aml_method,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/* polling results */
+static struct file_operations hotkey_polling_fops = {
+ .open = hotkey_polling_open_fs,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+struct acpi_hotkey_list global_hotkey_list; /* link all ev or pl hotkey */
+struct list_head hotkey_entries; /* head of the list of hotkey_list */
+
+static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
+{
+ ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
+
+ seq_printf(seq, "Hotkey generic driver ver: %s", HOTKEY_ACPI_VERSION);
+
+ return_VALUE(0);
+}
+
+static int hotkey_info_open_fs(struct inode *inode, struct file *file)
+{
+ return single_open(file, hotkey_info_seq_show, PDE(inode)->data);
+}
+
+static char *format_result(union acpi_object *object)
+{
+ char *buf = (char *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+
+ memset(buf, 0, sizeof(union acpi_object));
+
+ /* Now, just support integer type */
+ if (object->type == ACPI_TYPE_INTEGER)
+ sprintf(buf, "%d", (u32) object->integer.value);
+
+ return buf;
+}
+
+static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
+{
+ struct acpi_polling_hotkey *poll_hotkey =
+ (struct acpi_polling_hotkey *)seq->private;
+
+ ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
+
+ if (poll_hotkey->poll_result)
+ seq_printf(seq, "%s", format_result(poll_hotkey->poll_result));
+
+ return_VALUE(0);
+}
+
+static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
+{
+ return single_open(file, hotkey_polling_seq_show, PDE(inode)->data);
+}
+
+static int hotkey_action_open_fs(struct inode *inode, struct file *file)
+{
+ return single_open(file, hotkey_info_seq_show, PDE(inode)->data);
+}
+
+/* Mapping external hotkey number to standardized hotkey event num */
+static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
+{
+ struct list_head *entries, *next;
+ int val = 0;
+
+ ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
+
+ list_for_each_safe(entries, next, list->entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
+ && key->event_hotkey.external_hotkey_num == event)
+ val = key->link.hotkey_standard_num;
+ else
+ val = -1;
+ }
+
+ return_VALUE(val);
+}
+
+static void
+acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
+{
+ struct acpi_device *device = NULL;
+ u32 internal_event;
+
+ ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
+
+ if (acpi_bus_get_device(handle, &device))
+ return_VOID;
+
+ internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
+ acpi_bus_generate_event(device, event, 0);
+
+ return_VOID;
+}
+
+/* Need to invent automatically hotkey add method */
+static int auto_hotkey_add(struct acpi_device *device)
+{
+ /* Implement me */
+ return 0;
+}
+
+/* Need to invent automatically hotkey remove method */
+static int auto_hotkey_remove(struct acpi_device *device, int type)
+{
+ /* Implement me */
+ return 0;
+}
+
+/* Create a proc file for each polling method */
+static int create_polling_proc(union acpi_hotkey *device)
+{
+ struct proc_dir_entry *proc;
+ mode_t mode;
+
+ ACPI_FUNCTION_TRACE("create_polling_proc");
+ mode = S_IFREG | S_IRUGO | S_IWUGO;
+
+ proc = create_proc_entry(device->poll_hotkey.action_method,
+ mode, hotkey_proc_dir);
+
+ if (!proc) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ device->poll_hotkey.poll_method));
+ return_VALUE(-ENODEV);
+ } else {
+ proc->proc_fops = &hotkey_polling_fops;
+ proc->owner = THIS_MODULE;
+ proc->data = device;
+ proc->uid = 0;
+ proc->gid = 0;
+ device->poll_hotkey.proc = proc;
+ }
+ return_VALUE(0);
+}
+
+static int is_valid_acpi_path(const char *pathname)
+{
+ acpi_handle handle;
+ acpi_status status;
+ ACPI_FUNCTION_TRACE("is_valid_acpi_path");
+
+ status = acpi_get_handle(NULL, (char *)pathname, &handle);
+ return_VALUE(!ACPI_FAILURE(status));
+}
+
+static int is_valid_hotkey(union acpi_hotkey *device)
+{
+ ACPI_FUNCTION_TRACE("is_valid_hotkey");
+ /* Implement valid check */
+ return_VALUE(1);
+}
+
+static int hotkey_add(union acpi_hotkey *device)
+{
+ int status = 0;
+ struct acpi_device *dev = NULL;
+
+ ACPI_FUNCTION_TRACE("hotkey_add");
+
+ if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
+ status =
+ acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
+ if (status)
+ return_VALUE(status);
+
+ status = acpi_install_notify_handler(dev->handle,
+ ACPI_SYSTEM_NOTIFY,
+ acpi_hotkey_notify_handler,
+ device);
+ } else /* Add polling hotkey */
+ create_polling_proc(device);
+
+ global_hotkey_list.count++;
+
+ list_add_tail(&device->link.entries, global_hotkey_list.entries);
+
+ return_VALUE(status);
+}
+
+static int hotkey_remove(union acpi_hotkey *device)
+{
+ struct list_head *entries, *next;
+
+ ACPI_FUNCTION_TRACE("hotkey_remove");
+
+ list_for_each_safe(entries, next, global_hotkey_list.entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_standard_num ==
+ device->link.hotkey_standard_num) {
+ list_del(&key->link.entries);
+ remove_proc_entry(key->poll_hotkey.action_method,
+ hotkey_proc_dir);
+ global_hotkey_list.count--;
+ break;
+ }
+ }
+ return_VALUE(0);
+}
+
+static void hotkey_update(union acpi_hotkey *key)
+{
+ struct list_head *entries, *next;
+
+ ACPI_FUNCTION_TRACE("hotkey_update");
+
+ list_for_each_safe(entries, next, global_hotkey_list.entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_standard_num ==
+ key->link.hotkey_standard_num) {
+ key->event_hotkey.bus_handle =
+ key->event_hotkey.bus_handle;
+ key->event_hotkey.external_hotkey_num =
+ key->event_hotkey.external_hotkey_num;
+ key->event_hotkey.action_handle =
+ key->event_hotkey.action_handle;
+ key->event_hotkey.action_method =
+ key->event_hotkey.action_method;
+ break;
+ }
+ }
+
+ return_VOID;
+}
+
+static void free_hotkey_device(union acpi_hotkey *key)
+{
+ struct acpi_device *dev;
+ int status;
+
+ ACPI_FUNCTION_TRACE("free_hotkey_device");
+
+ if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
+ status =
+ acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
+ if (dev->handle)
+ acpi_remove_notify_handler(dev->handle,
+ ACPI_SYSTEM_NOTIFY,
+ acpi_hotkey_notify_handler);
+ } else
+ remove_proc_entry(key->poll_hotkey.action_method,
+ hotkey_proc_dir);
+ kfree(key);
+ return_VOID;
+}
+
+static int
+init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
+ char *method, int std_num, int external_num)
+{
+ ACPI_FUNCTION_TRACE("init_hotkey_device");
+
+ key->link.hotkey_type = ACPI_HOTKEY_EVENT;
+ key->link.hotkey_standard_num = std_num;
+ key->event_hotkey.flag = 0;
+ if (is_valid_acpi_path(bus_str))
+ acpi_get_handle((acpi_handle) 0,
+ bus_str, &(key->event_hotkey.bus_handle));
+ else
+ return_VALUE(-ENODEV);
+ key->event_hotkey.external_hotkey_num = external_num;
+ if (is_valid_acpi_path(action_str))
+ acpi_get_handle((acpi_handle) 0,
+ action_str, &(key->event_hotkey.action_handle));
+ key->event_hotkey.action_method = kmalloc(sizeof(method), GFP_KERNEL);
+ strcpy(key->event_hotkey.action_method, method);
+
+ return_VALUE(!is_valid_hotkey(key));
+}
+
+static int
+init_poll_hotkey_device(union acpi_hotkey *key,
+ char *poll_str,
+ char *poll_method,
+ char *action_str, char *action_method, int std_num)
+{
+ ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
+
+ key->link.hotkey_type = ACPI_HOTKEY_POLLING;
+ key->link.hotkey_standard_num = std_num;
+ key->poll_hotkey.flag = 0;
+ if (is_valid_acpi_path(poll_str))
+ acpi_get_handle((acpi_handle) 0,
+ poll_str, &(key->poll_hotkey.poll_handle));
+ else
+ return_VALUE(-ENODEV);
+ key->poll_hotkey.poll_method = poll_method;
+ if (is_valid_acpi_path(action_str))
+ acpi_get_handle((acpi_handle) 0,
+ action_str, &(key->poll_hotkey.action_handle));
+ key->poll_hotkey.action_method =
+ kmalloc(sizeof(action_method), GFP_KERNEL);
+ strcpy(key->poll_hotkey.action_method, action_method);
+ key->poll_hotkey.poll_result =
+ (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+ return_VALUE(is_valid_hotkey(key));
+}
+
+static int check_hotkey_valid(union acpi_hotkey *key,
+ struct acpi_hotkey_list *list)
+{
+ ACPI_FUNCTION_TRACE("check_hotkey_valid");
+ return_VALUE(0);
+}
+
+static int hotkey_open_config(struct inode *inode, struct file *file)
+{
+ ACPI_FUNCTION_TRACE("hotkey_open_config");
+ return_VALUE(single_open
+ (file, hotkey_config_seq_show, PDE(inode)->data));
+}
+
+static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
+{
+ struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
+ struct list_head *entries, *next;
+ char bus_name[ACPI_PATHNAME_MAX] = { 0 };
+ char action_name[ACPI_PATHNAME_MAX] = { 0 };
+ struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
+ struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
+
+ ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
+
+ if (!hotkey_list)
+ goto end;
+
+ list_for_each_safe(entries, next, hotkey_list->entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
+ acpi_get_name(key->event_hotkey.bus_handle,
+ ACPI_NAME_TYPE_MAX, &bus);
+ acpi_get_name(key->event_hotkey.action_handle,
+ ACPI_NAME_TYPE_MAX, &act);
+ seq_printf(seq, "%s:%s:%s:%d:%d", bus_name,
+ action_name,
+ key->event_hotkey.action_method,
+ key->link.hotkey_standard_num,
+ key->event_hotkey.external_hotkey_num);
+ } /* ACPI_HOTKEY_POLLING */
+ else {
+ acpi_get_name(key->poll_hotkey.poll_handle,
+ ACPI_NAME_TYPE_MAX, &bus);
+ acpi_get_name(key->poll_hotkey.action_handle,
+ ACPI_NAME_TYPE_MAX, &act);
+ seq_printf(seq, "%s:%s:%s:%s:%d", bus_name,
+ key->poll_hotkey.poll_method,
+ action_name,
+ key->poll_hotkey.action_method,
+ key->link.hotkey_standard_num);
+ }
+ }
+ seq_puts(seq, "\n");
+ end:
+ return_VALUE(0);
+}
+
+static int
+get_parms(char *config_record,
+ int *cmd,
+ char *bus_handle,
+ char *bus_method,
+ char *action_handle,
+ char *method, int *internal_event_num, int *external_event_num)
+{
+ char *tmp, *tmp1;
+ ACPI_FUNCTION_TRACE(("get_parms"));
+
+ sscanf(config_record, "%d", cmd);
+
+ tmp = strchr(config_record, ':');
+ tmp++;
+ tmp1 = strchr(tmp, ':');
+ strncpy(bus_handle, tmp, tmp1 - tmp);
+ bus_handle[tmp1 - tmp] = 0;
+
+ tmp = tmp1;
+ tmp++;
+ tmp1 = strchr(tmp, ':');
+ strncpy(bus_method, tmp, tmp1 - tmp);
+ bus_method[tmp1 - tmp] = 0;
+
+ tmp = tmp1;
+ tmp++;
+ tmp1 = strchr(tmp, ':');
+ strncpy(action_handle, tmp, tmp1 - tmp);
+ action_handle[tmp1 - tmp] = 0;
+
+ tmp = tmp1;
+ tmp++;
+ tmp1 = strchr(tmp, ':');
+ strncpy(method, tmp, tmp1 - tmp);
+ method[tmp1 - tmp] = 0;
+
+ sscanf(tmp1 + 1, "%d:%d", internal_event_num, external_event_num);
+ return_VALUE(6);
+}
+
+/* count is length for one input record */
+static ssize_t hotkey_write_config(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data)
+{
+ struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
+ char config_record[MAX_CONFIG_RECORD_LEN];
+ char bus_handle[MAX_NAME_PATH_LEN];
+ char bus_method[MAX_NAME_PATH_LEN];
+ char action_handle[MAX_NAME_PATH_LEN];
+ char method[20];
+ int cmd, internal_event_num, external_event_num;
+ int ret = 0;
+ union acpi_hotkey *key = NULL;
+
+ ACPI_FUNCTION_TRACE(("hotkey_write_config"));
+
+ if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n"));
+ return_VALUE(-EINVAL);
+ }
+
+ if (copy_from_user(config_record, buffer, count)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
+ return_VALUE(-EINVAL);
+ }
+ config_record[count] = '\0';
+
+ ret = get_parms(config_record,
+ &cmd,
+ bus_handle,
+ bus_method,
+ action_handle,
+ method, &internal_event_num, &external_event_num);
+ if (ret != 6) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Invalid data format ret=%d\n", ret));
+ return_VALUE(-EINVAL);
+ }
+
+ key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
+ ret = init_hotkey_device(key, bus_handle, action_handle, method,
+ internal_event_num, external_event_num);
+
+ if (ret || check_hotkey_valid(key, hotkey_list)) {
+ kfree(key);
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
+ return_VALUE(-EINVAL);
+ }
+ switch (cmd) {
+ case 0:
+ hotkey_add(key);
+ break;
+ case 1:
+ hotkey_remove(key);
+ free_hotkey_device(key);
+ break;
+ case 2:
+ hotkey_update(key);
+ break;
+ default:
+ break;
+ }
+ return_VALUE(count);
+}
+
+/* count is length for one input record */
+static ssize_t hotkey_write_poll_config(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data)
+{
+ struct seq_file *m = (struct seq_file *)file->private_data;
+ struct acpi_hotkey_list *hotkey_list =
+ (struct acpi_hotkey_list *)m->private;
+
+ char config_record[MAX_CONFIG_RECORD_LEN];
+ char polling_handle[MAX_NAME_PATH_LEN];
+ char action_handle[MAX_NAME_PATH_LEN];
+ char poll_method[20], action_method[20];
+ int ret, internal_event_num, cmd, external_event_num;
+ union acpi_hotkey *key = NULL;
+
+ ACPI_FUNCTION_TRACE("hotkey_write_poll_config");
+
+ if (!hotkey_list || count > MAX_CONFIG_RECORD_LEN) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid arguments\n"));
+ return_VALUE(-EINVAL);
+ }
+
+ if (copy_from_user(config_record, buffer, count)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n"));
+ return_VALUE(-EINVAL);
+ }
+ config_record[count] = '\0';
+
+ ret = get_parms(config_record,
+ &cmd,
+ polling_handle,
+ poll_method,
+ action_handle,
+ action_method,
+ &internal_event_num, &external_event_num);
+
+ if (ret != 6) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
+ return_VALUE(-EINVAL);
+ }
+
+ key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
+ ret = init_poll_hotkey_device(key, polling_handle, poll_method,
+ action_handle, action_method,
+ internal_event_num);
+ if (ret || check_hotkey_valid(key, hotkey_list)) {
+ kfree(key);
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n"));
+ return_VALUE(-EINVAL);
+ }
+ switch (cmd) {
+ case 0:
+ hotkey_add(key);
+ break;
+ case 1:
+ hotkey_remove(key);
+ break;
+ case 2:
+ hotkey_update(key);
+ break;
+ default:
+ break;
+ }
+ return_VALUE(count);
+}
+
+/*
+ * This function evaluates an ACPI method, given an int as parameter, the
+ * method is searched within the scope of the handle, can be NULL. The output
+ * of the method is written is output, which can also be NULL
+ *
+ * returns 1 if write is successful, 0 else.
+ */
+static int write_acpi_int(acpi_handle handle, const char *method, int val,
+ struct acpi_buffer *output)
+{
+ struct acpi_object_list params; /* list of input parameters (an int here) */
+ union acpi_object in_obj; /* the only param we use */
+ acpi_status status;
+
+ ACPI_FUNCTION_TRACE("write_acpi_int");
+ params.count = 1;
+ params.pointer = &in_obj;
+ in_obj.type = ACPI_TYPE_INTEGER;
+ in_obj.integer.value = val;
+
+ status = acpi_evaluate_object(handle, (char *)method, &params, output);
+
+ return_VALUE(status == AE_OK);
+}
+
+static int read_acpi_int(acpi_handle handle, const char *method, int *val)
+{
+ struct acpi_buffer output;
+ union acpi_object out_obj;
+ acpi_status status;
+
+ ACPI_FUNCTION_TRACE("read_acpi_int");
+ output.length = sizeof(out_obj);
+ output.pointer = &out_obj;
+
+ status = acpi_evaluate_object(handle, (char *)method, NULL, &output);
+ *val = out_obj.integer.value;
+ return_VALUE((status == AE_OK)
+ && (out_obj.type == ACPI_TYPE_INTEGER));
+}
+
+static acpi_handle
+get_handle_from_hotkeylist(struct acpi_hotkey_list *hotkey_list, int event_num)
+{
+ struct list_head *entries, *next;
+
+ list_for_each_safe(entries, next, hotkey_list->entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_type == ACPI_HOTKEY_EVENT
+ && key->link.hotkey_standard_num == event_num) {
+ return (key->event_hotkey.action_handle);
+ }
+ }
+ return (NULL);
+}
+
+static
+char *get_method_from_hotkeylist(struct acpi_hotkey_list *hotkey_list,
+ int event_num)
+{
+ struct list_head *entries, *next;
+
+ list_for_each_safe(entries, next, hotkey_list->entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+
+ if (key->link.hotkey_type == ACPI_HOTKEY_EVENT &&
+ key->link.hotkey_standard_num == event_num)
+ return (key->event_hotkey.action_method);
+ }
+ return (NULL);
+}
+
+static struct acpi_polling_hotkey *get_hotkey_by_event(struct
+ acpi_hotkey_list
+ *hotkey_list, int event)
+{
+ struct list_head *entries, *next;
+
+ list_for_each_safe(entries, next, hotkey_list->entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+ if (key->link.hotkey_type == ACPI_HOTKEY_POLLING
+ && key->link.hotkey_standard_num == event) {
+ return (&key->poll_hotkey);
+ }
+ }
+ return (NULL);
+}
+
+/*
+ * user call AML method interface:
+ * Call convention:
+ * echo "event_num: arg type : value"
+ * example: echo "1:1:30" > /proc/acpi/action
+ * Just support 1 integer arg passing to AML method
+ */
+
+static ssize_t hotkey_execute_aml_method(struct file *file,
+ const char __user * buffer,
+ size_t count, loff_t * data)
+{
+ struct acpi_hotkey_list *hotkey_list = &global_hotkey_list;
+ char arg[MAX_CALL_PARM];
+ int event, type, value;
+
+ char *method;
+ acpi_handle handle;
+
+ ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
+
+ if (!hotkey_list || count > MAX_CALL_PARM) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 1"));
+ return_VALUE(-EINVAL);
+ }
+
+ if (copy_from_user(arg, buffer, count)) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2"));
+ return_VALUE(-EINVAL);
+ }
+
+ arg[count] = '\0';
+
+ if (sscanf(arg, "%d:%d:%d", &event, &type, &value) != 3) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3"));
+ return_VALUE(-EINVAL);
+ }
+
+ if (type == ACPI_TYPE_INTEGER) {
+ handle = get_handle_from_hotkeylist(hotkey_list, event);
+ method = (char *)get_method_from_hotkeylist(hotkey_list, event);
+ if (IS_EVENT(event))
+ write_acpi_int(handle, method, value, NULL);
+ else if (IS_POLL(event)) {
+ struct acpi_polling_hotkey *key;
+ key = (struct acpi_polling_hotkey *)
+ get_hotkey_by_event(hotkey_list, event);
+ read_acpi_int(handle, method, key->poll_result);
+ }
+ } else {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported"));
+ return_VALUE(-EINVAL);
+ }
+
+ return_VALUE(count);
+}
+
+static int __init hotkey_init(void)
+{
+ int result;
+ mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
+
+ ACPI_FUNCTION_TRACE("hotkey_init");
+
+ if (acpi_disabled)
+ return -ENODEV;
+
+ if (acpi_specific_hotkey_enabled) {
+ printk("Using specific hotkey driver\n");
+ return -ENODEV;
+ }
+
+ hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir);
+ if (!hotkey_proc_dir) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ HOTKEY_PROC));
+ return (-ENODEV);
+ }
+ hotkey_proc_dir->owner = THIS_MODULE;
+
+ hotkey_config =
+ create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir);
+ if (!hotkey_config) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ HOTKEY_EV_CONFIG));
+ return (-ENODEV);
+ } else {
+ hotkey_config->proc_fops = &hotkey_config_fops;
+ hotkey_config->data = &global_hotkey_list;
+ hotkey_config->owner = THIS_MODULE;
+ hotkey_config->uid = 0;
+ hotkey_config->gid = 0;
+ }
+
+ hotkey_poll_config =
+ create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir);
+ if (!hotkey_poll_config) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ HOTKEY_EV_CONFIG));
+ return (-ENODEV);
+ } else {
+ hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
+ hotkey_poll_config->data = &global_hotkey_list;
+ hotkey_poll_config->owner = THIS_MODULE;
+ hotkey_poll_config->uid = 0;
+ hotkey_poll_config->gid = 0;
+ }
+
+ hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir);
+ if (!hotkey_action) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ HOTKEY_ACTION));
+ return (-ENODEV);
+ } else {
+ hotkey_action->proc_fops = &hotkey_action_fops;
+ hotkey_action->owner = THIS_MODULE;
+ hotkey_action->uid = 0;
+ hotkey_action->gid = 0;
+ }
+
+ hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir);
+ if (!hotkey_info) {
+ ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+ "Hotkey: Unable to create %s entry\n",
+ HOTKEY_INFO));
+ return (-ENODEV);
+ } else {
+ hotkey_info->proc_fops = &hotkey_info_fops;
+ hotkey_info->owner = THIS_MODULE;
+ hotkey_info->uid = 0;
+ hotkey_info->gid = 0;
+ }
+
+ result = acpi_bus_register_driver(&hotkey_driver);
+ if (result < 0) {
+ remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
+ return (-ENODEV);
+ }
+ global_hotkey_list.count = 0;
+ global_hotkey_list.entries = &hotkey_entries;
+
+ INIT_LIST_HEAD(&hotkey_entries);
+
+ return (0);
+}
+
+static void __exit hotkey_exit(void)
+{
+ struct list_head *entries, *next;
+
+ ACPI_FUNCTION_TRACE("hotkey_remove");
+
+ list_for_each_safe(entries, next, global_hotkey_list.entries) {
+ union acpi_hotkey *key =
+ container_of(entries, union acpi_hotkey, entries);
+
+ acpi_os_wait_events_complete(NULL);
+ list_del(&key->link.entries);
+ global_hotkey_list.count--;
+ free_hotkey_device(key);
+ }
+ acpi_bus_unregister_driver(&hotkey_driver);
+ remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir);
+ remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir);
+ remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir);
+ remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir);
+ remove_proc_entry(HOTKEY_PROC, acpi_root_dir);
+ return;
+}
+
+module_init(hotkey_init);
+module_exit(hotkey_exit);
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 0fb731a470d..ad85e10001f 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1025,7 +1025,7 @@ static int setup_notify(struct ibm_struct *ibm)
return 0;
}
-static int device_add(struct acpi_device *device)
+static int ibmacpi_device_add(struct acpi_device *device)
{
return 0;
}
@@ -1043,7 +1043,7 @@ static int register_driver(struct ibm_struct *ibm)
memset(ibm->driver, 0, sizeof(struct acpi_driver));
sprintf(ibm->driver->name, "%s/%s", IBM_NAME, ibm->name);
ibm->driver->ids = ibm->hid;
- ibm->driver->ops.add = &device_add;
+ ibm->driver->ops.add = &ibmacpi_device_add;
ret = acpi_bus_register_driver(ibm->driver);
if (ret < 0) {
@@ -1185,6 +1185,10 @@ static int __init acpi_ibm_init(void)
if (acpi_disabled)
return -ENODEV;
+ if (!acpi_specific_hotkey_enabled){
+ printk(IBM_ERR "Using generic hotkey driver\n");
+ return -ENODEV;
+ }
/* these handles are required */
if (IBM_HANDLE_INIT(ec, 1) < 0 ||
IBM_HANDLE_INIT(hkey, 1) < 0 ||
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index 1c0c12336c5..ece7a9dedd5 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -67,7 +67,8 @@
******************************************************************************/
acpi_status
-acpi_ns_root_initialize (void)
+acpi_ns_root_initialize (
+ void)
{
acpi_status status;
const struct acpi_predefined_names *init_val = NULL;
@@ -265,7 +266,7 @@ unlock_and_exit:
*
* FUNCTION: acpi_ns_lookup
*
- * PARAMETERS: prefix_node - Search scope if name is not fully qualified
+ * PARAMETERS: scope_info - Current scope info block
* Pathname - Search pathname, in internal format
* (as represented in the AML stream)
* Type - Type associated with name
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c
index bfd922c5c7d..5653a19d717 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/namespace/nsalloc.c
@@ -49,14 +49,20 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsalloc")
+/* Local prototypes */
+
+static void
+acpi_ns_remove_reference (
+ struct acpi_namespace_node *node);
+
/*******************************************************************************
*
* FUNCTION: acpi_ns_create_node
*
- * PARAMETERS: acpi_name - Name of the new node
+ * PARAMETERS: Name - Name of the new node (4 char ACPI name)
*
- * RETURN: None
+ * RETURN: New namespace node (Null on failure)
*
* DESCRIPTION: Create a namespace node
*
@@ -145,7 +151,6 @@ acpi_ns_delete_node (
}
}
-
ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].total_freed++);
/*
@@ -157,57 +162,6 @@ acpi_ns_delete_node (
}
-#ifdef ACPI_ALPHABETIC_NAMESPACE
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_compare_names
- *
- * PARAMETERS: Name1 - First name to compare
- * Name2 - Second name to compare
- *
- * RETURN: value from strncmp
- *
- * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
- * underscore are forced to be alphabetically first.
- *
- ******************************************************************************/
-
-int
-acpi_ns_compare_names (
- char *name1,
- char *name2)
-{
- char reversed_name1[ACPI_NAME_SIZE];
- char reversed_name2[ACPI_NAME_SIZE];
- u32 i;
- u32 j;
-
-
- /*
- * Replace all instances of "underscore" with a value that is smaller so
- * that all names that are prefixed with underscore(s) are alphabetically
- * first.
- *
- * Reverse the name bytewise so we can just do a 32-bit compare instead
- * of a strncmp.
- */
- for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
- reversed_name1[j] = name1[i];
- if (name1[i] == '_') {
- reversed_name1[j] = '*';
- }
-
- reversed_name2[j] = name2[i];
- if (name2[i] == '_') {
- reversed_name2[j] = '*';
- }
- }
-
- return (*(int *) reversed_name1 - *(int *) reversed_name2);
-}
-#endif
-
-
/*******************************************************************************
*
* FUNCTION: acpi_ns_install_node
@@ -271,7 +225,8 @@ acpi_ns_install_node (
* alphabetic placement.
*/
previous_child_node = NULL;
- while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node), acpi_ut_get_node_name (node)) < 0) {
+ while (acpi_ns_compare_names (acpi_ut_get_node_name (child_node),
+ acpi_ut_get_node_name (node)) < 0) {
if (child_node->flags & ANOBJ_END_OF_PEER_LIST) {
/* Last peer; Clear end-of-list flag */
@@ -429,7 +384,8 @@ acpi_ns_delete_children (
/* There should be only one reference remaining on this node */
if (child_node->reference_count != 1) {
- ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n",
+ ACPI_REPORT_WARNING ((
+ "Existing references (%d) on node being deleted (%p)\n",
child_node->reference_count, child_node));
}
@@ -548,7 +504,7 @@ acpi_ns_delete_namespace_subtree (
*
******************************************************************************/
-void
+static void
acpi_ns_remove_reference (
struct acpi_namespace_node *node)
{
@@ -683,3 +639,54 @@ acpi_ns_delete_namespace_by_owner (
}
+#ifdef ACPI_ALPHABETIC_NAMESPACE
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ns_compare_names
+ *
+ * PARAMETERS: Name1 - First name to compare
+ * Name2 - Second name to compare
+ *
+ * RETURN: value from strncmp
+ *
+ * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an
+ * underscore are forced to be alphabetically first.
+ *
+ ******************************************************************************/
+
+int
+acpi_ns_compare_names (
+ char *name1,
+ char *name2)
+{
+ char reversed_name1[ACPI_NAME_SIZE];
+ char reversed_name2[ACPI_NAME_SIZE];
+ u32 i;
+ u32 j;
+
+
+ /*
+ * Replace all instances of "underscore" with a value that is smaller so
+ * that all names that are prefixed with underscore(s) are alphabetically
+ * first.
+ *
+ * Reverse the name bytewise so we can just do a 32-bit compare instead
+ * of a strncmp.
+ */
+ for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) {
+ reversed_name1[j] = name1[i];
+ if (name1[i] == '_') {
+ reversed_name1[j] = '*';
+ }
+
+ reversed_name2[j] = name2[i];
+ if (name2[i] == '_') {
+ reversed_name2[j] = '*';
+ }
+ }
+
+ return (*(int *) reversed_name1 - *(int *) reversed_name2);
+}
+#endif
+
+
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 1f6af3eb6c9..6c2aef0e0dd 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -50,16 +50,32 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsdump")
+/* Local prototypes */
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+void
+acpi_ns_dump_root_devices (
+ void);
+static acpi_status
+acpi_ns_dump_one_device (
+ acpi_handle obj_handle,
+ u32 level,
+ void *context,
+ void **return_value);
+#endif
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*******************************************************************************
*
* FUNCTION: acpi_ns_print_pathname
*
- * PARAMETERS: num_segment - Number of ACPI name segments
+ * PARAMETERS: num_segments - Number of ACPI name segments
* Pathname - The compressed (internal) path
*
+ * RETURN: None
+ *
* DESCRIPTION: Print an object's full namespace pathname
*
******************************************************************************/
@@ -103,6 +119,8 @@ acpi_ns_print_pathname (
* Level - Desired debug level
* Component - Caller's component ID
*
+ * RETURN: None
+ *
* DESCRIPTION: Print an object's full namespace pathname
* Manages allocation/freeing of a pathname buffer
*
@@ -137,9 +155,12 @@ acpi_ns_dump_pathname (
*
* FUNCTION: acpi_ns_dump_one_object
*
- * PARAMETERS: Handle - Node to be dumped
+ * PARAMETERS: obj_handle - Node to be dumped
* Level - Nesting level of the handle
* Context - Passed into walk_namespace
+ * return_value - Not used
+ *
+ * RETURN: Status
*
* DESCRIPTION: Dump a single Node
* This procedure is a user_function called by acpi_ns_walk_namespace.
@@ -394,8 +415,7 @@ acpi_ns_dump_one_object (
return (AE_OK);
}
- acpi_os_printf ("(R%d)",
- obj_desc->common.reference_count);
+ acpi_os_printf ("(R%d)", obj_desc->common.reference_count);
switch (type) {
case ACPI_TYPE_METHOD:
@@ -551,18 +571,20 @@ cleanup:
#ifdef ACPI_FUTURE_USAGE
-
/*******************************************************************************
*
* FUNCTION: acpi_ns_dump_objects
*
* PARAMETERS: Type - Object type to be dumped
+ * display_type - 0 or ACPI_DISPLAY_SUMMARY
* max_depth - Maximum depth of dump. Use ACPI_UINT32_MAX
* for an effectively unlimited depth.
* owner_id - Dump only objects owned by this ID. Use
* ACPI_UINT32_MAX to match all owners.
* start_handle - Where in namespace to start/end search
*
+ * RETURN: None
+ *
* DESCRIPTION: Dump typed objects within the loaded namespace.
* Uses acpi_ns_walk_namespace in conjunction with acpi_ns_dump_one_object.
*
@@ -590,10 +612,44 @@ acpi_ns_dump_objects (
ACPI_NS_WALK_NO_UNLOCK, acpi_ns_dump_one_object,
(void *) &info, NULL);
}
+#endif /* ACPI_FUTURE_USAGE */
/*******************************************************************************
*
+ * FUNCTION: acpi_ns_dump_entry
+ *
+ * PARAMETERS: Handle - Node to be dumped
+ * debug_level - Output level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump a single Node
+ *
+ ******************************************************************************/
+
+void
+acpi_ns_dump_entry (
+ acpi_handle handle,
+ u32 debug_level)
+{
+ struct acpi_walk_info info;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ info.debug_level = debug_level;
+ info.owner_id = ACPI_UINT32_MAX;
+ info.display_type = ACPI_DISPLAY_SUMMARY;
+
+ (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
+}
+
+
+#ifdef _ACPI_ASL_COMPILER
+/*******************************************************************************
+ *
* FUNCTION: acpi_ns_dump_tables
*
* PARAMETERS: search_base - Root of subtree to be dumped, or
@@ -601,6 +657,8 @@ acpi_ns_dump_objects (
* max_depth - Maximum depth of dump. Use INT_MAX
* for an effectively unlimited depth.
*
+ * RETURN: None
+ *
* DESCRIPTION: Dump the name space, or a portion of it.
*
******************************************************************************/
@@ -626,7 +684,7 @@ acpi_ns_dump_tables (
}
if (ACPI_NS_ALL == search_base) {
- /* entire namespace */
+ /* Entire namespace */
search_handle = acpi_gbl_root_node;
ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
@@ -636,38 +694,5 @@ acpi_ns_dump_tables (
ACPI_UINT32_MAX, search_handle);
return_VOID;
}
-
-#endif /* ACPI_FUTURE_USAGE */
-
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ns_dump_entry
- *
- * PARAMETERS: Handle - Node to be dumped
- * debug_level - Output level
- *
- * DESCRIPTION: Dump a single Node
- *
- ******************************************************************************/
-
-void
-acpi_ns_dump_entry (
- acpi_handle handle,
- u32 debug_level)
-{
- struct acpi_walk_info info;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- info.debug_level = debug_level;
- info.owner_id = ACPI_UINT32_MAX;
- info.display_type = ACPI_DISPLAY_SUMMARY;
-
- (void) acpi_ns_dump_one_object (handle, 1, &info, NULL);
-}
-
-#endif
-
+#endif /* _ACPI_ASL_COMPILER */
+#endif /* defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) */
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/namespace/nsdumpdv.c
index d30a59e6b07..27c4f7cd2a4 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/namespace/nsdumpdv.c
@@ -43,15 +43,18 @@
#include <acpi/acpi.h>
-#include <acpi/acnamesp.h>
+/* TBD: This entire module is apparently obsolete and should be removed */
+
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsdumpdv")
-
+#ifdef ACPI_OBSOLETE_FUNCTIONS
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+#include <acpi/acnamesp.h>
+
/*******************************************************************************
*
* FUNCTION: acpi_ns_dump_one_device
@@ -59,13 +62,16 @@
* PARAMETERS: Handle - Node to be dumped
* Level - Nesting level of the handle
* Context - Passed into walk_namespace
+ * return_value - Not used
+ *
+ * RETURN: Status
*
* DESCRIPTION: Dump a single Node that represents a device
* This procedure is a user_function called by acpi_ns_walk_namespace.
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_dump_one_device (
acpi_handle obj_handle,
u32 level,
@@ -108,12 +114,15 @@ acpi_ns_dump_one_device (
*
* PARAMETERS: None
*
+ * RETURN: None
+ *
* DESCRIPTION: Dump all objects of type "device"
*
******************************************************************************/
void
-acpi_ns_dump_root_devices (void)
+acpi_ns_dump_root_devices (
+ void)
{
acpi_handle sys_bus_handle;
acpi_status status;
@@ -142,5 +151,6 @@ acpi_ns_dump_root_devices (void)
}
#endif
+#endif
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 0d008d53657..1ae89a1c882 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -52,19 +52,33 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nseval")
+/* Local prototypes */
+
+static acpi_status
+acpi_ns_execute_control_method (
+ struct acpi_parameter_info *info);
+
+static acpi_status
+acpi_ns_get_object_value (
+ struct acpi_parameter_info *info);
+
/*******************************************************************************
*
* FUNCTION: acpi_ns_evaluate_relative
*
- * PARAMETERS: Pathname - Name of method to execute, If NULL, the
- * handle is the object to execute
- * Info - Method info block
+ * PARAMETERS: Pathname - Name of method to execute, If NULL, the
+ * handle is the object to execute
+ * Info - Method info block, contains:
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * Params - List of parameters to pass to the method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
*
* RETURN: Status
*
- * DESCRIPTION: Find and execute the requested method using the handle as a
- * scope
+ * DESCRIPTION: Evaluate the object or find and execute the requested method
*
* MUTEX: Locks Namespace
*
@@ -157,8 +171,8 @@ cleanup1:
*
* FUNCTION: acpi_ns_evaluate_by_name
*
- * PARAMETERS: Pathname - Fully qualified pathname to the object
- * Info - Contains:
+ * PARAMETERS: Pathname - Fully qualified pathname to the object
+ * Info - Method info block, contains:
* return_object - Where to put method's return value (if
* any). If NULL, no value is returned.
* Params - List of parameters to pass to the method,
@@ -167,8 +181,8 @@ cleanup1:
*
* RETURN: Status
*
- * DESCRIPTION: Find and execute the requested method passing the given
- * parameters
+ * DESCRIPTION: Evaluate the object or rind and execute the requested method
+ * passing the given parameters
*
* MUTEX: Locks Namespace
*
@@ -241,17 +255,21 @@ cleanup:
*
* FUNCTION: acpi_ns_evaluate_by_handle
*
- * PARAMETERS: Handle - Method Node to execute
- * Params - List of parameters to pass to the method,
- * terminated by NULL. Params itself may be
+ * PARAMETERS: Info - Method info block, contains:
+ * Node - Method/Object Node to execute
+ * Parameters - List of parameters to pass to the method,
+ * terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
- * param_type - Type of Parameter list
- * return_object - Where to put method's return value (if
- * any). If NULL, no value is returned.
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * parameter_type - Type of Parameter list
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
*
* RETURN: Status
*
- * DESCRIPTION: Execute the requested method passing the given parameters
+ * DESCRIPTION: Evaluate object or execute the requested method passing the
+ * given parameters
*
* MUTEX: Locks Namespace
*
@@ -345,7 +363,16 @@ acpi_ns_evaluate_by_handle (
*
* FUNCTION: acpi_ns_execute_control_method
*
- * PARAMETERS: Info - Method info block (w/params)
+ * PARAMETERS: Info - Method info block, contains:
+ * Node - Method Node to execute
+ * Parameters - List of parameters to pass to the method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * parameter_type - Type of Parameter list
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
*
* RETURN: Status
*
@@ -355,7 +382,7 @@ acpi_ns_evaluate_by_handle (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_execute_control_method (
struct acpi_parameter_info *info)
{
@@ -414,7 +441,10 @@ acpi_ns_execute_control_method (
*
* FUNCTION: acpi_ns_get_object_value
*
- * PARAMETERS: Info - Method info block (w/params)
+ * PARAMETERS: Info - Method info block, contains:
+ * Node - Object's NS node
+ * return_object - Where to put object value (if
+ * any). If NULL, no value is returned.
*
* RETURN: Status
*
@@ -424,7 +454,7 @@ acpi_ns_execute_control_method (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_get_object_value (
struct acpi_parameter_info *info)
{
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 4a46b380605..362802ae29a 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -50,6 +50,22 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsinit")
+/* Local prototypes */
+
+static acpi_status
+acpi_ns_init_one_object (
+ acpi_handle obj_handle,
+ u32 level,
+ void *context,
+ void **return_value);
+
+static acpi_status
+acpi_ns_init_one_device (
+ acpi_handle obj_handle,
+ u32 nesting_level,
+ void *context,
+ void **return_value);
+
/*******************************************************************************
*
@@ -191,7 +207,7 @@ acpi_ns_initialize_devices (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_init_one_object (
acpi_handle obj_handle,
u32 level,
@@ -331,7 +347,7 @@ acpi_ns_init_one_object (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_init_one_device (
acpi_handle obj_handle,
u32 nesting_level,
@@ -374,7 +390,8 @@ acpi_ns_init_one_device (
/*
* Run _STA to determine if we can run _INI on the device.
*/
- ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_STA"));
+ ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD,
+ pinfo.node, METHOD_NAME__STA));
status = acpi_ut_execute_STA (pinfo.node, &flags);
if (ACPI_FAILURE (status)) {
@@ -399,8 +416,9 @@ acpi_ns_init_one_device (
/*
* The device is present. Run _INI.
*/
- ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, pinfo.node, "_INI"));
- status = acpi_ns_evaluate_relative ("_INI", &pinfo);
+ ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD,
+ pinfo.node, METHOD_NAME__INI));
+ status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo);
if (ACPI_FAILURE (status)) {
/* No _INI (AE_NOT_FOUND) means device requires no initialization */
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c
index 1d7aedf68a7..34e49701660 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/namespace/nsload.c
@@ -50,9 +50,24 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsload")
+/* Local prototypes */
-#ifndef ACPI_NO_METHOD_EXECUTION
+static acpi_status
+acpi_ns_load_table_by_type (
+ acpi_table_type table_type);
+
+#ifdef ACPI_FUTURE_IMPLEMENTATION
+acpi_status
+acpi_ns_unload_namespace (
+ acpi_handle handle);
+
+static acpi_status
+acpi_ns_delete_subtree (
+ acpi_handle start_handle);
+#endif
+
+#ifndef ACPI_NO_METHOD_EXECUTION
/*******************************************************************************
*
* FUNCTION: acpi_ns_load_table
@@ -159,7 +174,7 @@ acpi_ns_load_table (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_load_table_by_type (
acpi_table_type table_type)
{
@@ -321,8 +336,7 @@ acpi_ns_load_namespace (
}
-#ifdef ACPI_FUTURE_USAGE
-
+#ifdef ACPI_FUTURE_IMPLEMENTATION
/*******************************************************************************
*
* FUNCTION: acpi_ns_delete_subtree
@@ -339,7 +353,7 @@ acpi_ns_load_namespace (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ns_delete_subtree (
acpi_handle start_handle)
{
@@ -453,8 +467,6 @@ acpi_ns_unload_namespace (
return_ACPI_STATUS (status);
}
-
-#endif /* ACPI_FUTURE_USAGE */
-
+#endif
#endif
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index b6f8f910eff..d8ce7e39795 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -50,6 +50,14 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsnames")
+/* Local prototypes */
+
+static void
+acpi_ns_build_external_path (
+ struct acpi_namespace_node *node,
+ acpi_size size,
+ char *name_buffer);
+
/*******************************************************************************
*
@@ -66,7 +74,7 @@
*
******************************************************************************/
-void
+static void
acpi_ns_build_external_path (
struct acpi_namespace_node *node,
acpi_size size,
@@ -126,7 +134,7 @@ acpi_ns_build_external_path (
*
* FUNCTION: acpi_ns_get_external_pathname
*
- * PARAMETERS: Node - NS node whose pathname is needed
+ * PARAMETERS: Node - Namespace node whose pathname is needed
*
* RETURN: Pointer to storage containing the fully qualified name of
* the node, In external format (name segments separated by path
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/namespace/nsobject.c
index 4e41e66db61..27258c1ca4f 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/namespace/nsobject.c
@@ -60,6 +60,8 @@
* Type - Type of object, or ACPI_TYPE_ANY if not
* known
*
+ * RETURN: Status
+ *
* DESCRIPTION: Record the given object as the value associated with the
* name whose acpi_handle is passed. If Object is NULL
* and Type is ACPI_TYPE_ANY, set the name as having no value.
@@ -97,7 +99,8 @@ acpi_ns_attach_object (
if (!object && (ACPI_TYPE_ANY != type)) {
/* Null object */
- ACPI_REPORT_ERROR (("ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
+ ACPI_REPORT_ERROR ((
+ "ns_attach_object: Null object, but type not ACPI_TYPE_ANY\n"));
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
@@ -112,7 +115,8 @@ acpi_ns_attach_object (
/* Check if this object is already attached */
if (node->object == object) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in name_obj %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj %p already installed in name_obj %p\n",
object, node));
return_ACPI_STATUS (AE_OK);
@@ -192,7 +196,7 @@ acpi_ns_attach_object (
*
* FUNCTION: acpi_ns_detach_object
*
- * PARAMETERS: Node - An node whose object will be detached
+ * PARAMETERS: Node - A Namespace node whose object will be detached
*
* RETURN: None.
*
@@ -248,7 +252,7 @@ acpi_ns_detach_object (
*
* FUNCTION: acpi_ns_get_attached_object
*
- * PARAMETERS: Node - Parent Node to be examined
+ * PARAMETERS: Node - Namespace node
*
* RETURN: Current value of the object field from the Node whose
* handle is passed
@@ -284,7 +288,7 @@ acpi_ns_get_attached_object (
*
* FUNCTION: acpi_ns_get_secondary_object
*
- * PARAMETERS: Node - Parent Node to be examined
+ * PARAMETERS: Node - Namespace node
*
* RETURN: Current value of the object field from the Node whose
* handle is passed.
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 0e6dea23603..af8aaa9cc4f 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -49,15 +49,24 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nssearch")
+/* Local prototypes */
+
+static acpi_status
+acpi_ns_search_parent_tree (
+ u32 target_name,
+ struct acpi_namespace_node *node,
+ acpi_object_type type,
+ struct acpi_namespace_node **return_node);
+
/*******************************************************************************
*
* FUNCTION: acpi_ns_search_node
*
- * PARAMETERS: *target_name - Ascii ACPI name to search for
- * *Node - Starting node where search will begin
- * Type - Object type to match
- * **return_node - Where the matched Named obj is returned
+ * PARAMETERS: target_name - Ascii ACPI name to search for
+ * Node - Starting node where search will begin
+ * Type - Object type to match
+ * return_node - Where the matched Named obj is returned
*
* RETURN: Status
*
@@ -163,10 +172,10 @@ acpi_ns_search_node (
*
* FUNCTION: acpi_ns_search_parent_tree
*
- * PARAMETERS: *target_name - Ascii ACPI name to search for
- * *Node - Starting node where search will begin
- * Type - Object type to match
- * **return_node - Where the matched Node is returned
+ * PARAMETERS: target_name - Ascii ACPI name to search for
+ * Node - Starting node where search will begin
+ * Type - Object type to match
+ * return_node - Where the matched Node is returned
*
* RETURN: Status
*
@@ -257,12 +266,12 @@ acpi_ns_search_parent_tree (
*
* PARAMETERS: target_name - Ascii ACPI name to search for (4 chars)
* walk_state - Current state of the walk
- * *Node - Starting node where search will begin
+ * Node - Starting node where search will begin
* interpreter_mode - Add names only in ACPI_MODE_LOAD_PASS_x.
* Otherwise,search only.
* Type - Object type to match
* Flags - Flags describing the search restrictions
- * **return_node - Where the Node is returned
+ * return_node - Where the Node is returned
*
* RETURN: Status
*
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/namespace/nsutils.c
index 75da76cc0b1..c53b82e94ce 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/namespace/nsutils.c
@@ -51,6 +51,18 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nsutils")
+/* Local prototypes */
+
+static u8
+acpi_ns_valid_path_separator (
+ char sep);
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+acpi_name
+acpi_ns_find_parent_name (
+ struct acpi_namespace_node *node_to_search);
+#endif
+
/*******************************************************************************
*
@@ -59,7 +71,8 @@
* PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output)
* component_id - Caller's component ID (for error output)
- * Message - Error message to use on failure
+ * internal_name - Name or path of the namespace node
+ * lookup_status - Exception code from NS lookup
*
* RETURN: None
*
@@ -121,6 +134,9 @@ acpi_ns_report_error (
* line_number - Caller's line number (for error output)
* component_id - Caller's component ID (for error output)
* Message - Error message to use on failure
+ * prefix_node - Prefix relative to the path
+ * Path - Path to the node
+ * method_status - Execution status
*
* RETURN: None
*
@@ -161,8 +177,8 @@ acpi_ns_report_method_error (
*
* FUNCTION: acpi_ns_print_node_pathname
*
- * PARAMETERS: Node - Object
- * Msg - Prefix message
+ * PARAMETERS: Node - Object
+ * Message - Prefix message
*
* DESCRIPTION: Print an object's full namespace pathname
* Manages allocation/freeing of a pathname buffer
@@ -172,7 +188,7 @@ acpi_ns_report_method_error (
void
acpi_ns_print_node_pathname (
struct acpi_namespace_node *node,
- char *msg)
+ char *message)
{
struct acpi_buffer buffer;
acpi_status status;
@@ -189,8 +205,8 @@ acpi_ns_print_node_pathname (
status = acpi_ns_handle_to_pathname (node, &buffer);
if (ACPI_SUCCESS (status)) {
- if (msg) {
- acpi_os_printf ("%s ", msg);
+ if (message) {
+ acpi_os_printf ("%s ", message);
}
acpi_os_printf ("[%s] (Node %p)", (char *) buffer.pointer, node);
@@ -224,7 +240,7 @@ acpi_ns_valid_root_prefix (
*
* FUNCTION: acpi_ns_valid_path_separator
*
- * PARAMETERS: Sep - Character to be checked
+ * PARAMETERS: Sep - Character to be checked
*
* RETURN: TRUE if a valid path separator
*
@@ -232,7 +248,7 @@ acpi_ns_valid_root_prefix (
*
******************************************************************************/
-u8
+static u8
acpi_ns_valid_path_separator (
char sep)
{
@@ -245,10 +261,12 @@ acpi_ns_valid_path_separator (
*
* FUNCTION: acpi_ns_get_type
*
- * PARAMETERS: Handle - Parent Node to be examined
+ * PARAMETERS: Node - Parent Node to be examined
*
* RETURN: Type field from Node whose handle is passed
*
+ * DESCRIPTION: Return the type of a Namespace node
+ *
******************************************************************************/
acpi_object_type
@@ -271,11 +289,13 @@ acpi_ns_get_type (
*
* FUNCTION: acpi_ns_local
*
- * PARAMETERS: Type - A namespace object type
+ * PARAMETERS: Type - A namespace object type
*
* RETURN: LOCAL if names must be found locally in objects of the
* passed type, 0 if enclosing scopes should be searched
*
+ * DESCRIPTION: Returns scope rule for the given object type.
+ *
******************************************************************************/
u32
@@ -303,7 +323,7 @@ acpi_ns_local (
* PARAMETERS: Info - Info struct initialized with the
* external name pointer.
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Calculate the length of the internal (AML) namestring
* corresponding to the external (ASL) namestring.
@@ -551,14 +571,16 @@ acpi_ns_internalize_name (
*
* FUNCTION: acpi_ns_externalize_name
*
- * PARAMETERS: *internal_name - Internal representation of name
- * **converted_name - Where to return the resulting
- * external representation of name
+ * PARAMETERS: internal_name_length - Lenth of the internal name below
+ * internal_name - Internal representation of name
+ * converted_name_length - Where the length is returned
+ * converted_name - Where the resulting external name
+ * is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30)
- * to its external form (e.g. "\_PR_.CPU0")
+ * to its external (printable) form (e.g. "\_PR_.CPU0")
*
******************************************************************************/
@@ -717,8 +739,9 @@ acpi_ns_externalize_name (
*
* DESCRIPTION: Convert a namespace handle to a real Node
*
- * Note: Real integer handles allow for more verification
- * and keep all pointers within this subsystem.
+ * Note: Real integer handles would allow for more verification
+ * and keep all pointers within this subsystem - however this introduces
+ * more (and perhaps unnecessary) overhead.
*
******************************************************************************/
@@ -775,7 +798,7 @@ acpi_ns_convert_entry_to_handle (
return ((acpi_handle) node);
-/* ---------------------------------------------------
+/* Example future implementation ---------------------
if (!Node)
{
@@ -801,12 +824,13 @@ acpi_ns_convert_entry_to_handle (
*
* RETURN: none
*
- * DESCRIPTION: free memory allocated for table storage.
+ * DESCRIPTION: free memory allocated for namespace and ACPI table storage.
*
******************************************************************************/
void
-acpi_ns_terminate (void)
+acpi_ns_terminate (
+ void)
{
union acpi_operand_object *obj_desc;
@@ -940,7 +964,6 @@ acpi_ns_get_node_by_path (
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
cleanup:
- /* Cleanup */
if (internal_path) {
ACPI_MEM_FREE (internal_path);
}
@@ -950,55 +973,6 @@ cleanup:
/*******************************************************************************
*
- * FUNCTION: acpi_ns_find_parent_name
- *
- * PARAMETERS: *child_node - Named Obj whose name is to be found
- *
- * RETURN: The ACPI name
- *
- * DESCRIPTION: Search for the given obj in its parent scope and return the
- * name segment, or "????" if the parent name can't be found
- * (which "should not happen").
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
-acpi_name
-acpi_ns_find_parent_name (
- struct acpi_namespace_node *child_node)
-{
- struct acpi_namespace_node *parent_node;
-
-
- ACPI_FUNCTION_TRACE ("ns_find_parent_name");
-
-
- if (child_node) {
- /* Valid entry. Get the parent Node */
-
- parent_node = acpi_ns_get_parent_node (child_node);
- if (parent_node) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Parent of %p [%4.4s] is %p [%4.4s]\n",
- child_node, acpi_ut_get_node_name (child_node),
- parent_node, acpi_ut_get_node_name (parent_node)));
-
- if (parent_node->name.integer) {
- return_VALUE ((acpi_name) parent_node->name.integer);
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
- "Unable to find parent of %p (%4.4s)\n",
- child_node, acpi_ut_get_node_name (child_node)));
- }
-
- return_VALUE (ACPI_UNKNOWN_NAME);
-}
-#endif
-
-
-/*******************************************************************************
- *
* FUNCTION: acpi_ns_get_parent_node
*
* PARAMETERS: Node - Current table entry
@@ -1009,7 +983,6 @@ acpi_ns_find_parent_name (
*
******************************************************************************/
-
struct acpi_namespace_node *
acpi_ns_get_parent_node (
struct acpi_namespace_node *node)
@@ -1030,7 +1003,6 @@ acpi_ns_get_parent_node (
node = node->peer;
}
-
return (node->peer);
}
@@ -1049,7 +1021,6 @@ acpi_ns_get_parent_node (
*
******************************************************************************/
-
struct acpi_namespace_node *
acpi_ns_get_next_valid_node (
struct acpi_namespace_node *node)
@@ -1067,3 +1038,53 @@ acpi_ns_get_next_valid_node (
}
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ns_find_parent_name
+ *
+ * PARAMETERS: *child_node - Named Obj whose name is to be found
+ *
+ * RETURN: The ACPI name
+ *
+ * DESCRIPTION: Search for the given obj in its parent scope and return the
+ * name segment, or "????" if the parent name can't be found
+ * (which "should not happen").
+ *
+ ******************************************************************************/
+
+acpi_name
+acpi_ns_find_parent_name (
+ struct acpi_namespace_node *child_node)
+{
+ struct acpi_namespace_node *parent_node;
+
+
+ ACPI_FUNCTION_TRACE ("ns_find_parent_name");
+
+
+ if (child_node) {
+ /* Valid entry. Get the parent Node */
+
+ parent_node = acpi_ns_get_parent_node (child_node);
+ if (parent_node) {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Parent of %p [%4.4s] is %p [%4.4s]\n",
+ child_node, acpi_ut_get_node_name (child_node),
+ parent_node, acpi_ut_get_node_name (parent_node)));
+
+ if (parent_node->name.integer) {
+ return_VALUE ((acpi_name) parent_node->name.integer);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Unable to find parent of %p (%4.4s)\n",
+ child_node, acpi_ut_get_node_name (child_node)));
+ }
+
+ return_VALUE (ACPI_UNKNOWN_NAME);
+}
+#endif
+
+
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c
index 4de2444df30..f9a7277dca6 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/namespace/nswalk.c
@@ -56,7 +56,7 @@
*
* PARAMETERS: Type - Type of node to be searched for
* parent_node - Parent node whose children we are
- * getting
+ * getting
* child_node - Previous child that was found.
* The NEXT child will be returned
*
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index 1dc995586cb..12ea202257f 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -58,11 +58,11 @@
* FUNCTION: acpi_evaluate_object_typed
*
* PARAMETERS: Handle - Object handle (optional)
- * *Pathname - Object pathname (optional)
- * **external_params - List of parameters to pass to method,
+ * Pathname - Object pathname (optional)
+ * external_params - List of parameters to pass to method,
* terminated by NULL. May be NULL
* if no parameters are being passed.
- * *return_buffer - Where to put method's return value (if
+ * return_buffer - Where to put method's return value (if
* any). If NULL, no value is returned.
* return_type - Expected type of return object
*
@@ -73,6 +73,7 @@
* be valid (non-null)
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_evaluate_object_typed (
@@ -307,7 +308,8 @@ acpi_evaluate_object (
if (ACPI_SUCCESS (status)) {
/* Validate/Allocate/Clear caller buffer */
- status = acpi_ut_initialize_buffer (return_buffer, buffer_space_needed);
+ status = acpi_ut_initialize_buffer (return_buffer,
+ buffer_space_needed);
if (ACPI_FAILURE (status)) {
/*
* Caller's buffer is too small or a new one can't be allocated
@@ -423,7 +425,8 @@ acpi_walk_namespace (
return_ACPI_STATUS (status);
}
- status = acpi_ns_walk_namespace (type, start_object, max_depth, ACPI_NS_WALK_UNLOCK,
+ status = acpi_ns_walk_namespace (type, start_object, max_depth,
+ ACPI_NS_WALK_UNLOCK,
user_function, context, return_value);
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
@@ -525,7 +528,8 @@ acpi_ns_get_device_callback (
}
}
- status = info->user_function (obj_handle, nesting_level, info->context, return_value);
+ status = info->user_function (obj_handle, nesting_level, info->context,
+ return_value);
return (status);
}
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index f2405efd1b9..8d097914c49 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -57,9 +57,9 @@
* FUNCTION: acpi_get_handle
*
* PARAMETERS: Parent - Object to search under (search scope).
- * path_name - Pointer to an asciiz string containing the
- * name
- * ret_handle - Where the return handle is placed
+ * Pathname - Pointer to an asciiz string containing the
+ * name
+ * ret_handle - Where the return handle is returned
*
* RETURN: Status
*
@@ -220,7 +220,7 @@ EXPORT_SYMBOL(acpi_get_name);
* FUNCTION: acpi_get_object_info
*
* PARAMETERS: Handle - Object Handle
- * Info - Where the info is returned
+ * Buffer - Where the info is returned
*
* RETURN: Status
*
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/namespace/nsxfobj.c
index 19acf32674b..363e1f6cfb1 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/namespace/nsxfobj.c
@@ -56,7 +56,7 @@
* FUNCTION: acpi_get_type
*
* PARAMETERS: Handle - Handle of object whose type is desired
- * *ret_type - Where the type will be placed
+ * ret_type - Where the type will be placed
*
* RETURN: Status
*
@@ -258,5 +258,5 @@ unlock_and_exit:
(void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
return (status);
}
-EXPORT_SYMBOL(acpi_get_next_object);
+EXPORT_SYMBOL(acpi_get_next_object);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 5a9128de622..bdd9f37f810 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -71,6 +71,9 @@ EXPORT_SYMBOL(acpi_in_debugger);
extern char line_buf[80];
#endif /*ENABLE_DEBUGGER*/
+int acpi_specific_hotkey_enabled;
+EXPORT_SYMBOL(acpi_specific_hotkey_enabled);
+
static unsigned int acpi_irq_irq;
static acpi_osd_handler acpi_irq_handler;
static void *acpi_irq_context;
@@ -1152,6 +1155,15 @@ acpi_wake_gpes_always_on_setup(char *str)
__setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup);
+int __init
+acpi_hotkey_setup(char *str)
+{
+ acpi_specific_hotkey_enabled = TRUE;
+ return 1;
+}
+
+__setup("acpi_specific_hotkey", acpi_hotkey_setup);
+
/*
* max_cstate is defined in the base kernel so modules can
* change it w/o depending on the state of the processor module.
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index b5d98895f6a..b7ac68cc9e1 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -50,6 +50,16 @@
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psargs")
+/* Local prototypes */
+
+static u32
+acpi_ps_get_next_package_length (
+ struct acpi_parse_state *parser_state);
+
+static union acpi_parse_object *
+acpi_ps_get_next_field (
+ struct acpi_parse_state *parser_state);
+
/*******************************************************************************
*
@@ -64,7 +74,7 @@
*
******************************************************************************/
-u32
+static u32
acpi_ps_get_next_package_length (
struct acpi_parse_state *parser_state)
{
@@ -78,7 +88,6 @@ acpi_ps_get_next_package_length (
encoded_length = (u32) ACPI_GET8 (parser_state->aml);
parser_state->aml++;
-
switch (encoded_length >> 6) /* bits 6-7 contain encoding scheme */ {
case 0: /* 1-byte encoding (bits 0-5) */
@@ -287,13 +296,14 @@ acpi_ps_get_next_namepath (
* parent tree, but don't open a new scope -- we just want to lookup the
* object (MUST BE mode EXECUTE to perform upsearch)
*/
- status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
- ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &node);
+ status = acpi_ns_lookup (&scope_info, path, ACPI_TYPE_ANY,
+ ACPI_IMODE_EXECUTE,
+ ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+ NULL, &node);
if (ACPI_SUCCESS (status) && method_call) {
if (node->type == ACPI_TYPE_METHOD) {
- /*
- * This name is actually a control method invocation
- */
+ /* This name is actually a control method invocation */
+
method_desc = acpi_ns_get_attached_object (node);
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
"Control Method - %p Desc %p Path=%p\n",
@@ -360,7 +370,7 @@ acpi_ps_get_next_namepath (
/*
* We got a NOT_FOUND during table load or we encountered
* a cond_ref_of(x) where the target does not exist.
- * -- either case is ok
+ * Either case is ok
*/
status = AE_OK;
}
@@ -486,12 +496,13 @@ acpi_ps_get_next_simple_arg (
*
******************************************************************************/
-union acpi_parse_object *
+static union acpi_parse_object *
acpi_ps_get_next_field (
struct acpi_parse_state *parser_state)
{
- u32 aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
- parser_state->aml_start);
+ u32 aml_offset = (u32)
+ ACPI_PTR_DIFF (parser_state->aml,
+ parser_state->aml_start);
union acpi_parse_object *field;
u16 opcode;
u32 name;
@@ -500,7 +511,7 @@ acpi_ps_get_next_field (
ACPI_FUNCTION_TRACE ("ps_get_next_field");
- /* determine field type */
+ /* Determine field type */
switch (ACPI_GET8 (parser_state->aml)) {
default:
@@ -521,7 +532,6 @@ acpi_ps_get_next_field (
break;
}
-
/* Allocate a new field op */
field = acpi_ps_alloc_op (opcode);
@@ -582,10 +592,10 @@ acpi_ps_get_next_field (
*
* FUNCTION: acpi_ps_get_next_arg
*
- * PARAMETERS: parser_state - Current parser state object
+ * PARAMETERS: walk_state - Current state
+ * parser_state - Current parser state object
* arg_type - The argument type (AML_*_ARG)
- * arg_count - If the argument points to a control method
- * the method's argument is returned here.
+ * return_arg - Where the next arg is returned
*
* RETURN: Status, and an op object containing the next argument.
*
@@ -619,7 +629,7 @@ acpi_ps_get_next_arg (
case ARGP_NAME:
case ARGP_NAMESTRING:
- /* constants, strings, and namestrings are all the same size */
+ /* Constants, strings, and namestrings are all the same size */
arg = acpi_ps_alloc_op (AML_BYTE_OP);
if (!arg) {
@@ -654,7 +664,6 @@ acpi_ps_get_next_arg (
else {
arg = field;
}
-
prev = field;
}
@@ -677,8 +686,8 @@ acpi_ps_get_next_arg (
/* Fill in bytelist data */
- arg->common.value.size = (u32) ACPI_PTR_DIFF (parser_state->pkg_end,
- parser_state->aml);
+ arg->common.value.size = (u32)
+ ACPI_PTR_DIFF (parser_state->pkg_end, parser_state->aml);
arg->named.data = parser_state->aml;
/* Skip to End of byte data */
@@ -706,7 +715,7 @@ acpi_ps_get_next_arg (
status = acpi_ps_get_next_namepath (walk_state, parser_state, arg, 0);
}
else {
- /* single complex argument, nothing returned */
+ /* Single complex argument, nothing returned */
walk_state->arg_count = 1;
}
@@ -716,7 +725,7 @@ acpi_ps_get_next_arg (
case ARGP_DATAOBJ:
case ARGP_TERMARG:
- /* single complex argument, nothing returned */
+ /* Single complex argument, nothing returned */
walk_state->arg_count = 1;
break;
@@ -727,7 +736,7 @@ acpi_ps_get_next_arg (
case ARGP_OBJLIST:
if (parser_state->aml < parser_state->pkg_end) {
- /* non-empty list of variable arguments, nothing returned */
+ /* Non-empty list of variable arguments, nothing returned */
walk_state->arg_count = ACPI_VAR_ARGS;
}
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/parser/psopcode.c
index 03e33fedc11..5744673568c 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/parser/psopcode.c
@@ -44,6 +44,7 @@
#include <acpi/acpi.h>
#include <acpi/acparser.h>
+#include <acpi/acopcode.h>
#include <acpi/amlcode.h>
@@ -51,23 +52,6 @@
ACPI_MODULE_NAME ("psopcode")
-#define _UNK 0x6B
-/*
- * Reserved ASCII characters. Do not use any of these for
- * internal opcodes, since they are used to differentiate
- * name strings from AML opcodes
- */
-#define _ASC 0x6C
-#define _NAM 0x6C
-#define _PFX 0x6D
-#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */
-
-#define MAX_EXTENDED_OPCODE 0x88
-#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
-#define MAX_INTERNAL_OPCODE
-#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
-
-
/*******************************************************************************
*
* NAME: acpi_gbl_aml_op_info
@@ -79,274 +63,9 @@
*
******************************************************************************/
-
-/*
- * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed
- * into a 32-bit number and stored in the master opcode table at the end of this file.
- */
-
-
-#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
-#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
-#define ARGP_ARG0 ARG_NONE
-#define ARGP_ARG1 ARG_NONE
-#define ARGP_ARG2 ARG_NONE
-#define ARGP_ARG3 ARG_NONE
-#define ARGP_ARG4 ARG_NONE
-#define ARGP_ARG5 ARG_NONE
-#define ARGP_ARG6 ARG_NONE
-#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
-#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_BREAK_OP ARG_NONE
-#define ARGP_BREAK_POINT_OP ARG_NONE
-#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
-#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
-#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
-#define ARGP_CONTINUE_OP ARG_NONE
-#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME)
-#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
-#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_DEBUG_OP ARG_NONE
-#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
-#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
-#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
-#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
-#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
-#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
-#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
-#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
-#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
-#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
-#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
-#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
-#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_LOCAL0 ARG_NONE
-#define ARGP_LOCAL1 ARG_NONE
-#define ARGP_LOCAL2 ARG_NONE
-#define ARGP_LOCAL3 ARG_NONE
-#define ARGP_LOCAL4 ARG_NONE
-#define ARGP_LOCAL5 ARG_NONE
-#define ARGP_LOCAL6 ARG_NONE
-#define ARGP_LOCAL7 ARG_NONE
-#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
-#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
-#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
-#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_NOOP_OP ARG_NONE
-#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
-#define ARGP_ONE_OP ARG_NONE
-#define ARGP_ONES_OP ARG_NONE
-#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
-#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
-#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
-#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
-#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
-#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
-#define ARGP_REVISION_OP ARG_NONE
-#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
-#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
-#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
-#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
-#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
-#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
-#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
-#define ARGP_TIMER_OP ARG_NONE
-#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
-#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
-#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
-#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
-#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
-#define ARGP_ZERO_OP ARG_NONE
-
-
-/*
- * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed
- * into a 32-bit number and stored in the master opcode table at the end of this file.
- *
- * (Used by prep_operands procedure and the ASL Compiler)
- */
-
-
-#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
-#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
-#define ARGI_ARG0 ARG_NONE
-#define ARGI_ARG1 ARG_NONE
-#define ARGI_ARG2 ARG_NONE
-#define ARGI_ARG3 ARG_NONE
-#define ARGI_ARG4 ARG_NONE
-#define ARGI_ARG5 ARG_NONE
-#define ARGI_ARG6 ARG_NONE
-#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_BREAK_OP ARG_NONE
-#define ARGI_BREAK_POINT_OP ARG_NONE
-#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
-#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
-#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
-#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
-#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
-#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
-#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
-#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
-#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
-#define ARGI_DEBUG_OP ARG_NONE
-#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
-#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
-#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
-#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
-#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
-#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
-#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
-#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
-#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_IF_OP ARGI_INVALID_OPCODE
-#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
-#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
-#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
-#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
-#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
-#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
-#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
-#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
-#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF)
-#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
-#define ARGI_LOCAL0 ARG_NONE
-#define ARGI_LOCAL1 ARG_NONE
-#define ARGI_LOCAL2 ARG_NONE
-#define ARGI_LOCAL3 ARG_NONE
-#define ARGI_LOCAL4 ARG_NONE
-#define ARGI_LOCAL5 ARG_NONE
-#define ARGI_LOCAL6 ARG_NONE
-#define ARGI_LOCAL7 ARG_NONE
-#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
-#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
-#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
-#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
-#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
-#define ARGI_NAME_OP ARGI_INVALID_OPCODE
-#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
-#define ARGI_NOOP_OP ARG_NONE
-#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
-#define ARGI_ONE_OP ARG_NONE
-#define ARGI_ONES_OP ARG_NONE
-#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
-#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
-#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
-#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
-#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
-#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
-#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
-#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
-#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
-#define ARGI_REVISION_OP ARG_NONE
-#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
-#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
-#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
-#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
-#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
-#define ARGI_STRING_OP ARGI_INVALID_OPCODE
-#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
-#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
-#define ARGI_TIMER_OP ARG_NONE
-#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
-#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
-#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
-#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
-#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
-#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
-#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
-#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
-#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
-#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
-#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
-#define ARGI_WORD_OP ARGI_INVALID_OPCODE
-#define ARGI_ZERO_OP ARG_NONE
-
-
/*
* Summary of opcode types/flags
- */
-
-/******************************************************************************
+ *
Opcodes that have associated namespace objects (AML_NSOBJECT flag)
@@ -460,14 +179,13 @@
AML_CREATE_DWORD_FIELD_OP
AML_CREATE_QWORD_FIELD_OP
-******************************************************************************/
+ ******************************************************************************/
/*
- * Master Opcode information table. A summary of everything we know about each opcode, all in one place.
+ * Master Opcode information table. A summary of everything we know about each
+ * opcode, all in one place.
*/
-
-
const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES] =
{
/*! [Begin] no source code translation */
@@ -693,8 +411,7 @@ static const u8 acpi_gbl_long_op_index[NUM_EXTENDED_OPCODE] =
*
* PARAMETERS: Opcode - The AML opcode
*
- * RETURN: A pointer to the info about the opcode. NULL if the opcode was
- * not found in the table.
+ * RETURN: A pointer to the info about the opcode.
*
* DESCRIPTION: Find AML opcode description based on the opcode.
* NOTE: This procedure must ALWAYS return a valid pointer!
@@ -731,7 +448,8 @@ acpi_ps_get_opcode_info (
default:
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", opcode));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Unknown AML opcode [%4.4X]\n", opcode));
break;
}
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index e79edb53cb3..bbfdc1a58c2 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -64,6 +64,23 @@
static u32 acpi_gbl_depth = 0;
+/* Local prototypes */
+
+static void
+acpi_ps_complete_this_op (
+ struct acpi_walk_state *walk_state,
+ union acpi_parse_object *op);
+
+static acpi_status
+acpi_ps_next_parse_state (
+ struct acpi_walk_state *walk_state,
+ union acpi_parse_object *op,
+ acpi_status callback_status);
+
+static acpi_status
+acpi_ps_parse_loop (
+ struct acpi_walk_state *walk_state);
+
/*******************************************************************************
*
@@ -100,7 +117,7 @@ acpi_ps_get_opcode_size (
*
* PARAMETERS: parser_state - A parser state object
*
- * RETURN: Status
+ * RETURN: Next AML opcode
*
* DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
*
@@ -117,7 +134,6 @@ acpi_ps_peek_opcode (
aml = parser_state->aml;
opcode = (u16) ACPI_GET8 (aml);
-
if (opcode == AML_EXTOP) {
/* Extended opcode */
@@ -142,7 +158,7 @@ acpi_ps_peek_opcode (
*
******************************************************************************/
-void
+static void
acpi_ps_complete_this_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op)
@@ -272,7 +288,6 @@ acpi_ps_complete_this_op (
next = NULL;
}
}
-
prev = next;
}
}
@@ -280,7 +295,7 @@ acpi_ps_complete_this_op (
cleanup:
- /* Now we can actually delete the subtree rooted at op */
+ /* Now we can actually delete the subtree rooted at Op */
acpi_ps_delete_parse_tree (op);
return_VOID;
@@ -291,7 +306,9 @@ cleanup:
*
* FUNCTION: acpi_ps_next_parse_state
*
- * PARAMETERS: parser_state - Current parser state object
+ * PARAMETERS: walk_state - Current state
+ * Op - Current parse op
+ * callback_status - Status from previous operation
*
* RETURN: Status
*
@@ -300,7 +317,7 @@ cleanup:
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ps_next_parse_state (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
@@ -382,9 +399,8 @@ acpi_ps_next_parse_state (
case AE_CTRL_TRANSFER:
- /*
- * A method call (invocation) -- transfer control
- */
+ /* A method call (invocation) -- transfer control */
+
status = AE_CTRL_TRANSFER;
walk_state->prev_op = op;
walk_state->method_call_op = op;
@@ -397,6 +413,7 @@ acpi_ps_next_parse_state (
default:
+
status = callback_status;
if ((callback_status & AE_CODE_MASK) == AE_CODE_CONTROL) {
status = AE_OK;
@@ -412,7 +429,7 @@ acpi_ps_next_parse_state (
*
* FUNCTION: acpi_ps_parse_loop
*
- * PARAMETERS: parser_state - Current parser state object
+ * PARAMETERS: walk_state - Current state
*
* RETURN: Status
*
@@ -421,7 +438,7 @@ acpi_ps_next_parse_state (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ps_parse_loop (
struct acpi_walk_state *walk_state)
{
@@ -443,6 +460,7 @@ acpi_ps_parse_loop (
walk_state->arg_types = 0;
#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
+
if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
/* We are restarting a preempted control method */
@@ -471,7 +489,8 @@ acpi_ps_parse_loop (
acpi_format_exception (status)));
}
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "get_predicate Failed, %s\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "get_predicate Failed, %s\n",
acpi_format_exception (status)));
return_ACPI_STATUS (status);
}
@@ -492,16 +511,15 @@ acpi_ps_parse_loop (
}
#endif
- /*
- * Iterative parsing loop, while there is more aml to process:
- */
+ /* Iterative parsing loop, while there is more AML to process: */
+
while ((parser_state->aml < parser_state->aml_end) || (op)) {
aml_op_start = parser_state->aml;
if (!op) {
/* Get the next opcode from the AML stream */
walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
- parser_state->aml_start);
+ parser_state->aml_start);
walk_state->opcode = acpi_ps_peek_opcode (parser_state);
/*
@@ -578,8 +596,10 @@ acpi_ps_parse_loop (
INCREMENT_ARG_LIST (walk_state->arg_types);
}
- /* Make sure that we found a NAME and didn't run out of arguments */
-
+ /*
+ * Make sure that we found a NAME and didn't run out of
+ * arguments
+ */
if (!GET_CURRENT_ARG_TYPE (walk_state->arg_types)) {
status = AE_AML_NO_OPERAND;
goto close_this_op;
@@ -597,12 +617,13 @@ acpi_ps_parse_loop (
status = walk_state->descending_callback (walk_state, &op);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
- acpi_format_exception (status)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "During name lookup/catalog, %s\n",
+ acpi_format_exception (status)));
goto close_this_op;
}
- if (op == NULL) {
+ if (!op) {
continue;
}
@@ -659,7 +680,7 @@ acpi_ps_parse_loop (
if ((walk_state->descending_callback != NULL)) {
/*
- * Find the object. This will either insert the object into
+ * Find the object. This will either insert the object into
* the namespace or simply look it up
*/
walk_state->op = op;
@@ -688,11 +709,15 @@ acpi_ps_parse_loop (
}
- /* Start arg_count at zero because we don't know if there are any args yet */
-
+ /*
+ * Start arg_count at zero because we don't know if there are
+ * any args yet
+ */
walk_state->arg_count = 0;
- if (walk_state->arg_types) /* Are there any arguments that must be processed? */ {
+ /* Are there any arguments that must be processed? */
+
+ if (walk_state->arg_types) {
/* Get arguments */
switch (op->common.aml_opcode) {
@@ -720,14 +745,18 @@ acpi_ps_parse_loop (
default:
- /* Op is not a constant or string, append each argument to the Op */
-
+ /*
+ * Op is not a constant or string, append each argument
+ * to the Op
+ */
while (GET_CURRENT_ARG_TYPE (walk_state->arg_types) &&
!walk_state->arg_count) {
- walk_state->aml_offset = (u32) ACPI_PTR_DIFF (parser_state->aml,
- parser_state->aml_start);
+ walk_state->aml_offset = (u32)
+ ACPI_PTR_DIFF (parser_state->aml, parser_state->aml_start);
+
status = acpi_ps_get_next_arg (walk_state, parser_state,
- GET_CURRENT_ARG_TYPE (walk_state->arg_types), &arg);
+ GET_CURRENT_ARG_TYPE (walk_state->arg_types),
+ &arg);
if (ACPI_FAILURE (status)) {
goto close_this_op;
}
@@ -752,7 +781,8 @@ acpi_ps_parse_loop (
* Save the length and address of the body
*/
op->named.data = parser_state->aml;
- op->named.length = (u32) (parser_state->pkg_end - parser_state->aml);
+ op->named.length = (u32) (parser_state->pkg_end -
+ parser_state->aml);
/* Skip body of method */
@@ -773,7 +803,8 @@ acpi_ps_parse_loop (
* to parse them correctly.
*/
op->named.data = aml_op_start;
- op->named.length = (u32) (parser_state->pkg_end - aml_op_start);
+ op->named.length = (u32) (parser_state->pkg_end -
+ aml_op_start);
/* Skip body */
@@ -785,7 +816,8 @@ acpi_ps_parse_loop (
case AML_WHILE_OP:
if (walk_state->control_state) {
- walk_state->control_state->control.package_end = parser_state->pkg_end;
+ walk_state->control_state->control.package_end =
+ parser_state->pkg_end;
}
break;
@@ -801,8 +833,10 @@ acpi_ps_parse_loop (
/* Check for arguments that need to be processed */
if (walk_state->arg_count) {
- /* There are arguments (complex ones), push Op and prepare for argument */
-
+ /*
+ * There are arguments (complex ones), push Op and
+ * prepare for argument
+ */
status = acpi_ps_push_scope (parser_state, op,
walk_state->arg_types, walk_state->arg_count);
if (ACPI_FAILURE (status)) {
@@ -812,8 +846,10 @@ acpi_ps_parse_loop (
continue;
}
- /* All arguments have been processed -- Op is complete, prepare for next */
-
+ /*
+ * All arguments have been processed -- Op is complete,
+ * prepare for next
+ */
walk_state->op_info = acpi_ps_get_opcode_info (op->common.aml_opcode);
if (walk_state->op_info->flags & AML_NAMED) {
if (acpi_gbl_depth) {
@@ -880,9 +916,8 @@ close_this_op:
case AE_CTRL_TRANSFER:
- /*
- * We are about to transfer to a called method.
- */
+ /* We are about to transfer to a called method. */
+
walk_state->prev_op = op;
walk_state->prev_arg_types = walk_state->arg_types;
return_ACPI_STATUS (status);
@@ -1051,10 +1086,7 @@ close_this_op:
*
* FUNCTION: acpi_ps_parse_aml
*
- * PARAMETERS: start_scope - The starting point of the parse. Becomes the
- * root of the parsed op tree.
- * Aml - Pointer to the raw AML code to parse
- * aml_size - Length of the AML to parse
+ * PARAMETERS: walk_state - Current state
*
*
* RETURN: Status
@@ -1076,8 +1108,10 @@ acpi_ps_parse_aml (
ACPI_FUNCTION_TRACE ("ps_parse_aml");
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with walk_state=%p Aml=%p size=%X\n",
- walk_state, walk_state->parser_state.aml, walk_state->parser_state.aml_size));
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Entered with walk_state=%p Aml=%p size=%X\n",
+ walk_state, walk_state->parser_state.aml,
+ walk_state->parser_state.aml_size));
/* Create and initialize a new thread state */
@@ -1142,9 +1176,10 @@ acpi_ps_parse_aml (
if ((status == AE_ALREADY_EXISTS) &&
(!walk_state->method_desc->method.semaphore)) {
/*
- * This method is marked not_serialized, but it tried to create a named
- * object, causing the second thread entrance to fail. We will workaround
- * this by marking the method permanently as Serialized.
+ * This method is marked not_serialized, but it tried to create
+ * a named object, causing the second thread entrance to fail.
+ * We will workaround this by marking the method permanently
+ * as Serialized.
*/
walk_state->method_desc->method.method_flags |= AML_METHOD_SERIALIZED;
walk_state->method_desc->method.concurrency = 1;
@@ -1187,7 +1222,8 @@ acpi_ps_parse_aml (
previous_walk_state = walk_state;
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "return_value=%p, implicit_value=%p State=%p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "return_value=%p, implicit_value=%p State=%p\n",
walk_state->return_desc, walk_state->implicit_return_obj, walk_state));
/* Check if we have restarted a preempted walk */
@@ -1231,12 +1267,14 @@ acpi_ps_parse_aml (
*/
else if (previous_walk_state->caller_return_desc) {
if (previous_walk_state->implicit_return_obj) {
- *(previous_walk_state->caller_return_desc) = previous_walk_state->implicit_return_obj;
+ *(previous_walk_state->caller_return_desc) =
+ previous_walk_state->implicit_return_obj;
}
else {
/* NULL if no return value */
- *(previous_walk_state->caller_return_desc) = previous_walk_state->return_desc;
+ *(previous_walk_state->caller_return_desc) =
+ previous_walk_state->return_desc;
}
}
else {
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/parser/psscope.c
index dcbed49608b..8dcd1b1e713 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/parser/psscope.c
@@ -65,6 +65,7 @@ union acpi_parse_object *
acpi_ps_get_parent_scope (
struct acpi_parse_state *parser_state)
{
+
return (parser_state->scope->parse_scope.op);
}
@@ -87,8 +88,10 @@ u8
acpi_ps_has_completed_scope (
struct acpi_parse_state *parser_state)
{
- return ((u8) ((parser_state->aml >= parser_state->scope->parse_scope.arg_end ||
- !parser_state->scope->parse_scope.arg_count)));
+
+ return ((u8)
+ ((parser_state->aml >= parser_state->scope->parse_scope.arg_end ||
+ !parser_state->scope->parse_scope.arg_count)));
}
@@ -167,23 +170,23 @@ acpi_ps_push_scope (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE;
- scope->parse_scope.op = op;
- scope->parse_scope.arg_list = remaining_args;
- scope->parse_scope.arg_count = arg_count;
- scope->parse_scope.pkg_end = parser_state->pkg_end;
+ scope->common.data_type = ACPI_DESC_TYPE_STATE_PSCOPE;
+ scope->parse_scope.op = op;
+ scope->parse_scope.arg_list = remaining_args;
+ scope->parse_scope.arg_count = arg_count;
+ scope->parse_scope.pkg_end = parser_state->pkg_end;
/* Push onto scope stack */
acpi_ut_push_generic_state (&parser_state->scope, scope);
if (arg_count == ACPI_VAR_ARGS) {
- /* multiple arguments */
+ /* Multiple arguments */
scope->parse_scope.arg_end = parser_state->pkg_end;
}
else {
- /* single argument */
+ /* Single argument */
scope->parse_scope.arg_end = ACPI_TO_POINTER (ACPI_MAX_PTR);
}
@@ -221,18 +224,17 @@ acpi_ps_pop_scope (
ACPI_FUNCTION_TRACE ("ps_pop_scope");
- /*
- * Only pop the scope if there is in fact a next scope
- */
+ /* Only pop the scope if there is in fact a next scope */
+
if (scope->common.next) {
scope = acpi_ut_pop_generic_state (&parser_state->scope);
/* return to parsing previous op */
- *op = scope->parse_scope.op;
- *arg_list = scope->parse_scope.arg_list;
- *arg_count = scope->parse_scope.arg_count;
- parser_state->pkg_end = scope->parse_scope.pkg_end;
+ *op = scope->parse_scope.op;
+ *arg_list = scope->parse_scope.arg_list;
+ *arg_count = scope->parse_scope.arg_count;
+ parser_state->pkg_end = scope->parse_scope.pkg_end;
/* All done with this scope state structure */
@@ -241,12 +243,13 @@ acpi_ps_pop_scope (
else {
/* empty parse stack, prepare to fetch next opcode */
- *op = NULL;
- *arg_list = 0;
- *arg_count = 0;
+ *op = NULL;
+ *arg_list = 0;
+ *arg_count = 0;
}
- ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *op, *arg_count));
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Popped Op %p Args %X\n", *op, *arg_count));
return_VOID;
}
@@ -257,7 +260,7 @@ acpi_ps_pop_scope (
*
* PARAMETERS: parser_state - Current parser state object
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Destroy available list, remaining stack levels, and return
* root scope
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/parser/pstree.c
index 2140bd1ac10..d5aafe73fca 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/parser/pstree.c
@@ -49,6 +49,14 @@
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("pstree")
+/* Local prototypes */
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+union acpi_parse_object *
+acpi_ps_get_child (
+ union acpi_parse_object *op);
+#endif
+
/*******************************************************************************
*
@@ -57,7 +65,7 @@
* PARAMETERS: Op - Get an argument for this op
* Argn - Nth argument to get
*
- * RETURN: The argument (as an Op object). NULL if argument does not exist
+ * RETURN: The argument (as an Op object). NULL if argument does not exist
*
* DESCRIPTION: Get the specified op's argument.
*
@@ -152,7 +160,6 @@ acpi_ps_append_arg (
return;
}
-
/* Append the argument to the linked argument list */
if (op->common.value.arg) {
@@ -164,14 +171,12 @@ acpi_ps_append_arg (
}
prev_arg->common.next = arg;
}
-
else {
/* No argument list, this will be the first argument */
op->common.value.arg = arg;
}
-
/* Set the parent in this arg and any args linked after it */
while (arg) {
@@ -182,73 +187,6 @@ acpi_ps_append_arg (
#ifdef ACPI_FUTURE_USAGE
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ps_get_child
- *
- * PARAMETERS: Op - Get the child of this Op
- *
- * RETURN: Child Op, Null if none is found.
- *
- * DESCRIPTION: Get op's children or NULL if none
- *
- ******************************************************************************/
-union acpi_parse_object *
-acpi_ps_get_child (
- union acpi_parse_object *op)
-{
- union acpi_parse_object *child = NULL;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- switch (op->common.aml_opcode) {
- case AML_SCOPE_OP:
- case AML_ELSE_OP:
- case AML_DEVICE_OP:
- case AML_THERMAL_ZONE_OP:
- case AML_INT_METHODCALL_OP:
-
- child = acpi_ps_get_arg (op, 0);
- break;
-
-
- case AML_BUFFER_OP:
- case AML_PACKAGE_OP:
- case AML_METHOD_OP:
- case AML_IF_OP:
- case AML_WHILE_OP:
- case AML_FIELD_OP:
-
- child = acpi_ps_get_arg (op, 1);
- break;
-
-
- case AML_POWER_RES_OP:
- case AML_INDEX_FIELD_OP:
-
- child = acpi_ps_get_arg (op, 2);
- break;
-
-
- case AML_PROCESSOR_OP:
- case AML_BANK_FIELD_OP:
-
- child = acpi_ps_get_arg (op, 3);
- break;
-
-
- default:
- /* All others have no children */
- break;
- }
-
- return (child);
-}
-
-
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_depth_next
@@ -280,21 +218,21 @@ acpi_ps_get_depth_next (
return (NULL);
}
- /* look for an argument or child */
+ /* Look for an argument or child */
next = acpi_ps_get_arg (op, 0);
if (next) {
return (next);
}
- /* look for a sibling */
+ /* Look for a sibling */
next = op->common.next;
if (next) {
return (next);
}
- /* look for a sibling of parent */
+ /* Look for a sibling of parent */
parent = op->common.parent;
@@ -305,13 +243,13 @@ acpi_ps_get_depth_next (
}
if (arg == origin) {
- /* reached parent of origin, end search */
+ /* Reached parent of origin, end search */
return (NULL);
}
if (parent->common.next) {
- /* found sibling of parent */
+ /* Found sibling of parent */
return (parent->common.next);
}
@@ -323,5 +261,74 @@ acpi_ps_get_depth_next (
return (next);
}
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ps_get_child
+ *
+ * PARAMETERS: Op - Get the child of this Op
+ *
+ * RETURN: Child Op, Null if none is found.
+ *
+ * DESCRIPTION: Get op's children or NULL if none
+ *
+ ******************************************************************************/
+
+union acpi_parse_object *
+acpi_ps_get_child (
+ union acpi_parse_object *op)
+{
+ union acpi_parse_object *child = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (op->common.aml_opcode) {
+ case AML_SCOPE_OP:
+ case AML_ELSE_OP:
+ case AML_DEVICE_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_INT_METHODCALL_OP:
+
+ child = acpi_ps_get_arg (op, 0);
+ break;
+
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_METHOD_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_FIELD_OP:
+
+ child = acpi_ps_get_arg (op, 1);
+ break;
+
+
+ case AML_POWER_RES_OP:
+ case AML_INDEX_FIELD_OP:
+
+ child = acpi_ps_get_arg (op, 2);
+ break;
+
+
+ case AML_PROCESSOR_OP:
+ case AML_BANK_FIELD_OP:
+
+ child = acpi_ps_get_arg (op, 3);
+ break;
+
+
+ default:
+ /* All others have no children */
+ break;
+ }
+
+ return (child);
+}
+#endif
+
#endif /* ACPI_FUTURE_USAGE */
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/parser/psutils.c
index b3597cb19f8..a10f88715d4 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/parser/psutils.c
@@ -45,7 +45,6 @@
#include <acpi/acpi.h>
#include <acpi/acparser.h>
#include <acpi/amlcode.h>
-#include <acpi/acnamesp.h>
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psutils")
@@ -57,7 +56,7 @@
*
* PARAMETERS: None
*
- * RETURN: scope_op
+ * RETURN: A new Scope object, null on failure
*
* DESCRIPTION: Create a Scope and associated namepath op with the root name
*
@@ -75,7 +74,6 @@ acpi_ps_create_scope_op (
return (NULL);
}
-
scope_op->named.name = ACPI_ROOT_NAME;
return (scope_op);
}
@@ -88,10 +86,9 @@ acpi_ps_create_scope_op (
* PARAMETERS: Op - A newly allocated Op object
* Opcode - Opcode to store in the Op
*
- * RETURN: Status
+ * RETURN: None
*
- * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
- * opcode
+ * DESCRIPTION: Initialize a parse (Op) object
*
******************************************************************************/
@@ -107,7 +104,8 @@ acpi_ps_init_op (
op->common.aml_opcode = opcode;
ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (op->common.aml_op_name,
- (acpi_ps_get_opcode_info (opcode))->name, sizeof (op->common.aml_op_name)));
+ (acpi_ps_get_opcode_info (opcode))->name,
+ sizeof (op->common.aml_op_name)));
}
@@ -117,7 +115,7 @@ acpi_ps_init_op (
*
* PARAMETERS: Opcode - Opcode that will be stored in the new Op
*
- * RETURN: Pointer to the new Op.
+ * RETURN: Pointer to the new Op, null on failure
*
* DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
* opcode. A cache of opcodes is available for the pure
@@ -275,7 +273,6 @@ acpi_ps_get_name (
union acpi_parse_object *op)
{
-
/* The "generic" object has no name associated with it */
if (op->common.flags & ACPI_PARSEOP_GENERIC) {
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/parser/pswalk.c
index 110d2ce917b..9d20cb2ceb5 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/parser/pswalk.c
@@ -90,17 +90,15 @@ acpi_ps_delete_parse_tree (
}
}
- /*
- * No more children, this Op is complete.
- */
+ /* No more children, this Op is complete. */
+
next = op->common.next;
parent = op->common.parent;
acpi_ps_free_op (op);
- /*
- * If we are back to the starting point, the walk is complete.
- */
+ /* If we are back to the starting point, the walk is complete. */
+
if (op == subtree_root) {
return_VOID;
}
@@ -111,5 +109,6 @@ acpi_ps_delete_parse_tree (
op = parent;
}
}
+
return_VOID;
}
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index b318ad24726..dba893648e8 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -57,13 +57,16 @@
*
* FUNCTION: acpi_psx_execute
*
- * PARAMETERS: Info->Node - A method object containing both the AML
- * address and length.
- * **Params - List of parameters to pass to method,
+ * PARAMETERS: Info - Method info block, contains:
+ * Node - Method Node to execute
+ * Parameters - List of parameters to pass to the method,
* terminated by NULL. Params itself may be
* NULL if no parameters are being passed.
- * **return_obj_desc - Return object from execution of the
- * method.
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
+ * parameter_type - Type of Parameter list
+ * return_object - Where to put method's return value (if
+ * any). If NULL, no value is returned.
*
* RETURN: Status
*
@@ -196,9 +199,8 @@ acpi_psx_execute (
goto cleanup3;
}
- /*
- * The walk of the parse tree is where we actually execute the method
- */
+ /* The walk of the parse tree is where we actually execute the method */
+
status = acpi_ps_parse_aml (walk_state);
goto cleanup2; /* Walk state already deleted */
@@ -217,7 +219,8 @@ cleanup1:
for (i = 0; info->parameters[i]; i++) {
/* Ignore errors, just do them all */
- (void) acpi_ut_update_object_reference (info->parameters[i], REF_DECREMENT);
+ (void) acpi_ut_update_object_reference (
+ info->parameters[i], REF_DECREMENT);
}
}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 520b28ad074..6ad0e77df9b 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -72,10 +72,12 @@ struct acpi_pci_link_irq {
u8 active; /* Current IRQ */
u8 edge_level; /* All IRQs */
u8 active_high_low; /* All IRQs */
- u8 initialized;
u8 resource_type;
u8 possible_count;
u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
+ u8 initialized:1;
+ u8 suspend_resume:1;
+ u8 reserved:6;
};
struct acpi_pci_link {
@@ -530,6 +532,10 @@ static int acpi_pci_link_allocate(
ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
+ if (link->irq.suspend_resume) {
+ acpi_pci_link_set(link, link->irq.active);
+ link->irq.suspend_resume = 0;
+ }
if (link->irq.initialized)
return_VALUE(0);
@@ -713,38 +719,24 @@ end:
return_VALUE(result);
}
-
-static int
-acpi_pci_link_resume (
- struct acpi_pci_link *link)
-{
- ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
-
- if (link->irq.active && link->irq.initialized)
- return_VALUE(acpi_pci_link_set(link, link->irq.active));
- else
- return_VALUE(0);
-}
-
-
static int
-irqrouter_resume(
- struct sys_device *dev)
+irqrouter_suspend(
+ struct sys_device *dev,
+ u32 state)
{
struct list_head *node = NULL;
struct acpi_pci_link *link = NULL;
- ACPI_FUNCTION_TRACE("irqrouter_resume");
+ ACPI_FUNCTION_TRACE("irqrouter_suspend");
list_for_each(node, &acpi_link.entries) {
-
link = list_entry(node, struct acpi_pci_link, node);
if (!link) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
continue;
}
-
- acpi_pci_link_resume(link);
+ if (link->irq.active && link->irq.initialized)
+ link->irq.suspend_resume = 1;
}
return_VALUE(0);
}
@@ -812,9 +804,12 @@ static int __init acpi_irq_penalty_update(char *str, int used)
* There is no ISA_POSSIBLE weight, so we simply use
* the (small) PCI_USING penalty.
*/
-void acpi_penalize_isa_irq(int irq)
+void acpi_penalize_isa_irq(int irq, int active)
{
- acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+ if (active)
+ acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
+ else
+ acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
}
/*
@@ -856,7 +851,7 @@ __setup("acpi_irq_balance", acpi_irq_balance_set);
static struct sysdev_class irqrouter_sysdev_class = {
set_kset_name("irqrouter"),
- .resume = irqrouter_resume,
+ .suspend = irqrouter_suspend,
};
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 76156ac91bd..d56a439ac61 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -256,6 +256,43 @@ acpi_processor_errata (
/* --------------------------------------------------------------------------
+ Common ACPI processor fucntions
+ -------------------------------------------------------------------------- */
+
+/*
+ * _PDC is required for a BIOS-OS handshake for most of the newer
+ * ACPI processor features.
+ */
+
+int acpi_processor_set_pdc(struct acpi_processor *pr,
+ struct acpi_object_list *pdc_in)
+{
+ acpi_status status = AE_OK;
+ u32 arg0_buf[3];
+ union acpi_object arg0 = {ACPI_TYPE_BUFFER};
+ struct acpi_object_list no_object = {1, &arg0};
+ struct acpi_object_list *pdc;
+
+ ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
+
+ arg0.buffer.length = 12;
+ arg0.buffer.pointer = (u8 *) arg0_buf;
+ arg0_buf[0] = ACPI_PDC_REVISION_ID;
+ arg0_buf[1] = 0;
+ arg0_buf[2] = 0;
+
+ pdc = (pdc_in) ? pdc_in : &no_object;
+
+ status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
+
+ if ((ACPI_FAILURE(status)) && (pdc_in))
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
+
+ return_VALUE(status);
+}
+
+
+/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index c9d671cf785..893b074e3d1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -6,6 +6,8 @@
* Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
* Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
* - Added processor hotplug support
+ * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
+ * - Added support for C3 on SMP
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
@@ -142,7 +144,7 @@ acpi_processor_power_activate (
switch (old->type) {
case ACPI_STATE_C3:
/* Disable bus master reload */
- if (new->type != ACPI_STATE_C3)
+ if (new->type != ACPI_STATE_C3 && pr->flags.bm_check)
acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 0, ACPI_MTX_DO_NOT_LOCK);
break;
}
@@ -152,7 +154,7 @@ acpi_processor_power_activate (
switch (new->type) {
case ACPI_STATE_C3:
/* Enable bus master reload */
- if (old->type != ACPI_STATE_C3)
+ if (old->type != ACPI_STATE_C3 && pr->flags.bm_check)
acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 1, ACPI_MTX_DO_NOT_LOCK);
break;
}
@@ -163,6 +165,9 @@ acpi_processor_power_activate (
}
+static atomic_t c3_cpu_count;
+
+
static void acpi_processor_idle (void)
{
struct acpi_processor *pr = NULL;
@@ -297,8 +302,22 @@ static void acpi_processor_idle (void)
break;
case ACPI_STATE_C3:
- /* Disable bus master arbitration */
- acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK);
+
+ if (pr->flags.bm_check) {
+ if (atomic_inc_return(&c3_cpu_count) ==
+ num_online_cpus()) {
+ /*
+ * All CPUs are trying to go to C3
+ * Disable bus master arbitration
+ */
+ acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1,
+ ACPI_MTX_DO_NOT_LOCK);
+ }
+ } else {
+ /* SMP with no shared cache... Invalidate cache */
+ ACPI_FLUSH_CPU_CACHE();
+ }
+
/* Get start time (ticks) */
t1 = inl(acpi_fadt.xpm_tmr_blk.address);
/* Invoke C3 */
@@ -307,8 +326,12 @@ static void acpi_processor_idle (void)
t2 = inl(acpi_fadt.xpm_tmr_blk.address);
/* Get end time (ticks) */
t2 = inl(acpi_fadt.xpm_tmr_blk.address);
- /* Enable bus master arbitration */
- acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
+ if (pr->flags.bm_check) {
+ /* Enable bus master arbitration */
+ atomic_dec(&c3_cpu_count);
+ acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
+ }
+
/* Re-enable interrupts */
local_irq_enable();
/* Compute time (ticks) that we were actually asleep */
@@ -519,6 +542,29 @@ static int acpi_processor_get_power_info_fadt (struct acpi_processor *pr)
}
+static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
+{
+ int i;
+
+ ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
+
+ for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
+ memset(pr->power.states, 0, sizeof(struct acpi_processor_cx));
+
+ /* if info is obtained from pblk/fadt, type equals state */
+ pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
+ pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
+ pr->power.states[ACPI_STATE_C3].type = ACPI_STATE_C3;
+
+ /* the C0 state only exists as a filler in our array,
+ * and all processors need to support C1 */
+ pr->power.states[ACPI_STATE_C0].valid = 1;
+ pr->power.states[ACPI_STATE_C1].valid = 1;
+
+ return_VALUE(0);
+}
+
+
static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
{
acpi_status status = 0;
@@ -529,9 +575,6 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
- if (errata.smp)
- return_VALUE(-ENODEV);
-
if (nocst)
return_VALUE(-ENODEV);
@@ -664,13 +707,6 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
return_VOID;
}
- /* We're (currently) only supporting C2 on UP */
- else if (errata.smp) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "C2 not supported in SMP mode\n"));
- return_VOID;
- }
-
/*
* Otherwise we've met all of our C2 requirements.
* Normalize the C2 latency to expidite policy
@@ -686,6 +722,8 @@ static void acpi_processor_power_verify_c3(
struct acpi_processor *pr,
struct acpi_processor_cx *cx)
{
+ static int bm_check_flag;
+
ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
if (!cx->address)
@@ -702,20 +740,6 @@ static void acpi_processor_power_verify_c3(
return_VOID;
}
- /* bus mastering control is necessary */
- else if (!pr->flags.bm_control) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "C3 support requires bus mastering control\n"));
- return_VOID;
- }
-
- /* We're (currently) only supporting C2 on UP */
- else if (errata.smp) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "C3 not supported in SMP mode\n"));
- return_VOID;
- }
-
/*
* PIIX4 Erratum #18: We don't support C3 when Type-F (fast)
* DMA transfers are used by any ISA device to avoid livelock.
@@ -729,6 +753,39 @@ static void acpi_processor_power_verify_c3(
return_VOID;
}
+ /* All the logic here assumes flags.bm_check is same across all CPUs */
+ if (!bm_check_flag) {
+ /* Determine whether bm_check is needed based on CPU */
+ acpi_processor_power_init_bm_check(&(pr->flags), pr->id);
+ bm_check_flag = pr->flags.bm_check;
+ } else {
+ pr->flags.bm_check = bm_check_flag;
+ }
+
+ if (pr->flags.bm_check) {
+ printk("Disabling BM access before entering C3\n");
+ /* bus mastering control is necessary */
+ if (!pr->flags.bm_control) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "C3 support requires bus mastering control\n"));
+ return_VOID;
+ }
+ } else {
+ printk("Invalidating cache before entering C3\n");
+ /*
+ * WBINVD should be set in fadt, for C3 state to be
+ * supported on when bm_check is not required.
+ */
+ if (acpi_fadt.wb_invd != 1) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "Cache invalidation should work properly"
+ " for C3 to be enabled on SMP systems\n"));
+ return_VOID;
+ }
+ acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
+ 0, ACPI_MTX_DO_NOT_LOCK);
+ }
+
/*
* Otherwise we've met all of our C3 requirements.
* Normalize the C3 latency to expidite policy. Enable
@@ -737,7 +794,6 @@ static void acpi_processor_power_verify_c3(
*/
cx->valid = 1;
cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
- pr->flags.bm_check = 1;
return_VOID;
}
@@ -787,10 +843,7 @@ static int acpi_processor_get_power_info (
if ((result) || (acpi_processor_power_verify(pr) < 2)) {
result = acpi_processor_get_power_info_fadt(pr);
if (result)
- return_VALUE(result);
-
- if (acpi_processor_power_verify(pr) < 2)
- return_VALUE(-ENODEV);
+ result = acpi_processor_get_power_info_default_c1(pr);
}
/*
@@ -810,11 +863,10 @@ static int acpi_processor_get_power_info (
* CPU as being "idle manageable"
*/
for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
- if (pr->power.states[i].valid)
+ if (pr->power.states[i].valid) {
pr->power.count = i;
- if ((pr->power.states[i].valid) &&
- (pr->power.states[i].type >= ACPI_STATE_C2))
pr->flags.power = 1;
+ }
}
return_VALUE(0);
@@ -829,7 +881,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
if (!pr)
return_VALUE(-EINVAL);
- if (errata.smp || nocst) {
+ if ( nocst) {
return_VALUE(-ENODEV);
}
@@ -929,7 +981,6 @@ static struct file_operations acpi_processor_power_fops = {
.release = single_release,
};
-
int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device)
{
acpi_status status = 0;
@@ -946,7 +997,10 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
first_run++;
}
- if (!errata.smp && (pr->id == 0) && acpi_fadt.cst_cnt && !nocst) {
+ if (!pr)
+ return_VALUE(-EINVAL);
+
+ if (acpi_fadt.cst_cnt && !nocst) {
status = acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -954,6 +1008,8 @@ int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *dev
}
}
+ acpi_processor_power_init_pdc(&(pr->power), pr->id);
+ acpi_processor_set_pdc(pr, pr->power.pdc);
acpi_processor_get_power_info(pr);
/*
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index a9a1a8fe319..1f0d6256302 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -165,37 +165,6 @@ void acpi_processor_ppc_exit(void) {
acpi_processor_ppc_status &= ~PPC_REGISTERED;
}
-/*
- * when registering a cpufreq driver with this ACPI processor driver, the
- * _PCT and _PSS structures are read out and written into struct
- * acpi_processor_performance.
- */
-static int acpi_processor_set_pdc (struct acpi_processor *pr)
-{
- acpi_status status = AE_OK;
- u32 arg0_buf[3];
- union acpi_object arg0 = {ACPI_TYPE_BUFFER};
- struct acpi_object_list no_object = {1, &arg0};
- struct acpi_object_list *pdc;
-
- ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
-
- arg0.buffer.length = 12;
- arg0.buffer.pointer = (u8 *) arg0_buf;
- arg0_buf[0] = ACPI_PDC_REVISION_ID;
- arg0_buf[1] = 0;
- arg0_buf[2] = 0;
-
- pdc = (pr->performance->pdc) ? pr->performance->pdc : &no_object;
-
- status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
-
- if ((ACPI_FAILURE(status)) && (pr->performance->pdc))
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n"));
-
- return_VALUE(status);
-}
-
static int
acpi_processor_get_performance_control (
@@ -357,7 +326,7 @@ acpi_processor_get_performance_info (
if (!pr || !pr->performance || !pr->handle)
return_VALUE(-EINVAL);
- acpi_processor_set_pdc(pr);
+ acpi_processor_set_pdc(pr, pr->performance->pdc);
status = acpi_get_handle(pr->handle, "_PCT", &handle);
if (ACPI_FAILURE(status)) {
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/resources/rsaddr.c
index 4788c079735..55d264771c4 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/resources/rsaddr.c
@@ -77,21 +77,21 @@ acpi_rs_address16_resource (
u8 **output_buffer,
acpi_size *structure_size)
{
- u8 *buffer = byte_stream_buffer;
- struct acpi_resource *output_struct = (void *) *output_buffer;
- u8 *temp_ptr;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16);
u32 index;
u16 temp16;
u8 temp8;
+ u8 *temp_ptr;
+ u8 *buffer = byte_stream_buffer;
+ struct acpi_resource *output_struct = (void *) *output_buffer;
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_address16);
ACPI_FUNCTION_TRACE ("rs_address16_resource");
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -104,9 +104,8 @@ acpi_rs_address16_resource (
*bytes_consumed = temp16 + 3;
output_struct->id = ACPI_RSTYPE_ADDRESS16;
- /*
- * Get the Resource Type (Byte3)
- */
+ /* Get the Resource Type (Byte3) */
+
buffer += 2;
temp8 = *buffer;
@@ -118,9 +117,8 @@ acpi_rs_address16_resource (
output_struct->data.address16.resource_type = temp8;
- /*
- * Get the General Flags (Byte4)
- */
+ /* Get the General Flags (Byte4) */
+
buffer += 1;
temp8 = *buffer;
@@ -140,9 +138,8 @@ acpi_rs_address16_resource (
output_struct->data.address16.max_address_fixed = (temp8 >> 3) & 0x01;
- /*
- * Get the Type Specific Flags (Byte5)
- */
+ /* Get the Type Specific Flags (Byte5) */
+
buffer += 1;
temp8 = *buffer;
@@ -165,39 +162,34 @@ acpi_rs_address16_resource (
}
}
- /*
- * Get Granularity (Bytes 6-7)
- */
+ /* Get Granularity (Bytes 6-7) */
+
buffer += 1;
ACPI_MOVE_16_TO_32 (&output_struct->data.address16.granularity, buffer);
- /*
- * Get min_address_range (Bytes 8-9)
- */
+ /* Get min_address_range (Bytes 8-9) */
+
buffer += 2;
ACPI_MOVE_16_TO_32 (&output_struct->data.address16.min_address_range, buffer);
- /*
- * Get max_address_range (Bytes 10-11)
- */
+ /* Get max_address_range (Bytes 10-11) */
+
buffer += 2;
ACPI_MOVE_16_TO_32 (&output_struct->data.address16.max_address_range, buffer);
- /*
- * Get address_translation_offset (Bytes 12-13)
- */
+ /* Get address_translation_offset (Bytes 12-13) */
+
buffer += 2;
- ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset, buffer);
+ ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_translation_offset,
+ buffer);
+
+ /* Get address_length (Bytes 14-15) */
- /*
- * Get address_length (Bytes 14-15)
- */
buffer += 2;
ACPI_MOVE_16_TO_32 (&output_struct->data.address16.address_length, buffer);
- /*
- * Resource Source Index (if present)
- */
+ /* Resource Source Index (if present) */
+
buffer += 2;
/*
@@ -225,7 +217,8 @@ acpi_rs_address16_resource (
output_struct->data.address16.resource_source.string_ptr =
(char *)((u8 * )output_struct + struct_size);
- temp_ptr = (u8 *) output_struct->data.address16.resource_source.string_ptr;
+ temp_ptr = (u8 *)
+ output_struct->data.address16.resource_source.string_ptr;
/* Copy the string into the buffer */
@@ -239,9 +232,8 @@ acpi_rs_address16_resource (
index += 1;
}
- /*
- * Add the terminating null
- */
+ /* Add the terminating null */
+
*temp_ptr = 0x00;
output_struct->data.address16.resource_source.string_length = index + 1;
@@ -260,14 +252,12 @@ acpi_rs_address16_resource (
output_struct->data.address16.resource_source.string_ptr = NULL;
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -305,28 +295,24 @@ acpi_rs_address16_stream (
ACPI_FUNCTION_TRACE ("rs_address16_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x88;
buffer += 1;
- /*
- * Save a pointer to the Length field - to be filled in later
- */
+ /* Save a pointer to the Length field - to be filled in later */
+
length_field = buffer;
buffer += 2;
- /*
- * Set the Resource Type (Memory, Io, bus_number)
- */
+ /* Set the Resource Type (Memory, Io, bus_number) */
+
temp8 = (u8) (linked_list->data.address16.resource_type & 0x03);
*buffer = temp8;
buffer += 1;
- /*
- * Set the general flags
- */
+ /* Set the general flags */
+
temp8 = (u8) (linked_list->data.address16.producer_consumer & 0x01);
temp8 |= (linked_list->data.address16.decode & 0x01) << 1;
@@ -336,9 +322,8 @@ acpi_rs_address16_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the type specific flags
- */
+ /* Set the type specific flags */
+
temp8 = 0;
if (ACPI_MEMORY_RANGE == linked_list->data.address16.resource_type) {
@@ -362,39 +347,34 @@ acpi_rs_address16_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the address space granularity
- */
+ /* Set the address space granularity */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.granularity);
buffer += 2;
- /*
- * Set the address range minimum
- */
+ /* Set the address range minimum */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.min_address_range);
buffer += 2;
- /*
- * Set the address range maximum
- */
+ /* Set the address range maximum */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.max_address_range);
buffer += 2;
- /*
- * Set the address translation offset
- */
- ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_translation_offset);
+ /* Set the address translation offset */
+
+ ACPI_MOVE_32_TO_16 (buffer,
+ &linked_list->data.address16.address_translation_offset);
buffer += 2;
- /*
- * Set the address length
- */
+ /* Set the address length */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.address16.address_length);
buffer += 2;
- /*
- * Resource Source Index and Resource Source are optional
- */
+ /* Resource Source Index and Resource Source are optional */
+
if (0 != linked_list->data.address16.resource_source.string_length) {
temp8 = (u8) linked_list->data.address16.resource_source.index;
@@ -403,9 +383,8 @@ acpi_rs_address16_stream (
temp_pointer = (char *) buffer;
- /*
- * Copy the string
- */
+ /* Copy the string */
+
ACPI_STRCPY (temp_pointer,
linked_list->data.address16.resource_source.string_ptr);
@@ -413,12 +392,12 @@ acpi_rs_address16_stream (
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address16.resource_source.string_ptr) + 1);
+ buffer += (acpi_size)(ACPI_STRLEN (
+ linked_list->data.address16.resource_source.string_ptr) + 1);
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
actual_bytes = ACPI_PTR_DIFF (buffer, *output_buffer);
*bytes_consumed = actual_bytes;
@@ -475,9 +454,8 @@ acpi_rs_address32_resource (
buffer = byte_stream_buffer;
struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32);
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -490,9 +468,8 @@ acpi_rs_address32_resource (
*bytes_consumed = temp16 + 3;
output_struct->id = ACPI_RSTYPE_ADDRESS32;
- /*
- * Get the Resource Type (Byte3)
- */
+ /* Get the Resource Type (Byte3) */
+
buffer += 2;
temp8 = *buffer;
@@ -504,35 +481,29 @@ acpi_rs_address32_resource (
output_struct->data.address32.resource_type = temp8;
- /*
- * Get the General Flags (Byte4)
- */
+ /* Get the General Flags (Byte4) */
+
buffer += 1;
temp8 = *buffer;
- /*
- * Producer / Consumer
- */
+ /* Producer / Consumer */
+
output_struct->data.address32.producer_consumer = temp8 & 0x01;
- /*
- * Decode
- */
+ /* Decode */
+
output_struct->data.address32.decode = (temp8 >> 1) & 0x01;
- /*
- * Min Address Fixed
- */
+ /* Min Address Fixed */
+
output_struct->data.address32.min_address_fixed = (temp8 >> 2) & 0x01;
- /*
- * Max Address Fixed
- */
+ /* Max Address Fixed */
+
output_struct->data.address32.max_address_fixed = (temp8 >> 3) & 0x01;
- /*
- * Get the Type Specific Flags (Byte5)
- */
+ /* Get the Type Specific Flags (Byte5) */
+
buffer += 1;
temp8 = *buffer;
@@ -556,39 +527,34 @@ acpi_rs_address32_resource (
}
}
- /*
- * Get Granularity (Bytes 6-9)
- */
+ /* Get Granularity (Bytes 6-9) */
+
buffer += 1;
ACPI_MOVE_32_TO_32 (&output_struct->data.address32.granularity, buffer);
- /*
- * Get min_address_range (Bytes 10-13)
- */
+ /* Get min_address_range (Bytes 10-13) */
+
buffer += 4;
ACPI_MOVE_32_TO_32 (&output_struct->data.address32.min_address_range, buffer);
- /*
- * Get max_address_range (Bytes 14-17)
- */
+ /* Get max_address_range (Bytes 14-17) */
+
buffer += 4;
ACPI_MOVE_32_TO_32 (&output_struct->data.address32.max_address_range, buffer);
- /*
- * Get address_translation_offset (Bytes 18-21)
- */
+ /* Get address_translation_offset (Bytes 18-21) */
+
buffer += 4;
- ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset, buffer);
+ ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_translation_offset,
+ buffer);
+
+ /* Get address_length (Bytes 22-25) */
- /*
- * Get address_length (Bytes 22-25)
- */
buffer += 4;
ACPI_MOVE_32_TO_32 (&output_struct->data.address32.address_length, buffer);
- /*
- * Resource Source Index (if present)
- */
+ /* Resource Source Index (if present) */
+
buffer += 4;
/*
@@ -615,7 +581,8 @@ acpi_rs_address32_resource (
output_struct->data.address32.resource_source.string_ptr =
(char *)((u8 *)output_struct + struct_size);
- temp_ptr = (u8 *) output_struct->data.address32.resource_source.string_ptr;
+ temp_ptr = (u8 *)
+ output_struct->data.address32.resource_source.string_ptr;
/* Copy the string into the buffer */
@@ -628,9 +595,8 @@ acpi_rs_address32_resource (
index += 1;
}
- /*
- * Add the terminating null
- */
+ /* Add the terminating null */
+
*temp_ptr = 0x00;
output_struct->data.address32.resource_source.string_length = index + 1;
@@ -648,14 +614,12 @@ acpi_rs_address32_resource (
output_struct->data.address32.resource_source.string_ptr = NULL;
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -694,29 +658,25 @@ acpi_rs_address32_stream (
buffer = *output_buffer;
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x87;
buffer += 1;
- /*
- * Set a pointer to the Length field - to be filled in later
- */
+ /* Set a pointer to the Length field - to be filled in later */
+
length_field = ACPI_CAST_PTR (u16, buffer);
buffer += 2;
- /*
- * Set the Resource Type (Memory, Io, bus_number)
- */
+ /* Set the Resource Type (Memory, Io, bus_number) */
+
temp8 = (u8) (linked_list->data.address32.resource_type & 0x03);
*buffer = temp8;
buffer += 1;
- /*
- * Set the general flags
- */
+ /* Set the general flags */
+
temp8 = (u8) (linked_list->data.address32.producer_consumer & 0x01);
temp8 |= (linked_list->data.address32.decode & 0x01) << 1;
temp8 |= (linked_list->data.address32.min_address_fixed & 0x01) << 2;
@@ -725,9 +685,8 @@ acpi_rs_address32_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the type specific flags
- */
+ /* Set the type specific flags */
+
temp8 = 0;
if (ACPI_MEMORY_RANGE == linked_list->data.address32.resource_type) {
@@ -751,39 +710,34 @@ acpi_rs_address32_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the address space granularity
- */
+ /* Set the address space granularity */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.granularity);
buffer += 4;
- /*
- * Set the address range minimum
- */
+ /* Set the address range minimum */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.min_address_range);
buffer += 4;
- /*
- * Set the address range maximum
- */
+ /* Set the address range maximum */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.max_address_range);
buffer += 4;
- /*
- * Set the address translation offset
- */
- ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_translation_offset);
+ /* Set the address translation offset */
+
+ ACPI_MOVE_32_TO_32 (buffer,
+ &linked_list->data.address32.address_translation_offset);
buffer += 4;
- /*
- * Set the address length
- */
+ /* Set the address length */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.address32.address_length);
buffer += 4;
- /*
- * Resource Source Index and Resource Source are optional
- */
+ /* Resource Source Index and Resource Source are optional */
+
if (0 != linked_list->data.address32.resource_source.string_length) {
temp8 = (u8) linked_list->data.address32.resource_source.index;
@@ -792,9 +746,8 @@ acpi_rs_address32_stream (
temp_pointer = (char *) buffer;
- /*
- * Copy the string
- */
+ /* Copy the string */
+
ACPI_STRCPY (temp_pointer,
linked_list->data.address32.resource_source.string_ptr);
@@ -802,12 +755,12 @@ acpi_rs_address32_stream (
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address32.resource_source.string_ptr) + 1);
+ buffer += (acpi_size)(ACPI_STRLEN (
+ linked_list->data.address32.resource_source.string_ptr) + 1);
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
/*
@@ -864,9 +817,8 @@ acpi_rs_address64_resource (
struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64);
resource_type = *buffer;
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -879,9 +831,8 @@ acpi_rs_address64_resource (
*bytes_consumed = temp16 + 3;
output_struct->id = ACPI_RSTYPE_ADDRESS64;
- /*
- * Get the Resource Type (Byte3)
- */
+ /* Get the Resource Type (Byte3) */
+
buffer += 2;
temp8 = *buffer;
@@ -893,35 +844,29 @@ acpi_rs_address64_resource (
output_struct->data.address64.resource_type = temp8;
- /*
- * Get the General Flags (Byte4)
- */
+ /* Get the General Flags (Byte4) */
+
buffer += 1;
temp8 = *buffer;
- /*
- * Producer / Consumer
- */
+ /* Producer / Consumer */
+
output_struct->data.address64.producer_consumer = temp8 & 0x01;
- /*
- * Decode
- */
+ /* Decode */
+
output_struct->data.address64.decode = (temp8 >> 1) & 0x01;
- /*
- * Min Address Fixed
- */
+ /* Min Address Fixed */
+
output_struct->data.address64.min_address_fixed = (temp8 >> 2) & 0x01;
- /*
- * Max Address Fixed
- */
+ /* Max Address Fixed */
+
output_struct->data.address64.max_address_fixed = (temp8 >> 3) & 0x01;
- /*
- * Get the Type Specific Flags (Byte5)
- */
+ /* Get the Type Specific Flags (Byte5) */
+
buffer += 1;
temp8 = *buffer;
@@ -951,33 +896,29 @@ acpi_rs_address64_resource (
buffer += 2;
}
- /*
- * Get Granularity (Bytes 6-13) or (Bytes 8-15)
- */
+ /* Get Granularity (Bytes 6-13) or (Bytes 8-15) */
+
buffer += 1;
ACPI_MOVE_64_TO_64 (&output_struct->data.address64.granularity, buffer);
- /*
- * Get min_address_range (Bytes 14-21) or (Bytes 16-23)
- */
+ /* Get min_address_range (Bytes 14-21) or (Bytes 16-23) */
+
buffer += 8;
ACPI_MOVE_64_TO_64 (&output_struct->data.address64.min_address_range, buffer);
- /*
- * Get max_address_range (Bytes 22-29) or (Bytes 24-31)
- */
+ /* Get max_address_range (Bytes 22-29) or (Bytes 24-31) */
+
buffer += 8;
ACPI_MOVE_64_TO_64 (&output_struct->data.address64.max_address_range, buffer);
- /*
- * Get address_translation_offset (Bytes 30-37) or (Bytes 32-39)
- */
+ /* Get address_translation_offset (Bytes 30-37) or (Bytes 32-39) */
+
buffer += 8;
- ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset, buffer);
+ ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_translation_offset,
+ buffer);
+
+ /* Get address_length (Bytes 38-45) or (Bytes 40-47) */
- /*
- * Get address_length (Bytes 38-45) or (Bytes 40-47)
- */
buffer += 8;
ACPI_MOVE_64_TO_64 (&output_struct->data.address64.address_length, buffer);
@@ -989,14 +930,15 @@ acpi_rs_address64_resource (
/* Get type_specific_attribute (Bytes 48-55) */
buffer += 8;
- ACPI_MOVE_64_TO_64 (&output_struct->data.address64.type_specific_attributes, buffer);
+ ACPI_MOVE_64_TO_64 (
+ &output_struct->data.address64.type_specific_attributes,
+ buffer);
}
else {
output_struct->data.address64.type_specific_attributes = 0;
- /*
- * Resource Source Index (if present)
- */
+ /* Resource Source Index (if present) */
+
buffer += 8;
/*
@@ -1025,7 +967,8 @@ acpi_rs_address64_resource (
output_struct->data.address64.resource_source.string_ptr =
(char *)((u8 *)output_struct + struct_size);
- temp_ptr = (u8 *) output_struct->data.address64.resource_source.string_ptr;
+ temp_ptr = (u8 *)
+ output_struct->data.address64.resource_source.string_ptr;
/* Copy the string into the buffer */
@@ -1042,7 +985,8 @@ acpi_rs_address64_resource (
* Add the terminating null
*/
*temp_ptr = 0x00;
- output_struct->data.address64.resource_source.string_length = index + 1;
+ output_struct->data.address64.resource_source.string_length =
+ index + 1;
/*
* In order for the struct_size to fall on a 32-bit boundary,
@@ -1054,14 +998,12 @@ acpi_rs_address64_resource (
}
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -1100,29 +1042,25 @@ acpi_rs_address64_stream (
buffer = *output_buffer;
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x8A;
buffer += 1;
- /*
- * Set a pointer to the Length field - to be filled in later
- */
+ /* Set a pointer to the Length field - to be filled in later */
+
length_field = ACPI_CAST_PTR (u16, buffer);
buffer += 2;
- /*
- * Set the Resource Type (Memory, Io, bus_number)
- */
+ /* Set the Resource Type (Memory, Io, bus_number) */
+
temp8 = (u8) (linked_list->data.address64.resource_type & 0x03);
*buffer = temp8;
buffer += 1;
- /*
- * Set the general flags
- */
+ /* Set the general flags */
+
temp8 = (u8) (linked_list->data.address64.producer_consumer & 0x01);
temp8 |= (linked_list->data.address64.decode & 0x01) << 1;
temp8 |= (linked_list->data.address64.min_address_fixed & 0x01) << 2;
@@ -1131,9 +1069,8 @@ acpi_rs_address64_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the type specific flags
- */
+ /* Set the type specific flags */
+
temp8 = 0;
if (ACPI_MEMORY_RANGE == linked_list->data.address64.resource_type) {
@@ -1157,39 +1094,34 @@ acpi_rs_address64_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the address space granularity
- */
+ /* Set the address space granularity */
+
ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.granularity);
buffer += 8;
- /*
- * Set the address range minimum
- */
+ /* Set the address range minimum */
+
ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.min_address_range);
buffer += 8;
- /*
- * Set the address range maximum
- */
+ /* Set the address range maximum */
+
ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.max_address_range);
buffer += 8;
- /*
- * Set the address translation offset
- */
- ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_translation_offset);
+ /* Set the address translation offset */
+
+ ACPI_MOVE_64_TO_64 (buffer,
+ &linked_list->data.address64.address_translation_offset);
buffer += 8;
- /*
- * Set the address length
- */
+ /* Set the address length */
+
ACPI_MOVE_64_TO_64 (buffer, &linked_list->data.address64.address_length);
buffer += 8;
- /*
- * Resource Source Index and Resource Source are optional
- */
+ /* Resource Source Index and Resource Source are optional */
+
if (0 != linked_list->data.address64.resource_source.string_length) {
temp8 = (u8) linked_list->data.address64.resource_source.index;
@@ -1198,21 +1130,21 @@ acpi_rs_address64_stream (
temp_pointer = (char *) buffer;
- /*
- * Copy the string
- */
- ACPI_STRCPY (temp_pointer, linked_list->data.address64.resource_source.string_ptr);
+ /* Copy the string */
+
+ ACPI_STRCPY (temp_pointer,
+ linked_list->data.address64.resource_source.string_ptr);
/*
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.address64.resource_source.string_ptr) + 1);
+ buffer += (acpi_size)(ACPI_STRLEN (
+ linked_list->data.address64.resource_source.string_ptr) + 1);
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
/*
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index 8a5f0a52371..98176f2fcb5 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -81,9 +81,8 @@ acpi_rs_get_byte_stream_length (
while (!done) {
- /*
- * Init the variable that will hold the size to add to the total.
- */
+ /* Init the variable that will hold the size to add to the total. */
+
segment_size = 0;
switch (linked_list->id) {
@@ -196,7 +195,8 @@ acpi_rs_get_byte_stream_length (
segment_size = 16;
if (linked_list->data.address16.resource_source.string_ptr) {
- segment_size += linked_list->data.address16.resource_source.string_length;
+ segment_size +=
+ linked_list->data.address16.resource_source.string_length;
segment_size++;
}
break;
@@ -212,7 +212,8 @@ acpi_rs_get_byte_stream_length (
segment_size = 26;
if (linked_list->data.address32.resource_source.string_ptr) {
- segment_size += linked_list->data.address32.resource_source.string_length;
+ segment_size +=
+ linked_list->data.address32.resource_source.string_length;
segment_size++;
}
break;
@@ -227,7 +228,8 @@ acpi_rs_get_byte_stream_length (
segment_size = 46;
if (linked_list->data.address64.resource_source.string_ptr) {
- segment_size += linked_list->data.address64.resource_source.string_length;
+ segment_size +=
+ linked_list->data.address64.resource_source.string_length;
segment_size++;
}
break;
@@ -241,38 +243,36 @@ acpi_rs_get_byte_stream_length (
* Index + the length of the null terminated string
* Resource Source + 1 for the null.
*/
- segment_size = 9 +
- (((acpi_size) linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
+ segment_size = 9 + (((acpi_size)
+ linked_list->data.extended_irq.number_of_interrupts - 1) * 4);
if (linked_list->data.extended_irq.resource_source.string_ptr) {
- segment_size += linked_list->data.extended_irq.resource_source.string_length;
+ segment_size +=
+ linked_list->data.extended_irq.resource_source.string_length;
segment_size++;
}
break;
default:
- /*
- * If we get here, everything is out of sync, exit with error
- */
+
+ /* If we get here, everything is out of sync, exit with error */
+
return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
} /* switch (linked_list->Id) */
- /*
- * Update the total
- */
+ /* Update the total */
+
byte_stream_size_needed += segment_size;
- /*
- * Point to the next object
- */
+ /* Point to the next object */
+
linked_list = ACPI_PTR_ADD (struct acpi_resource,
linked_list, linked_list->length);
}
- /*
- * This is the data the caller needs
- */
+ /* This is the data the caller needs */
+
*size_needed = byte_stream_size_needed;
return_ACPI_STATUS (AE_OK);
}
@@ -320,9 +320,8 @@ acpi_rs_get_list_length (
while (bytes_parsed < byte_stream_buffer_length) {
- /*
- * The next byte in the stream is the resource type
- */
+ /* The next byte in the stream is the resource type */
+
resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
switch (resource_type) {
@@ -346,9 +345,8 @@ acpi_rs_get_list_length (
ACPI_MOVE_16_TO_16 (&temp16, buffer);
bytes_consumed = temp16 + 3;
- /*
- * Ensure a 32-bit boundary for the structure
- */
+ /* Ensure a 32-bit boundary for the structure */
+
temp16 = (u16) ACPI_ROUND_UP_to_32_bITS (temp16);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
@@ -416,9 +414,8 @@ acpi_rs_get_list_length (
temp8 = 0;
}
- /*
- * Ensure a 64-bit boundary for the structure
- */
+ /* Ensure a 64-bit boundary for the structure */
+
temp8 = (u8) ACPI_ROUND_UP_to_64_bITS (temp8);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address64) +
@@ -452,9 +449,8 @@ acpi_rs_get_list_length (
temp8 = 0;
}
- /*
- * Ensure a 32-bit boundary for the structure
- */
+ /* Ensure a 32-bit boundary for the structure */
+
temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address32) +
@@ -488,9 +484,8 @@ acpi_rs_get_list_length (
temp8 = 0;
}
- /*
- * Ensure a 32-bit boundary for the structure
- */
+ /* Ensure a 32-bit boundary for the structure */
+
temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_address16) +
@@ -537,9 +532,8 @@ acpi_rs_get_list_length (
temp8 = 0;
}
- /*
- * Ensure a 32-bit boundary for the structure
- */
+ /* Ensure a 32-bit boundary for the structure */
+
temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq) +
@@ -567,9 +561,8 @@ acpi_rs_get_list_length (
++buffer;
- /*
- * Look at the number of bits set
- */
+ /* Look at the number of bits set */
+
ACPI_MOVE_16_TO_16 (&temp16, buffer);
for (index = 0; index < 16; index++) {
@@ -596,9 +589,8 @@ acpi_rs_get_list_length (
++buffer;
- /*
- * Look at the number of bits set
- */
+ /* Look at the number of bits set */
+
temp8 = *buffer;
for(index = 0; index < 8; index++) {
@@ -670,9 +662,8 @@ acpi_rs_get_list_length (
temp8 = (u8) (temp8 & 0x7);
bytes_consumed = temp8 + 1;
- /*
- * Ensure a 32-bit boundary for the structure
- */
+ /* Ensure a 32-bit boundary for the structure */
+
temp8 = (u8) ACPI_ROUND_UP_to_32_bITS (temp8);
structure_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor) +
(temp8 * sizeof (u8));
@@ -697,21 +688,18 @@ acpi_rs_get_list_length (
return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
}
- /*
- * Update the return value and counter
- */
+ /* Update the return value and counter */
+
buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE (structure_size);
bytes_parsed += bytes_consumed;
- /*
- * Set the byte stream to point to the next resource
- */
+ /* Set the byte stream to point to the next resource */
+
byte_stream_buffer += bytes_consumed;
}
- /*
- * This is the data the caller needs
- */
+ /* This is the data the caller needs */
+
*size_needed = buffer_size;
return_ACPI_STATUS (AE_OK);
}
@@ -767,9 +755,8 @@ acpi_rs_get_pci_routing_table_length (
top_object_list = package_object->package.elements;
for (index = 0; index < number_of_elements; index++) {
- /*
- * Dereference the sub-package
- */
+ /* Dereference the sub-package */
+
package_element = *top_object_list;
/*
@@ -778,37 +765,40 @@ acpi_rs_get_pci_routing_table_length (
*/
sub_object_list = package_element->package.elements;
- /*
- * Scan the irq_table_elements for the Source Name String
- */
+ /* Scan the irq_table_elements for the Source Name String */
+
name_found = FALSE;
for (table_index = 0; table_index < 4 && !name_found; table_index++) {
- if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*sub_object_list)) ||
- ((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*sub_object_list)) &&
- ((*sub_object_list)->reference.opcode == AML_INT_NAMEPATH_OP))) {
+ if ((ACPI_TYPE_STRING ==
+ ACPI_GET_OBJECT_TYPE (*sub_object_list)) ||
+
+ ((ACPI_TYPE_LOCAL_REFERENCE ==
+ ACPI_GET_OBJECT_TYPE (*sub_object_list)) &&
+
+ ((*sub_object_list)->reference.opcode ==
+ AML_INT_NAMEPATH_OP))) {
name_found = TRUE;
}
else {
- /*
- * Look at the next element
- */
+ /* Look at the next element */
+
sub_object_list++;
}
}
temp_size_needed += (sizeof (struct acpi_pci_routing_table) - 4);
- /*
- * Was a String type found?
- */
+ /* Was a String type found? */
+
if (name_found) {
if (ACPI_GET_OBJECT_TYPE (*sub_object_list) == ACPI_TYPE_STRING) {
/*
* The length String.Length field does not include the
* terminating NULL, add 1
*/
- temp_size_needed += ((acpi_size) (*sub_object_list)->string.length + 1);
+ temp_size_needed += ((acpi_size)
+ (*sub_object_list)->string.length + 1);
}
else {
temp_size_needed += acpi_ns_get_pathname_length (
@@ -827,14 +817,14 @@ acpi_rs_get_pci_routing_table_length (
temp_size_needed = ACPI_ROUND_UP_to_64_bITS (temp_size_needed);
- /*
- * Point to the next union acpi_operand_object
- */
+ /* Point to the next union acpi_operand_object */
+
top_object_list++;
}
/*
- * Adding an extra element to the end of the list, essentially a NULL terminator
+ * Adding an extra element to the end of the list, essentially a
+ * NULL terminator
*/
*buffer_size_needed = temp_size_needed + sizeof (struct acpi_pci_routing_table);
return_ACPI_STATUS (AE_OK);
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index a3a0cbfda68..8e0eae0d50b 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -87,9 +87,8 @@ acpi_rs_create_resource_list (
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "byte_stream_buffer = %p\n",
byte_stream_buffer));
- /*
- * Params already validated, so we don't re-validate here
- */
+ /* Params already validated, so we don't re-validate here */
+
byte_stream_buffer_length = byte_stream_buffer->buffer.length;
byte_stream_start = byte_stream_buffer->buffer.pointer;
@@ -171,9 +170,8 @@ acpi_rs_create_pci_routing_table (
/* Params already validated, so we don't re-validate here */
- /*
- * Get the required buffer length
- */
+ /* Get the required buffer length */
+
status = acpi_rs_get_pci_routing_table_length (package_object,
&buffer_size_needed);
if (ACPI_FAILURE (status)) {
@@ -217,9 +215,8 @@ acpi_rs_create_pci_routing_table (
*/
user_prt->length = (sizeof (struct acpi_pci_routing_table) - 4);
- /*
- * Each element of the top-level package must also be a package
- */
+ /* Each element of the top-level package must also be a package */
+
if (ACPI_GET_OBJECT_TYPE (*top_object_list) != ACPI_TYPE_PACKAGE) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"(PRT[%X]) Need sub-package, found %s\n",
@@ -243,9 +240,8 @@ acpi_rs_create_pci_routing_table (
*/
sub_object_list = (*top_object_list)->package.elements;
- /*
- * 1) First subobject: Dereference the PRT.Address
- */
+ /* 1) First subobject: Dereference the PRT.Address */
+
obj_desc = sub_object_list[0];
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
user_prt->address = obj_desc->integer.value;
@@ -257,9 +253,8 @@ acpi_rs_create_pci_routing_table (
return_ACPI_STATUS (AE_BAD_DATA);
}
- /*
- * 2) Second subobject: Dereference the PRT.Pin
- */
+ /* 2) Second subobject: Dereference the PRT.Pin */
+
obj_desc = sub_object_list[1];
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
user_prt->pin = (u32) obj_desc->integer.value;
@@ -271,9 +266,8 @@ acpi_rs_create_pci_routing_table (
return_ACPI_STATUS (AE_BAD_DATA);
}
- /*
- * 3) Third subobject: Dereference the PRT.source_name
- */
+ /* 3) Third subobject: Dereference the PRT.source_name */
+
obj_desc = sub_object_list[2];
switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
case ACPI_TYPE_LOCAL_REFERENCE:
@@ -296,7 +290,9 @@ acpi_rs_create_pci_routing_table (
status = acpi_ns_handle_to_pathname ((acpi_handle) node, &path_buffer);
- user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1; /* include null terminator */
+ /* +1 to include null terminator */
+
+ user_prt->length += (u32) ACPI_STRLEN (user_prt->source) + 1;
break;
@@ -304,8 +300,10 @@ acpi_rs_create_pci_routing_table (
ACPI_STRCPY (user_prt->source, obj_desc->string.pointer);
- /* Add to the Length field the length of the string (add 1 for terminator) */
-
+ /*
+ * Add to the Length field the length of the string
+ * (add 1 for terminator)
+ */
user_prt->length += obj_desc->string.length + 1;
break;
@@ -333,9 +331,8 @@ acpi_rs_create_pci_routing_table (
user_prt->length = (u32) ACPI_ROUND_UP_to_64_bITS (user_prt->length);
- /*
- * 4) Fourth subobject: Dereference the PRT.source_index
- */
+ /* 4) Fourth subobject: Dereference the PRT.source_index */
+
obj_desc = sub_object_list[3];
if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
user_prt->source_index = (u32) obj_desc->integer.value;
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index eef1b1f2c68..1935dab2ab5 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -48,9 +48,62 @@
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsdump")
+/* Local prototypes */
-#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+static void
+acpi_rs_dump_irq (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_address16 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_address32 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_address64 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_dma (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_io (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_extended_irq (
+ union acpi_resource_data *data);
+static void
+acpi_rs_dump_fixed_io (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_fixed_memory32 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_memory24 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_memory32 (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_start_depend_fns (
+ union acpi_resource_data *data);
+
+static void
+acpi_rs_dump_vendor_specific (
+ union acpi_resource_data *data);
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*******************************************************************************
*
* FUNCTION: acpi_rs_dump_irq
@@ -63,7 +116,7 @@
*
******************************************************************************/
-void
+static void
acpi_rs_dump_irq (
union acpi_resource_data *data)
{
@@ -77,13 +130,13 @@ acpi_rs_dump_irq (
acpi_os_printf ("IRQ Resource\n");
acpi_os_printf (" %s Triggered\n",
- ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
+ ACPI_LEVEL_SENSITIVE == irq_data->edge_level ? "Level" : "Edge");
acpi_os_printf (" Active %s\n",
- ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
+ ACPI_ACTIVE_LOW == irq_data->active_high_low ? "Low" : "High");
acpi_os_printf (" %s\n",
- ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
+ ACPI_SHARED == irq_data->shared_exclusive ? "Shared" : "Exclusive");
acpi_os_printf (" %X Interrupts ( ", irq_data->number_of_interrupts);
@@ -108,7 +161,7 @@ acpi_rs_dump_irq (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_dma (
union acpi_resource_data *data)
{
@@ -144,7 +197,7 @@ acpi_rs_dump_dma (
}
acpi_os_printf (" %sBus Master\n",
- ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
+ ACPI_BUS_MASTER == dma_data->bus_master ? "" : "Not a ");
switch (dma_data->transfer) {
@@ -165,7 +218,8 @@ acpi_rs_dump_dma (
break;
}
- acpi_os_printf (" Number of Channels: %X ( ", dma_data->number_of_channels);
+ acpi_os_printf (" Number of Channels: %X ( ",
+ dma_data->number_of_channels);
for (index = 0; index < dma_data->number_of_channels; index++) {
acpi_os_printf ("%X ", dma_data->channels[index]);
@@ -188,7 +242,7 @@ acpi_rs_dump_dma (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_start_depend_fns (
union acpi_resource_data *data)
{
@@ -232,8 +286,7 @@ acpi_rs_dump_start_depend_fns (
break;
default:
- acpi_os_printf (" Invalid performance "
- "robustness preference\n");
+ acpi_os_printf (" Invalid performance robustness preference\n");
break;
}
@@ -253,7 +306,7 @@ acpi_rs_dump_start_depend_fns (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_io (
union acpi_resource_data *data)
{
@@ -266,19 +319,15 @@ acpi_rs_dump_io (
acpi_os_printf ("Io Resource\n");
acpi_os_printf (" %d bit decode\n",
- ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
+ ACPI_DECODE_16 == io_data->io_decode ? 16 : 10);
- acpi_os_printf (" Range minimum base: %08X\n",
- io_data->min_base_address);
+ acpi_os_printf (" Range minimum base: %08X\n", io_data->min_base_address);
- acpi_os_printf (" Range maximum base: %08X\n",
- io_data->max_base_address);
+ acpi_os_printf (" Range maximum base: %08X\n", io_data->max_base_address);
- acpi_os_printf (" Alignment: %08X\n",
- io_data->alignment);
+ acpi_os_printf (" Alignment: %08X\n", io_data->alignment);
- acpi_os_printf (" Range Length: %08X\n",
- io_data->range_length);
+ acpi_os_printf (" Range Length: %08X\n", io_data->range_length);
return;
}
@@ -296,7 +345,7 @@ acpi_rs_dump_io (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_fixed_io (
union acpi_resource_data *data)
{
@@ -307,11 +356,9 @@ acpi_rs_dump_fixed_io (
acpi_os_printf ("Fixed Io Resource\n");
- acpi_os_printf (" Range base address: %08X",
- fixed_io_data->base_address);
+ acpi_os_printf (" Range base address: %08X", fixed_io_data->base_address);
- acpi_os_printf (" Range length: %08X",
- fixed_io_data->range_length);
+ acpi_os_printf (" Range length: %08X", fixed_io_data->range_length);
return;
}
@@ -329,7 +376,7 @@ acpi_rs_dump_fixed_io (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_vendor_specific (
union acpi_resource_data *data)
{
@@ -346,7 +393,7 @@ acpi_rs_dump_vendor_specific (
for (index = 0; index < vendor_data->length; index++) {
acpi_os_printf (" Byte %X: %08X\n",
- index, vendor_data->reserved[index]);
+ index, vendor_data->reserved[index]);
}
return;
@@ -365,7 +412,7 @@ acpi_rs_dump_vendor_specific (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_memory24 (
union acpi_resource_data *data)
{
@@ -378,21 +425,19 @@ acpi_rs_dump_memory24 (
acpi_os_printf ("24-Bit Memory Range Resource\n");
acpi_os_printf (" Read%s\n",
- ACPI_READ_WRITE_MEMORY ==
- memory24_data->read_write_attribute ?
- "/Write" : " only");
+ ACPI_READ_WRITE_MEMORY ==
+ memory24_data->read_write_attribute ?
+ "/Write" : " only");
acpi_os_printf (" Range minimum base: %08X\n",
- memory24_data->min_base_address);
+ memory24_data->min_base_address);
acpi_os_printf (" Range maximum base: %08X\n",
- memory24_data->max_base_address);
+ memory24_data->max_base_address);
- acpi_os_printf (" Alignment: %08X\n",
- memory24_data->alignment);
+ acpi_os_printf (" Alignment: %08X\n", memory24_data->alignment);
- acpi_os_printf (" Range length: %08X\n",
- memory24_data->range_length);
+ acpi_os_printf (" Range length: %08X\n", memory24_data->range_length);
return;
}
@@ -410,7 +455,7 @@ acpi_rs_dump_memory24 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_memory32 (
union acpi_resource_data *data)
{
@@ -423,21 +468,19 @@ acpi_rs_dump_memory32 (
acpi_os_printf ("32-Bit Memory Range Resource\n");
acpi_os_printf (" Read%s\n",
- ACPI_READ_WRITE_MEMORY ==
- memory32_data->read_write_attribute ?
- "/Write" : " only");
+ ACPI_READ_WRITE_MEMORY ==
+ memory32_data->read_write_attribute ?
+ "/Write" : " only");
acpi_os_printf (" Range minimum base: %08X\n",
- memory32_data->min_base_address);
+ memory32_data->min_base_address);
acpi_os_printf (" Range maximum base: %08X\n",
- memory32_data->max_base_address);
+ memory32_data->max_base_address);
- acpi_os_printf (" Alignment: %08X\n",
- memory32_data->alignment);
+ acpi_os_printf (" Alignment: %08X\n", memory32_data->alignment);
- acpi_os_printf (" Range length: %08X\n",
- memory32_data->range_length);
+ acpi_os_printf (" Range length: %08X\n", memory32_data->range_length);
return;
}
@@ -455,11 +498,12 @@ acpi_rs_dump_memory32 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_fixed_memory32 (
union acpi_resource_data *data)
{
- struct acpi_resource_fixed_mem32 *fixed_memory32_data = (struct acpi_resource_fixed_mem32 *) data;
+ struct acpi_resource_fixed_mem32 *fixed_memory32_data =
+ (struct acpi_resource_fixed_mem32 *) data;
ACPI_FUNCTION_ENTRY ();
@@ -468,15 +512,14 @@ acpi_rs_dump_fixed_memory32 (
acpi_os_printf ("32-Bit Fixed Location Memory Range Resource\n");
acpi_os_printf (" Read%s\n",
- ACPI_READ_WRITE_MEMORY ==
- fixed_memory32_data->read_write_attribute ?
- "/Write" : " Only");
+ ACPI_READ_WRITE_MEMORY ==
+ fixed_memory32_data->read_write_attribute ? "/Write" : " Only");
acpi_os_printf (" Range base address: %08X\n",
- fixed_memory32_data->range_base_address);
+ fixed_memory32_data->range_base_address);
acpi_os_printf (" Range length: %08X\n",
- fixed_memory32_data->range_length);
+ fixed_memory32_data->range_length);
return;
}
@@ -494,7 +537,7 @@ acpi_rs_dump_fixed_memory32 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_address16 (
union acpi_resource_data *data)
{
@@ -514,35 +557,30 @@ acpi_rs_dump_address16 (
switch (address16_data->attribute.memory.cache_attribute) {
case ACPI_NON_CACHEABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Noncacheable memory\n");
+ acpi_os_printf (" Type Specific: Noncacheable memory\n");
break;
case ACPI_CACHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Cacheable memory\n");
+ acpi_os_printf (" Type Specific: Cacheable memory\n");
break;
case ACPI_WRITE_COMBINING_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Write-combining memory\n");
+ acpi_os_printf (" Type Specific: Write-combining memory\n");
break;
case ACPI_PREFETCHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Prefetchable memory\n");
+ acpi_os_printf (" Type Specific: Prefetchable memory\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid cache attribute\n");
+ acpi_os_printf (" Type Specific: Invalid cache attribute\n");
break;
}
acpi_os_printf (" Type Specific: Read%s\n",
ACPI_READ_WRITE_MEMORY ==
- address16_data->attribute.memory.read_write_attribute ?
- "/Write" : " Only");
+ address16_data->attribute.memory.read_write_attribute ?
+ "/Write" : " Only");
break;
case ACPI_IO_RANGE:
@@ -551,30 +589,26 @@ acpi_rs_dump_address16 (
switch (address16_data->attribute.io.range_attribute) {
case ACPI_NON_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "Non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
break;
case ACPI_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA Io Addresses\n");
break;
case ACPI_ENTIRE_RANGE:
- acpi_os_printf (" Type Specific: "
- "ISA and non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid range attribute\n");
+ acpi_os_printf (" Type Specific: Invalid range attribute\n");
break;
}
acpi_os_printf (" Type Specific: %s Translation\n",
ACPI_SPARSE_TRANSLATION ==
- address16_data->attribute.io.translation_attribute ?
- "Sparse" : "Dense");
+ address16_data->attribute.io.translation_attribute ?
+ "Sparse" : "Dense");
break;
case ACPI_BUS_NUMBER_RANGE:
@@ -589,41 +623,42 @@ acpi_rs_dump_address16 (
}
acpi_os_printf (" Resource %s\n",
- ACPI_CONSUMER == address16_data->producer_consumer ?
+ ACPI_CONSUMER == address16_data->producer_consumer ?
"Consumer" : "Producer");
acpi_os_printf (" %s decode\n",
- ACPI_SUB_DECODE == address16_data->decode ?
- "Subtractive" : "Positive");
+ ACPI_SUB_DECODE == address16_data->decode ?
+ "Subtractive" : "Positive");
acpi_os_printf (" Min address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
- "" : "not");
+ ACPI_ADDRESS_FIXED == address16_data->min_address_fixed ?
+ "" : "not");
acpi_os_printf (" Max address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
- "" : "not");
+ ACPI_ADDRESS_FIXED == address16_data->max_address_fixed ?
+ "" : "not");
acpi_os_printf (" Granularity: %08X\n",
- address16_data->granularity);
+ address16_data->granularity);
acpi_os_printf (" Address range min: %08X\n",
- address16_data->min_address_range);
+ address16_data->min_address_range);
acpi_os_printf (" Address range max: %08X\n",
- address16_data->max_address_range);
+ address16_data->max_address_range);
acpi_os_printf (" Address translation offset: %08X\n",
- address16_data->address_translation_offset);
+ address16_data->address_translation_offset);
acpi_os_printf (" Address Length: %08X\n",
- address16_data->address_length);
+ address16_data->address_length);
if (0xFF != address16_data->resource_source.index) {
acpi_os_printf (" Resource Source Index: %X\n",
- address16_data->resource_source.index);
+ address16_data->resource_source.index);
+
acpi_os_printf (" Resource Source: %s\n",
- address16_data->resource_source.string_ptr);
+ address16_data->resource_source.string_ptr);
}
return;
@@ -642,7 +677,7 @@ acpi_rs_dump_address16 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_address32 (
union acpi_resource_data *data)
{
@@ -661,35 +696,30 @@ acpi_rs_dump_address32 (
switch (address32_data->attribute.memory.cache_attribute) {
case ACPI_NON_CACHEABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Noncacheable memory\n");
+ acpi_os_printf (" Type Specific: Noncacheable memory\n");
break;
case ACPI_CACHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Cacheable memory\n");
+ acpi_os_printf (" Type Specific: Cacheable memory\n");
break;
case ACPI_WRITE_COMBINING_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Write-combining memory\n");
+ acpi_os_printf (" Type Specific: Write-combining memory\n");
break;
case ACPI_PREFETCHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Prefetchable memory\n");
+ acpi_os_printf (" Type Specific: Prefetchable memory\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid cache attribute\n");
+ acpi_os_printf (" Type Specific: Invalid cache attribute\n");
break;
}
acpi_os_printf (" Type Specific: Read%s\n",
ACPI_READ_WRITE_MEMORY ==
- address32_data->attribute.memory.read_write_attribute ?
- "/Write" : " Only");
+ address32_data->attribute.memory.read_write_attribute ?
+ "/Write" : " Only");
break;
case ACPI_IO_RANGE:
@@ -698,30 +728,26 @@ acpi_rs_dump_address32 (
switch (address32_data->attribute.io.range_attribute) {
case ACPI_NON_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "Non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
break;
case ACPI_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA Io Addresses\n");
break;
case ACPI_ENTIRE_RANGE:
- acpi_os_printf (" Type Specific: "
- "ISA and non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid Range attribute");
+ acpi_os_printf (" Type Specific: Invalid Range attribute");
break;
}
acpi_os_printf (" Type Specific: %s Translation\n",
ACPI_SPARSE_TRANSLATION ==
- address32_data->attribute.io.translation_attribute ?
- "Sparse" : "Dense");
+ address32_data->attribute.io.translation_attribute ?
+ "Sparse" : "Dense");
break;
case ACPI_BUS_NUMBER_RANGE:
@@ -731,46 +757,48 @@ acpi_rs_dump_address32 (
default:
- acpi_os_printf (" Resource Type: 0x%2.2X\n", address32_data->resource_type);
+ acpi_os_printf (" Resource Type: 0x%2.2X\n",
+ address32_data->resource_type);
break;
}
acpi_os_printf (" Resource %s\n",
- ACPI_CONSUMER == address32_data->producer_consumer ?
- "Consumer" : "Producer");
+ ACPI_CONSUMER == address32_data->producer_consumer ?
+ "Consumer" : "Producer");
acpi_os_printf (" %s decode\n",
- ACPI_SUB_DECODE == address32_data->decode ?
- "Subtractive" : "Positive");
+ ACPI_SUB_DECODE == address32_data->decode ?
+ "Subtractive" : "Positive");
acpi_os_printf (" Min address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
- "" : "not ");
+ ACPI_ADDRESS_FIXED == address32_data->min_address_fixed ?
+ "" : "not ");
acpi_os_printf (" Max address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
- "" : "not ");
+ ACPI_ADDRESS_FIXED == address32_data->max_address_fixed ?
+ "" : "not ");
acpi_os_printf (" Granularity: %08X\n",
- address32_data->granularity);
+ address32_data->granularity);
acpi_os_printf (" Address range min: %08X\n",
- address32_data->min_address_range);
+ address32_data->min_address_range);
acpi_os_printf (" Address range max: %08X\n",
- address32_data->max_address_range);
+ address32_data->max_address_range);
acpi_os_printf (" Address translation offset: %08X\n",
- address32_data->address_translation_offset);
+ address32_data->address_translation_offset);
acpi_os_printf (" Address Length: %08X\n",
- address32_data->address_length);
+ address32_data->address_length);
if(0xFF != address32_data->resource_source.index) {
acpi_os_printf (" Resource Source Index: %X\n",
- address32_data->resource_source.index);
+ address32_data->resource_source.index);
+
acpi_os_printf (" Resource Source: %s\n",
- address32_data->resource_source.string_ptr);
+ address32_data->resource_source.string_ptr);
}
return;
@@ -789,7 +817,7 @@ acpi_rs_dump_address32 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_address64 (
union acpi_resource_data *data)
{
@@ -808,35 +836,30 @@ acpi_rs_dump_address64 (
switch (address64_data->attribute.memory.cache_attribute) {
case ACPI_NON_CACHEABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Noncacheable memory\n");
+ acpi_os_printf (" Type Specific: Noncacheable memory\n");
break;
case ACPI_CACHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Cacheable memory\n");
+ acpi_os_printf (" Type Specific: Cacheable memory\n");
break;
case ACPI_WRITE_COMBINING_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Write-combining memory\n");
+ acpi_os_printf (" Type Specific: Write-combining memory\n");
break;
case ACPI_PREFETCHABLE_MEMORY:
- acpi_os_printf (" Type Specific: "
- "Prefetchable memory\n");
+ acpi_os_printf (" Type Specific: Prefetchable memory\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid cache attribute\n");
+ acpi_os_printf (" Type Specific: Invalid cache attribute\n");
break;
}
acpi_os_printf (" Type Specific: Read%s\n",
ACPI_READ_WRITE_MEMORY ==
- address64_data->attribute.memory.read_write_attribute ?
- "/Write" : " Only");
+ address64_data->attribute.memory.read_write_attribute ?
+ "/Write" : " Only");
break;
case ACPI_IO_RANGE:
@@ -845,30 +868,26 @@ acpi_rs_dump_address64 (
switch (address64_data->attribute.io.range_attribute) {
case ACPI_NON_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "Non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: Non-ISA Io Addresses\n");
break;
case ACPI_ISA_ONLY_RANGES:
- acpi_os_printf (" Type Specific: "
- "ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA Io Addresses\n");
break;
case ACPI_ENTIRE_RANGE:
- acpi_os_printf (" Type Specific: "
- "ISA and non-ISA Io Addresses\n");
+ acpi_os_printf (" Type Specific: ISA and non-ISA Io Addresses\n");
break;
default:
- acpi_os_printf (" Type Specific: "
- "Invalid Range attribute");
+ acpi_os_printf (" Type Specific: Invalid Range attribute");
break;
}
acpi_os_printf (" Type Specific: %s Translation\n",
ACPI_SPARSE_TRANSLATION ==
- address64_data->attribute.io.translation_attribute ?
- "Sparse" : "Dense");
+ address64_data->attribute.io.translation_attribute ?
+ "Sparse" : "Dense");
break;
case ACPI_BUS_NUMBER_RANGE:
@@ -878,49 +897,51 @@ acpi_rs_dump_address64 (
default:
- acpi_os_printf (" Resource Type: 0x%2.2X\n", address64_data->resource_type);
+ acpi_os_printf (" Resource Type: 0x%2.2X\n",
+ address64_data->resource_type);
break;
}
acpi_os_printf (" Resource %s\n",
- ACPI_CONSUMER == address64_data->producer_consumer ?
- "Consumer" : "Producer");
+ ACPI_CONSUMER == address64_data->producer_consumer ?
+ "Consumer" : "Producer");
acpi_os_printf (" %s decode\n",
- ACPI_SUB_DECODE == address64_data->decode ?
- "Subtractive" : "Positive");
+ ACPI_SUB_DECODE == address64_data->decode ?
+ "Subtractive" : "Positive");
acpi_os_printf (" Min address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
- "" : "not ");
+ ACPI_ADDRESS_FIXED == address64_data->min_address_fixed ?
+ "" : "not ");
acpi_os_printf (" Max address is %s fixed\n",
- ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
- "" : "not ");
+ ACPI_ADDRESS_FIXED == address64_data->max_address_fixed ?
+ "" : "not ");
acpi_os_printf (" Granularity: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->granularity));
+ ACPI_FORMAT_UINT64 (address64_data->granularity));
acpi_os_printf (" Address range min: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->min_address_range));
+ ACPI_FORMAT_UINT64 (address64_data->min_address_range));
acpi_os_printf (" Address range max: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->max_address_range));
+ ACPI_FORMAT_UINT64 (address64_data->max_address_range));
acpi_os_printf (" Address translation offset: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->address_translation_offset));
+ ACPI_FORMAT_UINT64 (address64_data->address_translation_offset));
acpi_os_printf (" Address Length: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->address_length));
+ ACPI_FORMAT_UINT64 (address64_data->address_length));
acpi_os_printf (" Type Specific Attributes: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes));
+ ACPI_FORMAT_UINT64 (address64_data->type_specific_attributes));
if (0xFF != address64_data->resource_source.index) {
acpi_os_printf (" Resource Source Index: %X\n",
- address64_data->resource_source.index);
+ address64_data->resource_source.index);
+
acpi_os_printf (" Resource Source: %s\n",
- address64_data->resource_source.string_ptr);
+ address64_data->resource_source.string_ptr);
}
return;
@@ -939,7 +960,7 @@ acpi_rs_dump_address64 (
*
******************************************************************************/
-void
+static void
acpi_rs_dump_extended_irq (
union acpi_resource_data *data)
{
@@ -953,23 +974,22 @@ acpi_rs_dump_extended_irq (
acpi_os_printf ("Extended IRQ Resource\n");
acpi_os_printf (" Resource %s\n",
- ACPI_CONSUMER == ext_irq_data->producer_consumer ?
- "Consumer" : "Producer");
+ ACPI_CONSUMER == ext_irq_data->producer_consumer ?
+ "Consumer" : "Producer");
acpi_os_printf (" %s\n",
- ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
- "Level" : "Edge");
+ ACPI_LEVEL_SENSITIVE == ext_irq_data->edge_level ?
+ "Level" : "Edge");
acpi_os_printf (" Active %s\n",
- ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
- "low" : "high");
+ ACPI_ACTIVE_LOW == ext_irq_data->active_high_low ?
+ "low" : "high");
acpi_os_printf (" %s\n",
- ACPI_SHARED == ext_irq_data->shared_exclusive ?
- "Shared" : "Exclusive");
+ ACPI_SHARED == ext_irq_data->shared_exclusive ?
+ "Shared" : "Exclusive");
- acpi_os_printf (" Interrupts : %X ( ",
- ext_irq_data->number_of_interrupts);
+ acpi_os_printf (" Interrupts : %X ( ", ext_irq_data->number_of_interrupts);
for (index = 0; index < ext_irq_data->number_of_interrupts; index++) {
acpi_os_printf ("%X ", ext_irq_data->interrupts[index]);
@@ -979,9 +999,10 @@ acpi_rs_dump_extended_irq (
if(0xFF != ext_irq_data->resource_source.index) {
acpi_os_printf (" Resource Source Index: %X",
- ext_irq_data->resource_source.index);
+ ext_irq_data->resource_source.index);
+
acpi_os_printf (" Resource Source: %s",
- ext_irq_data->resource_source.string_ptr);
+ ext_irq_data->resource_source.string_ptr);
}
return;
@@ -992,7 +1013,7 @@ acpi_rs_dump_extended_irq (
*
* FUNCTION: acpi_rs_dump_resource_list
*
- * PARAMETERS: Data - pointer to the resource structure to dump.
+ * PARAMETERS: Resource - pointer to the resource structure to dump.
*
* RETURN: None
*
@@ -1096,7 +1117,7 @@ acpi_rs_dump_resource_list (
*
* FUNCTION: acpi_rs_dump_irq_list
*
- * PARAMETERS: Data - pointer to the routing table to dump.
+ * PARAMETERS: route_table - pointer to the routing table to dump.
*
* RETURN: None
*
@@ -1124,20 +1145,17 @@ acpi_rs_dump_irq_list (
acpi_os_printf ("PCI IRQ Routing Table structure %X.\n", count++);
acpi_os_printf (" Address: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (prt_element->address));
+ ACPI_FORMAT_UINT64 (prt_element->address));
acpi_os_printf (" Pin: %X\n", prt_element->pin);
acpi_os_printf (" Source: %s\n", prt_element->source);
- acpi_os_printf (" source_index: %X\n",
- prt_element->source_index);
+ acpi_os_printf (" source_index: %X\n", prt_element->source_index);
buffer += prt_element->length;
-
prt_element = ACPI_CAST_PTR (struct acpi_pci_routing_table, buffer);
-
- if(0 == prt_element->length) {
+ if (0 == prt_element->length) {
done = TRUE;
}
}
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/resources/rsio.c
index 972c746d37e..23a4d149fac 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/resources/rsio.c
@@ -81,67 +81,60 @@ acpi_rs_io_resource (
struct acpi_resource *output_struct = (void *) *output_buffer;
u16 temp16 = 0;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_io);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_io);
ACPI_FUNCTION_TRACE ("rs_io_resource");
- /*
- * The number of bytes consumed are Constant
- */
+ /* The number of bytes consumed are Constant */
+
*bytes_consumed = 8;
output_struct->id = ACPI_RSTYPE_IO;
- /*
- * Check Decode
- */
+ /* Check Decode */
+
buffer += 1;
temp8 = *buffer;
output_struct->data.io.io_decode = temp8 & 0x01;
- /*
- * Check min_base Address
- */
+ /* Check min_base Address */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.io.min_base_address = temp16;
- /*
- * Check max_base Address
- */
+ /* Check max_base Address */
+
buffer += 2;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.io.max_base_address = temp16;
- /*
- * Check Base alignment
- */
+ /* Check Base alignment */
+
buffer += 2;
temp8 = *buffer;
output_struct->data.io.alignment = temp8;
- /*
- * Check range_length
- */
+ /* Check range_length */
+
buffer += 1;
temp8 = *buffer;
output_struct->data.io.range_length = temp8;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -179,43 +172,39 @@ acpi_rs_fixed_io_resource (
struct acpi_resource *output_struct = (void *) *output_buffer;
u16 temp16 = 0;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_io);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_fixed_io);
ACPI_FUNCTION_TRACE ("rs_fixed_io_resource");
- /*
- * The number of bytes consumed are Constant
- */
+ /* The number of bytes consumed are Constant */
+
*bytes_consumed = 4;
output_struct->id = ACPI_RSTYPE_FIXED_IO;
- /*
- * Check Range Base Address
- */
+ /* Check Range Base Address */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.fixed_io.base_address = temp16;
- /*
- * Check range_length
- */
+ /* Check range_length */
+
buffer += 2;
temp8 = *buffer;
output_struct->data.fixed_io.range_length = temp8;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -251,55 +240,48 @@ acpi_rs_io_stream (
ACPI_FUNCTION_TRACE ("rs_io_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x47;
buffer += 1;
- /*
- * Io Information Byte
- */
+ /* Io Information Byte */
+
temp8 = (u8) (linked_list->data.io.io_decode & 0x01);
*buffer = temp8;
buffer += 1;
- /*
- * Set the Range minimum base address
- */
+ /* Set the Range minimum base address */
+
temp16 = (u16) linked_list->data.io.min_base_address;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the Range maximum base address
- */
+ /* Set the Range maximum base address */
+
temp16 = (u16) linked_list->data.io.max_base_address;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the base alignment
- */
+ /* Set the base alignment */
+
temp8 = (u8) linked_list->data.io.alignment;
*buffer = temp8;
buffer += 1;
- /*
- * Set the range length
- */
+ /* Set the range length */
+
temp8 = (u8) linked_list->data.io.range_length;
*buffer = temp8;
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -335,32 +317,28 @@ acpi_rs_fixed_io_stream (
ACPI_FUNCTION_TRACE ("rs_fixed_io_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x4B;
buffer += 1;
- /*
- * Set the Range base address
- */
+ /* Set the Range base address */
+
temp16 = (u16) linked_list->data.fixed_io.base_address;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the range length
- */
+ /* Set the range length */
+
temp8 = (u8) linked_list->data.fixed_io.range_length;
*buffer = temp8;
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -399,21 +377,20 @@ acpi_rs_dma_resource (
u8 temp8 = 0;
u8 index;
u8 i;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_dma);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_dma);
ACPI_FUNCTION_TRACE ("rs_dma_resource");
- /*
- * The number of bytes consumed are Constant
- */
+ /* The number of bytes consumed are Constant */
+
*bytes_consumed = 3;
output_struct->id = ACPI_RSTYPE_DMA;
- /*
- * Point to the 8-bits of Byte 1
- */
+ /* Point to the 8-bits of Byte 1 */
+
buffer += 1;
temp8 = *buffer;
@@ -430,46 +407,40 @@ acpi_rs_dma_resource (
output_struct->data.dma.number_of_channels = i;
if (i > 0) {
- /*
- * Calculate the structure size based upon the number of interrupts
- */
+ /* Calculate the structure size based upon the number of interrupts */
+
struct_size += ((acpi_size) i - 1) * 4;
}
- /*
- * Point to Byte 2
- */
+ /* Point to Byte 2 */
+
buffer += 1;
temp8 = *buffer;
- /*
- * Check for transfer preference (Bits[1:0])
- */
+ /* Check for transfer preference (Bits[1:0]) */
+
output_struct->data.dma.transfer = temp8 & 0x03;
if (0x03 == output_struct->data.dma.transfer) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Invalid DMA.Transfer preference (3)\n"));
return_ACPI_STATUS (AE_BAD_DATA);
}
- /*
- * Get bus master preference (Bit[2])
- */
+ /* Get bus master preference (Bit[2]) */
+
output_struct->data.dma.bus_master = (temp8 >> 2) & 0x01;
- /*
- * Get channel speed support (Bits[6:5])
- */
+ /* Get channel speed support (Bits[6:5]) */
+
output_struct->data.dma.type = (temp8 >> 5) & 0x03;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -506,16 +477,14 @@ acpi_rs_dma_stream (
ACPI_FUNCTION_TRACE ("rs_dma_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x2A;
buffer += 1;
temp8 = 0;
- /*
- * Loop through all of the Channels and set the mask bits
- */
+ /* Loop through all of the Channels and set the mask bits */
+
for (index = 0;
index < linked_list->data.dma.number_of_channels;
index++) {
@@ -526,9 +495,8 @@ acpi_rs_dma_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Set the DMA Info
- */
+ /* Set the DMA Info */
+
temp8 = (u8) ((linked_list->data.dma.type & 0x03) << 5);
temp8 |= ((linked_list->data.dma.bus_master & 0x01) << 2);
temp8 |= (linked_list->data.dma.transfer & 0x03);
@@ -536,9 +504,8 @@ acpi_rs_dma_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/resources/rsirq.c
index fd07a8702fb..8a2b630be45 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/resources/rsirq.c
@@ -83,7 +83,8 @@ acpi_rs_irq_resource (
u8 temp8 = 0;
u8 index;
u8 i;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_irq);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_irq);
ACPI_FUNCTION_TRACE ("rs_irq_resource");
@@ -91,15 +92,14 @@ acpi_rs_irq_resource (
/*
* The number of bytes consumed are contained in the descriptor
- * (Bits:0-1)
+ * (Bits:0-1)
*/
temp8 = *buffer;
*bytes_consumed = (temp8 & 0x03) + 1;
output_struct->id = ACPI_RSTYPE_IRQ;
- /*
- * Point to the 16-bits of Bytes 1 and 2
- */
+ /* Point to the 16-bits of Bytes 1 and 2 */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -118,22 +118,19 @@ acpi_rs_irq_resource (
output_struct->data.irq.number_of_interrupts = i;
if (i > 0) {
- /*
- * Calculate the structure size based upon the number of interrupts
- */
+ /* Calculate the structure size based upon the number of interrupts */
+
struct_size += ((acpi_size) i - 1) * 4;
}
- /*
- * Point to Byte 3 if it is used
- */
+ /* Point to Byte 3 if it is used */
+
if (4 == *bytes_consumed) {
buffer += 2;
temp8 = *buffer;
- /*
- * Check for HE, LL interrupts
- */
+ /* Check for HE, LL interrupts */
+
switch (temp8 & 0x09) {
case 0x01: /* HE */
output_struct->data.irq.edge_level = ACPI_EDGE_SENSITIVE;
@@ -152,13 +149,13 @@ acpi_rs_irq_resource (
* so 0x00 and 0x09 are illegal.
*/
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Invalid interrupt polarity/trigger in resource list, %X\n", temp8));
+ "Invalid interrupt polarity/trigger in resource list, %X\n",
+ temp8));
return_ACPI_STATUS (AE_BAD_DATA);
}
- /*
- * Check for sharable
- */
+ /* Check for sharable */
+
output_struct->data.irq.shared_exclusive = (temp8 >> 3) & 0x01;
}
else {
@@ -171,14 +168,12 @@ acpi_rs_irq_resource (
output_struct->data.irq.shared_exclusive = ACPI_EXCLUSIVE;
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -234,9 +229,8 @@ acpi_rs_irq_stream (
buffer += 1;
temp16 = 0;
- /*
- * Loop through all of the interrupts and set the mask bits
- */
+ /* Loop through all of the interrupts and set the mask bits */
+
for(index = 0;
index < linked_list->data.irq.number_of_interrupts;
index++) {
@@ -247,9 +241,8 @@ acpi_rs_irq_stream (
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the IRQ Info byte if needed.
- */
+ /* Set the IRQ Info byte if needed. */
+
if (IRqinfo_byte_needed) {
temp8 = 0;
temp8 = (u8) ((linked_list->data.irq.shared_exclusive &
@@ -267,9 +260,8 @@ acpi_rs_irq_stream (
buffer += 1;
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -309,15 +301,15 @@ acpi_rs_extended_irq_resource (
u8 temp8 = 0;
u8 *temp_ptr;
u8 index;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_ext_irq);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_ext_irq);
ACPI_FUNCTION_TRACE ("rs_extended_irq_resource");
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -330,9 +322,8 @@ acpi_rs_extended_irq_resource (
*bytes_consumed = temp16 + 3;
output_struct->id = ACPI_RSTYPE_EXT_IRQ;
- /*
- * Point to the Byte3
- */
+ /* Point to the Byte3 */
+
buffer += 2;
temp8 = *buffer;
@@ -347,21 +338,18 @@ acpi_rs_extended_irq_resource (
* - Edge/Level are defined opposite in the table vs the headers
*/
output_struct->data.extended_irq.edge_level =
- (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
+ (temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
+
+ /* Check Interrupt Polarity */
- /*
- * Check Interrupt Polarity
- */
output_struct->data.extended_irq.active_high_low = (temp8 >> 2) & 0x1;
- /*
- * Check for sharable
- */
+ /* Check for sharable */
+
output_struct->data.extended_irq.shared_exclusive = (temp8 >> 3) & 0x01;
- /*
- * Point to Byte4 (IRQ Table length)
- */
+ /* Point to Byte4 (IRQ Table length) */
+
buffer += 1;
temp8 = *buffer;
@@ -379,14 +367,12 @@ acpi_rs_extended_irq_resource (
*/
struct_size += (temp8 - 1) * 4;
- /*
- * Point to Byte5 (First IRQ Number)
- */
+ /* Point to Byte5 (First IRQ Number) */
+
buffer += 1;
- /*
- * Cycle through every IRQ in the table
- */
+ /* Cycle through every IRQ in the table */
+
for (index = 0; index < temp8; index++) {
ACPI_MOVE_32_TO_32 (
&output_struct->data.extended_irq.interrupts[index], buffer);
@@ -407,7 +393,8 @@ acpi_rs_extended_irq_resource (
* we add 1 to the length.
*/
if (*bytes_consumed >
- ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) + (5 + 1)) {
+ ((acpi_size) output_struct->data.extended_irq.number_of_interrupts * 4) +
+ (5 + 1)) {
/* Dereference the Index */
temp8 = *buffer;
@@ -417,13 +404,13 @@ acpi_rs_extended_irq_resource (
buffer += 1;
- /*
- * Point the String pointer to the end of this structure.
- */
+ /* Point the String pointer to the end of this structure. */
+
output_struct->data.extended_irq.resource_source.string_ptr =
(char *)((char *) output_struct + struct_size);
- temp_ptr = (u8 *) output_struct->data.extended_irq.resource_source.string_ptr;
+ temp_ptr = (u8 *)
+ output_struct->data.extended_irq.resource_source.string_ptr;
/* Copy the string into the buffer */
@@ -436,9 +423,8 @@ acpi_rs_extended_irq_resource (
index += 1;
}
- /*
- * Add the terminating null
- */
+ /* Add the terminating null */
+
*temp_ptr = 0x00;
output_struct->data.extended_irq.resource_source.string_length = index + 1;
@@ -456,14 +442,12 @@ acpi_rs_extended_irq_resource (
output_struct->data.extended_irq.resource_source.string_ptr = NULL;
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -501,21 +485,18 @@ acpi_rs_extended_irq_stream (
ACPI_FUNCTION_TRACE ("rs_extended_irq_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x89;
buffer += 1;
- /*
- * Set a pointer to the Length field - to be filled in later
- */
+ /* Set a pointer to the Length field - to be filled in later */
+
length_field = ACPI_CAST_PTR (u16, buffer);
buffer += 2;
- /*
- * Set the Interrupt vector flags
- */
+ /* Set the Interrupt vector flags */
+
temp8 = (u8)(linked_list->data.extended_irq.producer_consumer & 0x01);
temp8 |= ((linked_list->data.extended_irq.shared_exclusive & 0x01) << 3);
@@ -532,17 +513,15 @@ acpi_rs_extended_irq_stream (
temp8 |= 0x2;
}
- /*
- * Set the Interrupt Polarity
- */
+ /* Set the Interrupt Polarity */
+
temp8 |= ((linked_list->data.extended_irq.active_high_low & 0x1) << 2);
*buffer = temp8;
buffer += 1;
- /*
- * Set the Interrupt table length
- */
+ /* Set the Interrupt table length */
+
temp8 = (u8) linked_list->data.extended_irq.number_of_interrupts;
*buffer = temp8;
@@ -555,18 +534,16 @@ acpi_rs_extended_irq_stream (
buffer += 4;
}
- /*
- * Resource Source Index and Resource Source are optional
- */
+ /* Resource Source Index and Resource Source are optional */
+
if (0 != linked_list->data.extended_irq.resource_source.string_length) {
*buffer = (u8) linked_list->data.extended_irq.resource_source.index;
buffer += 1;
temp_pointer = (char *) buffer;
- /*
- * Copy the string
- */
+ /* Copy the string */
+
ACPI_STRCPY (temp_pointer,
linked_list->data.extended_irq.resource_source.string_ptr);
@@ -574,12 +551,12 @@ acpi_rs_extended_irq_stream (
* Buffer needs to be set to the length of the sting + one for the
* terminating null
*/
- buffer += (acpi_size)(ACPI_STRLEN (linked_list->data.extended_irq.resource_source.string_ptr) + 1);
+ buffer += (acpi_size) (ACPI_STRLEN (
+ linked_list->data.extended_irq.resource_source.string_ptr) + 1);
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
/*
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index e49c1e030f9..db7bcb4e60e 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -55,7 +55,7 @@
*
* PARAMETERS: resource_start_byte - Byte 0 of a resource descriptor
*
- * RETURN: The Resource Type (Name) with no extraneous bits
+ * RETURN: The Resource Type with no extraneous bits
*
* DESCRIPTION: Extract the Resource Type/Name from the first byte of
* a resource descriptor.
@@ -70,28 +70,25 @@ acpi_rs_get_resource_type (
ACPI_FUNCTION_ENTRY ();
- /*
- * Determine if this is a small or large resource
- */
+ /* Determine if this is a small or large resource */
+
switch (resource_start_byte & ACPI_RDESC_TYPE_MASK) {
case ACPI_RDESC_TYPE_SMALL:
- /*
- * Small Resource Type -- Only bits 6:3 are valid
- */
+ /* Small Resource Type -- Only bits 6:3 are valid */
+
return ((u8) (resource_start_byte & ACPI_RDESC_SMALL_MASK));
case ACPI_RDESC_TYPE_LARGE:
- /*
- * Large Resource Type -- All bits are valid
- */
+ /* Large Resource Type -- All bits are valid */
+
return (resource_start_byte);
default:
- /* No other types of resource descriptor */
+ /* Invalid type */
break;
}
@@ -135,9 +132,8 @@ acpi_rs_byte_stream_to_list (
while (bytes_parsed < byte_stream_buffer_length &&
!end_tag_processed) {
- /*
- * The next byte in the stream is the resource type
- */
+ /* The next byte in the stream is the resource type */
+
resource_type = acpi_rs_get_resource_type (*byte_stream_buffer);
switch (resource_type) {
@@ -299,28 +295,23 @@ acpi_rs_byte_stream_to_list (
return_ACPI_STATUS (status);
}
- /*
- * Update the return value and counter
- */
+ /* Update the return value and counter */
+
bytes_parsed += bytes_consumed;
- /*
- * Set the byte stream to point to the next resource
- */
+ /* Set the byte stream to point to the next resource */
+
byte_stream_buffer += bytes_consumed;
- /*
- * Set the Buffer to the next structure
- */
+ /* Set the Buffer to the next structure */
+
resource = ACPI_CAST_PTR (struct acpi_resource, buffer);
resource->length = (u32) ACPI_ALIGN_RESOURCE_SIZE (resource->length);
buffer += ACPI_ALIGN_RESOURCE_SIZE (structure_size);
+ }
- } /* end while */
+ /* Check the reason for exiting the while loop */
- /*
- * Check the reason for exiting the while loop
- */
if (!end_tag_processed) {
return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
}
@@ -424,9 +415,8 @@ acpi_rs_list_to_byte_stream (
*/
status = acpi_rs_end_tag_stream (linked_list, &buffer, &bytes_consumed);
- /*
- * An End Tag indicates the end of the Resource Template
- */
+ /* An End Tag indicates the end of the Resource Template */
+
done = TRUE;
break;
@@ -488,27 +478,25 @@ acpi_rs_list_to_byte_stream (
default:
/*
* If we get here, everything is out of sync,
- * so exit with an error
+ * so exit with an error
*/
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Invalid descriptor type (%X) in resource list\n",
linked_list->id));
status = AE_BAD_DATA;
break;
-
- } /* switch (linked_list->Id) */
+ }
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
- /*
- * Set the Buffer to point to the open byte
- */
+ /* Set the Buffer to point to the open byte */
+
buffer += bytes_consumed;
- /*
- * Point to the next object
- */
+ /* Point to the next object */
+
linked_list = ACPI_PTR_ADD (struct acpi_resource,
linked_list, linked_list->length);
}
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/resources/rsmemory.c
index 7c935aecf07..91d0207f01a 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/resources/rsmemory.c
@@ -81,15 +81,15 @@ acpi_rs_memory24_resource (
struct acpi_resource *output_struct = (void *) *output_buffer;
u16 temp16 = 0;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem24);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_mem24);
ACPI_FUNCTION_TRACE ("rs_memory24_resource");
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -97,48 +97,41 @@ acpi_rs_memory24_resource (
*bytes_consumed = (acpi_size) temp16 + 3;
output_struct->id = ACPI_RSTYPE_MEM24;
- /*
- * Check Byte 3 the Read/Write bit
- */
+ /* Check Byte 3 the Read/Write bit */
+
temp8 = *buffer;
buffer += 1;
output_struct->data.memory24.read_write_attribute = temp8 & 0x01;
- /*
- * Get min_base_address (Bytes 4-5)
- */
+ /* Get min_base_address (Bytes 4-5) */
+
ACPI_MOVE_16_TO_16 (&temp16, buffer);
buffer += 2;
output_struct->data.memory24.min_base_address = temp16;
- /*
- * Get max_base_address (Bytes 6-7)
- */
+ /* Get max_base_address (Bytes 6-7) */
+
ACPI_MOVE_16_TO_16 (&temp16, buffer);
buffer += 2;
output_struct->data.memory24.max_base_address = temp16;
- /*
- * Get Alignment (Bytes 8-9)
- */
+ /* Get Alignment (Bytes 8-9) */
+
ACPI_MOVE_16_TO_16 (&temp16, buffer);
buffer += 2;
output_struct->data.memory24.alignment = temp16;
- /*
- * Get range_length (Bytes 10-11)
- */
+ /* Get range_length (Bytes 10-11) */
+
ACPI_MOVE_16_TO_16 (&temp16, buffer);
output_struct->data.memory24.range_length = temp16;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -174,53 +167,45 @@ acpi_rs_memory24_stream (
ACPI_FUNCTION_TRACE ("rs_memory24_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x81;
buffer += 1;
- /*
- * The length field is static
- */
+ /* The length field is static */
+
temp16 = 0x09;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the Information Byte
- */
+ /* Set the Information Byte */
+
temp8 = (u8) (linked_list->data.memory24.read_write_attribute & 0x01);
*buffer = temp8;
buffer += 1;
- /*
- * Set the Range minimum base address
- */
+ /* Set the Range minimum base address */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.min_base_address);
buffer += 2;
- /*
- * Set the Range maximum base address
- */
+ /* Set the Range maximum base address */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.max_base_address);
buffer += 2;
- /*
- * Set the base alignment
- */
+ /* Set the base alignment */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.alignment);
buffer += 2;
- /*
- * Set the range length
- */
+ /* Set the range length */
+
ACPI_MOVE_32_TO_16 (buffer, &linked_list->data.memory24.range_length);
buffer += 2;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -258,15 +243,15 @@ acpi_rs_memory32_range_resource (
struct acpi_resource *output_struct = (void *) *output_buffer;
u16 temp16 = 0;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_mem32);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_mem32);
ACPI_FUNCTION_TRACE ("rs_memory32_range_resource");
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -285,45 +270,38 @@ acpi_rs_memory32_range_resource (
* 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(u8)
*/
- /*
- * Check Byte 3 the Read/Write bit
- */
+ /* Check Byte 3 the Read/Write bit */
+
temp8 = *buffer;
buffer += 1;
output_struct->data.memory32.read_write_attribute = temp8 & 0x01;
- /*
- * Get min_base_address (Bytes 4-7)
- */
+ /* Get min_base_address (Bytes 4-7) */
+
ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.min_base_address, buffer);
buffer += 4;
- /*
- * Get max_base_address (Bytes 8-11)
- */
+ /* Get max_base_address (Bytes 8-11) */
+
ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.max_base_address, buffer);
buffer += 4;
- /*
- * Get Alignment (Bytes 12-15)
- */
+ /* Get Alignment (Bytes 12-15) */
+
ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.alignment, buffer);
buffer += 4;
- /*
- * Get range_length (Bytes 16-19)
- */
+ /* Get range_length (Bytes 16-19) */
+
ACPI_MOVE_32_TO_32 (&output_struct->data.memory32.range_length, buffer);
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -361,15 +339,15 @@ acpi_rs_fixed_memory32_resource (
struct acpi_resource *output_struct = (void *) *output_buffer;
u16 temp16 = 0;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_fixed_mem32);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_fixed_mem32);
ACPI_FUNCTION_TRACE ("rs_fixed_memory32_resource");
- /*
- * Point past the Descriptor to get the number of bytes consumed
- */
+ /* Point past the Descriptor to get the number of bytes consumed */
+
buffer += 1;
ACPI_MOVE_16_TO_16 (&temp16, buffer);
@@ -378,32 +356,28 @@ acpi_rs_fixed_memory32_resource (
output_struct->id = ACPI_RSTYPE_FIXED_MEM32;
- /*
- * Check Byte 3 the Read/Write bit
- */
+ /* Check Byte 3 the Read/Write bit */
+
temp8 = *buffer;
buffer += 1;
output_struct->data.fixed_memory32.read_write_attribute = temp8 & 0x01;
- /*
- * Get range_base_address (Bytes 4-7)
- */
- ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address, buffer);
+ /* Get range_base_address (Bytes 4-7) */
+
+ ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_base_address,
+ buffer);
buffer += 4;
- /*
- * Get range_length (Bytes 8-11)
- */
+ /* Get range_length (Bytes 8-11) */
+
ACPI_MOVE_32_TO_32 (&output_struct->data.fixed_memory32.range_length, buffer);
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -439,54 +413,46 @@ acpi_rs_memory32_range_stream (
ACPI_FUNCTION_TRACE ("rs_memory32_range_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x85;
buffer += 1;
- /*
- * The length field is static
- */
+ /* The length field is static */
+
temp16 = 0x11;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the Information Byte
- */
+ /* Set the Information Byte */
+
temp8 = (u8) (linked_list->data.memory32.read_write_attribute & 0x01);
*buffer = temp8;
buffer += 1;
- /*
- * Set the Range minimum base address
- */
+ /* Set the Range minimum base address */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.min_base_address);
buffer += 4;
- /*
- * Set the Range maximum base address
- */
+ /* Set the Range maximum base address */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.max_base_address);
buffer += 4;
- /*
- * Set the base alignment
- */
+ /* Set the base alignment */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.alignment);
buffer += 4;
- /*
- * Set the range length
- */
+ /* Set the range length */
+
ACPI_MOVE_32_TO_32 (buffer, &linked_list->data.memory32.range_length);
buffer += 4;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -522,44 +488,38 @@ acpi_rs_fixed_memory32_stream (
ACPI_FUNCTION_TRACE ("rs_fixed_memory32_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x86;
buffer += 1;
- /*
- * The length field is static
- */
+ /* The length field is static */
+
temp16 = 0x09;
ACPI_MOVE_16_TO_16 (buffer, &temp16);
buffer += 2;
- /*
- * Set the Information Byte
- */
+ /* Set the Information Byte */
+
temp8 = (u8) (linked_list->data.fixed_memory32.read_write_attribute & 0x01);
*buffer = temp8;
buffer += 1;
- /*
- * Set the Range base address
- */
+ /* Set the Range base address */
+
ACPI_MOVE_32_TO_32 (buffer,
- &linked_list->data.fixed_memory32.range_base_address);
+ &linked_list->data.fixed_memory32.range_base_address);
buffer += 4;
- /*
- * Set the range length
- */
+ /* Set the range length */
+
ACPI_MOVE_32_TO_32 (buffer,
- &linked_list->data.fixed_memory32.range_length);
+ &linked_list->data.fixed_memory32.range_length);
buffer += 4;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index d16be44b5df..a1f1741f0d8 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -84,24 +84,20 @@ acpi_rs_end_tag_resource (
ACPI_FUNCTION_TRACE ("rs_end_tag_resource");
- /*
- * The number of bytes consumed is static
- */
+ /* The number of bytes consumed is static */
+
*bytes_consumed = 2;
- /*
- * Fill out the structure
- */
+ /* Fill out the structure */
+
output_struct->id = ACPI_RSTYPE_END_TAG;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = 0;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -136,9 +132,8 @@ acpi_rs_end_tag_stream (
ACPI_FUNCTION_TRACE ("rs_end_tag_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x79;
buffer += 1;
@@ -151,9 +146,8 @@ acpi_rs_end_tag_stream (
*buffer = temp8;
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -192,21 +186,20 @@ acpi_rs_vendor_resource (
u16 temp16 = 0;
u8 temp8 = 0;
u8 index;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_vendor);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_vendor);
ACPI_FUNCTION_TRACE ("rs_vendor_resource");
- /*
- * Dereference the Descriptor to find if this is a large or small item.
- */
+ /* Dereference the Descriptor to find if this is a large or small item. */
+
temp8 = *buffer;
if (temp8 & 0x80) {
- /*
- * Large Item, point to the length field
- */
+ /* Large Item, point to the length field */
+
buffer += 1;
/* Dereference */
@@ -222,9 +215,8 @@ acpi_rs_vendor_resource (
buffer += 2;
}
else {
- /*
- * Small Item, dereference the size
- */
+ /* Small Item, dereference the size */
+
temp16 = (u8)(*buffer & 0x07);
/* Calculate bytes consumed */
@@ -251,14 +243,12 @@ acpi_rs_vendor_resource (
*/
struct_size += ACPI_ROUND_UP_to_32_bITS (temp16);
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -295,13 +285,11 @@ acpi_rs_vendor_stream (
ACPI_FUNCTION_TRACE ("rs_vendor_stream");
- /*
- * Dereference the length to find if this is a large or small item.
- */
+ /* Dereference the length to find if this is a large or small item. */
+
if(linked_list->data.vendor_specific.length > 7) {
- /*
- * Large Item, Set the descriptor field and length bytes
- */
+ /* Large Item, Set the descriptor field and length bytes */
+
*buffer = 0x84;
buffer += 1;
@@ -311,9 +299,8 @@ acpi_rs_vendor_stream (
buffer += 2;
}
else {
- /*
- * Small Item, Set the descriptor field
- */
+ /* Small Item, Set the descriptor field */
+
temp8 = 0x70;
temp8 |= (u8) linked_list->data.vendor_specific.length;
@@ -321,9 +308,8 @@ acpi_rs_vendor_stream (
buffer += 1;
}
- /*
- * Loop through all of the Vendor Specific fields
- */
+ /* Loop through all of the Vendor Specific fields */
+
for (index = 0; index < linked_list->data.vendor_specific.length; index++) {
temp8 = linked_list->data.vendor_specific.reserved[index];
@@ -331,9 +317,8 @@ acpi_rs_vendor_stream (
buffer += 1;
}
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -370,40 +355,37 @@ acpi_rs_start_depend_fns_resource (
u8 *buffer = byte_stream_buffer;
struct acpi_resource *output_struct = (void *) *output_buffer;
u8 temp8 = 0;
- acpi_size struct_size = ACPI_SIZEOF_RESOURCE (struct acpi_resource_start_dpf);
+ acpi_size struct_size = ACPI_SIZEOF_RESOURCE (
+ struct acpi_resource_start_dpf);
ACPI_FUNCTION_TRACE ("rs_start_depend_fns_resource");
- /*
- * The number of bytes consumed are contained in the descriptor (Bits:0-1)
- */
+ /* The number of bytes consumed are found in the descriptor (Bits:0-1) */
+
temp8 = *buffer;
*bytes_consumed = (temp8 & 0x01) + 1;
output_struct->id = ACPI_RSTYPE_START_DPF;
- /*
- * Point to Byte 1 if it is used
- */
+ /* Point to Byte 1 if it is used */
+
if (2 == *bytes_consumed) {
buffer += 1;
temp8 = *buffer;
- /*
- * Check Compatibility priority
- */
+ /* Check Compatibility priority */
+
output_struct->data.start_dpf.compatibility_priority = temp8 & 0x03;
if (3 == output_struct->data.start_dpf.compatibility_priority) {
return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
}
- /*
- * Check Performance/Robustness preference
- */
+ /* Check Performance/Robustness preference */
+
output_struct->data.start_dpf.performance_robustness = (temp8 >> 2) & 0x03;
if (3 == output_struct->data.start_dpf.performance_robustness) {
@@ -412,20 +394,18 @@ acpi_rs_start_depend_fns_resource (
}
else {
output_struct->data.start_dpf.compatibility_priority =
- ACPI_ACCEPTABLE_CONFIGURATION;
+ ACPI_ACCEPTABLE_CONFIGURATION;
output_struct->data.start_dpf.performance_robustness =
- ACPI_ACCEPTABLE_CONFIGURATION;
+ ACPI_ACCEPTABLE_CONFIGURATION;
}
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -466,24 +446,20 @@ acpi_rs_end_depend_fns_resource (
ACPI_FUNCTION_TRACE ("rs_end_depend_fns_resource");
- /*
- * The number of bytes consumed is static
- */
+ /* The number of bytes consumed is static */
+
*bytes_consumed = 1;
- /*
- * Fill out the structure
- */
+ /* Fill out the structure */
+
output_struct->id = ACPI_RSTYPE_END_DPF;
- /*
- * Set the Length parameter
- */
+ /* Set the Length parameter */
+
output_struct->length = (u32) struct_size;
- /*
- * Return the final size of the structure
- */
+ /* Return the final size of the structure */
+
*structure_size = struct_size;
return_ACPI_STATUS (AE_OK);
}
@@ -533,9 +509,8 @@ acpi_rs_start_depend_fns_stream (
*buffer = 0x31;
buffer += 1;
- /*
- * Set the Priority Byte Definition
- */
+ /* Set the Priority Byte Definition */
+
temp8 = 0;
temp8 = (u8) ((linked_list->data.start_dpf.performance_robustness &
0x03) << 2);
@@ -546,9 +521,8 @@ acpi_rs_start_depend_fns_stream (
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
@@ -582,15 +556,13 @@ acpi_rs_end_depend_fns_stream (
ACPI_FUNCTION_TRACE ("rs_end_depend_fns_stream");
- /*
- * The descriptor field is static
- */
+ /* The descriptor field is static */
+
*buffer = 0x38;
buffer += 1;
- /*
- * Return the number of bytes consumed in this operation
- */
+ /* Return the number of bytes consumed in this operation */
+
*bytes_consumed = ACPI_PTR_DIFF (buffer, *output_buffer);
return_ACPI_STATUS (AE_OK);
}
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index ee9ce13c053..700cf7d65d7 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -83,10 +83,10 @@ acpi_rs_get_prt_method_data (
/* Parameters guaranteed valid by caller */
- /*
- * Execute the method, no parameters
- */
- status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc);
+ /* Execute the method, no parameters */
+
+ status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRT,
+ ACPI_BTYPE_PACKAGE, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -136,10 +136,10 @@ acpi_rs_get_crs_method_data (
/* Parameters guaranteed valid by caller */
- /*
- * Execute the method, no parameters
- */
- status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc);
+ /* Execute the method, no parameters */
+
+ status = acpi_ut_evaluate_object (handle, METHOD_NAME__CRS,
+ ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -175,6 +175,7 @@ acpi_rs_get_crs_method_data (
* and the contents of the callers buffer is undefined.
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_rs_get_prs_method_data (
@@ -190,10 +191,10 @@ acpi_rs_get_prs_method_data (
/* Parameters guaranteed valid by caller */
- /*
- * Execute the method, no parameters
- */
- status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc);
+ /* Execute the method, no parameters */
+
+ status = acpi_ut_evaluate_object (handle, METHOD_NAME__PRS,
+ ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -218,6 +219,7 @@ acpi_rs_get_prs_method_data (
* FUNCTION: acpi_rs_get_method_data
*
* PARAMETERS: Handle - a handle to the containing object
+ * Path - Path to method, relative to Handle
* ret_buffer - a pointer to a buffer structure for the
* results
*
@@ -246,9 +248,8 @@ acpi_rs_get_method_data (
/* Parameters guaranteed valid by caller */
- /*
- * Execute the method, no parameters
- */
+ /* Execute the method, no parameters */
+
status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
@@ -314,18 +315,16 @@ acpi_rs_set_srs_method_data (
return_ACPI_STATUS (status);
}
- /*
- * Init the param object
- */
+ /* Init the param object */
+
params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
if (!params[0]) {
acpi_os_free (buffer.pointer);
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /*
- * Set up the parameter object
- */
+ /* Set up the parameter object */
+
params[0]->buffer.length = (u32) buffer.length;
params[0]->buffer.pointer = buffer.pointer;
params[0]->common.flags = AOPOBJ_DATA_VALID;
@@ -335,10 +334,9 @@ acpi_rs_set_srs_method_data (
info.parameters = params;
info.parameter_type = ACPI_PARAM_ARGS;
- /*
- * Execute the method, no return value
- */
- status = acpi_ns_evaluate_relative ("_SRS", &info);
+ /* Execute the method, no return value */
+
+ status = acpi_ns_evaluate_relative (METHOD_NAME__SRS, &info);
if (ACPI_SUCCESS (status)) {
/* Delete any return object (especially if implicit_return is enabled) */
@@ -347,9 +345,8 @@ acpi_rs_set_srs_method_data (
}
}
- /*
- * Clean up and return the status from acpi_ns_evaluate_relative
- */
+ /* Clean up and return the status from acpi_ns_evaluate_relative */
+
acpi_ut_remove_reference (params[0]);
return_ACPI_STATUS (status);
}
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index a9cdcbeb343..83c944b8b09 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -49,6 +49,23 @@
#define _COMPONENT ACPI_RESOURCES
ACPI_MODULE_NAME ("rsxface")
+/* Local macros for 16,32-bit to 64-bit conversion */
+
+#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
+#define ACPI_COPY_ADDRESS(out, in) \
+ ACPI_COPY_FIELD(out, in, resource_type); \
+ ACPI_COPY_FIELD(out, in, producer_consumer); \
+ ACPI_COPY_FIELD(out, in, decode); \
+ ACPI_COPY_FIELD(out, in, min_address_fixed); \
+ ACPI_COPY_FIELD(out, in, max_address_fixed); \
+ ACPI_COPY_FIELD(out, in, attribute); \
+ ACPI_COPY_FIELD(out, in, granularity); \
+ ACPI_COPY_FIELD(out, in, min_address_range); \
+ ACPI_COPY_FIELD(out, in, max_address_range); \
+ ACPI_COPY_FIELD(out, in, address_translation_offset); \
+ ACPI_COPY_FIELD(out, in, address_length); \
+ ACPI_COPY_FIELD(out, in, resource_source);
+
/*******************************************************************************
*
@@ -180,6 +197,7 @@ EXPORT_SYMBOL(acpi_get_current_resources);
* and the value of ret_buffer is undefined.
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_get_possible_resources (
@@ -346,9 +364,8 @@ acpi_set_current_resources (
ACPI_FUNCTION_TRACE ("acpi_set_current_resources");
- /*
- * Must have a valid handle and buffer
- */
+ /* Must have a valid handle and buffer */
+
if ((!device_handle) ||
(!in_buffer) ||
(!in_buffer->pointer) ||
@@ -362,21 +379,6 @@ acpi_set_current_resources (
EXPORT_SYMBOL(acpi_set_current_resources);
-#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
-#define ACPI_COPY_ADDRESS(out, in) \
- ACPI_COPY_FIELD(out, in, resource_type); \
- ACPI_COPY_FIELD(out, in, producer_consumer); \
- ACPI_COPY_FIELD(out, in, decode); \
- ACPI_COPY_FIELD(out, in, min_address_fixed); \
- ACPI_COPY_FIELD(out, in, max_address_fixed); \
- ACPI_COPY_FIELD(out, in, attribute); \
- ACPI_COPY_FIELD(out, in, granularity); \
- ACPI_COPY_FIELD(out, in, min_address_range); \
- ACPI_COPY_FIELD(out, in, max_address_range); \
- ACPI_COPY_FIELD(out, in, address_translation_offset); \
- ACPI_COPY_FIELD(out, in, address_length); \
- ACPI_COPY_FIELD(out, in, resource_source);
-
/******************************************************************************
*
* FUNCTION: acpi_resource_to_address64
@@ -408,14 +410,14 @@ acpi_resource_to_address64 (
case ACPI_RSTYPE_ADDRESS16:
address16 = (struct acpi_resource_address16 *) &resource->data;
- ACPI_COPY_ADDRESS(out, address16);
+ ACPI_COPY_ADDRESS (out, address16);
break;
case ACPI_RSTYPE_ADDRESS32:
address32 = (struct acpi_resource_address32 *) &resource->data;
- ACPI_COPY_ADDRESS(out, address32);
+ ACPI_COPY_ADDRESS (out, address32);
break;
@@ -434,4 +436,3 @@ acpi_resource_to_address64 (
return (AE_OK);
}
EXPORT_SYMBOL(acpi_resource_to_address64);
-
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 337d49b5564..cbcda30c172 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1061,13 +1061,15 @@ acpi_add_single_object (
/*
* Status
* ------
- * See if the device is present. We always assume that non-Device()
- * objects (e.g. thermal zones, power resources, processors, etc.) are
- * present, functioning, etc. (at least when parent object is present).
- * Note that _STA has a different meaning for some objects (e.g.
- * power resources) so we need to be careful how we use it.
+ * See if the device is present. We always assume that non-Device
+ * and non-Processor objects (e.g. thermal zones, power resources,
+ * etc.) are present, functioning, etc. (at least when parent object
+ * is present). Note that _STA has a different meaning for some
+ * objects (e.g. power resources) so we need to be careful how we use
+ * it.
*/
switch (type) {
+ case ACPI_BUS_TYPE_PROCESSOR:
case ACPI_BUS_TYPE_DEVICE:
result = acpi_bus_get_status(device);
if (ACPI_FAILURE(result) || !device->status.present) {
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 0a5d2a94131..7249ba2b7a2 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -1,6 +1,7 @@
/*
* sleep.c - ACPI sleep support.
*
+ * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
* Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com>
* Copyright (c) 2000-2003 Patrick Mochel
* Copyright (c) 2003 Open Source Development Lab
@@ -14,7 +15,6 @@
#include <linux/dmi.h>
#include <linux/device.h>
#include <linux/suspend.h>
-#include <asm/io.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include "sleep.h"
@@ -27,10 +27,11 @@ extern void do_suspend_lowlevel_s4bios(void);
extern void do_suspend_lowlevel(void);
static u32 acpi_suspend_states[] = {
- [PM_SUSPEND_ON] = ACPI_STATE_S0,
- [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
- [PM_SUSPEND_MEM] = ACPI_STATE_S3,
- [PM_SUSPEND_DISK] = ACPI_STATE_S4,
+ [PM_SUSPEND_ON] = ACPI_STATE_S0,
+ [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
+ [PM_SUSPEND_MEM] = ACPI_STATE_S3,
+ [PM_SUSPEND_DISK] = ACPI_STATE_S4,
+ [PM_SUSPEND_MAX] = ACPI_STATE_S5
};
static int init_8259A_after_S1;
@@ -44,30 +45,20 @@ static int init_8259A_after_S1;
* wakeup code to the waking vector.
*/
+extern int acpi_sleep_prepare(u32 acpi_state);
+extern void acpi_power_off(void);
+
static int acpi_pm_prepare(suspend_state_t pm_state)
{
u32 acpi_state = acpi_suspend_states[pm_state];
- if (!sleep_states[acpi_state])
+ if (!sleep_states[acpi_state]) {
+ printk("acpi_pm_prepare does not support %d \n", pm_state);
return -EPERM;
-
- /* do we have a wakeup address for S2 and S3? */
- /* Here, we support only S4BIOS, those we set the wakeup address */
- /* S4OS is only supported for now via swsusp.. */
- if (pm_state == PM_SUSPEND_MEM || pm_state == PM_SUSPEND_DISK) {
- if (!acpi_wakeup_address)
- return -EFAULT;
- acpi_set_firmware_waking_vector(
- (acpi_physical_address) virt_to_phys(
- (void *)acpi_wakeup_address));
}
- ACPI_FLUSH_CPU_CACHE();
- acpi_enable_wakeup_device_prep(acpi_state);
- acpi_enter_sleep_state_prep(acpi_state);
- return 0;
+ return acpi_sleep_prepare(acpi_state);
}
-
/**
* acpi_pm_enter - Actually enter a sleep state.
* @pm_state: State we're entering.
@@ -92,11 +83,9 @@ static int acpi_pm_enter(suspend_state_t pm_state)
return error;
}
-
local_irq_save(flags);
acpi_enable_wakeup_device(acpi_state);
- switch (pm_state)
- {
+ switch (pm_state) {
case PM_SUSPEND_STANDBY:
barrier();
status = acpi_enter_sleep_state(acpi_state);
@@ -112,6 +101,10 @@ static int acpi_pm_enter(suspend_state_t pm_state)
else
do_suspend_lowlevel_s4bios();
break;
+ case PM_SUSPEND_MAX:
+ acpi_power_off();
+ break;
+
default:
return -EINVAL;
}
@@ -126,11 +119,9 @@ static int acpi_pm_enter(suspend_state_t pm_state)
if (pm_state > PM_SUSPEND_STANDBY)
acpi_restore_state_mem();
-
return ACPI_SUCCESS(status) ? 0 : -EFAULT;
}
-
/**
* acpi_pm_finish - Finish up suspend sequence.
* @pm_state: State we're coming out of.
@@ -156,27 +147,26 @@ static int acpi_pm_finish(suspend_state_t pm_state)
return 0;
}
-
int acpi_suspend(u32 acpi_state)
{
suspend_state_t states[] = {
- [1] = PM_SUSPEND_STANDBY,
- [3] = PM_SUSPEND_MEM,
- [4] = PM_SUSPEND_DISK,
+ [1] = PM_SUSPEND_STANDBY,
+ [3] = PM_SUSPEND_MEM,
+ [4] = PM_SUSPEND_DISK,
+ [5] = PM_SUSPEND_MAX
};
- if (acpi_state <= 4 && states[acpi_state])
+ if (acpi_state < 6 && states[acpi_state])
return pm_suspend(states[acpi_state]);
return -EINVAL;
}
static struct pm_ops acpi_pm_ops = {
- .prepare = acpi_pm_prepare,
- .enter = acpi_pm_enter,
- .finish = acpi_pm_finish,
+ .prepare = acpi_pm_prepare,
+ .enter = acpi_pm_enter,
+ .finish = acpi_pm_finish,
};
-
/*
* Toshiba fails to preserve interrupts over S1, reinitialization
* of 8259 is needed after S1 resume.
@@ -190,16 +180,16 @@ static int __init init_ints_after_s1(struct dmi_system_id *d)
static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
{
- .callback = init_ints_after_s1,
- .ident = "Toshiba Satellite 4030cdt",
- .matches = { DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), },
- },
- { },
+ .callback = init_ints_after_s1,
+ .ident = "Toshiba Satellite 4030cdt",
+ .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
+ },
+ {},
};
static int __init acpi_sleep_init(void)
{
- int i = 0;
+ int i = 0;
dmi_check_system(acpisleep_dmi_table);
@@ -207,7 +197,7 @@ static int __init acpi_sleep_init(void)
return 0;
printk(KERN_INFO PREFIX "(supports");
- for (i=0; i < ACPI_S_STATE_COUNT; i++) {
+ for (i = 0; i < ACPI_S_STATE_COUNT; i++) {
acpi_status status;
u8 type_a, type_b;
status = acpi_get_sleep_type_data(i, &type_a, &type_b);
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c
index da237754ded..1fc86e6b5ab 100644
--- a/drivers/acpi/sleep/poweroff.c
+++ b/drivers/acpi/sleep/poweroff.c
@@ -3,35 +3,100 @@
*
* AKA S5, but it is independent of whether or not the kernel supports
* any other sleep support in the system.
+ *
+ * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
+ *
+ * This file is released under the GPLv2.
*/
#include <linux/pm.h>
#include <linux/init.h>
#include <acpi/acpi_bus.h>
#include <linux/sched.h>
+#include <linux/sysdev.h>
+#include <asm/io.h>
#include "sleep.h"
-static void
-acpi_power_off (void)
+int acpi_sleep_prepare(u32 acpi_state)
+{
+ /* Flag to do not allow second time invocation for S5 state */
+ static int shutdown_prepared = 0;
+#ifdef CONFIG_ACPI_SLEEP
+ /* do we have a wakeup address for S2 and S3? */
+ /* Here, we support only S4BIOS, those we set the wakeup address */
+ /* S4OS is only supported for now via swsusp.. */
+ if (acpi_state == ACPI_STATE_S3 || acpi_state == ACPI_STATE_S4) {
+ if (!acpi_wakeup_address) {
+ return -EFAULT;
+ }
+ acpi_set_firmware_waking_vector((acpi_physical_address)
+ virt_to_phys((void *)
+ acpi_wakeup_address));
+
+ }
+ ACPI_FLUSH_CPU_CACHE();
+ acpi_enable_wakeup_device_prep(acpi_state);
+#endif
+ if (acpi_state == ACPI_STATE_S5) {
+ /* Check if we were already called */
+ if (shutdown_prepared)
+ return 0;
+ acpi_wakeup_gpe_poweroff_prepare();
+ shutdown_prepared = 1;
+ }
+ acpi_enter_sleep_state_prep(acpi_state);
+ return 0;
+}
+
+void acpi_power_off(void)
{
- printk("%s called\n",__FUNCTION__);
+ printk("%s called\n", __FUNCTION__);
+ acpi_sleep_prepare(ACPI_STATE_S5);
+ local_irq_disable();
/* Some SMP machines only can poweroff in boot CPU */
set_cpus_allowed(current, cpumask_of_cpu(0));
- acpi_wakeup_gpe_poweroff_prepare();
- acpi_enter_sleep_state_prep(ACPI_STATE_S5);
- ACPI_DISABLE_IRQS();
acpi_enter_sleep_state(ACPI_STATE_S5);
}
+#ifdef CONFIG_PM
+
+static int acpi_shutdown(struct sys_device *x)
+{
+ return acpi_sleep_prepare(ACPI_STATE_S5);
+}
+
+static struct sysdev_class acpi_sysclass = {
+ set_kset_name("acpi"),
+ .shutdown = acpi_shutdown
+};
+
+static struct sys_device device_acpi = {
+ .id = 0,
+ .cls = &acpi_sysclass,
+};
+
+#endif
+
static int acpi_poweroff_init(void)
{
if (!acpi_disabled) {
u8 type_a, type_b;
acpi_status status;
- status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
- if (ACPI_SUCCESS(status))
+ status =
+ acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
+ if (ACPI_SUCCESS(status)) {
pm_power_off = acpi_power_off;
+#ifdef CONFIG_PM
+ {
+ int error;
+ error = sysdev_class_register(&acpi_sysclass);
+ if (!error)
+ error = sysdev_register(&device_acpi);
+ return error;
+ }
+#endif
+ }
}
return 0;
}
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index fd7c5a0649a..1be99f0996d 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -13,13 +13,17 @@
#include "sleep.h"
+#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
#define ACPI_SYSTEM_FILE_SLEEP "sleep"
+#endif
+
#define ACPI_SYSTEM_FILE_ALARM "alarm"
#define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup"
#define _COMPONENT ACPI_SYSTEM_COMPONENT
ACPI_MODULE_NAME ("sleep")
+#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
{
@@ -78,6 +82,7 @@ acpi_system_write_sleep (
Done:
return error ? error : count;
}
+#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
{
@@ -452,6 +457,7 @@ static struct file_operations acpi_system_wakeup_device_fops = {
.release = single_release,
};
+#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
static struct file_operations acpi_system_sleep_fops = {
.open = acpi_system_sleep_open_fs,
.read = seq_read,
@@ -459,6 +465,7 @@ static struct file_operations acpi_system_sleep_fops = {
.llseek = seq_lseek,
.release = single_release,
};
+#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */
static struct file_operations acpi_system_alarm_fops = {
.open = acpi_system_alarm_open_fs,
@@ -484,11 +491,13 @@ static int acpi_sleep_proc_init(void)
if (acpi_disabled)
return 0;
+#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP
/* 'sleep' [R/W]*/
entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP,
S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir);
if (entry)
entry->proc_fops = &acpi_system_sleep_fops;
+#endif
/* 'alarm' [R/W] */
entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM,
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index 334327c1f66..92e0c31539b 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -50,6 +50,24 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbconvrt")
+/* Local prototypes */
+
+static void
+acpi_tb_init_generic_address (
+ struct acpi_generic_address *new_gas_struct,
+ u8 register_bit_width,
+ acpi_physical_address address);
+
+static void
+acpi_tb_convert_fadt1 (
+ struct fadt_descriptor_rev2 *local_fadt,
+ struct fadt_descriptor_rev1 *original_fadt);
+
+static void
+acpi_tb_convert_fadt2 (
+ struct fadt_descriptor_rev2 *local_fadt,
+ struct fadt_descriptor_rev2 *original_fadt);
+
u8 acpi_fadt_is_v1;
EXPORT_SYMBOL(acpi_fadt_is_v1);
@@ -142,11 +160,13 @@ acpi_tb_convert_to_xsdt (
for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
if (acpi_gbl_RSDP->revision < 2) {
ACPI_STORE_ADDRESS (new_table->table_offset_entry[i],
- (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, table_info->pointer))->table_offset_entry[i]);
+ (ACPI_CAST_PTR (struct rsdt_descriptor_rev1,
+ table_info->pointer))->table_offset_entry[i]);
}
else {
new_table->table_offset_entry[i] =
- (ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info->pointer))->table_offset_entry[i];
+ (ACPI_CAST_PTR (XSDT_DESCRIPTOR,
+ table_info->pointer))->table_offset_entry[i];
}
}
@@ -164,7 +184,7 @@ acpi_tb_convert_to_xsdt (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_tb_init_generic_address
*
@@ -201,7 +221,7 @@ acpi_tb_init_generic_address (
* PARAMETERS: local_fadt - Pointer to new FADT
* original_fadt - Pointer to old FADT
*
- * RETURN: Populates local_fadt
+ * RETURN: None, populates local_fadt
*
* DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format
*
@@ -213,7 +233,6 @@ acpi_tb_convert_fadt1 (
struct fadt_descriptor_rev1 *original_fadt)
{
-
/* ACPI 1.0 FACS */
/* The BIOS stored FADT should agree with Revision 1.0 */
acpi_fadt_is_v1 = 1;
@@ -232,7 +251,8 @@ acpi_tb_convert_fadt1 (
ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt);
/*
- * System Interrupt Model isn't used in ACPI 2.0 (local_fadt->Reserved1 = 0;)
+ * System Interrupt Model isn't used in ACPI 2.0
+ * (local_fadt->Reserved1 = 0;)
*/
/*
@@ -269,7 +289,8 @@ acpi_tb_convert_fadt1 (
* that immediately follows.
*/
ACPI_MEMCPY (&local_fadt->reset_register,
- &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, original_fadt))->reset_register,
+ &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus,
+ original_fadt))->reset_register,
sizeof (struct acpi_generic_address) + 1);
}
else {
@@ -304,7 +325,8 @@ acpi_tb_convert_fadt1 (
acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
- (acpi_physical_address) (local_fadt->xpm1a_evt_blk.address +
+ (acpi_physical_address)
+ (local_fadt->xpm1a_evt_blk.address +
ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
/* PM1B is optional; leave null if not present */
@@ -312,7 +334,8 @@ acpi_tb_convert_fadt1 (
if (local_fadt->xpm1b_evt_blk.address) {
acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
- (acpi_physical_address) (local_fadt->xpm1b_evt_blk.address +
+ (acpi_physical_address)
+ (local_fadt->xpm1b_evt_blk.address +
ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
}
}
@@ -325,7 +348,7 @@ acpi_tb_convert_fadt1 (
* PARAMETERS: local_fadt - Pointer to new FADT
* original_fadt - Pointer to old FADT
*
- * RETURN: Populates local_fadt
+ * RETURN: None, populates local_fadt
*
* DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format.
* Handles optional "X" fields.
@@ -348,7 +371,8 @@ acpi_tb_convert_fadt2 (
* is zero.
*/
if (!(local_fadt->xfirmware_ctrl)) {
- ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl);
+ ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl,
+ local_fadt->V1_firmware_ctrl);
}
if (!(local_fadt->Xdsdt)) {
@@ -357,32 +381,38 @@ acpi_tb_convert_fadt2 (
if (!(local_fadt->xpm1a_evt_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk,
- local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
+ local_fadt->pm1_evt_len,
+ (acpi_physical_address) local_fadt->V1_pm1a_evt_blk);
}
if (!(local_fadt->xpm1b_evt_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk,
- local_fadt->pm1_evt_len, (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
+ local_fadt->pm1_evt_len,
+ (acpi_physical_address) local_fadt->V1_pm1b_evt_blk);
}
if (!(local_fadt->xpm1a_cnt_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk,
- local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
+ local_fadt->pm1_cnt_len,
+ (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk);
}
if (!(local_fadt->xpm1b_cnt_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk,
- local_fadt->pm1_cnt_len, (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
+ local_fadt->pm1_cnt_len,
+ (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk);
}
if (!(local_fadt->xpm2_cnt_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk,
- local_fadt->pm2_cnt_len, (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
+ local_fadt->pm2_cnt_len,
+ (acpi_physical_address) local_fadt->V1_pm2_cnt_blk);
}
if (!(local_fadt->xpm_tmr_blk.address)) {
acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk,
- local_fadt->pm_tm_len, (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
+ local_fadt->pm_tm_len,
+ (acpi_physical_address) local_fadt->V1_pm_tmr_blk);
}
if (!(local_fadt->xgpe0_blk.address)) {
@@ -399,18 +429,24 @@ acpi_tb_convert_fadt2 (
acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable,
(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
- (acpi_physical_address) (local_fadt->xpm1a_evt_blk.address +
+ (acpi_physical_address)
+ (local_fadt->xpm1a_evt_blk.address +
ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
- acpi_gbl_xpm1a_enable.address_space_id = local_fadt->xpm1a_evt_blk.address_space_id;
+
+ acpi_gbl_xpm1a_enable.address_space_id =
+ local_fadt->xpm1a_evt_blk.address_space_id;
/* PM1B is optional; leave null if not present */
if (local_fadt->xpm1b_evt_blk.address) {
acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable,
(u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len),
- (acpi_physical_address) (local_fadt->xpm1b_evt_blk.address +
+ (acpi_physical_address)
+ (local_fadt->xpm1b_evt_blk.address +
ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len)));
- acpi_gbl_xpm1b_enable.address_space_id = local_fadt->xpm1b_evt_blk.address_space_id;
+
+ acpi_gbl_xpm1b_enable.address_space_id =
+ local_fadt->xpm1b_evt_blk.address_space_id;
}
}
@@ -432,7 +468,8 @@ acpi_tb_convert_fadt2 (
******************************************************************************/
acpi_status
-acpi_tb_convert_table_fadt (void)
+acpi_tb_convert_table_fadt (
+ void)
{
struct fadt_descriptor_rev2 *local_fadt;
struct acpi_table_desc *table_desc;
@@ -446,7 +483,8 @@ acpi_tb_convert_table_fadt (void)
* at least as long as the version 1.0 FADT
*/
if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) {
- ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", acpi_gbl_FADT->length));
+ ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n",
+ acpi_gbl_FADT->length));
return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
}
@@ -461,8 +499,9 @@ acpi_tb_convert_table_fadt (void)
if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) {
/* Length is too short to be a V2.0 table */
- ACPI_REPORT_WARNING (("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
- acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
+ ACPI_REPORT_WARNING ((
+ "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n",
+ acpi_gbl_FADT->length, acpi_gbl_FADT->revision));
acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
}
@@ -478,9 +517,8 @@ acpi_tb_convert_table_fadt (void)
acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT);
}
- /*
- * Global FADT pointer will point to the new common V2.0 FADT
- */
+ /* Global FADT pointer will point to the new common V2.0 FADT */
+
acpi_gbl_FADT = local_fadt;
acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR);
@@ -508,7 +546,7 @@ acpi_tb_convert_table_fadt (void)
/*******************************************************************************
*
- * FUNCTION: acpi_tb_convert_table_facs
+ * FUNCTION: acpi_tb_build_common_facs
*
* PARAMETERS: table_info - Info for currently installed FACS
*
@@ -530,12 +568,14 @@ acpi_tb_build_common_facs (
/* Absolute minimum length is 24, but the ACPI spec says 64 */
if (acpi_gbl_FACS->length < 24) {
- ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", acpi_gbl_FACS->length));
+ ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n",
+ acpi_gbl_FACS->length));
return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
}
if (acpi_gbl_FACS->length < 64) {
- ACPI_REPORT_WARNING (("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
+ ACPI_REPORT_WARNING ((
+ "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n",
acpi_gbl_FACS->length));
}
@@ -548,7 +588,8 @@ acpi_tb_build_common_facs (
(!(acpi_gbl_FACS->xfirmware_waking_vector))) {
/* ACPI 1.0 FACS or short table or optional X_ field is zero */
- acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, &(acpi_gbl_FACS->firmware_waking_vector));
+ acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64,
+ &(acpi_gbl_FACS->firmware_waking_vector));
acpi_gbl_common_fACS.vector_width = 32;
}
else {
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 896f3ddda62..4ab2aadc613 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -49,6 +49,19 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbget")
+/* Local prototypes */
+
+static acpi_status
+acpi_tb_get_this_table (
+ struct acpi_pointer *address,
+ struct acpi_table_header *header,
+ struct acpi_table_desc *table_info);
+
+static acpi_status
+acpi_tb_table_override (
+ struct acpi_table_header *header,
+ struct acpi_table_desc *table_info);
+
/*******************************************************************************
*
@@ -76,9 +89,8 @@ acpi_tb_get_table (
ACPI_FUNCTION_TRACE ("tb_get_table");
- /*
- * Get the header in order to get signature and table size
- */
+ /* Get the header in order to get signature and table size */
+
status = acpi_tb_get_table_header (address, &header);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
@@ -127,8 +139,8 @@ acpi_tb_get_table_header (
/*
- * Flags contains the current processor mode (Virtual or Physical addressing)
- * The pointer_type is either Logical or Physical
+ * Flags contains the current processor mode (Virtual or Physical
+ * addressing) The pointer_type is either Logical or Physical
*/
switch (address->pointer_type) {
case ACPI_PHYSMODE_PHYSPTR:
@@ -136,7 +148,8 @@ acpi_tb_get_table_header (
/* Pointer matches processor mode, copy the header */
- ACPI_MEMCPY (return_header, address->pointer.logical, sizeof (struct acpi_table_header));
+ ACPI_MEMCPY (return_header, address->pointer.logical,
+ sizeof (struct acpi_table_header));
break;
@@ -144,10 +157,11 @@ acpi_tb_get_table_header (
/* Create a logical address for the physical pointer*/
- status = acpi_os_map_memory (address->pointer.physical, sizeof (struct acpi_table_header),
- (void *) &header);
+ status = acpi_os_map_memory (address->pointer.physical,
+ sizeof (struct acpi_table_header), (void *) &header);
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n",
+ ACPI_REPORT_ERROR ((
+ "Could not map memory at %8.8X%8.8X for length %X\n",
ACPI_FORMAT_UINT64 (address->pointer.physical),
sizeof (struct acpi_table_header)));
return_ACPI_STATUS (status);
@@ -210,9 +224,8 @@ acpi_tb_get_table_body (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
- /*
- * Attempt table override.
- */
+ /* Attempt table override. */
+
status = acpi_tb_table_override (header, table_info);
if (ACPI_SUCCESS (status)) {
/* Table was overridden by the host OS */
@@ -241,7 +254,7 @@ acpi_tb_get_table_body (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_table_override (
struct acpi_table_header *header,
struct acpi_table_desc *table_info)
@@ -315,7 +328,7 @@ acpi_tb_table_override (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_get_this_table (
struct acpi_pointer *address,
struct acpi_table_header *header,
@@ -330,8 +343,8 @@ acpi_tb_get_this_table (
/*
- * Flags contains the current processor mode (Virtual or Physical addressing)
- * The pointer_type is either Logical or Physical
+ * Flags contains the current processor mode (Virtual or Physical
+ * addressing) The pointer_type is either Logical or Physical
*/
switch (address->pointer_type) {
case ACPI_PHYSMODE_PHYSPTR:
@@ -341,7 +354,8 @@ acpi_tb_get_this_table (
full_table = ACPI_MEM_ALLOCATE (header->length);
if (!full_table) {
- ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n",
+ ACPI_REPORT_ERROR ((
+ "Could not allocate table memory for [%4.4s] length %X\n",
header->signature, header->length));
return_ACPI_STATUS (AE_NO_MEMORY);
}
@@ -362,12 +376,14 @@ acpi_tb_get_this_table (
* Just map the table's physical memory
* into our address space.
*/
- status = acpi_os_map_memory (address->pointer.physical, (acpi_size) header->length,
- (void *) &full_table);
+ status = acpi_os_map_memory (address->pointer.physical,
+ (acpi_size) header->length, (void *) &full_table);
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
+ ACPI_REPORT_ERROR ((
+ "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
header->signature,
- ACPI_FORMAT_UINT64 (address->pointer.physical), header->length));
+ ACPI_FORMAT_UINT64 (address->pointer.physical),
+ header->length));
return (status);
}
@@ -465,9 +481,8 @@ acpi_tb_get_table_ptr (
return_ACPI_STATUS (AE_OK);
}
- /*
- * Check for instance out of range
- */
+ /* Check for instance out of range */
+
if (instance > acpi_gbl_table_lists[table_type].count) {
return_ACPI_STATUS (AE_NOT_EXIST);
}
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index adc4270988b..eea5b8cb5eb 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -49,6 +49,19 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbgetall")
+/* Local prototypes */
+
+static acpi_status
+acpi_tb_get_primary_table (
+ struct acpi_pointer *address,
+ struct acpi_table_desc *table_info);
+
+static acpi_status
+acpi_tb_get_secondary_table (
+ struct acpi_pointer *address,
+ acpi_string signature,
+ struct acpi_table_desc *table_info);
+
/*******************************************************************************
*
@@ -63,7 +76,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_get_primary_table (
struct acpi_pointer *address,
struct acpi_table_desc *table_info)
@@ -81,9 +94,8 @@ acpi_tb_get_primary_table (
return_ACPI_STATUS (AE_OK);
}
- /*
- * Get the header in order to get signature and table size
- */
+ /* Get the header in order to get signature and table size */
+
status = acpi_tb_get_table_header (address, &header);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
@@ -130,7 +142,7 @@ acpi_tb_get_primary_table (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_get_secondary_table (
struct acpi_pointer *address,
acpi_string signature,
@@ -153,7 +165,8 @@ acpi_tb_get_secondary_table (
/* Signature must match request */
if (ACPI_STRNCMP (header.signature, signature, ACPI_NAME_SIZE)) {
- ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n",
+ ACPI_REPORT_ERROR ((
+ "Incorrect table signature - wanted [%s] found [%4.4s]\n",
signature, header.signature));
return_ACPI_STATUS (AE_BAD_SIGNATURE);
}
@@ -230,7 +243,8 @@ acpi_tb_get_required_tables (
for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
/* Get the table address from the common internal XSDT */
- address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
+ address.pointer.value =
+ acpi_gbl_XSDT->table_offset_entry[i];
/*
* Get the tables needed by this subsystem (FADT and any SSDTs).
@@ -252,18 +266,18 @@ acpi_tb_get_required_tables (
}
/*
- * Convert the FADT to a common format. This allows earlier revisions of the
- * table to coexist with newer versions, using common access code.
+ * Convert the FADT to a common format. This allows earlier revisions of
+ * the table to coexist with newer versions, using common access code.
*/
status = acpi_tb_convert_table_fadt ();
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n"));
+ ACPI_REPORT_ERROR ((
+ "Could not convert FADT to internal common format\n"));
return_ACPI_STATUS (status);
}
- /*
- * Get the FACS (Pointed to by the FADT)
- */
+ /* Get the FACS (Pointed to by the FADT) */
+
address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
status = acpi_tb_get_secondary_table (&address, FACS_SIG, &table_info);
@@ -282,9 +296,8 @@ acpi_tb_get_required_tables (
return_ACPI_STATUS (status);
}
- /*
- * Get/install the DSDT (Pointed to by the FADT)
- */
+ /* Get/install the DSDT (Pointed to by the FADT) */
+
address.pointer.value = acpi_gbl_FADT->Xdsdt;
status = acpi_tb_get_secondary_table (&address, DSDT_SIG, &table_info);
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index 85d5bb01022..629b64c8193 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -49,6 +49,14 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbinstal")
+/* Local prototypes */
+
+static acpi_status
+acpi_tb_match_signature (
+ char *signature,
+ struct acpi_table_desc *table_info,
+ u8 search_type);
+
/*******************************************************************************
*
@@ -56,6 +64,7 @@
*
* PARAMETERS: Signature - Table signature to match
* table_info - Return data
+ * search_type - Table type to match (primary/secondary)
*
* RETURN: Status
*
@@ -64,7 +73,7 @@
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_match_signature (
char *signature,
struct acpi_table_desc *table_info,
@@ -76,9 +85,8 @@ acpi_tb_match_signature (
ACPI_FUNCTION_TRACE ("tb_match_signature");
- /*
- * Search for a signature match among the known table types
- */
+ /* Search for a signature match among the known table types */
+
for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
if (!(acpi_gbl_table_data[i].flags & search_type)) {
continue;
@@ -161,6 +169,7 @@ acpi_tb_install_table (
* FUNCTION: acpi_tb_recognize_table
*
* PARAMETERS: table_info - Return value from acpi_tb_get_table_body
+ * search_type - Table type to match (primary/secondary)
*
* RETURN: Status
*
@@ -203,7 +212,8 @@ acpi_tb_recognize_table (
* This can be any one of many valid ACPI tables, it just isn't one of
* the tables that is consumed by the core subsystem
*/
- status = acpi_tb_match_signature (table_header->signature, table_info, search_type);
+ status = acpi_tb_match_signature (table_header->signature,
+ table_info, search_type);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -253,9 +263,8 @@ acpi_tb_init_table_descriptor (
return_ACPI_STATUS (AE_NO_MEMORY);
}
- /*
- * Install the table into the global data structure
- */
+ /* Install the table into the global data structure */
+
list_head = &acpi_gbl_table_lists[table_type];
/*
@@ -316,7 +325,8 @@ acpi_tb_init_table_descriptor (
table_desc->aml_start = (u8 *) (table_desc->pointer + 1),
table_desc->aml_length = (u32) (table_desc->length -
(u32) sizeof (struct acpi_table_header));
- table_desc->table_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_TABLE);
+ table_desc->table_id = acpi_ut_allocate_owner_id (
+ ACPI_OWNER_TYPE_TABLE);
table_desc->loaded_into_namespace = FALSE;
/*
@@ -349,7 +359,8 @@ acpi_tb_init_table_descriptor (
******************************************************************************/
void
-acpi_tb_delete_all_tables (void)
+acpi_tb_delete_all_tables (
+ void)
{
acpi_table_type type;
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 9c6913238d5..b7ffe39c362 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -84,8 +84,9 @@ acpi_tb_verify_rsdp (
/*
* Obtain access to the RSDP structure
*/
- status = acpi_os_map_memory (address->pointer.physical, sizeof (struct rsdp_descriptor),
- (void *) &rsdp);
+ status = acpi_os_map_memory (address->pointer.physical,
+ sizeof (struct rsdp_descriptor),
+ (void *) &rsdp);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -154,9 +155,9 @@ cleanup:
*
* FUNCTION: acpi_tb_get_rsdt_address
*
- * PARAMETERS: None
+ * PARAMETERS: out_address - Where the address is returned
*
- * RETURN: RSDT physical address
+ * RETURN: None, Address
*
* DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the
* version of the RSDP
@@ -181,7 +182,8 @@ acpi_tb_get_rsdt_address (
out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
}
else {
- out_address->pointer.value = acpi_gbl_RSDP->xsdt_physical_address;
+ out_address->pointer.value =
+ acpi_gbl_RSDP->xsdt_physical_address;
}
}
@@ -224,7 +226,8 @@ acpi_tb_validate_rsdt (
if (no_match) {
/* Invalid RSDT or XSDT signature */
- ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
+ ACPI_REPORT_ERROR ((
+ "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20);
@@ -282,6 +285,7 @@ acpi_tb_get_table_rsdt (
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n",
acpi_format_exception (status)));
+
return_ACPI_STATUS (status);
}
@@ -299,7 +303,8 @@ acpi_tb_get_table_rsdt (
/* Get the number of tables defined in the RSDT or XSDT */
- acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, table_info.pointer);
+ acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP,
+ table_info.pointer);
/* Convert and/or copy to an XSDT structure */
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index fede5804c78..e69d01d443d 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -49,48 +49,14 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbutils")
+/* Local prototypes */
-/*******************************************************************************
- *
- * FUNCTION: acpi_tb_handle_to_object
- *
- * PARAMETERS: table_id - Id for which the function is searching
- * table_desc - Pointer to return the matching table
- * descriptor.
- *
- * RETURN: Search the tables to find one with a matching table_id and
- * return a pointer to that table descriptor.
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_OBSOLETE_FUNCTIONS
acpi_status
acpi_tb_handle_to_object (
u16 table_id,
- struct acpi_table_desc **return_table_desc)
-{
- u32 i;
- struct acpi_table_desc *table_desc;
-
-
- ACPI_FUNCTION_NAME ("tb_handle_to_object");
-
-
- for (i = 0; i < ACPI_TABLE_MAX; i++) {
- table_desc = acpi_gbl_table_lists[i].next;
- while (table_desc) {
- if (table_desc->table_id == table_id) {
- *return_table_desc = table_desc;
- return (AE_OK);
- }
-
- table_desc = table_desc->next;
- }
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
- return (AE_BAD_PARAMETER);
-}
-#endif /* ACPI_FUTURE_USAGE */
+ struct acpi_table_desc **table_desc);
+#endif
/*******************************************************************************
@@ -128,6 +94,7 @@ acpi_tb_validate_table_header (
if (!acpi_os_readable (table_header, sizeof (struct acpi_table_header))) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Cannot read table header at %p\n", table_header));
+
return (AE_BAD_ADDRESS);
}
@@ -141,6 +108,7 @@ acpi_tb_validate_table_header (
ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n",
(char *) &signature));
+
ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
return (AE_BAD_SIGNATURE);
}
@@ -154,6 +122,7 @@ acpi_tb_validate_table_header (
ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n",
(u32) table_header->length));
+
ACPI_DUMP_BUFFER (table_header, sizeof (struct acpi_table_header));
return (AE_BAD_HEADER);
}
@@ -193,8 +162,10 @@ acpi_tb_verify_table_checksum (
/* Return the appropriate exception */
if (checksum) {
- ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
- table_header->signature, (u32) table_header->checksum, (u32) checksum));
+ ACPI_REPORT_WARNING ((
+ "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n",
+ table_header->signature, (u32) table_header->checksum,
+ (u32) checksum));
status = AE_BAD_CHECKSUM;
}
@@ -209,7 +180,7 @@ acpi_tb_verify_table_checksum (
* PARAMETERS: Buffer - Buffer to checksum
* Length - Size of the buffer
*
- * RETURNS 8 bit checksum of buffer
+ * RETURN: 8 bit checksum of buffer
*
* DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it.
*
@@ -238,3 +209,47 @@ acpi_tb_checksum (
}
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_tb_handle_to_object
+ *
+ * PARAMETERS: table_id - Id for which the function is searching
+ * table_desc - Pointer to return the matching table
+ * descriptor.
+ *
+ * RETURN: Search the tables to find one with a matching table_id and
+ * return a pointer to that table descriptor.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_tb_handle_to_object (
+ u16 table_id,
+ struct acpi_table_desc **return_table_desc)
+{
+ u32 i;
+ struct acpi_table_desc *table_desc;
+
+
+ ACPI_FUNCTION_NAME ("tb_handle_to_object");
+
+
+ for (i = 0; i < ACPI_TABLE_MAX; i++) {
+ table_desc = acpi_gbl_table_lists[i].next;
+ while (table_desc) {
+ if (table_desc->table_id == table_id) {
+ *return_table_desc = table_desc;
+ return (AE_OK);
+ }
+
+ table_desc = table_desc->next;
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "table_id=%X does not exist\n", table_id));
+ return (AE_BAD_PARAMETER);
+}
+#endif
+
+
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c
index 7715043461c..0c0b9085dbe 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/tables/tbxface.c
@@ -67,7 +67,8 @@
******************************************************************************/
acpi_status
-acpi_load_tables (void)
+acpi_load_tables (
+ void)
{
struct acpi_pointer rsdp_address;
acpi_status status;
@@ -82,7 +83,7 @@ acpi_load_tables (void)
&rsdp_address);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_load_tables: Could not get RSDP, %s\n",
- acpi_format_exception (status)));
+ acpi_format_exception (status)));
goto error_exit;
}
@@ -93,7 +94,7 @@ acpi_load_tables (void)
status = acpi_tb_verify_rsdp (&rsdp_address);
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_load_tables: RSDP Failed validation: %s\n",
- acpi_format_exception (status)));
+ acpi_format_exception (status)));
goto error_exit;
}
@@ -102,7 +103,7 @@ acpi_load_tables (void)
status = acpi_tb_get_table_rsdt ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_load_tables: Could not load RSDT: %s\n",
- acpi_format_exception (status)));
+ acpi_format_exception (status)));
goto error_exit;
}
@@ -110,20 +111,20 @@ acpi_load_tables (void)
status = acpi_tb_get_required_tables ();
if (ACPI_FAILURE (status)) {
- ACPI_REPORT_ERROR (("acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
- acpi_format_exception (status)));
+ ACPI_REPORT_ERROR ((
+ "acpi_load_tables: Error getting required tables (DSDT/FADT/FACS): %s\n",
+ acpi_format_exception (status)));
goto error_exit;
}
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
-
/* Load the namespace from the tables */
status = acpi_ns_load_namespace ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("acpi_load_tables: Could not load namespace: %s\n",
- acpi_format_exception (status)));
+ acpi_format_exception (status)));
goto error_exit;
}
@@ -139,7 +140,6 @@ error_exit:
#ifdef ACPI_FUTURE_USAGE
-
/*******************************************************************************
*
* FUNCTION: acpi_load_table
@@ -250,7 +250,6 @@ acpi_unload_table (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/* Find all tables of the requested type */
table_desc = acpi_gbl_table_lists[table_type].next;
@@ -321,7 +320,6 @@ acpi_get_table_header (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/* Get a pointer to the entire table */
status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
@@ -329,23 +327,20 @@ acpi_get_table_header (
return_ACPI_STATUS (status);
}
- /*
- * The function will return a NULL pointer if the table is not loaded
- */
+ /* The function will return a NULL pointer if the table is not loaded */
+
if (tbl_ptr == NULL) {
return_ACPI_STATUS (AE_NOT_EXIST);
}
- /*
- * Copy the header to the caller's buffer
- */
+ /* Copy the header to the caller's buffer */
+
ACPI_MEMCPY ((void *) out_table_header, (void *) tbl_ptr,
- sizeof (struct acpi_table_header));
+ sizeof (struct acpi_table_header));
return_ACPI_STATUS (status);
}
-
#endif /* ACPI_FUTURE_USAGE */
/*******************************************************************************
@@ -404,7 +399,6 @@ acpi_get_table (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
-
/* Get a pointer to the entire table */
status = acpi_tb_get_table_ptr (table_type, instance, &tbl_ptr);
@@ -423,9 +417,8 @@ acpi_get_table (
/* Get the table length */
if (table_type == ACPI_TABLE_RSDP) {
- /*
- * RSD PTR is the only "table" without a header
- */
+ /* RSD PTR is the only "table" without a header */
+
table_length = sizeof (struct rsdp_descriptor);
}
else {
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c
index 6e8072ebbac..dc3c3f6a9f6 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/tables/tbxfroot.c
@@ -50,6 +50,18 @@
#define _COMPONENT ACPI_TABLES
ACPI_MODULE_NAME ("tbxfroot")
+/* Local prototypes */
+
+static acpi_status
+acpi_tb_find_rsdp (
+ struct acpi_table_desc *table_info,
+ u32 flags);
+
+static u8 *
+acpi_tb_scan_memory_for_rsdp (
+ u8 *start_address,
+ u32 length);
+
/*******************************************************************************
*
@@ -57,7 +69,8 @@
*
* PARAMETERS: Signature - String with ACPI table signature
* oem_id - String with the table OEM ID
- * oem_table_id - String with the OEM Table ID.
+ * oem_table_id - String with the OEM Table ID
+ * table_ptr - Where the table pointer is returned
*
* RETURN: Status
*
@@ -99,14 +112,13 @@ acpi_tb_find_table (
if (!acpi_gbl_DSDT) {
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
-
table = acpi_gbl_DSDT;
}
else {
/* Find the table */
status = acpi_get_firmware_table (signature, 1,
- ACPI_LOGICAL_ADDRESSING, &table);
+ ACPI_LOGICAL_ADDRESSING, &table);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -114,14 +126,19 @@ acpi_tb_find_table (
/* Check oem_id and oem_table_id */
- if ((oem_id[0] && ACPI_STRNCMP (
- oem_id, table->oem_id, sizeof (table->oem_id))) ||
+ if ((oem_id[0] && ACPI_STRNCMP (
+ oem_id, table->oem_id,
+ sizeof (table->oem_id))) ||
+
(oem_table_id[0] && ACPI_STRNCMP (
- oem_table_id, table->oem_table_id, sizeof (table->oem_table_id)))) {
+ oem_table_id, table->oem_table_id,
+ sizeof (table->oem_table_id)))) {
return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", table->signature));
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
+ table->signature));
+
*table_ptr = table;
return_ACPI_STATUS (AE_OK);
}
@@ -191,8 +208,8 @@ acpi_get_firmware_table (
/* Map and validate the RSDP */
if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
- status = acpi_os_map_memory (address.pointer.physical, sizeof (struct rsdp_descriptor),
- (void *) &acpi_gbl_RSDP);
+ status = acpi_os_map_memory (address.pointer.physical,
+ sizeof (struct rsdp_descriptor), (void *) &acpi_gbl_RSDP);
if (ACPI_FAILURE (status)) {
return_ACPI_STATUS (status);
}
@@ -203,7 +220,8 @@ acpi_get_firmware_table (
/* The signature and checksum must both be correct */
- if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+ if (ACPI_STRNCMP ((char *) acpi_gbl_RSDP, RSDP_SIG,
+ sizeof (RSDP_SIG)-1) != 0) {
/* Nope, BAD Signature */
return_ACPI_STATUS (AE_BAD_SIGNATURE);
@@ -313,7 +331,8 @@ acpi_get_firmware_table (
cleanup:
- acpi_os_unmap_memory (rsdt_info->pointer, (acpi_size) rsdt_info->pointer->length);
+ acpi_os_unmap_memory (rsdt_info->pointer,
+ (acpi_size) rsdt_info->pointer->length);
ACPI_MEM_FREE (rsdt_info);
if (header) {
@@ -335,8 +354,8 @@ EXPORT_SYMBOL(acpi_get_firmware_table);
*
* FUNCTION: acpi_find_root_pointer
*
- * PARAMETERS: **rsdp_address - Where to place the RSDP address
- * Flags - Logical/Physical addressing
+ * PARAMETERS: Flags - Logical/Physical addressing
+ * rsdp_address - Where to place the RSDP address
*
* RETURN: Status, Physical address of the RSDP
*
@@ -363,6 +382,7 @@ acpi_find_root_pointer (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"RSDP structure not found, %s Flags=%X\n",
acpi_format_exception (status), flags));
+
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
@@ -385,7 +405,7 @@ acpi_find_root_pointer (
*
******************************************************************************/
-u8 *
+static u8 *
acpi_tb_scan_memory_for_rsdp (
u8 *start_address,
u32 length)
@@ -406,7 +426,8 @@ acpi_tb_scan_memory_for_rsdp (
mem_rover += ACPI_RSDP_SCAN_STEP) {
/* The signature and checksum must both be correct */
- if (ACPI_STRNCMP ((char *) mem_rover, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
+ if (ACPI_STRNCMP ((char *) mem_rover,
+ RSDP_SIG, sizeof (RSDP_SIG) - 1) != 0) {
/* No signature match, keep looking */
continue;
@@ -450,7 +471,7 @@ acpi_tb_scan_memory_for_rsdp (
*
* FUNCTION: acpi_tb_find_rsdp
*
- * PARAMETERS: *table_info - Where the table info is returned
+ * PARAMETERS: table_info - Where the table info is returned
* Flags - Current memory mode (logical vs.
* physical addressing)
*
@@ -468,7 +489,7 @@ acpi_tb_scan_memory_for_rsdp (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_tb_find_rsdp (
struct acpi_table_desc *table_info,
u32 flags)
@@ -483,43 +504,49 @@ acpi_tb_find_rsdp (
/*
- * Scan supports either 1) Logical addressing or 2) Physical addressing
+ * Scan supports either logical addressing or physical addressing
*/
if ((flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) {
- /*
- * 1a) Get the location of the EBDA
- */
- status = acpi_os_map_memory ((acpi_physical_address) ACPI_EBDA_PTR_LOCATION,
- ACPI_EBDA_PTR_LENGTH,
- (void *) &table_ptr);
+ /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
+
+ status = acpi_os_map_memory (
+ (acpi_physical_address) ACPI_EBDA_PTR_LOCATION,
+ ACPI_EBDA_PTR_LENGTH, (void *) &table_ptr);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not map memory at %8.8X for length %X\n",
ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
+
return_ACPI_STATUS (status);
}
ACPI_MOVE_16_TO_32 (&physical_address, table_ptr);
- physical_address <<= 4; /* Convert segment to physical address */
+
+ /* Convert segment part to physical address */
+
+ physical_address <<= 4;
acpi_os_unmap_memory (table_ptr, ACPI_EBDA_PTR_LENGTH);
/* EBDA present? */
if (physical_address > 0x400) {
/*
- * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 1_k length)
+ * 1b) Search EBDA paragraphs (EBDa is required to be a
+ * minimum of 1_k length)
*/
- status = acpi_os_map_memory ((acpi_physical_address) physical_address,
- ACPI_EBDA_WINDOW_SIZE,
- (void *) &table_ptr);
+ status = acpi_os_map_memory (
+ (acpi_physical_address) physical_address,
+ ACPI_EBDA_WINDOW_SIZE, (void *) &table_ptr);
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not map memory at %8.8X for length %X\n",
physical_address, ACPI_EBDA_WINDOW_SIZE));
+
return_ACPI_STATUS (status);
}
- mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr, ACPI_EBDA_WINDOW_SIZE);
+ mem_rover = acpi_tb_scan_memory_for_rsdp (table_ptr,
+ ACPI_EBDA_WINDOW_SIZE);
acpi_os_unmap_memory (table_ptr, ACPI_EBDA_WINDOW_SIZE);
if (mem_rover) {
@@ -527,7 +554,8 @@ acpi_tb_find_rsdp (
physical_address += ACPI_PTR_DIFF (mem_rover, table_ptr);
- table_info->physical_address = (acpi_physical_address) physical_address;
+ table_info->physical_address =
+ (acpi_physical_address) physical_address;
return_ACPI_STATUS (AE_OK);
}
}
@@ -535,13 +563,15 @@ acpi_tb_find_rsdp (
/*
* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
*/
- status = acpi_os_map_memory ((acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE,
- ACPI_HI_RSDP_WINDOW_SIZE,
- (void *) &table_ptr);
+ status = acpi_os_map_memory (
+ (acpi_physical_address) ACPI_HI_RSDP_WINDOW_BASE,
+ ACPI_HI_RSDP_WINDOW_SIZE, (void *) &table_ptr);
+
if (ACPI_FAILURE (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"Could not map memory at %8.8X for length %X\n",
ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
+
return_ACPI_STATUS (status);
}
@@ -551,9 +581,11 @@ acpi_tb_find_rsdp (
if (mem_rover) {
/* Found it, return the physical address */
- physical_address = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr);
+ physical_address =
+ ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (mem_rover, table_ptr);
- table_info->physical_address = (acpi_physical_address) physical_address;
+ table_info->physical_address =
+ (acpi_physical_address) physical_address;
return_ACPI_STATUS (AE_OK);
}
}
@@ -562,9 +594,8 @@ acpi_tb_find_rsdp (
* Physical addressing
*/
else {
- /*
- * 1a) Get the location of the EBDA
- */
+ /* 1a) Get the location of the EBDA */
+
ACPI_MOVE_16_TO_32 (&physical_address, ACPI_EBDA_PTR_LOCATION);
physical_address <<= 4; /* Convert segment to physical address */
@@ -572,9 +603,11 @@ acpi_tb_find_rsdp (
if (physical_address > 0x400) {
/*
- * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of 1_k length)
+ * 1b) Search EBDA paragraphs (EBDa is required to be a minimum of
+ * 1_k length)
*/
- mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (physical_address),
+ mem_rover = acpi_tb_scan_memory_for_rsdp (
+ ACPI_PHYSADDR_TO_PTR (physical_address),
ACPI_EBDA_WINDOW_SIZE);
if (mem_rover) {
/* Found it, return the physical address */
@@ -584,10 +617,10 @@ acpi_tb_find_rsdp (
}
}
- /*
- * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
- */
- mem_rover = acpi_tb_scan_memory_for_rsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
+ /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
+
+ mem_rover = acpi_tb_scan_memory_for_rsdp (
+ ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
ACPI_HI_RSDP_WINDOW_SIZE);
if (mem_rover) {
/* Found it, return the physical address */
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index c84997c9f96..73b1d8aeae9 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -263,6 +263,9 @@ dispatch_write(struct file* file, const char __user * buffer,
* destination so that sscanf can be used on it safely.
*/
tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
+ if(!tmp_buffer)
+ return -ENOMEM;
+
if (copy_from_user(tmp_buffer, buffer, count)) {
result = -EFAULT;
}
@@ -529,6 +532,11 @@ toshiba_acpi_init(void)
if (acpi_disabled)
return -ENODEV;
+
+ if (!acpi_specific_hotkey_enabled){
+ printk(MY_INFO "Using generic hotkey driver\n");
+ return -ENODEV;
+ }
/* simple device detection: look for HCI method */
if (is_valid_acpi_path(METHOD_HCI_1))
method_hci = METHOD_HCI_1;
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 3313439c4bc..c4e7f989a2b 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -47,8 +47,35 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utalloc")
+/* Local prototypes */
-/******************************************************************************
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+static struct acpi_debug_mem_block *
+acpi_ut_find_allocation (
+ u32 list_id,
+ void *allocation);
+
+static acpi_status
+acpi_ut_track_allocation (
+ u32 list_id,
+ struct acpi_debug_mem_block *address,
+ acpi_size size,
+ u8 alloc_type,
+ u32 component,
+ char *module,
+ u32 line);
+
+static acpi_status
+acpi_ut_remove_allocation (
+ u32 list_id,
+ struct acpi_debug_mem_block *address,
+ u32 component,
+ char *module,
+ u32 line);
+#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
+
+
+/*******************************************************************************
*
* FUNCTION: acpi_ut_release_to_cache
*
@@ -98,7 +125,8 @@ acpi_ut_release_to_cache (
/* Put the object at the head of the cache list */
- * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
+ * (ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) object)[cache_info->link_offset]))) = cache_info->list_head;
cache_info->list_head = object;
cache_info->cache_depth++;
@@ -115,7 +143,7 @@ acpi_ut_release_to_cache (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_acquire_from_cache
*
@@ -156,7 +184,8 @@ acpi_ut_acquire_from_cache (
/* There is an object available, use it */
object = cache_info->list_head;
- cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) object)[cache_info->link_offset])));
+ cache_info->list_head = *(ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) object)[cache_info->link_offset])));
ACPI_MEM_TRACKING (cache_info->cache_hits++);
cache_info->cache_depth--;
@@ -201,7 +230,7 @@ acpi_ut_acquire_from_cache (
#ifdef ACPI_ENABLE_OBJECT_CACHE
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_generic_cache
*
@@ -228,7 +257,8 @@ acpi_ut_delete_generic_cache (
while (cache_info->list_head) {
/* Delete one cached state object */
- next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) cache_info->list_head)[cache_info->link_offset])));
+ next = *(ACPI_CAST_INDIRECT_PTR (char,
+ &(((char *) cache_info->list_head)[cache_info->link_offset])));
ACPI_MEM_FREE (cache_info->list_head);
cache_info->list_head = next;
@@ -497,8 +527,8 @@ acpi_ut_allocate_and_track (
acpi_status status;
- allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header), component,
- module, line);
+ allocation = acpi_ut_allocate (size + sizeof (struct acpi_debug_mem_header),
+ component, module, line);
if (!allocation) {
return (NULL);
}
@@ -543,8 +573,8 @@ acpi_ut_callocate_and_track (
acpi_status status;
- allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header), component,
- module, line);
+ allocation = acpi_ut_callocate (size + sizeof (struct acpi_debug_mem_header),
+ component, module, line);
if (!allocation) {
/* Report allocation error */
@@ -637,7 +667,7 @@ acpi_ut_free_and_track (
*
******************************************************************************/
-struct acpi_debug_mem_block *
+static struct acpi_debug_mem_block *
acpi_ut_find_allocation (
u32 list_id,
void *allocation)
@@ -686,7 +716,7 @@ acpi_ut_find_allocation (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_track_allocation (
u32 list_id,
struct acpi_debug_mem_block *allocation,
@@ -721,10 +751,12 @@ acpi_ut_track_allocation (
element = acpi_ut_find_allocation (list_id, allocation);
if (element) {
- ACPI_REPORT_ERROR (("ut_track_allocation: Allocation already present in list! (%p)\n",
+ ACPI_REPORT_ERROR ((
+ "ut_track_allocation: Allocation already present in list! (%p)\n",
allocation));
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", element, allocation));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n",
+ element, allocation));
goto unlock_and_exit;
}
@@ -773,7 +805,7 @@ unlock_and_exit:
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_remove_allocation (
u32 list_id,
struct acpi_debug_mem_block *allocation,
@@ -797,7 +829,7 @@ acpi_ut_remove_allocation (
/* No allocations! */
_ACPI_REPORT_ERROR (module, line, component,
- ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
+ ("ut_remove_allocation: Empty allocation list, nothing to free!\n"));
return_ACPI_STATUS (AE_OK);
}
@@ -824,7 +856,8 @@ acpi_ut_remove_allocation (
ACPI_MEMSET (&allocation->user_space, 0xEA, allocation->size);
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", allocation->size));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
+ allocation->size));
status = acpi_ut_release_mutex (ACPI_MTX_MEMORY);
return_ACPI_STATUS (status);
@@ -842,6 +875,7 @@ acpi_ut_remove_allocation (
* DESCRIPTION: Print some info about the outstanding allocations.
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
void
acpi_ut_dump_allocation_info (
@@ -884,7 +918,8 @@ acpi_ut_dump_allocation_info (
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
("%30s: %4d (%3d Kb)\n", "Max Nodes",
acpi_gbl_max_concurrent_node_count,
- ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count * sizeof (struct acpi_namespace_node)))));
+ ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
+ sizeof (struct acpi_namespace_node)))));
*/
return_VOID;
}
@@ -933,26 +968,26 @@ acpi_ut_dump_allocations (
descriptor = ACPI_CAST_PTR (union acpi_descriptor, &element->user_space);
if (descriptor->descriptor_id != ACPI_DESC_TYPE_CACHED) {
acpi_os_printf ("%p Len %04X %9.9s-%d [%s] ",
- descriptor, element->size, element->module,
- element->line, acpi_ut_get_descriptor_name (descriptor));
+ descriptor, element->size, element->module,
+ element->line, acpi_ut_get_descriptor_name (descriptor));
/* Most of the elements will be Operand objects. */
switch (ACPI_GET_DESCRIPTOR_TYPE (descriptor)) {
case ACPI_DESC_TYPE_OPERAND:
acpi_os_printf ("%12.12s R%hd",
- acpi_ut_get_type_name (descriptor->object.common.type),
- descriptor->object.common.reference_count);
+ acpi_ut_get_type_name (descriptor->object.common.type),
+ descriptor->object.common.reference_count);
break;
case ACPI_DESC_TYPE_PARSER:
acpi_os_printf ("aml_opcode %04hX",
- descriptor->op.asl.aml_opcode);
+ descriptor->op.asl.aml_opcode);
break;
case ACPI_DESC_TYPE_NAMED:
acpi_os_printf ("%4.4s",
- acpi_ut_get_node_name (&descriptor->node));
+ acpi_ut_get_node_name (&descriptor->node));
break;
default:
@@ -983,6 +1018,5 @@ acpi_ut_dump_allocations (
return_VOID;
}
-
#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 0fcd98bde0d..11e88495716 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -49,21 +49,69 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utcopy")
+/* Local prototypes */
+
+static acpi_status
+acpi_ut_copy_isimple_to_esimple (
+ union acpi_operand_object *internal_object,
+ union acpi_object *external_object,
+ u8 *data_space,
+ acpi_size *buffer_space_used);
+
+static acpi_status
+acpi_ut_copy_ielement_to_ielement (
+ u8 object_type,
+ union acpi_operand_object *source_object,
+ union acpi_generic_state *state,
+ void *context);
+
+static acpi_status
+acpi_ut_copy_ipackage_to_epackage (
+ union acpi_operand_object *internal_object,
+ u8 *buffer,
+ acpi_size *space_used);
+
+static acpi_status
+acpi_ut_copy_esimple_to_isimple(
+ union acpi_object *user_obj,
+ union acpi_operand_object **return_obj);
+
+static acpi_status
+acpi_ut_copy_simple_object (
+ union acpi_operand_object *source_desc,
+ union acpi_operand_object *dest_desc);
+
+static acpi_status
+acpi_ut_copy_ielement_to_eelement (
+ u8 object_type,
+ union acpi_operand_object *source_object,
+ union acpi_generic_state *state,
+ void *context);
+
+static acpi_status
+acpi_ut_copy_ipackage_to_ipackage (
+ union acpi_operand_object *source_obj,
+ union acpi_operand_object *dest_obj,
+ struct acpi_walk_state *walk_state);
+
/*******************************************************************************
*
* FUNCTION: acpi_ut_copy_isimple_to_esimple
*
- * PARAMETERS: *internal_object - Pointer to the object we are examining
- * *Buffer - Where the object is returned
- * *space_used - Where the data length is returned
+ * PARAMETERS: internal_object - Source object to be copied
+ * external_object - Where to return the copied object
+ * data_space - Where object data is returned (such as
+ * buffer and string data)
+ * buffer_space_used - Length of data_space that was used
*
* RETURN: Status
*
- * DESCRIPTION: This function is called to place a simple object in a user
- * buffer.
+ * DESCRIPTION: This function is called to copy a simple internal object to
+ * an external object.
*
- * The buffer is assumed to have sufficient space for the object.
+ * The data_space buffer is assumed to have sufficient space for
+ * the object.
*
******************************************************************************/
@@ -107,10 +155,12 @@ acpi_ut_copy_isimple_to_esimple (
external_object->string.pointer = (char *) data_space;
external_object->string.length = internal_object->string.length;
- *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ((acpi_size) internal_object->string.length + 1);
+ *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (
+ (acpi_size) internal_object->string.length + 1);
- ACPI_MEMCPY ((void *) data_space, (void *) internal_object->string.pointer,
- (acpi_size) internal_object->string.length + 1);
+ ACPI_MEMCPY ((void *) data_space,
+ (void *) internal_object->string.pointer,
+ (acpi_size) internal_object->string.length + 1);
break;
@@ -118,10 +168,12 @@ acpi_ut_copy_isimple_to_esimple (
external_object->buffer.pointer = data_space;
external_object->buffer.length = internal_object->buffer.length;
- *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (internal_object->string.length);
+ *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD (
+ internal_object->string.length);
- ACPI_MEMCPY ((void *) data_space, (void *) internal_object->buffer.pointer,
- internal_object->buffer.length);
+ ACPI_MEMCPY ((void *) data_space,
+ (void *) internal_object->buffer.pointer,
+ internal_object->buffer.length);
break;
@@ -194,7 +246,7 @@ acpi_ut_copy_isimple_to_esimple (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_copy_ielement_to_eelement (
u8 object_type,
union acpi_operand_object *source_object,
@@ -213,7 +265,7 @@ acpi_ut_copy_ielement_to_eelement (
this_index = state->pkg.index;
target_object = (union acpi_object *)
- &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index];
+ &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index];
switch (object_type) {
case ACPI_COPY_TYPE_SIMPLE:
@@ -236,7 +288,8 @@ acpi_ut_copy_ielement_to_eelement (
*/
target_object->type = ACPI_TYPE_PACKAGE;
target_object->package.count = source_object->package.count;
- target_object->package.elements = ACPI_CAST_PTR (union acpi_object, info->free_space);
+ target_object->package.elements =
+ ACPI_CAST_PTR (union acpi_object, info->free_space);
/*
* Pass the new package object back to the package walk routine
@@ -248,7 +301,8 @@ acpi_ut_copy_ielement_to_eelement (
* update the buffer length counter
*/
object_space = ACPI_ROUND_UP_TO_NATIVE_WORD (
- (acpi_size) target_object->package.count * sizeof (union acpi_object));
+ (acpi_size) target_object->package.count *
+ sizeof (union acpi_object));
break;
@@ -266,9 +320,9 @@ acpi_ut_copy_ielement_to_eelement (
*
* FUNCTION: acpi_ut_copy_ipackage_to_epackage
*
- * PARAMETERS: *internal_object - Pointer to the object we are returning
- * *Buffer - Where the object is returned
- * *space_used - Where the object length is returned
+ * PARAMETERS: internal_object - Pointer to the object we are returning
+ * Buffer - Where the object is returned
+ * space_used - Where the object length is returned
*
* RETURN: Status
*
@@ -304,13 +358,15 @@ acpi_ut_copy_ipackage_to_epackage (
* Free space begins right after the first package
*/
info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
- info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
+ info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (
+ sizeof (union acpi_object));
info.object_space = 0;
info.num_packages = 1;
external_object->type = ACPI_GET_OBJECT_TYPE (internal_object);
external_object->package.count = internal_object->package.count;
- external_object->package.elements = ACPI_CAST_PTR (union acpi_object, info.free_space);
+ external_object->package.elements = ACPI_CAST_PTR (union acpi_object,
+ info.free_space);
/*
* Leave room for an array of ACPI_OBJECTS in the buffer
@@ -333,8 +389,8 @@ acpi_ut_copy_ipackage_to_epackage (
*
* FUNCTION: acpi_ut_copy_iobject_to_eobject
*
- * PARAMETERS: *internal_object - The internal object to be converted
- * *buffer_ptr - Where the object is returned
+ * PARAMETERS: internal_object - The internal object to be converted
+ * buffer_ptr - Where the object is returned
*
* RETURN: Status
*
@@ -367,10 +423,10 @@ acpi_ut_copy_iobject_to_eobject (
* Build a simple object (no nested objects)
*/
status = acpi_ut_copy_isimple_to_esimple (internal_object,
- (union acpi_object *) ret_buffer->pointer,
- ((u8 *) ret_buffer->pointer +
- ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))),
- &ret_buffer->length);
+ (union acpi_object *) ret_buffer->pointer,
+ ((u8 *) ret_buffer->pointer +
+ ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))),
+ &ret_buffer->length);
/*
* build simple does not include the object size in the length
* so we add it in here
@@ -386,8 +442,8 @@ acpi_ut_copy_iobject_to_eobject (
*
* FUNCTION: acpi_ut_copy_esimple_to_isimple
*
- * PARAMETERS: *external_object - The external object to be converted
- * *internal_object - Where the internal object is returned
+ * PARAMETERS: external_object - The external object to be converted
+ * ret_internal_object - Where the internal object is returned
*
* RETURN: Status
*
@@ -398,7 +454,7 @@ acpi_ut_copy_iobject_to_eobject (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_copy_esimple_to_isimple (
union acpi_object *external_object,
union acpi_operand_object **ret_internal_object)
@@ -417,7 +473,8 @@ acpi_ut_copy_esimple_to_isimple (
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_INTEGER:
- internal_object = acpi_ut_create_internal_object ((u8) external_object->type);
+ internal_object = acpi_ut_create_internal_object (
+ (u8) external_object->type);
if (!internal_object) {
return_ACPI_STATUS (AE_NO_MEMORY);
}
@@ -486,7 +543,6 @@ error_exit:
#ifdef ACPI_FUTURE_IMPLEMENTATION
-
/* Code to convert packages that are parameters to control methods */
/*******************************************************************************
@@ -614,7 +670,7 @@ acpi_ut_copy_eobject_to_iobject (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_copy_simple_object (
union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc)
@@ -724,7 +780,7 @@ acpi_ut_copy_simple_object (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_copy_ielement_to_ielement (
u8 object_type,
union acpi_operand_object *source_object,
@@ -837,7 +893,7 @@ error_exit:
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_copy_ipackage_to_ipackage (
union acpi_operand_object *source_obj,
union acpi_operand_object *dest_obj,
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/utilities/utdebug.c
index 985c5d045b7..794c7df3f2a 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/utilities/utdebug.c
@@ -56,7 +56,7 @@ static char *acpi_gbl_fn_entry_str = "----Entry";
static char *acpi_gbl_fn_exit_str = "----Exit-";
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_init_stack_ptr_trace
*
@@ -64,9 +64,9 @@ static char *acpi_gbl_fn_exit_str = "----Exit-";
*
* RETURN: None
*
- * DESCRIPTION: Save the current stack pointer
+ * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_init_stack_ptr_trace (
@@ -79,7 +79,7 @@ acpi_ut_init_stack_ptr_trace (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_track_stack_ptr
*
@@ -87,9 +87,9 @@ acpi_ut_init_stack_ptr_trace (
*
* RETURN: None
*
- * DESCRIPTION: Save the current stack pointer
+ * DESCRIPTION: Save the current CPU stack pointer
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_track_stack_ptr (
@@ -110,16 +110,16 @@ acpi_ut_track_stack_ptr (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_debug_print
*
- * PARAMETERS: debug_level - Requested debug print level
- * proc_name - Caller's procedure name
- * module_name - Caller's module name (for error output)
+ * PARAMETERS: requested_debug_level - Requested debug print level
* line_number - Caller's line number (for error output)
- * component_id - Caller's component ID (for error output)
- *
+ * dbg_info - Contains:
+ * proc_name - Caller's procedure name
+ * module_name - Caller's module name
+ * component_id - Caller's component ID
* Format - Printf format field
* ... - Optional printf arguments
*
@@ -128,7 +128,7 @@ acpi_ut_track_stack_ptr (
* DESCRIPTION: Print error message with prefix consisting of the module name,
* line number, and component ID.
*
- ****************************************************************************/
+ ******************************************************************************/
void ACPI_INTERNAL_VAR_XFACE
acpi_ut_debug_print (
@@ -157,7 +157,8 @@ acpi_ut_debug_print (
if (thread_id != acpi_gbl_prev_thread_id) {
if (ACPI_LV_THREADS & acpi_dbg_level) {
- acpi_os_printf ("\n**** Context Switch from TID %X to TID %X ****\n\n",
+ acpi_os_printf (
+ "\n**** Context Switch from TID %X to TID %X ****\n\n",
acpi_gbl_prev_thread_id, thread_id);
}
@@ -174,15 +175,16 @@ acpi_ut_debug_print (
acpi_os_printf ("[%04lX] ", thread_id);
}
- acpi_os_printf ("[%02ld] %-22.22s: ", acpi_gbl_nesting_level, dbg_info->proc_name);
+ acpi_os_printf ("[%02ld] %-22.22s: ",
+ acpi_gbl_nesting_level, dbg_info->proc_name);
va_start (args, format);
acpi_os_vprintf (format, args);
}
-EXPORT_SYMBOL(acpi_ut_debug_print);
+EXPORT_SYMBOL(acpi_ut_debug_print);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_debug_print_raw
*
@@ -200,7 +202,7 @@ EXPORT_SYMBOL(acpi_ut_debug_print);
* DESCRIPTION: Print message with no headers. Has same interface as
* debug_print so that the same macros can be used.
*
- ****************************************************************************/
+ ******************************************************************************/
void ACPI_INTERNAL_VAR_XFACE
acpi_ut_debug_print_raw (
@@ -224,7 +226,7 @@ acpi_ut_debug_print_raw (
EXPORT_SYMBOL(acpi_ut_debug_print_raw);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_trace
*
@@ -239,7 +241,7 @@ EXPORT_SYMBOL(acpi_ut_debug_print_raw);
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_trace (
@@ -256,7 +258,7 @@ acpi_ut_trace (
EXPORT_SYMBOL(acpi_ut_trace);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_trace_ptr
*
@@ -272,7 +274,7 @@ EXPORT_SYMBOL(acpi_ut_trace);
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_trace_ptr (
@@ -288,7 +290,7 @@ acpi_ut_trace_ptr (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_trace_str
*
@@ -304,7 +306,7 @@ acpi_ut_trace_ptr (
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_trace_str (
@@ -321,7 +323,7 @@ acpi_ut_trace_str (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_trace_u32
*
@@ -337,7 +339,7 @@ acpi_ut_trace_str (
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_trace_u32 (
@@ -354,7 +356,7 @@ acpi_ut_trace_u32 (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_exit
*
@@ -369,7 +371,7 @@ acpi_ut_trace_u32 (
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_exit (
@@ -385,7 +387,7 @@ acpi_ut_exit (
EXPORT_SYMBOL(acpi_ut_exit);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_status_exit
*
@@ -401,7 +403,7 @@ EXPORT_SYMBOL(acpi_ut_exit);
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level. Prints exit status also.
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_status_exit (
@@ -426,7 +428,7 @@ acpi_ut_status_exit (
EXPORT_SYMBOL(acpi_ut_status_exit);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_value_exit
*
@@ -442,7 +444,7 @@ EXPORT_SYMBOL(acpi_ut_status_exit);
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level. Prints exit value also.
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_value_exit (
@@ -460,7 +462,7 @@ acpi_ut_value_exit (
EXPORT_SYMBOL(acpi_ut_value_exit);
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_ptr_exit
*
@@ -469,14 +471,14 @@ EXPORT_SYMBOL(acpi_ut_value_exit);
* proc_name - Caller's procedure name
* module_name - Caller's module name
* component_id - Caller's component ID
- * Value - Value to be printed with exit msg
+ * Ptr - Pointer to display
*
* RETURN: None
*
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in debug_level. Prints exit value also.
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_ptr_exit (
@@ -494,7 +496,7 @@ acpi_ut_ptr_exit (
#endif
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_dump_buffer
*
@@ -507,7 +509,7 @@ acpi_ut_ptr_exit (
*
* DESCRIPTION: Generic dump buffer in both hex and ascii.
*
- ****************************************************************************/
+ ******************************************************************************/
void
acpi_ut_dump_buffer (
@@ -533,34 +535,28 @@ acpi_ut_dump_buffer (
display = DB_BYTE_DISPLAY;
}
- acpi_os_printf ("\nOffset Value\n");
+ /* Nasty little dump buffer routine! */
- /*
- * Nasty little dump buffer routine!
- */
while (i < count) {
/* Print current offset */
- acpi_os_printf ("%05X ", (u32) i);
+ acpi_os_printf ("%6.4X: ", (u32) i);
/* Print 16 hex chars */
for (j = 0; j < 16;) {
if (i + j >= count) {
- acpi_os_printf ("\n");
- return;
- }
+ /* Dump fill spaces */
- /* Make sure that the s8 doesn't get sign-extended! */
+ acpi_os_printf ("%*s", ((display * 2) + 1), " ");
+ j += display;
+ continue;
+ }
switch (display) {
- /* Default is BYTE display */
+ default: /* Default is BYTE display */
- default:
-
- acpi_os_printf ("%02X ",
- *((u8 *) &buffer[i + j]));
- j += 1;
+ acpi_os_printf ("%02X ", buffer[i + j]);
break;
@@ -568,7 +564,6 @@ acpi_ut_dump_buffer (
ACPI_MOVE_16_TO_32 (&temp32, &buffer[i + j]);
acpi_os_printf ("%04X ", temp32);
- j += 2;
break;
@@ -576,7 +571,6 @@ acpi_ut_dump_buffer (
ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j]);
acpi_os_printf ("%08X ", temp32);
- j += 4;
break;
@@ -587,15 +581,17 @@ acpi_ut_dump_buffer (
ACPI_MOVE_32_TO_32 (&temp32, &buffer[i + j + 4]);
acpi_os_printf ("%08X ", temp32);
- j += 8;
break;
}
+
+ j += display;
}
/*
* Print the ASCII equivalent characters
* But watch out for the bad unprintable ones...
*/
+ acpi_os_printf (" ");
for (j = 0; j < 16; j++) {
if (i + j >= count) {
acpi_os_printf ("\n");
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 9a52ad52a23..bc540302268 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -51,12 +51,23 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utdelete")
+/* Local prototypes */
+
+static void
+acpi_ut_delete_internal_obj (
+ union acpi_operand_object *object);
+
+static void
+acpi_ut_update_ref_count (
+ union acpi_operand_object *object,
+ u32 action);
+
/*******************************************************************************
*
* FUNCTION: acpi_ut_delete_internal_obj
*
- * PARAMETERS: *Object - Pointer to the list to be deleted
+ * PARAMETERS: Object - Object to be deleted
*
* RETURN: None
*
@@ -65,7 +76,7 @@
*
******************************************************************************/
-void
+static void
acpi_ut_delete_internal_obj (
union acpi_operand_object *object)
{
@@ -152,7 +163,8 @@ acpi_ut_delete_internal_obj (
case ACPI_TYPE_MUTEX:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Mutex %p, Semaphore %p\n",
object, object->mutex.semaphore));
acpi_ex_unlink_mutex (object);
@@ -162,7 +174,8 @@ acpi_ut_delete_internal_obj (
case ACPI_TYPE_EVENT:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Event %p, Semaphore %p\n",
object, object->event.semaphore));
(void) acpi_os_delete_semaphore (object->event.semaphore);
@@ -172,7 +185,8 @@ acpi_ut_delete_internal_obj (
case ACPI_TYPE_METHOD:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", object));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Method %p\n", object));
/* Delete the method semaphore if it exists */
@@ -185,7 +199,8 @@ acpi_ut_delete_internal_obj (
case ACPI_TYPE_REGION:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", object));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Region %p\n", object));
second_desc = acpi_ns_get_secondary_object (object);
if (second_desc) {
@@ -212,7 +227,8 @@ acpi_ut_delete_internal_obj (
case ACPI_TYPE_BUFFER_FIELD:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", object));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "***** Buffer Field %p\n", object));
second_desc = acpi_ns_get_secondary_object (object);
if (second_desc) {
@@ -247,7 +263,7 @@ acpi_ut_delete_internal_obj (
*
* FUNCTION: acpi_ut_delete_internal_object_list
*
- * PARAMETERS: *obj_list - Pointer to the list to be deleted
+ * PARAMETERS: obj_list - Pointer to the list to be deleted
*
* RETURN: None
*
@@ -283,7 +299,7 @@ acpi_ut_delete_internal_object_list (
*
* FUNCTION: acpi_ut_update_ref_count
*
- * PARAMETERS: *Object - Object whose ref count is to be updated
+ * PARAMETERS: Object - Object whose ref count is to be updated
* Action - What to do
*
* RETURN: New ref count
@@ -312,7 +328,8 @@ acpi_ut_update_ref_count (
new_count = count;
/*
- * Perform the reference count action (increment, decrement, or force delete)
+ * Perform the reference count action
+ * (increment, decrement, or force delete)
*/
switch (action) {
@@ -321,7 +338,8 @@ acpi_ut_update_ref_count (
new_count++;
object->common.reference_count = new_count;
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, [Incremented]\n",
object, new_count));
break;
@@ -329,7 +347,8 @@ acpi_ut_update_ref_count (
case REF_DECREMENT:
if (count < 1) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, can't decrement! (Set to 0)\n",
object, new_count));
new_count = 0;
@@ -337,12 +356,14 @@ acpi_ut_update_ref_count (
else {
new_count--;
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, [Decremented]\n",
object, new_count));
}
if (ACPI_GET_OBJECT_TYPE (object) == ACPI_TYPE_METHOD) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Method Obj %p Refs=%X, [Decremented]\n",
object, new_count));
}
@@ -356,7 +377,8 @@ acpi_ut_update_ref_count (
case REF_FORCE_DELETE:
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n",
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Obj %p Refs=%X, Force delete! (Set to 0)\n",
object, count));
new_count = 0;
@@ -390,7 +412,7 @@ acpi_ut_update_ref_count (
*
* FUNCTION: acpi_ut_update_object_reference
*
- * PARAMETERS: *Object - Increment ref count for this object
+ * PARAMETERS: Object - Increment ref count for this object
* and all sub-objects
* Action - Either REF_INCREMENT or REF_DECREMENT or
* REF_FORCE_DELETE
@@ -431,7 +453,8 @@ acpi_ut_update_object_reference (
/* Make sure that this isn't a namespace handle */
if (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_NAMED) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", object));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
+ "Object %p is NS handle\n", object));
return_ACPI_STATUS (AE_OK);
}
@@ -614,8 +637,8 @@ error_exit:
*
* FUNCTION: acpi_ut_add_reference
*
- * PARAMETERS: *Object - Object whose reference count is to be
- * incremented
+ * PARAMETERS: Object - Object whose reference count is to be
+ * incremented
*
* RETURN: None
*
@@ -652,7 +675,7 @@ acpi_ut_add_reference (
*
* FUNCTION: acpi_ut_remove_reference
*
- * PARAMETERS: *Object - Object whose ref count will be decremented
+ * PARAMETERS: Object - Object whose ref count will be decremented
*
* RETURN: None
*
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index ead27d2c4d1..00046dd5d92 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -50,6 +50,19 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("uteval")
+/* Local prototypes */
+
+static void
+acpi_ut_copy_id_string (
+ char *destination,
+ char *source,
+ acpi_size max_length);
+
+static acpi_status
+acpi_ut_translate_one_cid (
+ union acpi_operand_object *obj_desc,
+ struct acpi_compatible_id *one_cid);
+
/*******************************************************************************
*
@@ -237,9 +250,9 @@ acpi_ut_evaluate_object (
*
* FUNCTION: acpi_ut_evaluate_numeric_object
*
- * PARAMETERS: *object_name - Object name to be evaluated
+ * PARAMETERS: object_name - Object name to be evaluated
* device_node - Node for the device
- * *Address - Where the value is returned
+ * Address - Where the value is returned
*
* RETURN: Status
*
@@ -303,7 +316,6 @@ acpi_ut_copy_id_string (
acpi_size max_length)
{
-
/*
* Workaround for ID strings that have a leading asterisk. This construct
* is not allowed by the ACPI specification (ID strings must be
@@ -325,7 +337,7 @@ acpi_ut_copy_id_string (
* FUNCTION: acpi_ut_execute_HID
*
* PARAMETERS: device_node - Node for the device
- * *Hid - Where the HID is returned
+ * Hid - Where the HID is returned
*
* RETURN: Status
*
@@ -429,7 +441,7 @@ acpi_ut_translate_one_cid (
* FUNCTION: acpi_ut_execute_CID
*
* PARAMETERS: device_node - Node for the device
- * *Cid - Where the CID is returned
+ * return_cid_list - Where the CID list is returned
*
* RETURN: Status
*
@@ -488,10 +500,10 @@ acpi_ut_execute_CID (
cid_list->size = size;
/*
- * A _CID can return either a single compatible ID or a package of compatible
- * IDs. Each compatible ID can be one of the following:
- * -- Number (32 bit compressed EISA ID) or
- * -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
+ * A _CID can return either a single compatible ID or a package of
+ * compatible IDs. Each compatible ID can be one of the following:
+ * 1) Integer (32 bit compressed EISA ID) or
+ * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
*/
/* The _CID object can be either a single CID or a package (list) of CIDs */
@@ -534,7 +546,7 @@ acpi_ut_execute_CID (
* FUNCTION: acpi_ut_execute_UID
*
* PARAMETERS: device_node - Node for the device
- * *Uid - Where the UID is returned
+ * Uid - Where the UID is returned
*
* RETURN: Status
*
@@ -587,7 +599,7 @@ acpi_ut_execute_UID (
* FUNCTION: acpi_ut_execute_STA
*
* PARAMETERS: device_node - Node for the device
- * *Flags - Where the status flags are returned
+ * Flags - Where the status flags are returned
*
* RETURN: Status
*
@@ -641,7 +653,7 @@ acpi_ut_execute_STA (
* FUNCTION: acpi_ut_execute_Sxds
*
* PARAMETERS: device_node - Node for the device
- * *Flags - Where the status flags are returned
+ * Flags - Where the status flags are returned
*
* RETURN: Status
*
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 25b0f8ae1bc..4146019b543 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -44,7 +44,6 @@
#define DEFINE_ACPI_GLOBALS
#include <linux/module.h>
-
#include <acpi/acpi.h>
#include <acpi/acnamesp.h>
@@ -52,13 +51,14 @@
ACPI_MODULE_NAME ("utglobal")
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_format_exception
*
* PARAMETERS: Status - The acpi_status code to be formatted
*
- * RETURN: A string containing the exception text
+ * RETURN: A string containing the exception text. A valid pointer is
+ * always returned.
*
* DESCRIPTION: This function translates an ACPI exception into an ASCII string.
*
@@ -68,8 +68,8 @@ const char *
acpi_format_exception (
acpi_status status)
{
- const char *exception = "UNKNOWN_STATUS_CODE";
acpi_status sub_status;
+ const char *exception = NULL;
ACPI_FUNCTION_NAME ("format_exception");
@@ -82,57 +82,55 @@ acpi_format_exception (
if (sub_status <= AE_CODE_ENV_MAX) {
exception = acpi_gbl_exception_names_env [sub_status];
- break;
}
- goto unknown;
+ break;
case AE_CODE_PROGRAMMER:
if (sub_status <= AE_CODE_PGM_MAX) {
exception = acpi_gbl_exception_names_pgm [sub_status -1];
- break;
}
- goto unknown;
+ break;
case AE_CODE_ACPI_TABLES:
if (sub_status <= AE_CODE_TBL_MAX) {
exception = acpi_gbl_exception_names_tbl [sub_status -1];
- break;
}
- goto unknown;
+ break;
case AE_CODE_AML:
if (sub_status <= AE_CODE_AML_MAX) {
exception = acpi_gbl_exception_names_aml [sub_status -1];
- break;
}
- goto unknown;
+ break;
case AE_CODE_CONTROL:
if (sub_status <= AE_CODE_CTRL_MAX) {
exception = acpi_gbl_exception_names_ctrl [sub_status -1];
- break;
}
- goto unknown;
+ break;
default:
- goto unknown;
+ break;
}
+ if (!exception) {
+ /* Exception code was not recognized */
- return ((const char *) exception);
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Unknown exception code: 0x%8.8X\n", status));
-unknown:
+ return ((const char *) "UNKNOWN_STATUS_CODE");
+ }
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", status));
return ((const char *) exception);
}
-/******************************************************************************
+/*******************************************************************************
*
* Static global variable initialization.
*
@@ -212,13 +210,12 @@ const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STR
};
-/******************************************************************************
+/*******************************************************************************
*
* Namespace globals
*
******************************************************************************/
-
/*
* Predefined ACPI Names (Built-in to the Interpreter)
*
@@ -241,9 +238,11 @@ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
{"_OSI", ACPI_TYPE_METHOD, (char *) 1},
#endif
- {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */
-};
+ /* Table terminator */
+
+ {NULL, ACPI_TYPE_ANY, NULL}
+};
/*
* Properties of the ACPI Object Types, both internal and external.
@@ -288,22 +287,25 @@ const u8 acpi_gbl_ns_properties[] =
/* Hex to ASCII conversion table */
static const char acpi_gbl_hex_to_ascii[] =
- {'0','1','2','3','4','5','6','7',
- '8','9','A','B','C','D','E','F'};
+{
+ '0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'
+};
+
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_hex_to_ascii_char
*
* PARAMETERS: Integer - Contains the hex digit
* Position - bit position of the digit within the
- * integer
+ * integer (multiple of 4)
*
- * RETURN: Ascii character
+ * RETURN: The converted Ascii character
*
- * DESCRIPTION: Convert a hex digit to an ascii character
+ * DESCRIPTION: Convert a hex digit to an Ascii character
*
- ****************************************************************************/
+ ******************************************************************************/
char
acpi_ut_hex_to_ascii_char (
@@ -315,7 +317,7 @@ acpi_ut_hex_to_ascii_char (
}
-/******************************************************************************
+/*******************************************************************************
*
* Table name globals
*
@@ -324,7 +326,7 @@ acpi_ut_hex_to_ascii_char (
* that are not used by the subsystem are simply ignored.
*
* Do NOT add any table to this list that is not consumed directly by this
- * subsystem.
+ * subsystem (No MADT, ECDT, SBST, etc.)
*
******************************************************************************/
@@ -391,7 +393,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
/* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
};
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_region_name
*
@@ -401,7 +403,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVE
*
* DESCRIPTION: Translate a Space ID into a name string (Debug only)
*
- ****************************************************************************/
+ ******************************************************************************/
/* Region type decoding */
@@ -429,7 +431,6 @@ acpi_ut_get_region_name (
{
return ("user_defined_region");
}
-
else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
{
return ("invalid_space_id");
@@ -439,7 +440,7 @@ acpi_ut_get_region_name (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_event_name
*
@@ -449,7 +450,7 @@ acpi_ut_get_region_name (
*
* DESCRIPTION: Translate a Event ID into a name string (Debug only)
*
- ****************************************************************************/
+ ******************************************************************************/
/* Event type decoding */
@@ -477,7 +478,7 @@ acpi_ut_get_event_name (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_type_name
*
@@ -487,20 +488,21 @@ acpi_ut_get_event_name (
*
* DESCRIPTION: Translate a Type ID into a name string (Debug only)
*
- ****************************************************************************/
+ ******************************************************************************/
/*
* Elements of acpi_gbl_ns_type_names below must match
* one-to-one with values of acpi_object_type
*
- * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
- * stored in a table it really means that we have thus far seen no evidence to
- * indicate what type is actually going to be stored for this entry.
+ * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
+ * when stored in a table it really means that we have thus far seen no
+ * evidence to indicate what type is actually going to be stored for this entry.
*/
static const char acpi_gbl_bad_type[] = "UNDEFINED";
-#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */
-static const char *acpi_gbl_ns_type_names[] = /* printable names of ACPI types */
+/* Printable names of the ACPI object types */
+
+static const char *acpi_gbl_ns_type_names[] =
{
/* 00 */ "Untyped",
/* 01 */ "Integer",
@@ -564,7 +566,7 @@ acpi_ut_get_object_type_name (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_node_name
*
@@ -574,7 +576,7 @@ acpi_ut_get_object_type_name (
*
* DESCRIPTION: Validate the node and return the node's ACPI name.
*
- ****************************************************************************/
+ ******************************************************************************/
char *
acpi_ut_get_node_name (
@@ -618,7 +620,7 @@ acpi_ut_get_node_name (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_descriptor_name
*
@@ -628,9 +630,11 @@ acpi_ut_get_node_name (
*
* DESCRIPTION: Validate object and return the descriptor type
*
- ****************************************************************************/
+ ******************************************************************************/
+
+/* Printable names of object descriptor types */
-static const char *acpi_gbl_desc_type_names[] = /* printable names of descriptor types */
+static const char *acpi_gbl_desc_type_names[] =
{
/* 00 */ "Invalid",
/* 01 */ "Cached",
@@ -676,17 +680,18 @@ acpi_ut_get_descriptor_name (
* Strings and procedures used for debug only
*/
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_get_mutex_name
*
- * PARAMETERS: None.
+ * PARAMETERS: mutex_id - The predefined ID for this mutex.
*
- * RETURN: Status
+ * RETURN: String containing the name of the mutex. Always returns a valid
+ * pointer.
*
* DESCRIPTION: Translate a mutex ID into a name string (Debug only)
*
- ****************************************************************************/
+ ******************************************************************************/
char *
acpi_ut_get_mutex_name (
@@ -700,21 +705,20 @@ acpi_ut_get_mutex_name (
return (acpi_gbl_mutex_names[mutex_id]);
}
-
#endif
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_valid_object_type
*
* PARAMETERS: Type - Object type to be validated
*
- * RETURN: TRUE if valid object type
+ * RETURN: TRUE if valid object type, FALSE otherwise
*
* DESCRIPTION: Validate an object type
*
- ****************************************************************************/
+ ******************************************************************************/
u8
acpi_ut_valid_object_type (
@@ -732,7 +736,7 @@ acpi_ut_valid_object_type (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_allocate_owner_id
*
@@ -740,7 +744,10 @@ acpi_ut_valid_object_type (
*
* DESCRIPTION: Allocate a table or method owner id
*
- ***************************************************************************/
+ * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and
+ * should be revisited (TBD)
+ *
+ ******************************************************************************/
acpi_owner_id
acpi_ut_allocate_owner_id (
@@ -796,16 +803,18 @@ acpi_ut_allocate_owner_id (
}
-/****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_ut_init_globals
*
- * PARAMETERS: none
+ * PARAMETERS: None
+ *
+ * RETURN: None
*
* DESCRIPTION: Init library globals. All globals that require specific
* initialization should be initialized here!
*
- ***************************************************************************/
+ ******************************************************************************/
void
acpi_ut_init_globals (
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/utilities/utinit.c
index bdbadaf48d2..7f3713889ff 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/utilities/utinit.c
@@ -49,19 +49,29 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utinit")
+/* Local prototypes */
+
+static void
+acpi_ut_fadt_register_error (
+ char *register_name,
+ u32 value,
+ acpi_size offset);
+
+static void acpi_ut_terminate (
+ void);
+
/*******************************************************************************
*
* FUNCTION: acpi_ut_fadt_register_error
*
- * PARAMETERS: *register_name - Pointer to string identifying register
+ * PARAMETERS: register_name - Pointer to string identifying register
* Value - Actual register contents value
- * acpi_test_spec_section - TDS section containing assertion
- * acpi_assertion - Assertion number being tested
+ * Offset - Byte offset in the FADT
*
* RETURN: AE_BAD_VALUE
*
- * DESCRIPTION: Display failure message and link failure to TDS assertion
+ * DESCRIPTION: Display failure message
*
******************************************************************************/
@@ -166,12 +176,13 @@ acpi_ut_validate_fadt (
*
* RETURN: none
*
- * DESCRIPTION: free global memory
+ * DESCRIPTION: Free global memory
*
******************************************************************************/
-void
-acpi_ut_terminate (void)
+static void
+acpi_ut_terminate (
+ void)
{
struct acpi_gpe_block_info *gpe_block;
struct acpi_gpe_block_info *next_gpe_block;
@@ -183,8 +194,6 @@ acpi_ut_terminate (void)
/* Free global tables, etc. */
-
-
/* Free global GPE blocks and related info structures */
gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
@@ -221,7 +230,8 @@ acpi_ut_terminate (void)
******************************************************************************/
void
-acpi_ut_subsystem_shutdown (void)
+acpi_ut_subsystem_shutdown (
+ void)
{
ACPI_FUNCTION_TRACE ("ut_subsystem_shutdown");
@@ -229,14 +239,16 @@ acpi_ut_subsystem_shutdown (void)
/* Just exit if subsystem is already shutdown */
if (acpi_gbl_shutdown) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "ACPI Subsystem is already terminated\n"));
return_VOID;
}
/* Subsystem appears active, go ahead and shut it down */
acpi_gbl_shutdown = TRUE;
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Shutting down ACPI Subsystem...\n"));
/* Close the acpi_event Handling */
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/utilities/utmath.c
index 2525c1a9354..0d527c91543 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/utilities/utmath.c
@@ -259,6 +259,8 @@ acpi_ut_divide (
*
* FUNCTION: acpi_ut_short_divide, acpi_ut_divide
*
+ * PARAMETERS: See function headers above
+ *
* DESCRIPTION: Native versions of the ut_divide functions. Use these if either
* 1) The target is a 64-bit platform and therefore 64-bit
* integer math is supported directly by the machine.
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f6598547389..f6de4ed3d52 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -49,12 +49,57 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utmisc")
+/* Local prototypes */
+
+static acpi_status
+acpi_ut_create_mutex (
+ acpi_mutex_handle mutex_id);
+
+static acpi_status
+acpi_ut_delete_mutex (
+ acpi_mutex_handle mutex_id);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: acpi_ut_strupr (strupr)
+ *
+ * PARAMETERS: src_string - The source string to convert
+ *
+ * RETURN: Converted src_string (same as input pointer)
+ *
+ * DESCRIPTION: Convert string to uppercase
+ *
+ * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
+ *
+ ******************************************************************************/
+
+char *
+acpi_ut_strupr (
+ char *src_string)
+{
+ char *string;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Walk entire string, uppercasing the letters */
+
+ for (string = src_string; *string; string++) {
+ *string = (char) ACPI_TOUPPER (*string);
+ }
+
+ return (src_string);
+}
+
/*******************************************************************************
*
* FUNCTION: acpi_ut_print_string
*
* PARAMETERS: String - Null terminated ASCII string
+ * max_length - Maximum output length
*
* RETURN: None
*
@@ -148,6 +193,8 @@ acpi_ut_print_string (
*
* PARAMETERS: Value - Value to be converted
*
+ * RETURN: u32 integer with bytes swapped
+ *
* DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
*
******************************************************************************/
@@ -160,7 +207,6 @@ acpi_ut_dword_byte_swap (
u32 value;
u8 bytes[4];
} out;
-
union {
u32 value;
u8 bytes[4];
@@ -219,7 +265,8 @@ acpi_ut_set_integer_width (
*
* FUNCTION: acpi_ut_display_init_pathname
*
- * PARAMETERS: obj_handle - Handle whose pathname will be displayed
+ * PARAMETERS: Type - Object type of the node
+ * obj_handle - Handle whose pathname will be displayed
* Path - Additional path string to be appended.
* (NULL if no extra path)
*
@@ -270,7 +317,8 @@ acpi_ut_display_init_pathname (
/* Print the object type and pathname */
- acpi_os_printf ("%-12s %s", acpi_ut_get_type_name (type), (char *) buffer.pointer);
+ acpi_os_printf ("%-12s %s",
+ acpi_ut_get_type_name (type), (char *) buffer.pointer);
/* Extra path is used to append names like _STA, _INI, etc. */
@@ -288,9 +336,9 @@ acpi_ut_display_init_pathname (
*
* FUNCTION: acpi_ut_valid_acpi_name
*
- * PARAMETERS: Character - The character to be examined
+ * PARAMETERS: Name - The name to be examined
*
- * RETURN: 1 if Character may appear in a name, else 0
+ * RETURN: TRUE if the name is valid, FALSE otherwise
*
* DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
* 1) Upper case alpha
@@ -495,40 +543,6 @@ error_exit:
/*******************************************************************************
*
- * FUNCTION: acpi_ut_strupr
- *
- * PARAMETERS: src_string - The source string to convert to
- *
- * RETURN: src_string
- *
- * DESCRIPTION: Convert string to uppercase
- *
- ******************************************************************************/
-#ifdef ACPI_FUTURE_USAGE
-char *
-acpi_ut_strupr (
- char *src_string)
-{
- char *string;
-
-
- ACPI_FUNCTION_ENTRY ();
-
-
- /* Walk entire string, uppercasing the letters */
-
- for (string = src_string; *string; ) {
- *string = (char) ACPI_TOUPPER (*string);
- string++;
- }
-
- return (src_string);
-}
-#endif /* ACPI_FUTURE_USAGE */
-
-
-/*******************************************************************************
- *
* FUNCTION: acpi_ut_mutex_initialize
*
* PARAMETERS: None.
@@ -611,7 +625,7 @@ acpi_ut_mutex_terminate (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_create_mutex (
acpi_mutex_handle mutex_id)
{
@@ -648,7 +662,7 @@ acpi_ut_create_mutex (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_delete_mutex (
acpi_mutex_handle mutex_id)
{
@@ -715,16 +729,16 @@ acpi_ut_acquire_mutex (
if (acpi_gbl_mutex_info[i].owner_id == this_thread_id) {
if (i == mutex_id) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Mutex [%s] already acquired by this thread [%X]\n",
- acpi_ut_get_mutex_name (mutex_id), this_thread_id));
+ "Mutex [%s] already acquired by this thread [%X]\n",
+ acpi_ut_get_mutex_name (mutex_id), this_thread_id));
return (AE_ALREADY_ACQUIRED);
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
- this_thread_id, acpi_ut_get_mutex_name (i),
- acpi_ut_get_mutex_name (mutex_id)));
+ "Invalid acquire order: Thread %X owns [%s], wants [%s]\n",
+ this_thread_id, acpi_ut_get_mutex_name (i),
+ acpi_ut_get_mutex_name (mutex_id)));
return (AE_ACQUIRE_DEADLOCK);
}
@@ -733,22 +747,23 @@ acpi_ut_acquire_mutex (
#endif
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
- "Thread %X attempting to acquire Mutex [%s]\n",
- this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
+ "Thread %X attempting to acquire Mutex [%s]\n",
+ this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
status = acpi_os_wait_semaphore (acpi_gbl_mutex_info[mutex_id].mutex,
1, ACPI_WAIT_FOREVER);
if (ACPI_SUCCESS (status)) {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n",
- this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
+ this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
acpi_gbl_mutex_info[mutex_id].use_count++;
acpi_gbl_mutex_info[mutex_id].owner_id = this_thread_id;
}
else {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n",
- this_thread_id, acpi_ut_get_mutex_name (mutex_id),
- acpi_format_exception (status)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Thread %X could not acquire Mutex [%s] %s\n",
+ this_thread_id, acpi_ut_get_mutex_name (mutex_id),
+ acpi_format_exception (status)));
}
return (status);
@@ -793,8 +808,8 @@ acpi_ut_release_mutex (
*/
if (acpi_gbl_mutex_info[mutex_id].owner_id == ACPI_MUTEX_NOT_ACQUIRED) {
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Mutex [%s] is not acquired, cannot release\n",
- acpi_ut_get_mutex_name (mutex_id)));
+ "Mutex [%s] is not acquired, cannot release\n",
+ acpi_ut_get_mutex_name (mutex_id)));
return (AE_NOT_ACQUIRED);
}
@@ -812,8 +827,8 @@ acpi_ut_release_mutex (
}
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
- "Invalid release order: owns [%s], releasing [%s]\n",
- acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
+ "Invalid release order: owns [%s], releasing [%s]\n",
+ acpi_ut_get_mutex_name (i), acpi_ut_get_mutex_name (mutex_id)));
return (AE_RELEASE_DEADLOCK);
}
@@ -826,13 +841,14 @@ acpi_ut_release_mutex (
status = acpi_os_signal_semaphore (acpi_gbl_mutex_info[mutex_id].mutex, 1);
if (ACPI_FAILURE (status)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n",
- this_thread_id, acpi_ut_get_mutex_name (mutex_id),
- acpi_format_exception (status)));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Thread %X could not release Mutex [%s] %s\n",
+ this_thread_id, acpi_ut_get_mutex_name (mutex_id),
+ acpi_format_exception (status)));
}
else {
ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n",
- this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
+ this_thread_id, acpi_ut_get_mutex_name (mutex_id)));
}
return (status);
@@ -843,11 +859,11 @@ acpi_ut_release_mutex (
*
* FUNCTION: acpi_ut_create_update_state_and_push
*
- * PARAMETERS: *Object - Object to be added to the new state
+ * PARAMETERS: Object - Object to be added to the new state
* Action - Increment/Decrement
* state_list - List the state will be added to
*
- * RETURN: None
+ * RETURN: Status
*
* DESCRIPTION: Create a new state and push it
*
@@ -885,15 +901,16 @@ acpi_ut_create_update_state_and_push (
*
* FUNCTION: acpi_ut_create_pkg_state_and_push
*
- * PARAMETERS: *Object - Object to be added to the new state
+ * PARAMETERS: Object - Object to be added to the new state
* Action - Increment/Decrement
* state_list - List the state will be added to
*
- * RETURN: None
+ * RETURN: Status
*
* DESCRIPTION: Create a new state and push it
*
******************************************************************************/
+
#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_ut_create_pkg_state_and_push (
@@ -925,7 +942,7 @@ acpi_ut_create_pkg_state_and_push (
* PARAMETERS: list_head - Head of the state stack
* State - State object to push
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Push a state object onto a state stack
*
@@ -954,7 +971,7 @@ acpi_ut_push_generic_state (
*
* PARAMETERS: list_head - Head of the state stack
*
- * RETURN: Status
+ * RETURN: The popped state object
*
* DESCRIPTION: Pop a state object from a state stack
*
@@ -989,7 +1006,7 @@ acpi_ut_pop_generic_state (
*
* PARAMETERS: None
*
- * RETURN: Status
+ * RETURN: The new state object. NULL on failure.
*
* DESCRIPTION: Create a generic state object. Attempt to obtain one from
* the global state cache; If none available, create a new one.
@@ -997,7 +1014,8 @@ acpi_ut_pop_generic_state (
******************************************************************************/
union acpi_generic_state *
-acpi_ut_create_generic_state (void)
+acpi_ut_create_generic_state (
+ void)
{
union acpi_generic_state *state;
@@ -1023,7 +1041,7 @@ acpi_ut_create_generic_state (void)
*
* PARAMETERS: None
*
- * RETURN: Thread State
+ * RETURN: New Thread State. NULL on failure
*
* DESCRIPTION: Create a "Thread State" - a flavor of the generic state used
* to track per-thread info during method execution
@@ -1060,11 +1078,10 @@ acpi_ut_create_thread_state (
*
* FUNCTION: acpi_ut_create_update_state
*
- * PARAMETERS: Object - Initial Object to be installed in the
- * state
- * Action - Update action to be performed
+ * PARAMETERS: Object - Initial Object to be installed in the state
+ * Action - Update action to be performed
*
- * RETURN: Status
+ * RETURN: New state object, null on failure
*
* DESCRIPTION: Create an "Update State" - a flavor of the generic state used
* to update reference counts and delete complex objects such
@@ -1104,11 +1121,10 @@ acpi_ut_create_update_state (
*
* FUNCTION: acpi_ut_create_pkg_state
*
- * PARAMETERS: Object - Initial Object to be installed in the
- * state
- * Action - Update action to be performed
+ * PARAMETERS: Object - Initial Object to be installed in the state
+ * Action - Update action to be performed
*
- * RETURN: Status
+ * RETURN: New state object, null on failure
*
* DESCRIPTION: Create a "Package State"
*
@@ -1151,7 +1167,7 @@ acpi_ut_create_pkg_state (
*
* PARAMETERS: None
*
- * RETURN: Status
+ * RETURN: New state object, null on failure
*
* DESCRIPTION: Create a "Control State" - a flavor of the generic state used
* to support nested IF/WHILE constructs in the AML.
@@ -1190,7 +1206,7 @@ acpi_ut_create_control_state (
*
* PARAMETERS: State - The state object to be deleted
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Put a state object back into the global state cache. The object
* is not actually freed at this time.
@@ -1216,7 +1232,7 @@ acpi_ut_delete_generic_state (
*
* PARAMETERS: None
*
- * RETURN: Status
+ * RETURN: None
*
* DESCRIPTION: Purge the global state object cache. Used during subsystem
* termination.
@@ -1240,7 +1256,10 @@ acpi_ut_delete_generic_state_cache (
*
* FUNCTION: acpi_ut_walk_package_tree
*
- * PARAMETERS: obj_desc - The Package object on which to resolve refs
+ * PARAMETERS: source_object - The package to walk
+ * target_object - Target object (if package is being copied)
+ * walk_callback - Called once for each package element
+ * Context - Passed to the callback function
*
* RETURN: Status
*
@@ -1359,7 +1378,7 @@ acpi_ut_walk_package_tree (
* PARAMETERS: Buffer - Buffer to be scanned
* Length - number of bytes to examine
*
- * RETURN: checksum
+ * RETURN: The generated checksum
*
* DESCRIPTION: Generate a checksum on a raw buffer
*
@@ -1442,7 +1461,6 @@ acpi_ut_get_resource_end_tag (
* PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output)
* component_id - Caller's component ID (for error output)
- * Message - Error message to use on failure
*
* RETURN: None
*
@@ -1457,7 +1475,6 @@ acpi_ut_report_error (
u32 component_id)
{
-
acpi_os_printf ("%8s-%04d: *** Error: ", module_name, line_number);
}
@@ -1469,7 +1486,6 @@ acpi_ut_report_error (
* PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output)
* component_id - Caller's component ID (for error output)
- * Message - Error message to use on failure
*
* RETURN: None
*
@@ -1495,7 +1511,6 @@ acpi_ut_report_warning (
* PARAMETERS: module_name - Caller's module name (for error output)
* line_number - Caller's line number (for error output)
* component_id - Caller's component ID (for error output)
- * Message - Error message to use on failure
*
* RETURN: None
*
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 9ee40a484e0..cd3899b9cc5 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -50,6 +50,25 @@
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utobject")
+/* Local prototypes */
+
+static acpi_status
+acpi_ut_get_simple_object_size (
+ union acpi_operand_object *obj,
+ acpi_size *obj_length);
+
+static acpi_status
+acpi_ut_get_package_object_size (
+ union acpi_operand_object *obj,
+ acpi_size *obj_length);
+
+static acpi_status
+acpi_ut_get_element_length (
+ u8 object_type,
+ union acpi_operand_object *source_object,
+ union acpi_generic_state *state,
+ void *context);
+
/*******************************************************************************
*
@@ -60,7 +79,7 @@
* component_id - Component type of caller
* Type - ACPI Type of the new object
*
- * RETURN: Object - The new object. Null on failure
+ * RETURN: A new internal object, null on failure
*
* DESCRIPTION: Create and initialize a new internal object.
*
@@ -83,7 +102,8 @@ acpi_ut_create_internal_object_dbg (
union acpi_operand_object *second_object;
- ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg", acpi_ut_get_type_name (type));
+ ACPI_FUNCTION_TRACE_STR ("ut_create_internal_object_dbg",
+ acpi_ut_get_type_name (type));
/* Allocate the raw object descriptor */
@@ -99,7 +119,8 @@ acpi_ut_create_internal_object_dbg (
/* These types require a secondary object */
- second_object = acpi_ut_allocate_object_desc_dbg (module_name, line_number, component_id);
+ second_object = acpi_ut_allocate_object_desc_dbg (module_name,
+ line_number, component_id);
if (!second_object) {
acpi_ut_delete_object_desc (object);
return_PTR (NULL);
@@ -138,7 +159,7 @@ acpi_ut_create_internal_object_dbg (
*
* PARAMETERS: buffer_size - Size of buffer to be created
*
- * RETURN: Pointer to a new Buffer object
+ * RETURN: Pointer to a new Buffer object, null on failure
*
* DESCRIPTION: Create a fully initialized buffer object
*
@@ -192,9 +213,9 @@ acpi_ut_create_buffer_object (
*
* FUNCTION: acpi_ut_create_string_object
*
- * PARAMETERS: string_size - Size of string to be created. Does not
- * include NULL terminator, this is added
- * automatically.
+ * PARAMETERS: string_size - Size of string to be created. Does not
+ * include NULL terminator, this is added
+ * automatically.
*
* RETURN: Pointer to a new String object
*
@@ -249,7 +270,9 @@ acpi_ut_create_string_object (
*
* PARAMETERS: Object - Object to be validated
*
- * RETURN: Validate a pointer to be an union acpi_operand_object
+ * RETURN: TRUE if object is valid, FALSE otherwise
+ *
+ * DESCRIPTION: Validate a pointer to be an union acpi_operand_object
*
******************************************************************************/
@@ -399,8 +422,8 @@ acpi_ut_delete_object_cache (
*
* FUNCTION: acpi_ut_get_simple_object_size
*
- * PARAMETERS: *internal_object - Pointer to the object we are examining
- * *obj_length - Where the length is returned
+ * PARAMETERS: internal_object - An ACPI operand object
+ * obj_length - Where the length is returned
*
* RETURN: Status
*
@@ -412,7 +435,7 @@ acpi_ut_delete_object_cache (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_get_simple_object_size (
union acpi_operand_object *internal_object,
acpi_size *obj_length)
@@ -424,8 +447,10 @@ acpi_ut_get_simple_object_size (
ACPI_FUNCTION_TRACE_PTR ("ut_get_simple_object_size", internal_object);
- /* Handle a null object (Could be a uninitialized package element -- which is legal) */
-
+ /*
+ * Handle a null object (Could be a uninitialized package
+ * element -- which is legal)
+ */
if (!internal_object) {
*obj_length = 0;
return_ACPI_STATUS (AE_OK);
@@ -480,7 +505,8 @@ acpi_ut_get_simple_object_size (
* Get the actual length of the full pathname to this object.
* The reference will be converted to the pathname to the object
*/
- length += ACPI_ROUND_UP_TO_NATIVE_WORD (acpi_ns_get_pathname_length (internal_object->reference.node));
+ length += ACPI_ROUND_UP_TO_NATIVE_WORD (
+ acpi_ns_get_pathname_length (internal_object->reference.node));
break;
default:
@@ -530,7 +556,7 @@ acpi_ut_get_simple_object_size (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_get_element_length (
u8 object_type,
union acpi_operand_object *source_object,
@@ -582,8 +608,8 @@ acpi_ut_get_element_length (
*
* FUNCTION: acpi_ut_get_package_object_size
*
- * PARAMETERS: *internal_object - Pointer to the object we are examining
- * *obj_length - Where the length is returned
+ * PARAMETERS: internal_object - An ACPI internal object
+ * obj_length - Where the length is returned
*
* RETURN: Status
*
@@ -595,7 +621,7 @@ acpi_ut_get_element_length (
*
******************************************************************************/
-acpi_status
+static acpi_status
acpi_ut_get_package_object_size (
union acpi_operand_object *internal_object,
acpi_size *obj_length)
@@ -636,8 +662,8 @@ acpi_ut_get_package_object_size (
*
* FUNCTION: acpi_ut_get_object_size
*
- * PARAMETERS: *internal_object - Pointer to the object we are examining
- * *obj_length - Where the length will be returned
+ * PARAMETERS: internal_object - An ACPI internal object
+ * obj_length - Where the length will be returned
*
* RETURN: Status
*
@@ -647,7 +673,7 @@ acpi_ut_get_package_object_size (
******************************************************************************/
acpi_status
-acpi_ut_get_object_size(
+acpi_ut_get_object_size (
union acpi_operand_object *internal_object,
acpi_size *obj_length)
{
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index 97a91f3f06f..e8803d81065 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -73,6 +73,7 @@ acpi_initialize_subsystem (
{
acpi_status status;
+
ACPI_FUNCTION_TRACE ("acpi_initialize_subsystem");
@@ -105,7 +106,6 @@ acpi_initialize_subsystem (
* Initialize the namespace manager and
* the root of the namespace tree
*/
-
status = acpi_ns_root_initialize ();
if (ACPI_FAILURE (status)) {
ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n",
@@ -113,7 +113,6 @@ acpi_initialize_subsystem (
return_ACPI_STATUS (status);
}
-
/* If configured, initialize the AML debugger */
ACPI_DEBUGGER_EXEC (status = acpi_db_initialize ());
@@ -150,7 +149,8 @@ acpi_enable_subsystem (
* The values from the FADT are validated here.
*/
if (!(flags & ACPI_NO_HARDWARE_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Initializing ACPI hardware\n"));
status = acpi_hw_initialize ();
if (ACPI_FAILURE (status)) {
@@ -178,7 +178,8 @@ acpi_enable_subsystem (
* install_address_space_handler interface.
*/
if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Installing default address space handlers\n"));
status = acpi_ev_install_region_handlers ();
if (ACPI_FAILURE (status)) {
@@ -189,12 +190,14 @@ acpi_enable_subsystem (
/*
* Initialize ACPI Event handling (Fixed and General Purpose)
*
- * NOTE: We must have the hardware AND events initialized before we can execute
- * ANY control methods SAFELY. Any control method can require ACPI hardware
- * support, so the hardware MUST be initialized before execution!
+ * NOTE: We must have the hardware AND events initialized before we can
+ * execute ANY control methods SAFELY. Any control method can require
+ * ACPI hardware support, so the hardware MUST be initialized before
+ * execution!
*/
if (!(flags & ACPI_NO_EVENT_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Initializing ACPI events\n"));
status = acpi_ev_initialize_events ();
if (ACPI_FAILURE (status)) {
@@ -205,7 +208,8 @@ acpi_enable_subsystem (
/* Install the SCI handler and Global Lock handler */
if (!(flags & ACPI_NO_HANDLER_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Installing SCI/GL handlers\n"));
status = acpi_ev_install_xrupt_handlers ();
if (ACPI_FAILURE (status)) {
@@ -247,7 +251,8 @@ acpi_initialize_objects (
* contain executable AML (see call to acpi_ns_initialize_objects below).
*/
if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG op_region methods\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Executing _REG op_region methods\n"));
status = acpi_ev_initialize_op_regions ();
if (ACPI_FAILURE (status)) {
@@ -261,7 +266,8 @@ acpi_initialize_objects (
* objects: operation_regions, buffer_fields, Buffers, and Packages.
*/
if (!(flags & ACPI_NO_OBJECT_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Completing Initialization of ACPI Objects\n"));
status = acpi_ns_initialize_objects ();
if (ACPI_FAILURE (status)) {
@@ -274,7 +280,8 @@ acpi_initialize_objects (
* This runs the _STA and _INI methods.
*/
if (!(flags & ACPI_NO_DEVICE_INIT)) {
- ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "[Init] Initializing ACPI Devices\n"));
status = acpi_ns_initialize_devices ();
if (ACPI_FAILURE (status)) {
@@ -307,7 +314,8 @@ acpi_initialize_objects (
******************************************************************************/
acpi_status
-acpi_terminate (void)
+acpi_terminate (
+ void)
{
acpi_status status;
@@ -344,8 +352,7 @@ acpi_terminate (void)
#ifdef ACPI_FUTURE_USAGE
-
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_subsystem_status
*
@@ -354,14 +361,16 @@ acpi_terminate (void)
* RETURN: Status of the ACPI subsystem
*
* DESCRIPTION: Other drivers that use the ACPI subsystem should call this
- * before making any other calls, to ensure the subsystem initial-
- * ized successfully.
+ * before making any other calls, to ensure the subsystem
+ * initialized successfully.
*
- ****************************************************************************/
+ ******************************************************************************/
acpi_status
-acpi_subsystem_status (void)
+acpi_subsystem_status (
+ void)
{
+
if (acpi_gbl_startup_flags & ACPI_INITIALIZED_OK) {
return (AE_OK);
}
@@ -371,13 +380,12 @@ acpi_subsystem_status (void)
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: acpi_get_system_info
*
- * PARAMETERS: out_buffer - a pointer to a buffer to receive the
- * resources for the device
- * buffer_length - the number of bytes available in the buffer
+ * PARAMETERS: out_buffer - A buffer to receive the resources for the
+ * device
*
* RETURN: Status - the status of the call
*
@@ -395,8 +403,8 @@ acpi_get_system_info (
struct acpi_buffer *out_buffer)
{
struct acpi_system_info *info_ptr;
- u32 i;
acpi_status status;
+ u32 i;
ACPI_FUNCTION_TRACE ("acpi_get_system_info");
@@ -466,6 +474,7 @@ EXPORT_SYMBOL(acpi_get_system_info);
* FUNCTION: acpi_install_initialization_handler
*
* PARAMETERS: Handler - Callback procedure
+ * Function - Not (currently) used, see below
*
* RETURN: Status
*
@@ -495,7 +504,6 @@ acpi_install_initialization_handler (
#endif /* ACPI_FUTURE_USAGE */
-
/*****************************************************************************
*
* FUNCTION: acpi_purge_cached_objects
@@ -509,7 +517,8 @@ acpi_install_initialization_handler (
****************************************************************************/
acpi_status
-acpi_purge_cached_objects (void)
+acpi_purge_cached_objects (
+ void)
{
ACPI_FUNCTION_TRACE ("acpi_purge_cached_objects");
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 71fa1011715..2cf264fd52e 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -564,12 +564,13 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
int count = 0;
union acpi_object *o;
- br = kmalloc(sizeof &br, GFP_KERNEL);
+ br = kmalloc(sizeof(*br), GFP_KERNEL);
if (!br) {
printk(KERN_ERR "can't allocate memory\n");
} else {
- memset(br, 0, sizeof &br);
- br->levels = kmalloc(obj->package.count * sizeof &br->levels, GFP_KERNEL);
+ memset(br, 0, sizeof(*br));
+ br->levels = kmalloc(obj->package.count *
+ sizeof *(br->levels), GFP_KERNEL);
if (!br->levels)
goto out;
@@ -584,8 +585,7 @@ acpi_video_device_find_cap (struct acpi_video_device *device)
}
out:
if (count < 2) {
- if (br->levels)
- kfree(br->levels);
+ kfree(br->levels);
kfree(br);
} else {
br->count = count;
@@ -595,8 +595,7 @@ out:
}
}
- if (obj)
- kfree(obj);
+ kfree(obj);
return_VOID;
}
@@ -1585,7 +1584,7 @@ acpi_video_switch_output(
ACPI_FUNCTION_TRACE("acpi_video_switch_output");
list_for_each_safe(node, next, &video->video_device_list) {
- struct acpi_video_device * dev = container_of(node, struct acpi_video_device, entry);
+ dev = container_of(node, struct acpi_video_device, entry);
status = acpi_video_device_get_state(dev, &state);
if (state & 0x2){
dev_next = container_of(node->next, struct acpi_video_device, entry);
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index f37a13de804..214b9643540 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -22,7 +22,6 @@
#include <linux/string.h>
#include <linux/pm.h>
-
extern struct subsystem devices_subsys;
#define to_sysdev(k) container_of(k, struct sys_device, kobj)
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index 5413f290885..eb7058cbf01 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -24,6 +24,8 @@
#include <asm/io.h>
#include <asm/reboot.h>
+#include <asm/vr41xx/giu.h>
+#include <asm/vr41xx/tb0219.h>
MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>");
MODULE_DESCRIPTION("TANBAC TB0219 base board driver");
@@ -266,6 +268,21 @@ static void tb0219_restart(char *command)
tb0219_write(TB0219_RESET, 0);
}
+static void tb0219_pci_irq_init(void)
+{
+ /* PCI Slot 1 */
+ vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+ vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN, IRQ_LEVEL_LOW);
+
+ /* PCI Slot 2 */
+ vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+ vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN, IRQ_LEVEL_LOW);
+
+ /* PCI Slot 3 */
+ vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+ vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW);
+}
+
static int tb0219_probe(struct device *dev)
{
int retval;
@@ -292,6 +309,8 @@ static int tb0219_probe(struct device *dev)
old_machine_restart = _machine_restart;
_machine_restart = tb0219_restart;
+ tb0219_pci_irq_init();
+
if (major == 0) {
major = retval;
printk(KERN_INFO "TB0219: major number %d\n", major);
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
new file mode 100644
index 00000000000..140d5f851a5
--- /dev/null
+++ b/drivers/hwmon/Kconfig
@@ -0,0 +1,420 @@
+#
+# I2C Sensor chip drivers configuration
+#
+
+menu "Hardware Monitoring support"
+
+config HWMON
+ tristate "Hardware Monitoring support"
+ default y
+ help
+ Hardware monitoring devices let you monitor the hardware health
+ of a system. Most modern motherboards include such a device. It
+ can include temperature sensors, voltage sensors, fan speed
+ sensors and various additional features such as the ability to
+ control the speed of the fans.
+
+config SENSORS_ADM1021
+ tristate "Analog Devices ADM1021 and compatibles"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Analog Devices ADM1021
+ and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
+ Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10,
+ and the XEON processor built-in sensor.
+
+ This driver can also be built as a module. If so, the module
+ will be called adm1021.
+
+config SENSORS_ADM1025
+ tristate "Analog Devices ADM1025 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Analog Devices ADM1025
+ and Philips NE1619 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called adm1025.
+
+config SENSORS_ADM1026
+ tristate "Analog Devices ADM1026 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Analog Devices ADM1026
+ sensor chip.
+
+ This driver can also be built as a module. If so, the module
+ will be called adm1026.
+
+config SENSORS_ADM1031
+ tristate "Analog Devices ADM1031 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Analog Devices ADM1031
+ and ADM1030 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called adm1031.
+
+config SENSORS_ADM9240
+ tristate "Analog Devices ADM9240 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Analog Devices ADM9240,
+ Dallas DS1780, National Semiconductor LM81 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called adm9240.
+
+config SENSORS_ASB100
+ tristate "Asus ASB100 Bach"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for the ASB100 Bach sensor
+ chip found on some Asus mainboards.
+
+ This driver can also be built as a module. If so, the module
+ will be called asb100.
+
+config SENSORS_ATXP1
+ tristate "Attansic ATXP1 VID controller"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for the Attansic ATXP1 VID
+ controller.
+
+ If your board have such a chip, you are able to control your CPU
+ core and other voltages.
+
+ This driver can also be built as a module. If so, the module
+ will be called atxp1.
+
+config SENSORS_DS1621
+ tristate "Dallas Semiconductor DS1621 and DS1625"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Dallas Semiconductor
+ DS1621 and DS1625 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called ds1621.
+
+config SENSORS_FSCHER
+ tristate "FSC Hermes"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Fujitsu Siemens
+ Computers Hermes sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called fscher.
+
+config SENSORS_FSCPOS
+ tristate "FSC Poseidon"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Fujitsu Siemens
+ Computers Poseidon sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called fscpos.
+
+config SENSORS_GL518SM
+ tristate "Genesys Logic GL518SM"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Genesys Logic GL518SM
+ sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called gl518sm.
+
+config SENSORS_GL520SM
+ tristate "Genesys Logic GL520SM"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for Genesys Logic GL520SM
+ sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called gl520sm.
+
+config SENSORS_IT87
+ tristate "ITE IT87xx and compatibles"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for ITE IT87xx sensor chips
+ and clones: SiS960.
+
+ This driver can also be built as a module. If so, the module
+ will be called it87.
+
+config SENSORS_LM63
+ tristate "National Semiconductor LM63"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for the National Semiconductor
+ LM63 remote diode digital temperature sensor with integrated fan
+ control. Such chips are found on the Tyan S4882 (Thunder K8QS Pro)
+ motherboard, among others.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm63.
+
+config SENSORS_LM75
+ tristate "National Semiconductor LM75 and compatibles"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM75
+ sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
+ 9-bit precision mode), and TelCom (now Microchip) TCN75.
+
+ The DS75 and DS1775 in 10- to 12-bit precision modes will require
+ a force module parameter. The driver will not handle the extra
+ precision anyhow.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm75.
+
+config SENSORS_LM77
+ tristate "National Semiconductor LM77"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM77
+ sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm77.
+
+config SENSORS_LM78
+ tristate "National Semiconductor LM78 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM78,
+ LM78-J and LM79.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm78.
+
+config SENSORS_LM80
+ tristate "National Semiconductor LM80"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor
+ LM80 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm80.
+
+config SENSORS_LM83
+ tristate "National Semiconductor LM83"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor
+ LM83 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm83.
+
+config SENSORS_LM85
+ tristate "National Semiconductor LM85 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM85
+ sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm85.
+
+config SENSORS_LM87
+ tristate "National Semiconductor LM87"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM87
+ sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm87.
+
+config SENSORS_LM90
+ tristate "National Semiconductor LM90 and compatibles"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM90,
+ LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
+ MAX6658 sensor chips.
+
+ The Analog Devices ADT7461 sensor chip is also supported, but only
+ if found in ADM1032 compatibility mode.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm90.
+
+config SENSORS_LM92
+ tristate "National Semiconductor LM92 and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for National Semiconductor LM92
+ and Maxim MAX6635 sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called lm92.
+
+config SENSORS_MAX1619
+ tristate "Maxim MAX1619 sensor chip"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for MAX1619 sensor chip.
+
+ This driver can also be built as a module. If so, the module
+ will be called max1619.
+
+config SENSORS_PC87360
+ tristate "National Semiconductor PC87360 family"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get access to the hardware monitoring
+ functions of the National Semiconductor PC8736x Super-I/O chips.
+ The PC87360, PC87363 and PC87364 only have fan monitoring and
+ control. The PC87365 and PC87366 additionally have voltage and
+ temperature monitoring.
+
+ This driver can also be built as a module. If so, the module
+ will be called pc87360.
+
+config SENSORS_SIS5595
+ tristate "Silicon Integrated Systems Corp. SiS5595"
+ depends on HWMON && I2C && PCI && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get support for the integrated sensors in
+ SiS5595 South Bridges.
+
+ This driver can also be built as a module. If so, the module
+ will be called sis5595.
+
+config SENSORS_SMSC47M1
+ tristate "SMSC LPC47M10x and compatibles"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get support for the integrated fan
+ monitoring and control capabilities of the SMSC LPC47B27x,
+ LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called smsc47m1.
+
+config SENSORS_SMSC47B397
+ tristate "SMSC LPC47B397-NC"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get support for the SMSC LPC47B397-NC
+ sensor chip.
+
+ This driver can also be built as a module. If so, the module
+ will be called smsc47b397.
+
+config SENSORS_VIA686A
+ tristate "VIA686A"
+ depends on HWMON && I2C && PCI
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get support for the integrated sensors in
+ Via 686A/B South Bridges.
+
+ This driver can also be built as a module. If so, the module
+ will be called via686a.
+
+config SENSORS_W83781D
+ tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
+ depends on HWMON && I2C
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for the Winbond W8378x series
+ of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
+ and the similar Asus AS99127F.
+
+ This driver can also be built as a module. If so, the module
+ will be called w83781d.
+
+config SENSORS_W83L785TS
+ tristate "Winbond W83L785TS-S"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ help
+ If you say yes here you get support for the Winbond W83L785TS-S
+ sensor chip, which is used on the Asus A7N8X, among other
+ motherboards.
+
+ This driver can also be built as a module. If so, the module
+ will be called w83l785ts.
+
+config SENSORS_W83627HF
+ tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get support for the Winbond W836X7 series
+ of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
+
+ This driver can also be built as a module. If so, the module
+ will be called w83627hf.
+
+config SENSORS_W83627EHF
+ tristate "Winbond W83627EHF"
+ depends on HWMON && I2C && EXPERIMENTAL
+ select I2C_SENSOR
+ select I2C_ISA
+ help
+ If you say yes here you get preliminary support for the hardware
+ monitoring functionality of the Winbond W83627EHF Super-I/O chip.
+ Only fan and temperature inputs are supported at the moment, while
+ the chip does much more than that.
+
+ This driver can also be built as a module. If so, the module
+ will be called w83627ehf.
+
+config HWMON_DEBUG_CHIP
+ bool "Hardware Monitoring Chip debugging messages"
+ depends on HWMON
+ default n
+ help
+ Say Y here if you want the I2C chip drivers to produce a bunch of
+ debug messages to the system log. Select this if you are having
+ a problem with I2C support and want to see more of what is going
+ on.
+
+endmenu
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
new file mode 100644
index 00000000000..2781403a023
--- /dev/null
+++ b/drivers/hwmon/Makefile
@@ -0,0 +1,44 @@
+#
+# Makefile for sensor chip drivers.
+#
+
+# asb100, then w83781d go first, as they can override other drivers' addresses.
+obj-$(CONFIG_SENSORS_ASB100) += asb100.o
+obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
+obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
+
+obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
+obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
+obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
+obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
+obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
+obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
+obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
+obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
+obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
+obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
+obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+obj-$(CONFIG_SENSORS_IT87) += it87.o
+obj-$(CONFIG_SENSORS_LM63) += lm63.o
+obj-$(CONFIG_SENSORS_LM75) += lm75.o
+obj-$(CONFIG_SENSORS_LM77) += lm77.o
+obj-$(CONFIG_SENSORS_LM78) += lm78.o
+obj-$(CONFIG_SENSORS_LM80) += lm80.o
+obj-$(CONFIG_SENSORS_LM83) += lm83.o
+obj-$(CONFIG_SENSORS_LM85) += lm85.o
+obj-$(CONFIG_SENSORS_LM87) += lm87.o
+obj-$(CONFIG_SENSORS_LM90) += lm90.o
+obj-$(CONFIG_SENSORS_LM92) += lm92.o
+obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
+obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
+obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
+obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
+obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
+obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
+obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
+obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
+
+ifeq ($(CONFIG_HWMON_DEBUG_CHIP),y)
+EXTRA_CFLAGS += -DDEBUG
+endif
+
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/hwmon/adm1021.c
index d2c774c32f4..d2c774c32f4 100644
--- a/drivers/i2c/chips/adm1021.c
+++ b/drivers/hwmon/adm1021.c
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/hwmon/adm1025.c
index e452d0daf90..e452d0daf90 100644
--- a/drivers/i2c/chips/adm1025.c
+++ b/drivers/hwmon/adm1025.c
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/hwmon/adm1026.c
index 3c85fe150cd..3c85fe150cd 100644
--- a/drivers/i2c/chips/adm1026.c
+++ b/drivers/hwmon/adm1026.c
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/hwmon/adm1031.c
index 9168e983ca1..9168e983ca1 100644
--- a/drivers/i2c/chips/adm1031.c
+++ b/drivers/hwmon/adm1031.c
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/hwmon/adm9240.c
index 5c68e9c311a..5c68e9c311a 100644
--- a/drivers/i2c/chips/adm9240.c
+++ b/drivers/hwmon/adm9240.c
diff --git a/drivers/i2c/chips/asb100.c b/drivers/hwmon/asb100.c
index 70d996d6fe0..70d996d6fe0 100644
--- a/drivers/i2c/chips/asb100.c
+++ b/drivers/hwmon/asb100.c
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/hwmon/atxp1.c
index 0bcf82b4c07..0bcf82b4c07 100644
--- a/drivers/i2c/chips/atxp1.c
+++ b/drivers/hwmon/atxp1.c
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/hwmon/ds1621.c
index 5360d58804f..5360d58804f 100644
--- a/drivers/i2c/chips/ds1621.c
+++ b/drivers/hwmon/ds1621.c
diff --git a/drivers/i2c/chips/fscher.c b/drivers/hwmon/fscher.c
index da411741c2c..da411741c2c 100644
--- a/drivers/i2c/chips/fscher.c
+++ b/drivers/hwmon/fscher.c
diff --git a/drivers/i2c/chips/fscpos.c b/drivers/hwmon/fscpos.c
index 3beaa6191ef..3beaa6191ef 100644
--- a/drivers/i2c/chips/fscpos.c
+++ b/drivers/hwmon/fscpos.c
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/hwmon/gl518sm.c
index 6bedf729dcf..6bedf729dcf 100644
--- a/drivers/i2c/chips/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
diff --git a/drivers/i2c/chips/gl520sm.c b/drivers/hwmon/gl520sm.c
index a13a504f5bf..a13a504f5bf 100644
--- a/drivers/i2c/chips/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
diff --git a/drivers/i2c/chips/it87.c b/drivers/hwmon/it87.c
index db20c9e4739..db20c9e4739 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/hwmon/it87.c
diff --git a/drivers/i2c/chips/lm63.c b/drivers/hwmon/lm63.c
index 7c6f9ea5a25..7c6f9ea5a25 100644
--- a/drivers/i2c/chips/lm63.c
+++ b/drivers/hwmon/lm63.c
diff --git a/drivers/i2c/chips/lm75.c b/drivers/hwmon/lm75.c
index 5be164ed278..5be164ed278 100644
--- a/drivers/i2c/chips/lm75.c
+++ b/drivers/hwmon/lm75.c
diff --git a/drivers/i2c/chips/lm75.h b/drivers/hwmon/lm75.h
index 63e3f2fb4c2..63e3f2fb4c2 100644
--- a/drivers/i2c/chips/lm75.h
+++ b/drivers/hwmon/lm75.h
diff --git a/drivers/i2c/chips/lm77.c b/drivers/hwmon/lm77.c
index b98f4495299..b98f4495299 100644
--- a/drivers/i2c/chips/lm77.c
+++ b/drivers/hwmon/lm77.c
diff --git a/drivers/i2c/chips/lm78.c b/drivers/hwmon/lm78.c
index 29241469dcb..29241469dcb 100644
--- a/drivers/i2c/chips/lm78.c
+++ b/drivers/hwmon/lm78.c
diff --git a/drivers/i2c/chips/lm80.c b/drivers/hwmon/lm80.c
index 8100595feb4..8100595feb4 100644
--- a/drivers/i2c/chips/lm80.c
+++ b/drivers/hwmon/lm80.c
diff --git a/drivers/i2c/chips/lm83.c b/drivers/hwmon/lm83.c
index a49008b444c..a49008b444c 100644
--- a/drivers/i2c/chips/lm83.c
+++ b/drivers/hwmon/lm83.c
diff --git a/drivers/i2c/chips/lm85.c b/drivers/hwmon/lm85.c
index b4d7fd41826..b4d7fd41826 100644
--- a/drivers/i2c/chips/lm85.c
+++ b/drivers/hwmon/lm85.c
diff --git a/drivers/i2c/chips/lm87.c b/drivers/hwmon/lm87.c
index 1921ed1af18..1921ed1af18 100644
--- a/drivers/i2c/chips/lm87.c
+++ b/drivers/hwmon/lm87.c
diff --git a/drivers/i2c/chips/lm90.c b/drivers/hwmon/lm90.c
index a67dcadf7cb..a67dcadf7cb 100644
--- a/drivers/i2c/chips/lm90.c
+++ b/drivers/hwmon/lm90.c
diff --git a/drivers/i2c/chips/lm92.c b/drivers/hwmon/lm92.c
index 215c8e40ffd..215c8e40ffd 100644
--- a/drivers/i2c/chips/lm92.c
+++ b/drivers/hwmon/lm92.c
diff --git a/drivers/i2c/chips/max1619.c b/drivers/hwmon/max1619.c
index bf553dcd97d..bf553dcd97d 100644
--- a/drivers/i2c/chips/max1619.c
+++ b/drivers/hwmon/max1619.c
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/hwmon/pc87360.c
index 876c68f3af3..876c68f3af3 100644
--- a/drivers/i2c/chips/pc87360.c
+++ b/drivers/hwmon/pc87360.c
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/hwmon/sis5595.c
index 6bbfc8fb4f1..6bbfc8fb4f1 100644
--- a/drivers/i2c/chips/sis5595.c
+++ b/drivers/hwmon/sis5595.c
diff --git a/drivers/i2c/chips/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 251ac265955..251ac265955 100644
--- a/drivers/i2c/chips/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 897117a7213..897117a7213 100644
--- a/drivers/i2c/chips/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
diff --git a/drivers/i2c/chips/via686a.c b/drivers/hwmon/via686a.c
index 137d9b7cacd..164d4794839 100644
--- a/drivers/i2c/chips/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -1,9 +1,9 @@
/*
via686a.c - Part of lm_sensors, Linux kernel modules
- for hardware monitoring
+ for hardware monitoring
Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
- Kyösti Mälkki <kmalkki@cc.hut.fi>,
+ Kyösti Mälkki <kmalkki@cc.hut.fi>,
Mark Studebaker <mdsxyz123@yahoo.com>,
and Bob Dougherty <bobd@stanford.edu>
(Some conversion-factor data were contributed by Jonathan Teh Soon Yew
@@ -171,18 +171,18 @@ static inline u8 FAN_TO_REG(long rpm, int div)
/******** TEMP CONVERSIONS (Bob Dougherty) *********/
/* linear fits from HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew)
if(temp<169)
- return double(temp)*0.427-32.08;
+ return double(temp)*0.427-32.08;
else if(temp>=169 && temp<=202)
- return double(temp)*0.582-58.16;
+ return double(temp)*0.582-58.16;
else
- return double(temp)*0.924-127.33;
+ return double(temp)*0.924-127.33;
A fifth-order polynomial fits the unofficial data (provided by Alex van
Kaam <darkside@chello.nl>) a bit better. It also give more reasonable
numbers on my machine (ie. they agree with what my BIOS tells me).
Here's the fifth-order fit to the 8-bit data:
temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 -
- 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0.
+ 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0.
(2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for
finding my typos in this formula!)
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 8a40b6976e1..8a40b6976e1 100644
--- a/drivers/i2c/chips/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/hwmon/w83627hf.c
index bd87a42e068..bd87a42e068 100644
--- a/drivers/i2c/chips/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/hwmon/w83781d.c
index 0bb131ce09e..0bb131ce09e 100644
--- a/drivers/i2c/chips/w83781d.c
+++ b/drivers/hwmon/w83781d.c
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index 4469d52aba4..4469d52aba4 100644
--- a/drivers/i2c/chips/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
diff --git a/drivers/i2c/algos/i2c-algo-ite.c b/drivers/i2c/algos/i2c-algo-ite.c
index 68e9e6832ca..e6cae39f47a 100644
--- a/drivers/i2c/algos/i2c-algo-ite.c
+++ b/drivers/i2c/algos/i2c-algo-ite.c
@@ -208,7 +208,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
goto bailout;
}
sdalo(adap);
- printk("test_bus:1 scl: %d sda: %d \n",getscl(adap),
+ printk("test_bus:1 scl: %d sda: %d\n", getscl(adap),
getsda(adap));
if ( 0 != getsda(adap) ) {
printk("test_bus: %s SDA stuck high!\n",name);
@@ -221,7 +221,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
goto bailout;
}
sdahi(adap);
- printk("test_bus:2 scl: %d sda: %d \n",getscl(adap),
+ printk("test_bus:2 scl: %d sda: %d\n", getscl(adap),
getsda(adap));
if ( 0 == getsda(adap) ) {
printk("test_bus: %s SDA stuck low!\n",name);
@@ -234,7 +234,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
goto bailout;
}
scllo(adap);
- printk("test_bus:3 scl: %d sda: %d \n",getscl(adap),
+ printk("test_bus:3 scl: %d sda: %d\n", getscl(adap),
getsda(adap));
if ( 0 != getscl(adap) ) {
@@ -247,7 +247,7 @@ static int test_bus(struct i2c_algo_iic_data *adap, char *name) {
goto bailout;
}
sclhi(adap);
- printk("test_bus:4 scl: %d sda: %d \n",getscl(adap),
+ printk("test_bus:4 scl: %d sda: %d\n", getscl(adap),
getsda(adap));
if ( 0 == getscl(adap) ) {
printk("test_bus: %s SCL stuck low!\n",name);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 45e6efb1dcd..0ab7e37f5b0 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -194,7 +194,7 @@ static int i801_transaction(void)
/* Make sure the SMBus host is ready to start transmitting */
/* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */
if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
- dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting... \n",
+ dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting...\n",
temp);
outb_p(temp, SMBHSTSTS);
if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
@@ -315,7 +315,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
}
if (temp & errmask) {
dev_dbg(&I801_dev->dev, "SMBus busy (%02x). "
- "Resetting... \n", temp);
+ "Resetting...\n", temp);
outb_p(temp, SMBHSTSTS);
if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) {
dev_err(&I801_dev->dev,
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 1f80ba9da6f..6d34ee381ce 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -243,7 +243,7 @@ static int piix4_transaction(void)
/* Make sure the SMBus host is ready to start transmitting */
if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
- "Resetting... \n", temp);
+ "Resetting...\n", temp);
outb_p(temp, SMBHSTSTS);
if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 2b5911cfb7b..bbd5e4e52f0 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -228,7 +228,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
/* Make sure the SMBus host is ready to start transmitting */
temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
if (temp != 0x00) {
- dev_dbg(&adap->dev, "SMBus busy (%04x). Resetting... \n", temp);
+ dev_dbg(&adap->dev, "SMBus busy (%04x). Resetting...\n", temp);
sis5595_write(SMB_STS_LO, temp & 0xff);
sis5595_write(SMB_STS_HI, temp >> 8);
if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index a0982da0980..43f70dbfc03 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -1,409 +1,12 @@
#
-# I2C Sensor and "other" chip configuration
+# Miscellaneous I2C chip drivers configuration
#
-menu "Hardware Sensors Chip support"
- depends on I2C
-
config I2C_SENSOR
tristate
default n
-config SENSORS_ADM1021
- tristate "Analog Devices ADM1021 and compatibles"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for Analog Devices ADM1021
- and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
- Genesys Logic GL523SM, National Semiconductor LM84, TI THMC10,
- and the XEON processor built-in sensor.
-
- This driver can also be built as a module. If so, the module
- will be called adm1021.
-
-config SENSORS_ADM1025
- tristate "Analog Devices ADM1025 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Analog Devices ADM1025
- and Philips NE1619 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called adm1025.
-
-config SENSORS_ADM1026
- tristate "Analog Devices ADM1026 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Analog Devices ADM1026
- sensor chip.
-
- This driver can also be built as a module. If so, the module
- will be called adm1026.
-
-config SENSORS_ADM1031
- tristate "Analog Devices ADM1031 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Analog Devices ADM1031
- and ADM1030 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called adm1031.
-
-config SENSORS_ADM9240
- tristate "Analog Devices ADM9240 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Analog Devices ADM9240,
- Dallas DS1780, National Semiconductor LM81 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called adm9240.
-
-config SENSORS_ASB100
- tristate "Asus ASB100 Bach"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for the ASB100 Bach sensor
- chip found on some Asus mainboards.
-
- This driver can also be built as a module. If so, the module
- will be called asb100.
-
-config SENSORS_ATXP1
- tristate "Attansic ATXP1 VID controller"
- depends on I2C && EXPERIMENTAL
- help
- If you say yes here you get support for the Attansic ATXP1 VID
- controller.
-
- If your board have such a chip, you are able to control your CPU
- core and other voltages.
-
- This driver can also be built as a module. If so, the module
- will be called atxp1.
-
-config SENSORS_DS1621
- tristate "Dallas Semiconductor DS1621 and DS1625"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Dallas Semiconductor
- DS1621 and DS1625 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called ds1621.
-
-config SENSORS_FSCHER
- tristate "FSC Hermes"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Fujitsu Siemens
- Computers Hermes sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called fscher.
-
-config SENSORS_FSCPOS
- tristate "FSC Poseidon"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Fujitsu Siemens
- Computers Poseidon sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called fscpos.
-
-config SENSORS_GL518SM
- tristate "Genesys Logic GL518SM"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for Genesys Logic GL518SM
- sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called gl518sm.
-
-config SENSORS_GL520SM
- tristate "Genesys Logic GL520SM"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for Genesys Logic GL520SM
- sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called gl520sm.
-
-config SENSORS_IT87
- tristate "ITE IT87xx and compatibles"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for ITE IT87xx sensor chips
- and clones: SiS960.
-
- This driver can also be built as a module. If so, the module
- will be called it87.
-
-config SENSORS_LM63
- tristate "National Semiconductor LM63"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for the National Semiconductor
- LM63 remote diode digital temperature sensor with integrated fan
- control. Such chips are found on the Tyan S4882 (Thunder K8QS Pro)
- motherboard, among others.
-
- This driver can also be built as a module. If so, the module
- will be called lm63.
-
-config SENSORS_LM75
- tristate "National Semiconductor LM75 and compatibles"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM75
- sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
- 9-bit precision mode), and TelCom (now Microchip) TCN75.
-
- The DS75 and DS1775 in 10- to 12-bit precision modes will require
- a force module parameter. The driver will not handle the extra
- precision anyhow.
-
- This driver can also be built as a module. If so, the module
- will be called lm75.
-
-config SENSORS_LM77
- tristate "National Semiconductor LM77"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM77
- sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called lm77.
-
-config SENSORS_LM78
- tristate "National Semiconductor LM78 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM78,
- LM78-J and LM79.
-
- This driver can also be built as a module. If so, the module
- will be called lm78.
-
-config SENSORS_LM80
- tristate "National Semiconductor LM80"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor
- LM80 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called lm80.
-
-config SENSORS_LM83
- tristate "National Semiconductor LM83"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor
- LM83 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called lm83.
-
-config SENSORS_LM85
- tristate "National Semiconductor LM85 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM85
- sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
-
- This driver can also be built as a module. If so, the module
- will be called lm85.
-
-config SENSORS_LM87
- tristate "National Semiconductor LM87"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM87
- sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called lm87.
-
-config SENSORS_LM90
- tristate "National Semiconductor LM90 and compatibles"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM90,
- LM86, LM89 and LM99, Analog Devices ADM1032 and Maxim MAX6657 and
- MAX6658 sensor chips.
-
- The Analog Devices ADT7461 sensor chip is also supported, but only
- if found in ADM1032 compatibility mode.
-
- This driver can also be built as a module. If so, the module
- will be called lm90.
-
-config SENSORS_LM92
- tristate "National Semiconductor LM92 and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for National Semiconductor LM92
- and Maxim MAX6635 sensor chips.
-
- This driver can also be built as a module. If so, the module
- will be called lm92.
-
-config SENSORS_MAX1619
- tristate "Maxim MAX1619 sensor chip"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for MAX1619 sensor chip.
-
- This driver can also be built as a module. If so, the module
- will be called max1619.
-
-config SENSORS_PC87360
- tristate "National Semiconductor PC87360 family"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get access to the hardware monitoring
- functions of the National Semiconductor PC8736x Super-I/O chips.
- The PC87360, PC87363 and PC87364 only have fan monitoring and
- control. The PC87365 and PC87366 additionally have voltage and
- temperature monitoring.
-
- This driver can also be built as a module. If so, the module
- will be called pc87360.
-
-config SENSORS_SMSC47B397
- tristate "SMSC LPC47B397-NC"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get support for the SMSC LPC47B397-NC
- sensor chip.
-
- This driver can also be built as a module. If so, the module
- will be called smsc47b397.
-
-config SENSORS_SIS5595
- tristate "Silicon Integrated Systems Corp. SiS5595"
- depends on I2C && PCI && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get support for the integrated sensors in
- SiS5595 South Bridges.
-
- This driver can also be built as a module. If so, the module
- will be called sis5595.
-
-config SENSORS_SMSC47M1
- tristate "SMSC LPC47M10x and compatibles"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get support for the integrated fan
- monitoring and control capabilities of the SMSC LPC47B27x,
- LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.
-
- This driver can also be built as a module. If so, the module
- will be called smsc47m1.
-
-config SENSORS_VIA686A
- tristate "VIA686A"
- depends on I2C && PCI
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get support for the integrated sensors in
- Via 686A/B South Bridges.
-
- This driver can also be built as a module. If so, the module
- will be called via686a.
-
-config SENSORS_W83781D
- tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
- depends on I2C
- select I2C_SENSOR
- help
- If you say yes here you get support for the Winbond W8378x series
- of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
- and the similar Asus AS99127F.
-
- This driver can also be built as a module. If so, the module
- will be called w83781d.
-
-config SENSORS_W83L785TS
- tristate "Winbond W83L785TS-S"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- help
- If you say yes here you get support for the Winbond W83L785TS-S
- sensor chip, which is used on the Asus A7N8X, among other
- motherboards.
-
- This driver can also be built as a module. If so, the module
- will be called w83l785ts.
-
-config SENSORS_W83627HF
- tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get support for the Winbond W836X7 series
- of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
-
- This driver can also be built as a module. If so, the module
- will be called w83627hf.
-
-config SENSORS_W83627EHF
- tristate "Winbond W83627EHF"
- depends on I2C && EXPERIMENTAL
- select I2C_SENSOR
- select I2C_ISA
- help
- If you say yes here you get preliminary support for the hardware
- monitoring functionality of the Winbond W83627EHF Super-I/O chip.
- Only fan and temperature inputs are supported at the moment, while
- the chip does much more than that.
-
- This driver can also be built as a module. If so, the module
- will be called w83627ehf.
-
-endmenu
-
-menu "Other I2C Chip support"
+menu "Miscellaneous I2C Chip support"
depends on I2C
config SENSORS_DS1337
@@ -509,7 +112,6 @@ config TPS65010
This driver can also be built as a module. If so, the module
will be called tps65010.
-
config SENSORS_M41T00
tristate "ST M41T00 RTC chip"
depends on I2C && PPC32
@@ -520,13 +122,16 @@ config SENSORS_M41T00
will be called m41t00.
config SENSORS_MAX6875
- tristate "MAXIM MAX6875 Power supply supervisor"
+ tristate "Maxim MAX6875 Power supply supervisor"
depends on I2C && EXPERIMENTAL
help
- If you say yes here you get support for the MAX6875
- EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors.
+ If you say yes here you get support for the Maxim MAX6875
+ EEPROM-programmable, quad power-supply sequencer/supervisor.
+
+ This provides an interface to program the EEPROM and reset the chip.
- This provides a interface to program the EEPROM and reset the chip.
+ This driver also supports the Maxim MAX6874 hex power-supply
+ sequencer/supervisor if found at a compatible address.
This driver can also be built as a module. If so, the module
will be called max6875.
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index b5e6d2f84f9..a876dd42b86 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -1,52 +1,16 @@
#
-# Makefile for sensor and "other" I2C chip drivers.
+# Makefile for miscellaneous I2C chip drivers.
#
-# asb100, then w83781d go first, as they can override other drivers' addresses.
-obj-$(CONFIG_SENSORS_ASB100) += asb100.o
-obj-$(CONFIG_SENSORS_W83627HF) += w83627hf.o
-obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
-
-obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
-obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
-obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
-obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
-obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
-obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
obj-$(CONFIG_SENSORS_DS1337) += ds1337.o
obj-$(CONFIG_SENSORS_DS1374) += ds1374.o
-obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o
-obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
-obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
-obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
-obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
-obj-$(CONFIG_SENSORS_IT87) += it87.o
-obj-$(CONFIG_SENSORS_LM63) += lm63.o
-obj-$(CONFIG_SENSORS_LM75) += lm75.o
-obj-$(CONFIG_SENSORS_LM77) += lm77.o
-obj-$(CONFIG_SENSORS_LM78) += lm78.o
-obj-$(CONFIG_SENSORS_LM80) += lm80.o
-obj-$(CONFIG_SENSORS_LM83) += lm83.o
-obj-$(CONFIG_SENSORS_LM85) += lm85.o
-obj-$(CONFIG_SENSORS_LM87) += lm87.o
-obj-$(CONFIG_SENSORS_LM90) += lm90.o
-obj-$(CONFIG_SENSORS_LM92) += lm92.o
-obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
-obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
-obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
-obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
-obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
-obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
-obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
-obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
-
obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
obj-$(CONFIG_TPS65010) += tps65010.o
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index addf0adc24d..6ea413f6d5e 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -173,9 +173,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
| I2C_FUNC_SMBUS_BYTE))
goto exit;
- /* OK. For now, we presume we have a valid client. We now create the
- client structure, even though we cannot fill it completely yet.
- But it allows us to access eeprom_{read,write}_value. */
if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
err = -ENOMEM;
goto exit;
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 5e463c47bfb..778d7e12859 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -207,7 +207,7 @@ m41t00_detach(struct i2c_client *client)
int rc;
if ((rc = i2c_detach_client(client)) == 0) {
- kfree(i2c_get_clientdata(client));
+ kfree(client);
tasklet_kill(&m41t00_tasklet);
}
return rc;
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index fe6b150ec4c..c4f14d9623c 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -37,7 +37,8 @@
#include <linux/i2c-sensor.h>
/* Addresses to scan */
-static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END};
+/* No address scanned by default, as this could corrupt standard EEPROMS. */
+static unsigned short normal_i2c[] = {I2C_CLIENT_END};
static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
/* Insmod parameters */
@@ -369,6 +370,9 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
new_client->driver = &max6875_driver;
new_client->flags = 0;
+ /* Prevent 24RF08 corruption */
+ i2c_smbus_write_quick(new_client, 0);
+
/* Setup the user section */
data->blocks[max6875_eeprom_user].type = max6875_eeprom_user;
data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index c0ac01b6003..280e9638c0f 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#undef DEBUG
#include <linux/config.h>
#include <linux/kernel.h>
@@ -49,11 +48,7 @@
MODULE_DESCRIPTION("TPS6501x Power Management Driver");
MODULE_LICENSE("GPL");
-/* only two addresses possible */
-#define TPS_BASE 0x48
-static unsigned short normal_i2c[] = {
- TPS_BASE,
- I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { 0x48, /* 0x49, */ I2C_CLIENT_END };
static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
@@ -102,7 +97,7 @@ struct tps65010 {
u8 chgstatus, regstatus, chgconf;
u8 nmask1, nmask2;
- /* plus four GPIOs, probably used to switch power */
+ /* not currently tracking GPIO state */
};
#define POWER_POLL_DELAY msecs_to_jiffies(800)
@@ -135,7 +130,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus)
(regstatus & TPS_REG_COVER) ? " uncover" : "",
(regstatus & TPS_REG_UVLO) ? " UVLO" : "",
(regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "",
- (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "",
+ (regstatus & TPS_REG_PG_LD02) ? " ld02_bad" : "",
(regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "",
(regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "",
(regstatus & TPS_REG_PG_CORE) ? " core_bad" : "");
@@ -143,7 +138,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus)
static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig)
{
- char *hibit;
+ const char *hibit;
if (por)
hibit = (chgconfig & TPS_CHARGE_POR)
@@ -295,7 +290,7 @@ static int dbg_show(struct seq_file *s, void *_)
seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2);
for (i = 0; i < 4; i++) {
- if (value & (1 << (4 +i)))
+ if (value & (1 << (4 + i)))
seq_printf(s, " gpio%d-out %s\n", i + 1,
(value & (1 << i)) ? "low" : "hi ");
else
@@ -481,7 +476,7 @@ static int __exit tps65010_detach_client(struct i2c_client *client)
debugfs_remove(tps->file);
if (i2c_detach_client(client) == 0)
kfree(tps);
- the_tps = 0;
+ the_tps = NULL;
return 0;
}
@@ -514,7 +509,6 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
INIT_WORK(&tps->work, tps65010_work, tps);
tps->irq = -1;
tps->client.addr = address;
- i2c_set_clientdata(&tps->client, tps);
tps->client.adapter = bus;
tps->client.driver = &tps65010_driver;
strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE);
@@ -523,9 +517,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
if (status < 0) {
dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n",
DRIVER_NAME, address, status);
-fail1:
- kfree(tps);
- return 0;
+ goto fail1;
}
#ifdef CONFIG_ARM
@@ -535,7 +527,7 @@ fail1:
tps->irq = OMAP_GPIO_IRQ(58);
omap_request_gpio(58);
omap_set_gpio_direction(58, 1);
- omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE);
+ set_irq_type(tps->irq, IRQT_FALLING);
}
if (machine_is_omap_osk()) {
tps->model = TPS65010;
@@ -543,7 +535,7 @@ fail1:
tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1));
omap_request_gpio(OMAP_MPUIO(1));
omap_set_gpio_direction(OMAP_MPUIO(1), 1);
- omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE);
+ set_irq_type(tps->irq, IRQT_FALLING);
}
if (machine_is_omap_h3()) {
tps->model = TPS65013;
@@ -633,6 +625,9 @@ fail1:
tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
tps, DEBUG_FOPS);
return 0;
+fail1:
+ kfree(tps);
+ return 0;
}
static int __init tps65010_scan_bus(struct i2c_adapter *bus)
@@ -645,7 +640,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus)
static struct i2c_driver tps65010_driver = {
.owner = THIS_MODULE,
.name = "tps65010",
- .id = 888, /* FIXME assign "official" value */
.flags = I2C_DF_NOTIFY,
.attach_adapter = tps65010_scan_bus,
.detach_client = __exit_p(tps65010_detach_client),
@@ -744,7 +738,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
if (!the_tps)
return -ENODEV;
- if(led == LED1)
+ if (led == LED1)
offs = 0;
else {
offs = 2;
@@ -753,11 +747,13 @@ int tps65010_set_led(unsigned led, unsigned mode)
down(&the_tps->lock);
- dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,
- i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));
+ pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
+ i2c_smbus_read_byte_data(&the_tps->client,
+ TPS_LED1_ON + offs));
- dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,
- i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));
+ pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led,
+ i2c_smbus_read_byte_data(&the_tps->client,
+ TPS_LED1_PER + offs));
switch (mode) {
case OFF:
@@ -773,7 +769,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
led_per = 0x08 | (1 << 7);
break;
default:
- printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n",
+ printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
DRIVER_NAME);
up(&the_tps->lock);
return -EINVAL;
@@ -789,7 +785,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
return status;
}
- dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,
+ pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));
status = i2c_smbus_write_byte_data(&the_tps->client,
@@ -802,8 +798,9 @@ int tps65010_set_led(unsigned led, unsigned mode)
return status;
}
- dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,
- i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));
+ pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led,
+ i2c_smbus_read_byte_data(&the_tps->client,
+ TPS_LED1_PER + offs));
up(&the_tps->lock);
@@ -874,7 +871,7 @@ int tps65010_set_low_pwr(unsigned mode)
if (status != 0)
printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
- DRIVER_NAME);
+ DRIVER_NAME);
else
pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
@@ -900,14 +897,14 @@ int tps65010_config_vregs1(unsigned value)
down(&the_tps->lock);
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
- i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
status = i2c_smbus_write_byte_data(&the_tps->client,
TPS_VREGS1, value);
if (status != 0)
printk(KERN_ERR "%s: Failed to write vregs1 register\n",
- DRIVER_NAME);
+ DRIVER_NAME);
else
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
@@ -1009,7 +1006,7 @@ static int __init tps_init(void)
msleep(10);
}
-#if defined(CONFIG_ARM)
+#ifdef CONFIG_ARM
if (machine_is_omap_osk()) {
// FIXME: More should be placed in the initialization code
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 51ce268998c..4fd4f52c8e9 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -156,7 +156,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
goto out_unlock;
}
- res = idr_get_new(&i2c_adapter_idr, NULL, &id);
+ res = idr_get_new(&i2c_adapter_idr, adap, &id);
if (res < 0) {
if (res == -EAGAIN)
res = -ENOMEM;
@@ -765,20 +765,15 @@ int i2c_adapter_id(struct i2c_adapter *adap)
struct i2c_adapter* i2c_get_adapter(int id)
{
- struct list_head *item;
struct i2c_adapter *adapter;
down(&core_lists);
- list_for_each(item,&adapters) {
- adapter = list_entry(item, struct i2c_adapter, list);
- if (id == adapter->nr &&
- try_module_get(adapter->owner)) {
- up(&core_lists);
- return adapter;
- }
- }
+ adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
+ if (adapter && !try_module_get(adapter->owner))
+ adapter = NULL;
+
up(&core_lists);
- return NULL;
+ return adapter;
}
void i2c_put_adapter(struct i2c_adapter *adap)
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 0a31cfda08a..74af7e07486 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -431,7 +431,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
#if VERBOSE_IDE_CD_ERRORS
{
int i;
- const char *s;
+ const char *s = "bad sense key!";
char buf[80];
printk ("ATAPI device %s:\n", drive->name);
@@ -446,8 +446,6 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
if (sense->sense_key < ARY_LEN(sense_key_texts))
s = sense_key_texts[sense->sense_key];
- else
- s = "bad sense key!";
printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 0c1b8520ef8..785806bdb24 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -63,6 +63,7 @@ struct multipath {
unsigned nr_priority_groups;
struct list_head priority_groups;
unsigned pg_init_required; /* pg_init needs calling? */
+ unsigned pg_init_in_progress; /* Only one pg_init allowed at once */
unsigned nr_valid_paths; /* Total number of usable paths */
struct pgpath *current_pgpath;
@@ -72,7 +73,7 @@ struct multipath {
unsigned queue_io; /* Must we queue all I/O? */
unsigned queue_if_no_path; /* Queue I/O if last path fails? */
- unsigned suspended; /* Has dm core suspended our I/O? */
+ unsigned saved_queue_if_no_path;/* Saved state during suspension */
struct work_struct process_queued_ios;
struct bio_list queued_ios;
@@ -304,11 +305,12 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
m->queue_size--;
if ((pgpath && m->queue_io) ||
- (!pgpath && m->queue_if_no_path && !m->suspended)) {
+ (!pgpath && m->queue_if_no_path)) {
/* Queue for the daemon to resubmit */
bio_list_add(&m->queued_ios, bio);
m->queue_size++;
- if (m->pg_init_required || !m->queue_io)
+ if ((m->pg_init_required && !m->pg_init_in_progress) ||
+ !m->queue_io)
queue_work(kmultipathd, &m->process_queued_ios);
pgpath = NULL;
r = 0;
@@ -333,8 +335,9 @@ static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path)
spin_lock_irqsave(&m->lock, flags);
+ m->saved_queue_if_no_path = m->queue_if_no_path;
m->queue_if_no_path = queue_if_no_path;
- if (!m->queue_if_no_path)
+ if (!m->queue_if_no_path && m->queue_size)
queue_work(kmultipathd, &m->process_queued_ios);
spin_unlock_irqrestore(&m->lock, flags);
@@ -379,25 +382,31 @@ static void process_queued_ios(void *data)
{
struct multipath *m = (struct multipath *) data;
struct hw_handler *hwh = &m->hw_handler;
- struct pgpath *pgpath;
- unsigned init_required, must_queue = 0;
+ struct pgpath *pgpath = NULL;
+ unsigned init_required = 0, must_queue = 1;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
+ if (!m->queue_size)
+ goto out;
+
if (!m->current_pgpath)
__choose_pgpath(m);
pgpath = m->current_pgpath;
- if ((pgpath && m->queue_io) ||
- (!pgpath && m->queue_if_no_path && !m->suspended))
- must_queue = 1;
+ if ((pgpath && !m->queue_io) ||
+ (!pgpath && !m->queue_if_no_path))
+ must_queue = 0;
- init_required = m->pg_init_required;
- if (init_required)
+ if (m->pg_init_required && !m->pg_init_in_progress) {
m->pg_init_required = 0;
+ m->pg_init_in_progress = 1;
+ init_required = 1;
+ }
+out:
spin_unlock_irqrestore(&m->lock, flags);
if (init_required)
@@ -752,6 +761,8 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
static void multipath_dtr(struct dm_target *ti)
{
struct multipath *m = (struct multipath *) ti->private;
+
+ flush_workqueue(kmultipathd);
free_multipath(m);
}
@@ -765,6 +776,9 @@ static int multipath_map(struct dm_target *ti, struct bio *bio,
struct mpath_io *mpio;
struct multipath *m = (struct multipath *) ti->private;
+ if (bio_barrier(bio))
+ return -EOPNOTSUPP;
+
mpio = mempool_alloc(m->mpio_pool, GFP_NOIO);
dm_bio_record(&mpio->details, bio);
@@ -837,7 +851,7 @@ static int reinstate_path(struct pgpath *pgpath)
pgpath->path.is_active = 1;
m->current_pgpath = NULL;
- if (!m->nr_valid_paths++)
+ if (!m->nr_valid_paths++ && m->queue_size)
queue_work(kmultipathd, &m->process_queued_ios);
queue_work(kmultipathd, &m->trigger_event);
@@ -963,12 +977,13 @@ void dm_pg_init_complete(struct path *path, unsigned err_flags)
bypass_pg(m, pg, 1);
spin_lock_irqsave(&m->lock, flags);
- if (!err_flags)
- m->queue_io = 0;
- else {
+ if (err_flags) {
m->current_pgpath = NULL;
m->current_pg = NULL;
- }
+ } else if (!m->pg_init_required)
+ m->queue_io = 0;
+
+ m->pg_init_in_progress = 0;
queue_work(kmultipathd, &m->process_queued_ios);
spin_unlock_irqrestore(&m->lock, flags);
}
@@ -988,9 +1003,12 @@ static int do_end_io(struct multipath *m, struct bio *bio,
if ((error == -EWOULDBLOCK) && bio_rw_ahead(bio))
return error;
+ if (error == -EOPNOTSUPP)
+ return error;
+
spin_lock(&m->lock);
if (!m->nr_valid_paths) {
- if (!m->queue_if_no_path || m->suspended) {
+ if (!m->queue_if_no_path) {
spin_unlock(&m->lock);
return -EIO;
} else {
@@ -1051,27 +1069,27 @@ static int multipath_end_io(struct dm_target *ti, struct bio *bio,
/*
* Suspend can't complete until all the I/O is processed so if
- * the last path failed we will now error any queued I/O.
+ * the last path fails we must error any remaining I/O.
+ * Note that if the freeze_bdev fails while suspending, the
+ * queue_if_no_path state is lost - userspace should reset it.
*/
static void multipath_presuspend(struct dm_target *ti)
{
struct multipath *m = (struct multipath *) ti->private;
- unsigned long flags;
- spin_lock_irqsave(&m->lock, flags);
- m->suspended = 1;
- if (m->queue_if_no_path)
- queue_work(kmultipathd, &m->process_queued_ios);
- spin_unlock_irqrestore(&m->lock, flags);
+ queue_if_no_path(m, 0);
}
+/*
+ * Restore the queue_if_no_path setting.
+ */
static void multipath_resume(struct dm_target *ti)
{
struct multipath *m = (struct multipath *) ti->private;
unsigned long flags;
spin_lock_irqsave(&m->lock, flags);
- m->suspended = 0;
+ m->queue_if_no_path = m->saved_queue_if_no_path;
spin_unlock_irqrestore(&m->lock, flags);
}
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7e691ab9a74..ab54f99b7c3 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -777,7 +777,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
/* Full snapshots are not usable */
if (!s->valid)
- return -1;
+ return -EIO;
/*
* Write to snapshot - higher level takes care of RW/RO
@@ -931,6 +931,10 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
if (!snap->valid)
continue;
+ /* Nothing to do if writing beyond end of snapshot */
+ if (bio->bi_sector >= dm_table_get_size(snap->table))
+ continue;
+
down_write(&snap->lock);
/*
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 18e9b9953fc..a5a4c0ed8a1 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -943,6 +943,7 @@ EXPORT_SYMBOL(dm_vcalloc);
EXPORT_SYMBOL(dm_get_device);
EXPORT_SYMBOL(dm_put_device);
EXPORT_SYMBOL(dm_table_event);
+EXPORT_SYMBOL(dm_table_get_size);
EXPORT_SYMBOL(dm_table_get_mode);
EXPORT_SYMBOL(dm_table_put);
EXPORT_SYMBOL(dm_table_get);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index f6b03957efc..54fabbf0667 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -384,7 +384,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
/* error the io and bail out */
struct dm_io *io = tio->io;
free_tio(tio->io->md, tio);
- dec_pending(io, -EIO);
+ dec_pending(io, r);
bio_put(clone);
}
}
@@ -966,23 +966,20 @@ static void __flush_deferred_io(struct mapped_device *md, struct bio *c)
*/
int dm_swap_table(struct mapped_device *md, struct dm_table *table)
{
- int r;
+ int r = -EINVAL;
down_write(&md->lock);
/* device must be suspended */
- if (!test_bit(DMF_SUSPENDED, &md->flags)) {
- up_write(&md->lock);
- return -EPERM;
- }
+ if (!test_bit(DMF_SUSPENDED, &md->flags))
+ goto out;
__unbind(md);
r = __bind(md, table);
- if (r)
- return r;
+out:
up_write(&md->lock);
- return 0;
+ return r;
}
/*
@@ -1055,14 +1052,17 @@ int dm_suspend(struct mapped_device *md)
if (test_bit(DMF_BLOCK_IO, &md->flags))
goto out_read_unlock;
- error = __lock_fs(md);
- if (error)
- goto out_read_unlock;
-
map = dm_get_table(md);
if (map)
+ /* This does not get reverted if there's an error later. */
dm_table_presuspend_targets(map);
+ error = __lock_fs(md);
+ if (error) {
+ dm_table_put(map);
+ goto out_read_unlock;
+ }
+
up_read(&md->lock);
/*
@@ -1121,7 +1121,6 @@ int dm_suspend(struct mapped_device *md)
return 0;
out_unfreeze:
- /* FIXME Undo dm_table_presuspend_targets */
__unlock_fs(md);
clear_bit(DMF_BLOCK_IO, &md->flags);
out_write_unlock:
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index 4adb2843f8b..ab7a1fba442 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -1,5 +1,5 @@
/*
- * $Id: ir-common.c,v 1.10 2005/05/22 19:23:39 nsh Exp $
+ * $Id: ir-common.c,v 1.11 2005/07/07 14:44:43 mchehab Exp $
*
* some common structs and functions to handle infrared remotes via
* input layer ...
@@ -46,79 +46,49 @@ module_param(debug, int, 0644);
/* see http://users.pandora.be/nenya/electronics/rc5/codes00.htm */
/* used by old (black) Hauppauge remotes */
IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE] = {
- [ 0x00 ] = KEY_KP0, // 0
- [ 0x01 ] = KEY_KP1, // 1
- [ 0x02 ] = KEY_KP2, // 2
- [ 0x03 ] = KEY_KP3, // 3
- [ 0x04 ] = KEY_KP4, // 4
- [ 0x05 ] = KEY_KP5, // 5
- [ 0x06 ] = KEY_KP6, // 6
- [ 0x07 ] = KEY_KP7, // 7
- [ 0x08 ] = KEY_KP8, // 8
- [ 0x09 ] = KEY_KP9, // 9
-
- [ 0x0b ] = KEY_CHANNEL, // channel / program (japan: 11)
- [ 0x0c ] = KEY_POWER, // standby
- [ 0x0d ] = KEY_MUTE, // mute / demute
- [ 0x0f ] = KEY_TV, // display
- [ 0x10 ] = KEY_VOLUMEUP, // volume +
- [ 0x11 ] = KEY_VOLUMEDOWN, // volume -
- [ 0x12 ] = KEY_BRIGHTNESSUP, // brightness +
- [ 0x13 ] = KEY_BRIGHTNESSDOWN, // brightness -
- [ 0x1e ] = KEY_SEARCH, // search +
- [ 0x20 ] = KEY_CHANNELUP, // channel / program +
- [ 0x21 ] = KEY_CHANNELDOWN, // channel / program -
- [ 0x22 ] = KEY_CHANNEL, // alt / channel
- [ 0x23 ] = KEY_LANGUAGE, // 1st / 2nd language
- [ 0x26 ] = KEY_SLEEP, // sleeptimer
- [ 0x2e ] = KEY_MENU, // 2nd controls (USA: menu)
- [ 0x30 ] = KEY_PAUSE, // pause
- [ 0x32 ] = KEY_REWIND, // rewind
- [ 0x33 ] = KEY_GOTO, // go to
- [ 0x35 ] = KEY_PLAY, // play
- [ 0x36 ] = KEY_STOP, // stop
- [ 0x37 ] = KEY_RECORD, // recording
- [ 0x3c ] = KEY_TEXT, // teletext submode (Japan: 12)
- [ 0x3d ] = KEY_SUSPEND, // system standby
-
-#if 0 /* FIXME */
- [ 0x0a ] = KEY_RESERVED, // 1/2/3 digits (japan: 10)
- [ 0x0e ] = KEY_RESERVED, // P.P. (personal preference)
- [ 0x14 ] = KEY_RESERVED, // colour saturation +
- [ 0x15 ] = KEY_RESERVED, // colour saturation -
- [ 0x16 ] = KEY_RESERVED, // bass +
- [ 0x17 ] = KEY_RESERVED, // bass -
- [ 0x18 ] = KEY_RESERVED, // treble +
- [ 0x19 ] = KEY_RESERVED, // treble -
- [ 0x1a ] = KEY_RESERVED, // balance right
- [ 0x1b ] = KEY_RESERVED, // balance left
- [ 0x1c ] = KEY_RESERVED, // contrast +
- [ 0x1d ] = KEY_RESERVED, // contrast -
- [ 0x1f ] = KEY_RESERVED, // tint/hue +
- [ 0x24 ] = KEY_RESERVED, // spacial stereo on/off
- [ 0x25 ] = KEY_RESERVED, // mono / stereo (USA)
- [ 0x27 ] = KEY_RESERVED, // tint / hue -
- [ 0x28 ] = KEY_RESERVED, // RF switch/PIP select
- [ 0x29 ] = KEY_RESERVED, // vote
- [ 0x2a ] = KEY_RESERVED, // timed page/channel clck
- [ 0x2b ] = KEY_RESERVED, // increment (USA)
- [ 0x2c ] = KEY_RESERVED, // decrement (USA)
- [ 0x2d ] = KEY_RESERVED, //
- [ 0x2f ] = KEY_RESERVED, // PIP shift
- [ 0x31 ] = KEY_RESERVED, // erase
- [ 0x34 ] = KEY_RESERVED, // wind
- [ 0x38 ] = KEY_RESERVED, // external 1
- [ 0x39 ] = KEY_RESERVED, // external 2
- [ 0x3a ] = KEY_RESERVED, // PIP display mode
- [ 0x3b ] = KEY_RESERVED, // view data mode / advance
- [ 0x3e ] = KEY_RESERVED, // crispener on/off
- [ 0x3f ] = KEY_RESERVED, // system select
-#endif
+ /* Keys 0 to 9 */
+ [ 0x00 ] = KEY_KP0,
+ [ 0x01 ] = KEY_KP1,
+ [ 0x02 ] = KEY_KP2,
+ [ 0x03 ] = KEY_KP3,
+ [ 0x04 ] = KEY_KP4,
+ [ 0x05 ] = KEY_KP5,
+ [ 0x06 ] = KEY_KP6,
+ [ 0x07 ] = KEY_KP7,
+ [ 0x08 ] = KEY_KP8,
+ [ 0x09 ] = KEY_KP9,
+
+ [ 0x0b ] = KEY_CHANNEL, /* channel / program (japan: 11) */
+ [ 0x0c ] = KEY_POWER, /* standby */
+ [ 0x0d ] = KEY_MUTE, /* mute / demute */
+ [ 0x0f ] = KEY_TV, /* display */
+ [ 0x10 ] = KEY_VOLUMEUP,
+ [ 0x11 ] = KEY_VOLUMEDOWN,
+ [ 0x12 ] = KEY_BRIGHTNESSUP,
+ [ 0x13 ] = KEY_BRIGHTNESSDOWN,
+ [ 0x1e ] = KEY_SEARCH, /* search + */
+ [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
+ [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
+ [ 0x22 ] = KEY_CHANNEL, /* alt / channel */
+ [ 0x23 ] = KEY_LANGUAGE, /* 1st / 2nd language */
+ [ 0x26 ] = KEY_SLEEP, /* sleeptimer */
+ [ 0x2e ] = KEY_MENU, /* 2nd controls (USA: menu) */
+ [ 0x30 ] = KEY_PAUSE,
+ [ 0x32 ] = KEY_REWIND,
+ [ 0x33 ] = KEY_GOTO,
+ [ 0x35 ] = KEY_PLAY,
+ [ 0x36 ] = KEY_STOP,
+ [ 0x37 ] = KEY_RECORD, /* recording */
+ [ 0x3c ] = KEY_TEXT, /* teletext submode (Japan: 12) */
+ [ 0x3d ] = KEY_SUSPEND, /* system standby */
+
};
EXPORT_SYMBOL_GPL(ir_codes_rc5_tv);
/* Table for Leadtek Winfast Remote Controls - used by both bttv and cx88 */
IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
+ /* Keys 0 to 9 */
+ [ 18 ] = KEY_KP0,
[ 5 ] = KEY_KP1,
[ 6 ] = KEY_KP2,
[ 7 ] = KEY_KP3,
@@ -128,39 +98,31 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
[ 13 ] = KEY_KP7,
[ 14 ] = KEY_KP8,
[ 15 ] = KEY_KP9,
- [ 18 ] = KEY_KP0,
[ 0 ] = KEY_POWER,
-// [ 27 ] = MTS button
- [ 2 ] = KEY_TUNER, // TV/FM
+ [ 2 ] = KEY_TUNER, /* TV/FM */
[ 30 ] = KEY_VIDEO,
-// [ 22 ] = display button
[ 4 ] = KEY_VOLUMEUP,
[ 8 ] = KEY_VOLUMEDOWN,
[ 12 ] = KEY_CHANNELUP,
[ 16 ] = KEY_CHANNELDOWN,
- [ 3 ] = KEY_ZOOM, // fullscreen
- [ 31 ] = KEY_SUBTITLE, // closed caption/teletext
+ [ 3 ] = KEY_ZOOM, /* fullscreen */
+ [ 31 ] = KEY_SUBTITLE, /* closed caption/teletext */
[ 32 ] = KEY_SLEEP,
-// [ 41 ] = boss key
[ 20 ] = KEY_MUTE,
[ 43 ] = KEY_RED,
[ 44 ] = KEY_GREEN,
[ 45 ] = KEY_YELLOW,
[ 46 ] = KEY_BLUE,
- [ 24 ] = KEY_KPPLUS, //fine tune +
- [ 25 ] = KEY_KPMINUS, //fine tune -
-// [ 42 ] = picture in picture
+ [ 24 ] = KEY_KPPLUS, /* fine tune + */
+ [ 25 ] = KEY_KPMINUS, /* fine tune - */
[ 33 ] = KEY_KPDOT,
[ 19 ] = KEY_KPENTER,
-// [ 17 ] = recall
[ 34 ] = KEY_BACK,
[ 35 ] = KEY_PLAYPAUSE,
[ 36 ] = KEY_NEXT,
-// [ 37 ] = time shifting
[ 38 ] = KEY_STOP,
[ 39 ] = KEY_RECORD
-// [ 40 ] = snapshot
};
EXPORT_SYMBOL_GPL(ir_codes_winfast);
@@ -174,54 +136,61 @@ EXPORT_SYMBOL_GPL(ir_codes_empty);
* slightly different versions), shipped with cx88+ivtv cards.
* almost rc5 coding, but some non-standard keys */
IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE] = {
- [ 0x00 ] = KEY_KP0, // 0
- [ 0x01 ] = KEY_KP1, // 1
- [ 0x02 ] = KEY_KP2, // 2
- [ 0x03 ] = KEY_KP3, // 3
- [ 0x04 ] = KEY_KP4, // 4
- [ 0x05 ] = KEY_KP5, // 5
- [ 0x06 ] = KEY_KP6, // 6
- [ 0x07 ] = KEY_KP7, // 7
- [ 0x08 ] = KEY_KP8, // 8
- [ 0x09 ] = KEY_KP9, // 9
- [ 0x0a ] = KEY_TEXT, // keypad asterisk as well
- [ 0x0b ] = KEY_RED, // red button
- [ 0x0c ] = KEY_RADIO, // radio
- [ 0x0d ] = KEY_MENU, // menu
- [ 0x0e ] = KEY_SUBTITLE, // also the # key
- [ 0x0f ] = KEY_MUTE, // mute
- [ 0x10 ] = KEY_VOLUMEUP, // volume +
- [ 0x11 ] = KEY_VOLUMEDOWN, // volume -
- [ 0x12 ] = KEY_PREVIOUS, // previous channel
- [ 0x14 ] = KEY_UP, // up
- [ 0x15 ] = KEY_DOWN, // down
- [ 0x16 ] = KEY_LEFT, // left
- [ 0x17 ] = KEY_RIGHT, // right
- [ 0x18 ] = KEY_VIDEO, // Videos
- [ 0x19 ] = KEY_AUDIO, // Music
- [ 0x1a ] = KEY_MHP, // Pictures - presume this means "Multimedia Home Platform"- no "PICTURES" key in input.h
- [ 0x1b ] = KEY_EPG, // Guide
- [ 0x1c ] = KEY_TV, // TV
- [ 0x1e ] = KEY_NEXTSONG, // skip >|
- [ 0x1f ] = KEY_EXIT, // back/exit
- [ 0x20 ] = KEY_CHANNELUP, // channel / program +
- [ 0x21 ] = KEY_CHANNELDOWN, // channel / program -
- [ 0x22 ] = KEY_CHANNEL, // source (old black remote)
- [ 0x24 ] = KEY_PREVIOUSSONG, // replay |<
- [ 0x25 ] = KEY_ENTER, // OK
- [ 0x26 ] = KEY_SLEEP, // minimize (old black remote)
- [ 0x29 ] = KEY_BLUE, // blue key
- [ 0x2e ] = KEY_GREEN, // green button
- [ 0x30 ] = KEY_PAUSE, // pause
- [ 0x32 ] = KEY_REWIND, // backward <<
- [ 0x34 ] = KEY_FASTFORWARD, // forward >>
- [ 0x35 ] = KEY_PLAY, // play
- [ 0x36 ] = KEY_STOP, // stop
- [ 0x37 ] = KEY_RECORD, // recording
- [ 0x38 ] = KEY_YELLOW, // yellow key
- [ 0x3b ] = KEY_SELECT, // top right button
- [ 0x3c ] = KEY_ZOOM, // full
- [ 0x3d ] = KEY_POWER, // system power (green button)
+ /* Keys 0 to 9 */
+ [ 0x00 ] = KEY_KP0,
+ [ 0x01 ] = KEY_KP1,
+ [ 0x02 ] = KEY_KP2,
+ [ 0x03 ] = KEY_KP3,
+ [ 0x04 ] = KEY_KP4,
+ [ 0x05 ] = KEY_KP5,
+ [ 0x06 ] = KEY_KP6,
+ [ 0x07 ] = KEY_KP7,
+ [ 0x08 ] = KEY_KP8,
+ [ 0x09 ] = KEY_KP9,
+
+ [ 0x0a ] = KEY_TEXT, /* keypad asterisk as well */
+ [ 0x0b ] = KEY_RED, /* red button */
+ [ 0x0c ] = KEY_RADIO,
+ [ 0x0d ] = KEY_MENU,
+ [ 0x0e ] = KEY_SUBTITLE, /* also the # key */
+ [ 0x0f ] = KEY_MUTE,
+ [ 0x10 ] = KEY_VOLUMEUP,
+ [ 0x11 ] = KEY_VOLUMEDOWN,
+ [ 0x12 ] = KEY_PREVIOUS, /* previous channel */
+ [ 0x14 ] = KEY_UP,
+ [ 0x15 ] = KEY_DOWN,
+ [ 0x16 ] = KEY_LEFT,
+ [ 0x17 ] = KEY_RIGHT,
+ [ 0x18 ] = KEY_VIDEO, /* Videos */
+ [ 0x19 ] = KEY_AUDIO, /* Music */
+ /* 0x1a: Pictures - presume this means
+ "Multimedia Home Platform" -
+ no "PICTURES" key in input.h
+ */
+ [ 0x1a ] = KEY_MHP,
+
+ [ 0x1b ] = KEY_EPG, /* Guide */
+ [ 0x1c ] = KEY_TV,
+ [ 0x1e ] = KEY_NEXTSONG, /* skip >| */
+ [ 0x1f ] = KEY_EXIT, /* back/exit */
+ [ 0x20 ] = KEY_CHANNELUP, /* channel / program + */
+ [ 0x21 ] = KEY_CHANNELDOWN, /* channel / program - */
+ [ 0x22 ] = KEY_CHANNEL, /* source (old black remote) */
+ [ 0x24 ] = KEY_PREVIOUSSONG, /* replay |< */
+ [ 0x25 ] = KEY_ENTER, /* OK */
+ [ 0x26 ] = KEY_SLEEP, /* minimize (old black remote) */
+ [ 0x29 ] = KEY_BLUE, /* blue key */
+ [ 0x2e ] = KEY_GREEN, /* green button */
+ [ 0x30 ] = KEY_PAUSE, /* pause */
+ [ 0x32 ] = KEY_REWIND, /* backward << */
+ [ 0x34 ] = KEY_FASTFORWARD, /* forward >> */
+ [ 0x35 ] = KEY_PLAY,
+ [ 0x36 ] = KEY_STOP,
+ [ 0x37 ] = KEY_RECORD, /* recording */
+ [ 0x38 ] = KEY_YELLOW, /* yellow key */
+ [ 0x3b ] = KEY_SELECT, /* top right button */
+ [ 0x3c ] = KEY_ZOOM, /* full */
+ [ 0x3d ] = KEY_POWER, /* system power (green button) */
};
EXPORT_SYMBOL(ir_codes_hauppauge_new);
@@ -237,9 +206,9 @@ IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
[ 10 ] = KEY_KP8,
[ 18 ] = KEY_KP9,
- [ 3 ] = KEY_TUNER, // TV/FM
- [ 7 ] = KEY_SEARCH, // scan
- [ 28 ] = KEY_ZOOM, // full screen
+ [ 3 ] = KEY_TUNER, /* TV/FM */
+ [ 7 ] = KEY_SEARCH, /* scan */
+ [ 28 ] = KEY_ZOOM, /* full screen */
[ 30 ] = KEY_POWER,
[ 23 ] = KEY_VOLUMEDOWN,
[ 31 ] = KEY_VOLUMEUP,
@@ -247,14 +216,14 @@ IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = {
[ 22 ] = KEY_CHANNELUP,
[ 24 ] = KEY_MUTE,
- [ 0 ] = KEY_LIST, // source
- [ 19 ] = KEY_INFO, // loop
- [ 16 ] = KEY_LAST, // +100
- [ 13 ] = KEY_CLEAR, // reset
- [ 12 ] = BTN_RIGHT, // fun++
- [ 4 ] = BTN_LEFT, // fun--
- [ 14 ] = KEY_GOTO, // function
- [ 15 ] = KEY_STOP, // freeze
+ [ 0 ] = KEY_LIST, /* source */
+ [ 19 ] = KEY_INFO, /* loop */
+ [ 16 ] = KEY_LAST, /* +100 */
+ [ 13 ] = KEY_CLEAR, /* reset */
+ [ 12 ] = BTN_RIGHT, /* fun++ */
+ [ 4 ] = BTN_LEFT, /* fun-- */
+ [ 14 ] = KEY_GOTO, /* function */
+ [ 15 ] = KEY_STOP, /* freeze */
};
EXPORT_SYMBOL(ir_codes_pixelview);
@@ -321,10 +290,6 @@ void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
ir->keypressed = 1;
ir_input_key_event(dev,ir);
}
-#if 0
- /* maybe do something like this ??? */
- input_event(a, EV_IR, ir->ir_type, ir->ir_raw);
-#endif
}
/* -------------------------------------------------------------------------- */
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 9bd12832e3d..07a0b0a968a 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -928,7 +928,7 @@ static int dst_get_signal(struct dst_state* state)
{
int retval;
u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
- printk("%s: Getting Signal strength and other parameters !!!!!!!!\n", __FUNCTION__);
+ dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
state->decode_lock = state->decode_strength = state->decode_snr = 0;
return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index bdd72f77970..3491ff40885 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -175,7 +175,7 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
int dvb_usb_fe_init(struct dvb_usb_device* d)
{
if (d->props.frontend_attach == NULL) {
- err("strange '%s' don't want to attach a frontend.",d->desc->name);
+ err("strange '%s' doesn't want to attach a frontend.",d->desc->name);
return 0;
}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index c3b3ae4f3ec..65f0c095abc 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -51,17 +51,17 @@ static int dvb_usb_init(struct dvb_usb_device *d)
/* speed - when running at FULL speed we need a HW PID filter */
if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) {
- err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a HW PID filter)");
+ err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)");
return -ENODEV;
}
if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) ||
(d->props.caps & DVB_USB_NEED_PID_FILTERING)) {
- info("will use the device's hw PID filter.");
+ info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count);
d->pid_filtering = 1;
d->max_feed_count = d->props.pid_filter_count;
} else {
- info("will pass the complete MPEG2 transport stream to the demuxer.");
+ info("will pass the complete MPEG2 transport stream to the software demuxer.");
d->pid_filtering = 0;
d->max_feed_count = 255;
}
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 5adc5d69ec8..9ac95f54f9f 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -128,7 +128,7 @@ static struct dvb_usb_rc_key vp7045_rc_keys[] = {
{ 0x00, 0x0f, KEY_TEXT } /* Teletext */
};
-static int vp7045_rc_query(struct dvb_usb_device *d, u32 *key_buf, int *state)
+static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
{
u8 key;
int i;
@@ -144,7 +144,7 @@ static int vp7045_rc_query(struct dvb_usb_device *d, u32 *key_buf, int *state)
for (i = 0; i < sizeof(vp7045_rc_keys)/sizeof(struct dvb_usb_rc_key); i++)
if (vp7045_rc_keys[i].data == key) {
*state = REMOTE_KEY_PRESSED;
- *key_buf = vp7045_rc_keys[i].event;
+ *event = vp7045_rc_keys[i].event;
break;
}
return 0;
diff --git a/drivers/media/dvb/frontends/lgdt3302.c b/drivers/media/dvb/frontends/lgdt3302.c
index 09c914256e4..2eea03d218c 100644
--- a/drivers/media/dvb/frontends/lgdt3302.c
+++ b/drivers/media/dvb/frontends/lgdt3302.c
@@ -1,6 +1,4 @@
/*
- * $Id: lgdt3302.c,v 1.5 2005/07/07 03:47:15 mkrufky Exp $
- *
* Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
*
* Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
@@ -83,7 +81,10 @@ static int i2c_writebytes (struct lgdt3302_state* state,
if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
- return -EREMOTEIO;
+ if (err < 0)
+ return err;
+ else
+ return -EREMOTEIO;
}
} else {
u8 tmp[] = { buf[0], buf[1] };
@@ -96,7 +97,10 @@ static int i2c_writebytes (struct lgdt3302_state* state,
tmp[1] = buf[i];
if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
- return -EREMOTEIO;
+ if (err < 0)
+ return err;
+ else
+ return -EREMOTEIO;
}
tmp[0]++;
}
@@ -218,6 +222,8 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
/* Change only if we are actually changing the modulation */
if (state->current_modulation != param->u.vsb.modulation) {
+ int value;
+
switch(param->u.vsb.modulation) {
case VSB_8:
dprintk("%s: VSB_8 MODE\n", __FUNCTION__);
@@ -266,36 +272,29 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
i2c_writebytes(state, state->config->demod_address,
demux_ctrl_cfg, sizeof(demux_ctrl_cfg));
- if (param->u.vsb.modulation == VSB_8) {
- /* Initialization for VSB modes only */
- /* Change the value of NCOCTFV[25:0]of carrier
- recovery center frequency register for VSB */
- i2c_writebytes(state, state->config->demod_address,
+ /* Change the value of NCOCTFV[25:0] of carrier
+ recovery center frequency register */
+ i2c_writebytes(state, state->config->demod_address,
vsb_freq_cfg, sizeof(vsb_freq_cfg));
- } else {
- /* Initialization for QAM modes only */
- /* Set the value of 'INLVTHD' register 0x2a/0x2c
- to value from 'IFACC' register 0x39/0x3b -1 */
- int value;
- i2c_selectreadbytes(state, AGC_RFIF_ACC0,
- &agc_delay_cfg[1], 3);
- value = ((agc_delay_cfg[1] & 0x0f) << 8) | agc_delay_cfg[3];
- value = value -1;
- dprintk("%s IFACC -1 = 0x%03x\n", __FUNCTION__, value);
- agc_delay_cfg[1] = (value >> 8) & 0x0f;
- agc_delay_cfg[2] = 0x00;
- agc_delay_cfg[3] = value & 0xff;
- i2c_writebytes(state, state->config->demod_address,
- agc_delay_cfg, sizeof(agc_delay_cfg));
-
- /* Change the value of IAGCBW[15:8]
- of inner AGC loop filter bandwith */
- i2c_writebytes(state, state->config->demod_address,
- agc_loop_cfg, sizeof(agc_loop_cfg));
- }
+ /* Set the value of 'INLVTHD' register 0x2a/0x2c
+ to value from 'IFACC' register 0x39/0x3b -1 */
+ i2c_selectreadbytes(state, AGC_RFIF_ACC0,
+ &agc_delay_cfg[1], 3);
+ value = ((agc_delay_cfg[1] & 0x0f) << 8) | agc_delay_cfg[3];
+ value = value -1;
+ dprintk("%s IFACC -1 = 0x%03x\n", __FUNCTION__, value);
+ agc_delay_cfg[1] = (value >> 8) & 0x0f;
+ agc_delay_cfg[2] = 0x00;
+ agc_delay_cfg[3] = value & 0xff;
+ i2c_writebytes(state, state->config->demod_address,
+ agc_delay_cfg, sizeof(agc_delay_cfg));
+
+ /* Change the value of IAGCBW[15:8]
+ of inner AGC loop filter bandwith */
+ i2c_writebytes(state, state->config->demod_address,
+ agc_loop_cfg, sizeof(agc_loop_cfg));
state->config->set_ts_params(fe, 0);
- lgdt3302_SwReset(state);
state->current_modulation = param->u.vsb.modulation;
}
@@ -311,11 +310,10 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
i2c_readbytes(state, state->config->pll_address, buf, 1);
dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
- lgdt3302_SwReset(state);
-
/* Update current frequency */
state->current_frequency = param->frequency;
}
+ lgdt3302_SwReset(state);
return 0;
}
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index b65f4b0a481..9746d2bb916 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1022,7 +1022,7 @@ static struct pci_device_id pci_tbl[] = {
MODULE_DEVICE_TABLE(pci, pci_tbl);
static struct saa7146_extension budget_extension = {
- .name = "budget dvb /w video in\0",
+ .name = "budget_av",
.pci_tbl = pci_tbl,
.module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 2c17a5f5834..aa43b5fcb8e 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1626,7 +1626,7 @@ static struct usb_device_id ttusb_table[] = {
MODULE_DEVICE_TABLE(usb, ttusb_table);
static struct usb_driver ttusb_driver = {
- .name = "Technotrend/Hauppauge USB-Nova",
+ .name = "ttusb",
.probe = ttusb_probe,
.disconnect = ttusb_disconnect,
.id_table = ttusb_table,
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index e771064689e..f461750c764 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -7,19 +7,6 @@ menu "Video For Linux"
comment "Video Adapters"
-config TUNER_MULTI_I2C
- bool "Enable support for multiple I2C devices on Video Adapters (EXPERIMENTAL)"
- depends on VIDEO_DEV && EXPERIMENTAL
- ---help---
- Some video adapters have more than one tuner inside. This patch
- enables support for using more than one tuner. This is required
- for some cards to allow tunning both video and radio.
- It also improves I2C autodetection for these cards.
-
- Only few tuners currently is supporting this. More to come.
-
- It is safe to say 'Y' here even if your card has only one I2C tuner.
-
config VIDEO_BT848
tristate "BT848 Video For Linux"
depends on VIDEO_DEV && PCI && I2C
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index 9a642c7de54..a070417e65e 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -138,25 +138,13 @@ int bt832_init(struct i2c_client *i2c_client_s)
bt832_hexdump(i2c_client_s,buf);
-#if 0
- // Full 30/25 Frame rate
- printk("Full 30/25 Frame rate\n");
- buf[0]=BT832_VP_CONTROL0; // Reg.39
- buf[1]= 0x00;
- if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
- printk("bt832: i2c i/o error FFR: rc == %d (should be 2)\n",rc);
-
- bt832_hexdump(i2c_client_s,buf);
-#endif
-#if 1
// for testing (even works when no camera attached)
printk("bt832: *** Generate NTSC M Bars *****\n");
buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42
buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally
if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc);
-#endif
printk("Bt832: Camera Present: %s\n",
(buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no");
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 251092e7f19..2dbf5ec43ab 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -1,5 +1,5 @@
/*
- $Id: bttv-cards.c,v 1.49 2005/06/10 17:20:24 mchehab Exp $
+ $Id: bttv-cards.c,v 1.53 2005/07/05 17:37:35 nsh Exp $
bttv-cards.c
@@ -39,9 +39,6 @@
#include <asm/io.h>
#include "bttvp.h"
-#if 0 /* not working yet */
-#include "bt832.h"
-#endif
/* fwd decl */
static void boot_msp34xx(struct bttv *btv, int pin);
@@ -513,13 +510,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x01fe00,
.muxsel = { 2, 3, 1, 1},
-#if 0
- // old
- .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
-#else
// 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru>
.audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
-#endif
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -766,14 +758,9 @@ struct tvcard bttv_tvcards[] = {
.tuner = 0,
.svhs = 2,
.muxsel = { 2, 3, 1, 1, 0}, // TV, CVid, SVid, CVid over SVid connector
-#if 0
- .gpiomask = 0xc33000,
- .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
-#else
/* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
.gpiomask = 0xb33000,
.audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 },
-#endif
/* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
gpio23 -- hef4052:nEnable (0x800000)
gpio12 -- hef4052:A1
@@ -1603,20 +1590,11 @@ struct tvcard bttv_tvcards[] = {
.video_inputs = 4,
.audio_inputs = 1,
.tuner = -1,
-#if 0 /* TODO ... */
- .svhs = OSPREY540_SVID_ANALOG,
- .muxsel = { [OSPREY540_COMP_ANALOG] = 2,
- [OSPREY540_SVID_ANALOG] = 3, },
-#endif
.pll = PLL_28,
.tuner_type = -1,
.no_msp34xx = 1,
.no_tda9875 = 1,
.no_tda7432 = 1,
-#if 0 /* TODO ... */
- .muxsel_hook = osprey_540_muxsel,
- .picture_hook = osprey_540_set_picture,
-#endif
},{
/* ---- card 0x5C ---------------------------------- */
@@ -2546,21 +2524,12 @@ static void eagle_muxsel(struct bttv *btv, unsigned int input)
btaor((2)<<5, ~(3<<5), BT848_IFORM);
gpio_bits(3,bttv_tvcards[btv->c.type].muxsel[input&7]);
-#if 0
- /* svhs */
- /* wake chroma ADC */
- btand(~BT848_ADC_C_SLEEP, BT848_ADC);
- /* set to YC video */
- btor(BT848_CONTROL_COMP, BT848_E_CONTROL);
- btor(BT848_CONTROL_COMP, BT848_O_CONTROL);
-#else
/* composite */
/* set chroma ADC to sleep */
btor(BT848_ADC_C_SLEEP, BT848_ADC);
/* set to composite video */
btand(~BT848_CONTROL_COMP, BT848_E_CONTROL);
btand(~BT848_CONTROL_COMP, BT848_O_CONTROL);
-#endif
/* switch sync drive off */
gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE);
@@ -2813,10 +2782,18 @@ void __devinit bttv_init_card2(struct bttv *btv)
btv->tuner_type = tuner[btv->c.nr];
printk("bttv%d: using tuner=%d\n",btv->c.nr,btv->tuner_type);
if (btv->pinnacle_id != UNSET)
- bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
+ bttv_call_i2c_clients(btv, AUDC_CONFIG_PINNACLE,
&btv->pinnacle_id);
- if (btv->tuner_type != UNSET)
- bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
+ if (btv->tuner_type != UNSET) {
+ struct tuner_setup tun_setup;
+
+ tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
+ tun_setup.type = btv->tuner_type;
+ tun_setup.addr = ADDR_UNSET;
+
+ bttv_call_i2c_clients(btv, TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
+
btv->svhs = bttv_tvcards[btv->c.type].svhs;
if (svhs[btv->c.nr] != UNSET)
btv->svhs = svhs[btv->c.nr];
@@ -3125,14 +3102,6 @@ static int tuner_0_table[] = {
TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM,
TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL,
TUNER_PHILIPS_FM1216ME_MK3 };
-#if 0
-int tuner_0_fm_table[] = {
- PHILIPS_FR1236_NTSC, PHILIPS_FR1216_PAL,
- PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
- PHILIPS_FR1216_PAL, PHILIPS_FR1216_PAL,
- PHILIPS_FR1236_SECAM, PHILIPS_FR1236_SECAM,
- PHILIPS_FR1236_SECAM, PHILIPS_FR1216_PAL};
-#endif
static int tuner_1_table[] = {
TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL,
@@ -3218,36 +3187,6 @@ static void __devinit boot_msp34xx(struct bttv *btv, int pin)
static void __devinit boot_bt832(struct bttv *btv)
{
-#if 0 /* not working yet */
- int resetbit=0;
-
- switch (btv->c.type) {
- case BTTV_PXELVWPLTVPAK:
- resetbit = 0x400000;
- break;
- case BTTV_MODTEC_205:
- resetbit = 1<<9;
- break;
- default:
- BUG();
- }
-
- request_module("bt832");
- bttv_call_i2c_clients(btv, BT832_HEXDUMP, NULL);
-
- printk("bttv%d: Reset Bt832 [line=0x%x]\n",btv->c.nr,resetbit);
- gpio_write(0);
- gpio_inout(resetbit, resetbit);
- udelay(5);
- gpio_bits(resetbit, resetbit);
- udelay(5);
- gpio_bits(resetbit, 0);
- udelay(5);
-
- // bt832 on pixelview changes from i2c 0x8a to 0x88 after
- // being reset as above. So we must follow by this:
- bttv_call_i2c_clients(btv, BT832_REATTACH, NULL);
-#endif
}
/* ----------------------------------------------------------------------- */
@@ -3572,11 +3511,6 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq)
{
dprintk("tea5757_set_freq %d\n",freq);
tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */
-#if 0
- /* breaks Miro PCTV */
- value = tea5757_read(btv);
- dprintk("bttv%d: tea5757 readback=0x%x\n",btv->c.nr,value);
-#endif
}
@@ -3656,13 +3590,8 @@ gvbctv5pci_audio(struct bttv *btv, struct video_audio *v, int set)
{
unsigned int val, con;
-#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
if (btv->radio_user)
return;
-#else
- if (btv->radio)
- return;
-#endif
val = gpio_read();
if (set) {
@@ -3851,13 +3780,8 @@ pvbt878p9b_audio(struct bttv *btv, struct video_audio *v, int set)
{
unsigned int val = 0;
-#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
if (btv->radio_user)
return;
-#else
- if (btv->radio)
- return;
-#endif
if (set) {
if (v->mode & VIDEO_SOUND_MONO) {
@@ -3888,13 +3812,8 @@ fv2000s_audio(struct bttv *btv, struct video_audio *v, int set)
{
unsigned int val = 0xffff;
-#if BTTV_VERSION_CODE > KERNEL_VERSION(0,8,0)
if (btv->radio_user)
return;
-#else
- if (btv->radio)
- return;
-#endif
if (set) {
if (v->mode & VIDEO_SOUND_MONO) {
val = 0x0000;
@@ -4371,11 +4290,6 @@ void __devinit bttv_check_chipset(void)
latency = 0x0A;
#endif
-#if 0
- /* print which chipset we have */
- while ((dev = pci_find_class(PCI_CLASS_BRIDGE_HOST << 8,dev)))
- printk(KERN_INFO "bttv: Host bridge is %s\n",pci_name(dev));
-#endif
/* print warnings about any quirks found */
if (triton1)
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 7d62b394c50..51a0f6d68e7 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -1,5 +1,5 @@
/*
- $Id: bttv-driver.c,v 1.40 2005/06/16 21:38:45 nsh Exp $
+ $Id: bttv-driver.c,v 1.42 2005/07/05 17:37:35 nsh Exp $
bttv - Bt848 frame grabber driver
@@ -35,6 +35,7 @@
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/kdev_t.h>
+#include <linux/dma-mapping.h>
#include <asm/io.h>
#include <asm/byteorder.h>
@@ -698,12 +699,10 @@ int locked_btres(struct bttv *btv, int bit)
static
void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits)
{
-#if 1 /* DEBUG */
if ((fh->resources & bits) != bits) {
/* trying to free ressources not allocated by us ... */
printk("bttv: BUG! (btres)\n");
}
-#endif
down(&btv->reslock);
fh->resources &= ~bits;
btv->resources &= ~bits;
@@ -943,11 +942,6 @@ audio_mux(struct bttv *btv, int mode)
i2c_mux = mux = (btv->audio & AUDIO_MUTE) ? AUDIO_OFF : btv->audio;
if (btv->opt_automute && !signal && !btv->radio_user)
mux = AUDIO_OFF;
-#if 0
- printk("bttv%d: amux: mode=%d audio=%d signal=%s mux=%d/%d irq=%s\n",
- btv->c.nr, mode, btv->audio, signal ? "yes" : "no",
- mux, i2c_mux, in_interrupt() ? "yes" : "no");
-#endif
val = bttv_tvcards[btv->c.type].audiomux[mux];
gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val);
@@ -994,11 +988,6 @@ set_tvnorm(struct bttv *btv, unsigned int norm)
case BTTV_VOODOOTV_FM:
bttv_tda9880_setnorm(btv,norm);
break;
-#if 0
- case BTTV_OSPREY540:
- osprey_540_set_norm(btv,norm);
- break;
-#endif
}
return 0;
}
@@ -1849,7 +1838,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
if (unlikely(f->tuner != 0))
return -EINVAL;
- if (unlikely(f->type != V4L2_TUNER_ANALOG_TV))
+ if (unlikely (f->type != V4L2_TUNER_ANALOG_TV))
return -EINVAL;
down(&btv->lock);
btv->freq = f->frequency;
@@ -3865,7 +3854,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
btv->c.nr);
return -EIO;
}
- if (pci_set_dma_mask(dev, 0xffffffff)) {
+ if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
printk(KERN_WARNING "bttv%d: No suitable DMA available.\n",
btv->c.nr);
return -EIO;
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index da448a5f9e9..234a8556376 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -1,5 +1,5 @@
/*
- $Id: bttv-i2c.c,v 1.21 2005/06/10 17:20:24 mchehab Exp $
+ $Id: bttv-i2c.c,v 1.25 2005/07/05 17:37:35 nsh Exp $
bttv-i2c.c -- all the i2c code is here
@@ -295,14 +295,26 @@ static int attach_inform(struct i2c_client *client)
{
struct bttv *btv = i2c_get_adapdata(client->adapter);
- if (btv->tuner_type != UNSET)
- bttv_call_i2c_clients(btv,TUNER_SET_TYPE,&btv->tuner_type);
+ if (bttv_debug)
+ printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
+ btv->c.nr,client->driver->name,client->addr,
+ i2c_clientname(client));
+ if (!client->driver->command)
+ return 0;
+
+ if (btv->tuner_type != UNSET) {
+ struct tuner_setup tun_setup;
+
+ tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
+ tun_setup.type = btv->tuner_type;
+ tun_setup.addr = ADDR_UNSET;
+
+ client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
+
if (btv->pinnacle_id != UNSET)
- bttv_call_i2c_clients(btv,AUDC_CONFIG_PINNACLE,
+ client->driver->command(client,AUDC_CONFIG_PINNACLE,
&btv->pinnacle_id);
- if (bttv_debug)
- printk("bttv%d: i2c attach [client=%s]\n",
- btv->c.nr, i2c_clientname(client));
return 0;
}
diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bttv-risc.c
index bdc5ce6c43b..9ed21fd190c 100644
--- a/drivers/media/video/bttv-risc.c
+++ b/drivers/media/video/bttv-risc.c
@@ -334,10 +334,6 @@ bttv_calc_geo(struct bttv *btv, struct bttv_geometry *geo,
}
vdelay = tvnorm->vdelay;
-#if 0 /* FIXME */
- if (vdelay < btv->vbi.lines*2)
- vdelay = btv->vbi.lines*2;
-#endif
xsf = (width*scaledtwidth)/swidth;
geo->hscale = ((totalwidth*4096UL)/xsf-4096);
@@ -776,13 +772,8 @@ bttv_overlay_risc(struct bttv *btv,
bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0);
break;
case V4L2_FIELD_INTERLACED:
-#if 0
- bttv_risc_overlay(btv, &buf->top, fmt, ov, 1, 0);
- bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 1);
-#else
bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1);
bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0);
-#endif
break;
default:
BUG();
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 91f8afeded8..4f39688f780 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -690,11 +690,9 @@ static void blackbird_codec_settings(struct cx8802_dev *dev)
int bitrate_mode = 1;
int bitrate = 7500000;
int bitrate_peak = 7500000;
-#if 1
bitrate_mode = BLACKBIRD_VIDEO_CBR;
bitrate = 4000*1024;
bitrate_peak = 4000*1024;
-#endif
/* assign stream type */
blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM);
@@ -810,9 +808,6 @@ static int blackbird_initialize_codec(struct cx8802_dev *dev)
cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */
cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */
-#if 0 /* FIXME */
- set_scale(dev, 720, 480, V4L2_FIELD_INTERLACED);
-#endif
blackbird_codec_settings(dev);
msleep(1);
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 96cb0ff33bb..5e868f5cd0c 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-core.c,v 1.31 2005/06/22 22:58:04 mchehab Exp $
+ * $Id: cx88-core.c,v 1.33 2005/07/07 14:17:47 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* driver core
@@ -470,25 +470,6 @@ int cx88_risc_decode(u32 risc)
return incr[risc >> 28] ? incr[risc >> 28] : 1;
}
-#if 0 /* currently unused, but useful for debugging */
-void cx88_risc_disasm(struct cx88_core *core,
- struct btcx_riscmem *risc)
-{
- unsigned int i,j,n;
-
- printk("%s: risc disasm: %p [dma=0x%08lx]\n",
- core->name, risc->cpu, (unsigned long)risc->dma);
- for (i = 0; i < (risc->size >> 2); i += n) {
- printk("%s: %04d: ", core->name, i);
- n = cx88_risc_decode(risc->cpu[i]);
- for (j = 1; j < n; j++)
- printk("%s: %04d: 0x%08x [ arg #%d ]\n",
- core->name, i+j, risc->cpu[i+j], j);
- if (risc->cpu[i] == RISC_JUMP)
- break;
- }
-}
-#endif
void cx88_sram_channel_dump(struct cx88_core *core,
struct sram_channel *ch)
@@ -545,30 +526,12 @@ void cx88_sram_channel_dump(struct cx88_core *core,
core->name,cx_read(ch->cnt2_reg));
}
-/* Used only on cx88-core */
static char *cx88_pci_irqs[32] = {
"vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
"src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
"brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
"i2c", "i2c_rack", "ir_smp", "gpio0", "gpio1"
};
-/* Used only on cx88-video */
-char *cx88_vid_irqs[32] = {
- "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
- "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
- "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
- "y_sync", "u_sync", "v_sync", "vbi_sync",
- "opc_err", "par_err", "rip_err", "pci_abort",
-};
-/* Used only on cx88-mpeg */
-char *cx88_mpeg_irqs[32] = {
- "ts_risci1", NULL, NULL, NULL,
- "ts_risci2", NULL, NULL, NULL,
- "ts_oflow", NULL, NULL, NULL,
- "ts_sync", NULL, NULL, NULL,
- "opc_err", "par_err", "rip_err", "pci_abort",
- "ts_err?",
-};
void cx88_print_irqbits(char *name, char *tag, char **strings,
u32 bits, u32 mask)
@@ -618,16 +581,11 @@ void cx88_wakeup(struct cx88_core *core,
break;
buf = list_entry(q->active.next,
struct cx88_buffer, vb.queue);
-#if 0
- if (buf->count > count)
- break;
-#else
/* count comes from the hw and is is 16bit wide --
* this trick handles wrap-arounds correctly for
* up to 32767 buffers in flight... */
if ((s16) (count - buf->count) < 0)
break;
-#endif
do_gettimeofday(&buf->vb.ts);
dprintk(2,"[%p/%d] wakeup reg=%d buf=%d\n",buf,buf->vb.i,
count, buf->count);
@@ -955,12 +913,10 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
norm->cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
cx_andor(MO_INPUT_FORMAT, 0xf, norm->cxiformat);
-#if 1
// FIXME: as-is from DScaler
dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
norm->cxoformat, cx_read(MO_OUTPUT_FORMAT));
cx_write(MO_OUTPUT_FORMAT, norm->cxoformat);
-#endif
// MO_SCONV_REG = adc clock / video dec clock * 2^17
tmp64 = adc_clock * (u64)(1 << 17);
@@ -1219,8 +1175,6 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
/* ------------------------------------------------------------------ */
EXPORT_SYMBOL(cx88_print_ioctl);
-EXPORT_SYMBOL(cx88_vid_irqs);
-EXPORT_SYMBOL(cx88_mpeg_irqs);
EXPORT_SYMBOL(cx88_print_irqbits);
EXPORT_SYMBOL(cx88_core_irq);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 690477a6791..8db68f2d135 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-dvb.c,v 1.39 2005/07/02 20:00:46 mkrufky Exp $
+ * $Id: cx88-dvb.c,v 1.41 2005/07/04 19:35:05 mkrufky Exp $
*
* device driver for Conexant 2388x based TV cards
* MPEG Transport Stream (DVB) routines
@@ -30,22 +30,25 @@
#include <linux/file.h>
#include <linux/suspend.h>
-/* these three frontends need merging via linuxtv cvs ... */
-#define HAVE_CX22702 1
-#define HAVE_OR51132 1
-#define HAVE_LGDT3302 1
+#define CONFIG_DVB_MT352 1
+#define CONFIG_DVB_CX22702 1
+#define CONFIG_DVB_OR51132 1
+#define CONFIG_DVB_LGDT3302 1
#include "cx88.h"
#include "dvb-pll.h"
-#include "mt352.h"
-#include "mt352_priv.h"
-#if HAVE_CX22702
+
+#if CONFIG_DVB_MT352
+# include "mt352.h"
+# include "mt352_priv.h"
+#endif
+#if CONFIG_DVB_CX22702
# include "cx22702.h"
#endif
-#if HAVE_OR51132
+#if CONFIG_DVB_OR51132
# include "or51132.h"
#endif
-#if HAVE_LGDT3302
+#if CONFIG_DVB_LGDT3302
# include "lgdt3302.h"
#endif
@@ -104,6 +107,7 @@ static struct videobuf_queue_ops dvb_qops = {
/* ------------------------------------------------------------------ */
+#if CONFIG_DVB_MT352
static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
{
static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
@@ -171,8 +175,9 @@ static struct mt352_config dntv_live_dvbt_config = {
.demod_init = dntv_live_dvbt_demod_init,
.pll_set = mt352_pll_set,
};
+#endif
-#if HAVE_CX22702
+#if CONFIG_DVB_CX22702
static struct cx22702_config connexant_refboard_config = {
.demod_address = 0x43,
.pll_address = 0x60,
@@ -186,7 +191,7 @@ static struct cx22702_config hauppauge_novat_config = {
};
#endif
-#if HAVE_OR51132
+#if CONFIG_DVB_OR51132
static int or51132_set_ts_param(struct dvb_frontend* fe,
int is_punctured)
{
@@ -203,7 +208,7 @@ static struct or51132_config pchdtv_hd3000 = {
};
#endif
-#if HAVE_LGDT3302
+#if CONFIG_DVB_LGDT3302
static int lgdt3302_set_ts_param(struct dvb_frontend* fe, int is_punctured)
{
struct cx8802_dev *dev= fe->dvb->priv;
@@ -237,7 +242,7 @@ static int dvb_register(struct cx8802_dev *dev)
/* init frontend */
switch (dev->core->board) {
-#if HAVE_CX22702
+#if CONFIG_DVB_CX22702
case CX88_BOARD_HAUPPAUGE_DVB_T1:
dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config,
&dev->core->i2c_adap);
@@ -248,6 +253,7 @@ static int dvb_register(struct cx8802_dev *dev)
&dev->core->i2c_adap);
break;
#endif
+#if CONFIG_DVB_MT352
case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
dev->core->pll_addr = 0x61;
dev->core->pll_desc = &dvb_pll_lg_z201;
@@ -268,13 +274,14 @@ static int dvb_register(struct cx8802_dev *dev)
dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config,
&dev->core->i2c_adap);
break;
-#if HAVE_OR51132
+#endif
+#if CONFIG_DVB_OR51132
case CX88_BOARD_PCHDTV_HD3000:
dev->dvb.frontend = or51132_attach(&pchdtv_hd3000,
&dev->core->i2c_adap);
break;
#endif
-#if HAVE_LGDT3302
+#if CONFIG_DVB_LGDT3302
case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
dev->ts_gen_cntrl = 0x08;
{
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index b5342234b30..8403c4e9505 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -1,5 +1,5 @@
/*
- $Id: cx88-i2c.c,v 1.24 2005/06/17 18:46:23 mkrufky Exp $
+ $Id: cx88-i2c.c,v 1.28 2005/07/05 17:37:35 nsh Exp $
cx88-i2c.c -- all the i2c code is here
@@ -91,25 +91,32 @@ static int cx8800_bit_getsda(void *data)
static int attach_inform(struct i2c_client *client)
{
- struct tuner_addr tun_addr;
+ struct tuner_setup tun_setup;
struct cx88_core *core = i2c_get_adapdata(client->adapter);
- dprintk(1, "i2c attach [addr=0x%x,client=%s]\n",
- client->addr, i2c_clientname(client));
+ dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
+ client->driver->name,client->addr,i2c_clientname(client));
if (!client->driver->command)
return 0;
if (core->radio_type != UNSET) {
- tun_addr.v4l2_tuner = V4L2_TUNER_RADIO;
- tun_addr.type = core->radio_type;
- tun_addr.addr = core->radio_addr;
- client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr);
+ if ((core->radio_addr==ADDR_UNSET)||(core->radio_addr==client->addr)) {
+ tun_setup.mode_mask = T_RADIO;
+ tun_setup.type = core->radio_type;
+ tun_setup.addr = core->radio_addr;
+
+ client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
}
if (core->tuner_type != UNSET) {
- tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV;
- tun_addr.type = core->tuner_type;
- tun_addr.addr = core->tuner_addr;
- client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr);
+ if ((core->tuner_addr==ADDR_UNSET)||(core->tuner_addr==client->addr)) {
+
+ tun_setup.mode_mask = T_ANALOG_TV;
+ tun_setup.type = core->tuner_type;
+ tun_setup.addr = core->tuner_addr;
+
+ client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
}
if (core->tda9887_conf)
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index bdc26e75ab5..21488779819 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-input.c,v 1.13 2005/06/13 16:07:46 nsh Exp $
+ * $Id: cx88-input.c,v 1.15 2005/07/07 13:58:38 mchehab Exp $
*
* Device driver for GPIO attached remote control interfaces
* on Conexant 2388x based TV/DVB cards.
@@ -38,199 +38,206 @@
/* DigitalNow DNTV Live DVB-T Remote */
static IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE] = {
- [ 0x00 ] = KEY_ESC, // 'go up a level?'
- [ 0x01 ] = KEY_KP1, // '1'
- [ 0x02 ] = KEY_KP2, // '2'
- [ 0x03 ] = KEY_KP3, // '3'
- [ 0x04 ] = KEY_KP4, // '4'
- [ 0x05 ] = KEY_KP5, // '5'
- [ 0x06 ] = KEY_KP6, // '6'
- [ 0x07 ] = KEY_KP7, // '7'
- [ 0x08 ] = KEY_KP8, // '8'
- [ 0x09 ] = KEY_KP9, // '9'
- [ 0x0a ] = KEY_KP0, // '0'
- [ 0x0b ] = KEY_TUNER, // 'tv/fm'
- [ 0x0c ] = KEY_SEARCH, // 'scan'
- [ 0x0d ] = KEY_STOP, // 'stop'
- [ 0x0e ] = KEY_PAUSE, // 'pause'
- [ 0x0f ] = KEY_LIST, // 'source'
-
- [ 0x10 ] = KEY_MUTE, // 'mute'
- [ 0x11 ] = KEY_REWIND, // 'backward <<'
- [ 0x12 ] = KEY_POWER, // 'power'
- [ 0x13 ] = KEY_S, // 'snap'
- [ 0x14 ] = KEY_AUDIO, // 'stereo'
- [ 0x15 ] = KEY_CLEAR, // 'reset'
- [ 0x16 ] = KEY_PLAY, // 'play'
- [ 0x17 ] = KEY_ENTER, // 'enter'
- [ 0x18 ] = KEY_ZOOM, // 'full screen'
- [ 0x19 ] = KEY_FASTFORWARD, // 'forward >>'
- [ 0x1a ] = KEY_CHANNELUP, // 'channel +'
- [ 0x1b ] = KEY_VOLUMEUP, // 'volume +'
- [ 0x1c ] = KEY_INFO, // 'preview'
- [ 0x1d ] = KEY_RECORD, // 'record'
- [ 0x1e ] = KEY_CHANNELDOWN, // 'channel -'
- [ 0x1f ] = KEY_VOLUMEDOWN, // 'volume -'
+ [0x00] = KEY_ESC, /* 'go up a level?' */
+ /* Keys 0 to 9 */
+ [0x0a] = KEY_KP0,
+ [0x01] = KEY_KP1,
+ [0x02] = KEY_KP2,
+ [0x03] = KEY_KP3,
+ [0x04] = KEY_KP4,
+ [0x05] = KEY_KP5,
+ [0x06] = KEY_KP6,
+ [0x07] = KEY_KP7,
+ [0x08] = KEY_KP8,
+ [0x09] = KEY_KP9,
+
+ [0x0b] = KEY_TUNER, /* tv/fm */
+ [0x0c] = KEY_SEARCH, /* scan */
+ [0x0d] = KEY_STOP,
+ [0x0e] = KEY_PAUSE,
+ [0x0f] = KEY_LIST, /* source */
+
+ [0x10] = KEY_MUTE,
+ [0x11] = KEY_REWIND, /* backward << */
+ [0x12] = KEY_POWER,
+ [0x13] = KEY_S, /* snap */
+ [0x14] = KEY_AUDIO, /* stereo */
+ [0x15] = KEY_CLEAR, /* reset */
+ [0x16] = KEY_PLAY,
+ [0x17] = KEY_ENTER,
+ [0x18] = KEY_ZOOM, /* full screen */
+ [0x19] = KEY_FASTFORWARD, /* forward >> */
+ [0x1a] = KEY_CHANNELUP,
+ [0x1b] = KEY_VOLUMEUP,
+ [0x1c] = KEY_INFO, /* preview */
+ [0x1d] = KEY_RECORD, /* record */
+ [0x1e] = KEY_CHANNELDOWN,
+ [0x1f] = KEY_VOLUMEDOWN,
};
/* ---------------------------------------------------------------------- */
/* IO-DATA BCTV7E Remote */
static IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE] = {
- [ 0x40 ] = KEY_TV, // TV
- [ 0x20 ] = KEY_RADIO, // FM
- [ 0x60 ] = KEY_EPG, // EPG
- [ 0x00 ] = KEY_POWER, // power
-
- [ 0x50 ] = KEY_KP1, // 1
- [ 0x30 ] = KEY_KP2, // 2
- [ 0x70 ] = KEY_KP3, // 3
- [ 0x10 ] = KEY_L, // Live
-
- [ 0x48 ] = KEY_KP4, // 4
- [ 0x28 ] = KEY_KP5, // 5
- [ 0x68 ] = KEY_KP6, // 6
- [ 0x08 ] = KEY_T, // Time Shift
-
- [ 0x58 ] = KEY_KP7, // 7
- [ 0x38 ] = KEY_KP8, // 8
- [ 0x78 ] = KEY_KP9, // 9
- [ 0x18 ] = KEY_PLAYPAUSE, // Play
-
- [ 0x44 ] = KEY_KP0, // 10
- [ 0x24 ] = KEY_ENTER, // 11
- [ 0x64 ] = KEY_ESC, // 12
- [ 0x04 ] = KEY_M, // Multi
-
- [ 0x54 ] = KEY_VIDEO, // VIDEO
- [ 0x34 ] = KEY_CHANNELUP, // channel +
- [ 0x74 ] = KEY_VOLUMEUP, // volume +
- [ 0x14 ] = KEY_MUTE, // Mute
-
- [ 0x4c ] = KEY_S, // SVIDEO
- [ 0x2c ] = KEY_CHANNELDOWN, // channel -
- [ 0x6c ] = KEY_VOLUMEDOWN, // volume -
- [ 0x0c ] = KEY_ZOOM, // Zoom
-
- [ 0x5c ] = KEY_PAUSE, // pause
- [ 0x3c ] = KEY_C, // || (red)
- [ 0x7c ] = KEY_RECORD, // recording
- [ 0x1c ] = KEY_STOP, // stop
-
- [ 0x41 ] = KEY_REWIND, // backward <<
- [ 0x21 ] = KEY_PLAY, // play
- [ 0x61 ] = KEY_FASTFORWARD, // forward >>
- [ 0x01 ] = KEY_NEXT, // skip >|
+ [0x40] = KEY_TV,
+ [0x20] = KEY_RADIO, /* FM */
+ [0x60] = KEY_EPG,
+ [0x00] = KEY_POWER,
+
+ /* Keys 0 to 9 */
+ [0x44] = KEY_KP0, /* 10 */
+ [0x50] = KEY_KP1,
+ [0x30] = KEY_KP2,
+ [0x70] = KEY_KP3,
+ [0x48] = KEY_KP4,
+ [0x28] = KEY_KP5,
+ [0x68] = KEY_KP6,
+ [0x58] = KEY_KP7,
+ [0x38] = KEY_KP8,
+ [0x78] = KEY_KP9,
+
+ [0x10] = KEY_L, /* Live */
+ [0x08] = KEY_T, /* Time Shift */
+
+ [0x18] = KEY_PLAYPAUSE, /* Play */
+
+ [0x24] = KEY_ENTER, /* 11 */
+ [0x64] = KEY_ESC, /* 12 */
+ [0x04] = KEY_M, /* Multi */
+
+ [0x54] = KEY_VIDEO,
+ [0x34] = KEY_CHANNELUP,
+ [0x74] = KEY_VOLUMEUP,
+ [0x14] = KEY_MUTE,
+
+ [0x4c] = KEY_S, /* SVIDEO */
+ [0x2c] = KEY_CHANNELDOWN,
+ [0x6c] = KEY_VOLUMEDOWN,
+ [0x0c] = KEY_ZOOM,
+
+ [0x5c] = KEY_PAUSE,
+ [0x3c] = KEY_C, /* || (red) */
+ [0x7c] = KEY_RECORD, /* recording */
+ [0x1c] = KEY_STOP,
+
+ [0x41] = KEY_REWIND, /* backward << */
+ [0x21] = KEY_PLAY,
+ [0x61] = KEY_FASTFORWARD, /* forward >> */
+ [0x01] = KEY_NEXT, /* skip >| */
};
/* ---------------------------------------------------------------------- */
/* ADS Tech Instant TV DVB-T PCI Remote */
static IR_KEYTAB_TYPE ir_codes_adstech_dvb_t_pci[IR_KEYTAB_SIZE] = {
- [ 0x5b ] = KEY_POWER,
- [ 0x5f ] = KEY_MUTE,
- [ 0x57 ] = KEY_1,
- [ 0x4f ] = KEY_2,
- [ 0x53 ] = KEY_3,
- [ 0x56 ] = KEY_4,
- [ 0x4e ] = KEY_5,
- [ 0x5e ] = KEY_6,
- [ 0x54 ] = KEY_7,
- [ 0x4c ] = KEY_8,
- [ 0x5c ] = KEY_9,
- [ 0x4d ] = KEY_0,
- [ 0x55 ] = KEY_GOTO,
- [ 0x5d ] = KEY_SEARCH,
- [ 0x17 ] = KEY_EPG, // Guide
- [ 0x1f ] = KEY_MENU,
- [ 0x0f ] = KEY_UP,
- [ 0x46 ] = KEY_DOWN,
- [ 0x16 ] = KEY_LEFT,
- [ 0x1e ] = KEY_RIGHT,
- [ 0x0e ] = KEY_SELECT, // Enter
- [ 0x5a ] = KEY_INFO,
- [ 0x52 ] = KEY_EXIT,
- [ 0x59 ] = KEY_PREVIOUS,
- [ 0x51 ] = KEY_NEXT,
- [ 0x58 ] = KEY_REWIND,
- [ 0x50 ] = KEY_FORWARD,
- [ 0x44 ] = KEY_PLAYPAUSE,
- [ 0x07 ] = KEY_STOP,
- [ 0x1b ] = KEY_RECORD,
- [ 0x13 ] = KEY_TUNER, // Live
- [ 0x0a ] = KEY_A,
- [ 0x12 ] = KEY_B,
- [ 0x03 ] = KEY_PROG1, // 1
- [ 0x01 ] = KEY_PROG2, // 2
- [ 0x00 ] = KEY_PROG3, // 3
- [ 0x06 ] = KEY_DVD,
- [ 0x48 ] = KEY_AUX, // Photo
- [ 0x40 ] = KEY_VIDEO,
- [ 0x19 ] = KEY_AUDIO, // Music
- [ 0x0b ] = KEY_CHANNELUP,
- [ 0x08 ] = KEY_CHANNELDOWN,
- [ 0x15 ] = KEY_VOLUMEUP,
- [ 0x1c ] = KEY_VOLUMEDOWN,
+ /* Keys 0 to 9 */
+ [0x4d] = KEY_0,
+ [0x57] = KEY_1,
+ [0x4f] = KEY_2,
+ [0x53] = KEY_3,
+ [0x56] = KEY_4,
+ [0x4e] = KEY_5,
+ [0x5e] = KEY_6,
+ [0x54] = KEY_7,
+ [0x4c] = KEY_8,
+ [0x5c] = KEY_9,
+
+ [0x5b] = KEY_POWER,
+ [0x5f] = KEY_MUTE,
+ [0x55] = KEY_GOTO,
+ [0x5d] = KEY_SEARCH,
+ [0x17] = KEY_EPG, /* Guide */
+ [0x1f] = KEY_MENU,
+ [0x0f] = KEY_UP,
+ [0x46] = KEY_DOWN,
+ [0x16] = KEY_LEFT,
+ [0x1e] = KEY_RIGHT,
+ [0x0e] = KEY_SELECT, /* Enter */
+ [0x5a] = KEY_INFO,
+ [0x52] = KEY_EXIT,
+ [0x59] = KEY_PREVIOUS,
+ [0x51] = KEY_NEXT,
+ [0x58] = KEY_REWIND,
+ [0x50] = KEY_FORWARD,
+ [0x44] = KEY_PLAYPAUSE,
+ [0x07] = KEY_STOP,
+ [0x1b] = KEY_RECORD,
+ [0x13] = KEY_TUNER, /* Live */
+ [0x0a] = KEY_A,
+ [0x12] = KEY_B,
+ [0x03] = KEY_PROG1, /* 1 */
+ [0x01] = KEY_PROG2, /* 2 */
+ [0x00] = KEY_PROG3, /* 3 */
+ [0x06] = KEY_DVD,
+ [0x48] = KEY_AUX, /* Photo */
+ [0x40] = KEY_VIDEO,
+ [0x19] = KEY_AUDIO, /* Music */
+ [0x0b] = KEY_CHANNELUP,
+ [0x08] = KEY_CHANNELDOWN,
+ [0x15] = KEY_VOLUMEUP,
+ [0x1c] = KEY_VOLUMEDOWN,
};
/* ---------------------------------------------------------------------- */
/* MSI TV@nywhere remote */
static IR_KEYTAB_TYPE ir_codes_msi_tvanywhere[IR_KEYTAB_SIZE] = {
- [ 0x00 ] = KEY_0, /* '0' */
- [ 0x01 ] = KEY_1, /* '1' */
- [ 0x02 ] = KEY_2, /* '2' */
- [ 0x03 ] = KEY_3, /* '3' */
- [ 0x04 ] = KEY_4, /* '4' */
- [ 0x05 ] = KEY_5, /* '5' */
- [ 0x06 ] = KEY_6, /* '6' */
- [ 0x07 ] = KEY_7, /* '7' */
- [ 0x08 ] = KEY_8, /* '8' */
- [ 0x09 ] = KEY_9, /* '9' */
- [ 0x0c ] = KEY_MUTE, /* 'Mute' */
- [ 0x0f ] = KEY_SCREEN, /* 'Full Screen' */
- [ 0x10 ] = KEY_F, /* 'Funtion' */
- [ 0x11 ] = KEY_T, /* 'Time shift' */
- [ 0x12 ] = KEY_POWER, /* 'Power' */
- [ 0x13 ] = KEY_MEDIA, /* 'MTS' */
- [ 0x14 ] = KEY_SLOW, /* 'Slow' */
- [ 0x16 ] = KEY_REWIND, /* 'backward <<' */
- [ 0x17 ] = KEY_ENTER, /* 'Return' */
- [ 0x18 ] = KEY_FASTFORWARD, /* 'forward >>' */
- [ 0x1a ] = KEY_CHANNELUP, /* 'Channel+' */
- [ 0x1b ] = KEY_VOLUMEUP, /* 'Volume+' */
- [ 0x1e ] = KEY_CHANNELDOWN, /* 'Channel-' */
- [ 0x1f ] = KEY_VOLUMEDOWN, /* 'Volume-' */
+ /* Keys 0 to 9 */
+ [0x00] = KEY_0,
+ [0x01] = KEY_1,
+ [0x02] = KEY_2,
+ [0x03] = KEY_3,
+ [0x04] = KEY_4,
+ [0x05] = KEY_5,
+ [0x06] = KEY_6,
+ [0x07] = KEY_7,
+ [0x08] = KEY_8,
+ [0x09] = KEY_9,
+
+ [0x0c] = KEY_MUTE,
+ [0x0f] = KEY_SCREEN, /* Full Screen */
+ [0x10] = KEY_F, /* Funtion */
+ [0x11] = KEY_T, /* Time shift */
+ [0x12] = KEY_POWER,
+ [0x13] = KEY_MEDIA, /* MTS */
+ [0x14] = KEY_SLOW,
+ [0x16] = KEY_REWIND, /* backward << */
+ [0x17] = KEY_ENTER, /* Return */
+ [0x18] = KEY_FASTFORWARD, /* forward >> */
+ [0x1a] = KEY_CHANNELUP,
+ [0x1b] = KEY_VOLUMEUP,
+ [0x1e] = KEY_CHANNELDOWN,
+ [0x1f] = KEY_VOLUMEDOWN,
};
/* ---------------------------------------------------------------------- */
struct cx88_IR {
- struct cx88_core *core;
- struct input_dev input;
- struct ir_input_state ir;
- char name[32];
- char phys[32];
+ struct cx88_core *core;
+ struct input_dev input;
+ struct ir_input_state ir;
+ char name[32];
+ char phys[32];
/* sample from gpio pin 16 */
- int sampling;
- u32 samples[16];
- int scount;
- unsigned long release;
+ int sampling;
+ u32 samples[16];
+ int scount;
+ unsigned long release;
/* poll external decoder */
- int polling;
- struct work_struct work;
- struct timer_list timer;
- u32 gpio_addr;
- u32 last_gpio;
- u32 mask_keycode;
- u32 mask_keydown;
- u32 mask_keyup;
+ int polling;
+ struct work_struct work;
+ struct timer_list timer;
+ u32 gpio_addr;
+ u32 last_gpio;
+ u32 mask_keycode;
+ u32 mask_keydown;
+ u32 mask_keyup;
};
static int ir_debug = 0;
-module_param(ir_debug, int, 0644); /* debug level [IR] */
+module_param(ir_debug, int, 0644); /* debug level [IR] */
MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
#define ir_dprintk(fmt, arg...) if (ir_debug) \
@@ -254,37 +261,37 @@ static void cx88_ir_handle_key(struct cx88_IR *ir)
/* extract data */
data = ir_extract_bits(gpio, ir->mask_keycode);
ir_dprintk("irq gpio=0x%x code=%d | %s%s%s\n",
- gpio, data,
- ir->polling ? "poll" : "irq",
- (gpio & ir->mask_keydown) ? " down" : "",
- (gpio & ir->mask_keyup) ? " up" : "");
+ gpio, data,
+ ir->polling ? "poll" : "irq",
+ (gpio & ir->mask_keydown) ? " down" : "",
+ (gpio & ir->mask_keyup) ? " up" : "");
if (ir->mask_keydown) {
/* bit set on keydown */
if (gpio & ir->mask_keydown) {
- ir_input_keydown(&ir->input,&ir->ir,data,data);
+ ir_input_keydown(&ir->input, &ir->ir, data, data);
} else {
- ir_input_nokey(&ir->input,&ir->ir);
+ ir_input_nokey(&ir->input, &ir->ir);
}
} else if (ir->mask_keyup) {
/* bit cleared on keydown */
if (0 == (gpio & ir->mask_keyup)) {
- ir_input_keydown(&ir->input,&ir->ir,data,data);
+ ir_input_keydown(&ir->input, &ir->ir, data, data);
} else {
- ir_input_nokey(&ir->input,&ir->ir);
+ ir_input_nokey(&ir->input, &ir->ir);
}
} else {
/* can't distinguish keydown/up :-/ */
- ir_input_keydown(&ir->input,&ir->ir,data,data);
- ir_input_nokey(&ir->input,&ir->ir);
+ ir_input_keydown(&ir->input, &ir->ir, data, data);
+ ir_input_nokey(&ir->input, &ir->ir);
}
}
static void ir_timer(unsigned long data)
{
- struct cx88_IR *ir = (struct cx88_IR*)data;
+ struct cx88_IR *ir = (struct cx88_IR *)data;
schedule_work(&ir->work);
}
@@ -307,62 +314,62 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
IR_KEYTAB_TYPE *ir_codes = NULL;
int ir_type = IR_TYPE_OTHER;
- ir = kmalloc(sizeof(*ir),GFP_KERNEL);
+ ir = kmalloc(sizeof(*ir), GFP_KERNEL);
if (NULL == ir)
return -ENOMEM;
- memset(ir,0,sizeof(*ir));
+ memset(ir, 0, sizeof(*ir));
/* detect & configure */
switch (core->board) {
case CX88_BOARD_DNTV_LIVE_DVB_T:
case CX88_BOARD_KWORLD_DVB_T:
- ir_codes = ir_codes_dntv_live_dvb_t;
- ir->gpio_addr = MO_GP1_IO;
+ ir_codes = ir_codes_dntv_live_dvb_t;
+ ir->gpio_addr = MO_GP1_IO;
ir->mask_keycode = 0x1f;
- ir->mask_keyup = 0x60;
- ir->polling = 50; // ms
+ ir->mask_keyup = 0x60;
+ ir->polling = 50; /* ms */
break;
case CX88_BOARD_HAUPPAUGE:
case CX88_BOARD_HAUPPAUGE_DVB_T1:
- ir_codes = ir_codes_hauppauge_new;
- ir_type = IR_TYPE_RC5;
- ir->sampling = 1;
+ ir_codes = ir_codes_hauppauge_new;
+ ir_type = IR_TYPE_RC5;
+ ir->sampling = 1;
break;
case CX88_BOARD_WINFAST2000XP_EXPERT:
- ir_codes = ir_codes_winfast;
- ir->gpio_addr = MO_GP0_IO;
+ ir_codes = ir_codes_winfast;
+ ir->gpio_addr = MO_GP0_IO;
ir->mask_keycode = 0x8f8;
- ir->mask_keyup = 0x100;
- ir->polling = 1; // ms
+ ir->mask_keyup = 0x100;
+ ir->polling = 1; /* ms */
break;
case CX88_BOARD_IODATA_GVBCTV7E:
- ir_codes = ir_codes_iodata_bctv7e;
- ir->gpio_addr = MO_GP0_IO;
+ ir_codes = ir_codes_iodata_bctv7e;
+ ir->gpio_addr = MO_GP0_IO;
ir->mask_keycode = 0xfd;
ir->mask_keydown = 0x02;
- ir->polling = 5; // ms
+ ir->polling = 5; /* ms */
break;
case CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO:
- ir_codes = ir_codes_pixelview;
- ir->gpio_addr = MO_GP1_IO;
+ ir_codes = ir_codes_pixelview;
+ ir->gpio_addr = MO_GP1_IO;
ir->mask_keycode = 0x1f;
- ir->mask_keyup = 0x80;
- ir->polling = 1; // ms
+ ir->mask_keyup = 0x80;
+ ir->polling = 1; /* ms */
break;
case CX88_BOARD_ADSTECH_DVB_T_PCI:
- ir_codes = ir_codes_adstech_dvb_t_pci;
- ir->gpio_addr = MO_GP1_IO;
+ ir_codes = ir_codes_adstech_dvb_t_pci;
+ ir->gpio_addr = MO_GP1_IO;
ir->mask_keycode = 0xbf;
- ir->mask_keyup = 0x40;
- ir->polling = 50; // ms
+ ir->mask_keyup = 0x40;
+ ir->polling = 50; /* ms */
+ break;
+ case CX88_BOARD_MSI_TVANYWHERE_MASTER:
+ ir_codes = ir_codes_msi_tvanywhere;
+ ir->gpio_addr = MO_GP1_IO;
+ ir->mask_keycode = 0x1f;
+ ir->mask_keyup = 0x40;
+ ir->polling = 1; /* ms */
break;
- case CX88_BOARD_MSI_TVANYWHERE_MASTER:
- ir_codes = ir_codes_msi_tvanywhere;
- ir->gpio_addr = MO_GP1_IO;
- ir->mask_keycode = 0x1f;
- ir->mask_keyup = 0x40;
- ir->polling = 1;
- break;
}
if (NULL == ir_codes) {
@@ -373,8 +380,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
/* init input device */
snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)",
cx88_boards[core->board].name);
- snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
- pci_name(pci));
+ snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
ir_input_init(&ir->input, &ir->ir, ir_type, ir_codes);
ir->input.name = ir->name;
@@ -382,10 +388,10 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
ir->input.id.bustype = BUS_PCI;
ir->input.id.version = 1;
if (pci->subsystem_vendor) {
- ir->input.id.vendor = pci->subsystem_vendor;
+ ir->input.id.vendor = pci->subsystem_vendor;
ir->input.id.product = pci->subsystem_device;
} else {
- ir->input.id.vendor = pci->vendor;
+ ir->input.id.vendor = pci->vendor;
ir->input.id.product = pci->device;
}
@@ -397,13 +403,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
INIT_WORK(&ir->work, cx88_ir_work, ir);
init_timer(&ir->timer);
ir->timer.function = ir_timer;
- ir->timer.data = (unsigned long)ir;
+ ir->timer.data = (unsigned long)ir;
schedule_work(&ir->work);
}
if (ir->sampling) {
- core->pci_irqmask |= (1<<18); // IR_SMP_INT
- cx_write(MO_DDS_IO, 0xa80a80); // 4 kHz sample rate
- cx_write(MO_DDSCFG_IO, 0x5); // enable
+ core->pci_irqmask |= (1 << 18); /* IR_SMP_INT */
+ cx_write(MO_DDS_IO, 0xa80a80); /* 4 kHz sample rate */
+ cx_write(MO_DDSCFG_IO, 0x5); /* enable */
}
/* all done */
@@ -439,7 +445,7 @@ int cx88_ir_fini(struct cx88_core *core)
void cx88_ir_irq(struct cx88_core *core)
{
struct cx88_IR *ir = core->ir;
- u32 samples,rc5;
+ u32 samples, rc5;
int i;
if (NULL == ir)
@@ -448,7 +454,7 @@ void cx88_ir_irq(struct cx88_core *core)
return;
samples = cx_read(MO_SAMPLE_IO);
- if (0 != samples && 0xffffffff != samples) {
+ if (0 != samples && 0xffffffff != samples) {
/* record sample data */
if (ir->scount < ARRAY_SIZE(ir->samples))
ir->samples[ir->scount++] = samples;
@@ -456,8 +462,8 @@ void cx88_ir_irq(struct cx88_core *core)
}
if (!ir->scount) {
/* nothing to sample */
- if (ir->ir.keypressed && time_after(jiffies,ir->release))
- ir_input_nokey(&ir->input,&ir->ir);
+ if (ir->ir.keypressed && time_after(jiffies, ir->release))
+ ir_input_nokey(&ir->input, &ir->ir);
return;
}
@@ -467,14 +473,14 @@ void cx88_ir_irq(struct cx88_core *core)
for (i = 0; i < ir->scount; i++)
ir->samples[i] = ~ir->samples[i];
if (ir_debug)
- ir_dump_samples(ir->samples,ir->scount);
+ ir_dump_samples(ir->samples, ir->scount);
/* decode it */
switch (core->board) {
case CX88_BOARD_HAUPPAUGE:
case CX88_BOARD_HAUPPAUGE_DVB_T1:
- rc5 = ir_decode_biphase(ir->samples,ir->scount,5,7);
- ir_dprintk("biphase decoded: %x\n",rc5);
+ rc5 = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
+ ir_dprintk("biphase decoded: %x\n", rc5);
if ((rc5 & 0xfffff000) != 0x3000)
break;
ir_input_keydown(&ir->input, &ir->ir, rc5 & 0x3f, rc5);
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 85da6dc8d0e..fe2767c0ff9 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-mpeg.c,v 1.30 2005/07/05 19:44:40 mkrufky Exp $
+ * $Id: cx88-mpeg.c,v 1.31 2005/07/07 14:17:47 mchehab Exp $
*
* Support for the mpeg transport stream transfers
* PCI function #2 of the cx2388x.
@@ -64,7 +64,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
/* write TS length to chip */
cx_write(MO_TS_LNGTH, buf->vb.width);
-#if 1
/* FIXME: this needs a review.
* also: move to cx88-blackbird + cx88-dvb source files? */
@@ -76,9 +75,9 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
cx_write(TS_HW_SOP_CNTRL,0x47<<16|188<<4|0x01);
if ((core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q) ||
(core->board == CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T)) {
- cx_write(TS_SOP_STAT, 0<<16 | 0<<14 | 1<<13 | 0<<12);
+ cx_write(TS_SOP_STAT, 1<<13);
} else {
- cx_write(TS_SOP_STAT,0x00);
+ cx_write(TS_SOP_STAT, 0x00);
}
cx_write(TS_GEN_CNTRL, dev->ts_gen_cntrl);
udelay(100);
@@ -98,7 +97,6 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */
udelay(100);
}
-#endif
/* reset counter */
cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
@@ -270,6 +268,15 @@ static void cx8802_timeout(unsigned long data)
do_cancel_buffers(dev,"timeout",1);
}
+static char *cx88_mpeg_irqs[32] = {
+ "ts_risci1", NULL, NULL, NULL,
+ "ts_risci2", NULL, NULL, NULL,
+ "ts_oflow", NULL, NULL, NULL,
+ "ts_sync", NULL, NULL, NULL,
+ "opc_err", "par_err", "rip_err", "pci_abort",
+ "ts_err?",
+};
+
static void cx8802_mpeg_irq(struct cx8802_dev *dev)
{
struct cx88_core *core = dev->core;
@@ -282,10 +289,7 @@ static void cx8802_mpeg_irq(struct cx8802_dev *dev)
return;
cx_write(MO_TS_INTSTAT, status);
-#if 0
- cx88_print_irqbits(core->name, "irq mpeg ",
- cx88_mpeg_irqs, status, mask);
-#endif
+
if (debug || (status & mask & ~0xff))
cx88_print_irqbits(core->name, "irq mpeg ",
cx88_mpeg_irqs, status, mask);
@@ -441,10 +445,8 @@ int cx8802_suspend_common(struct pci_dev *pci_dev, pm_message_t state)
}
spin_unlock(&dev->slock);
-#if 1
/* FIXME -- shutdown device */
cx88_shutdown(dev->core);
-#endif
pci_save_state(pci_dev);
if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -466,10 +468,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev)
pci_set_power_state(pci_dev, PCI_D0);
pci_restore_state(pci_dev);
-#if 1
/* FIXME: re-initialize hardware */
cx88_reset(dev->core);
-#endif
/* restart video+vbi capture */
spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88-reg.h b/drivers/media/video/cx88/cx88-reg.h
index 63ad33f5818..37f82662d26 100644
--- a/drivers/media/video/cx88/cx88-reg.h
+++ b/drivers/media/video/cx88/cx88-reg.h
@@ -1,5 +1,5 @@
/*
- $Id: cx88-reg.h,v 1.7 2005/06/03 13:31:51 mchehab Exp $
+ $Id: cx88-reg.h,v 1.8 2005/07/07 13:58:38 mchehab Exp $
cx88x-hw.h - CX2388x register offsets
@@ -604,20 +604,11 @@
#define EN_I2SIN_STR2DAC 0x00004000
#define EN_I2SIN_ENABLE 0x00008000
-#if 0
-/* old */
-#define EN_DMTRX_SUMDIFF 0x00000800
-#define EN_DMTRX_SUMR 0x00000880
-#define EN_DMTRX_LR 0x00000900
-#define EN_DMTRX_MONO 0x00000980
-#else
-/* dscaler cvs */
#define EN_DMTRX_SUMDIFF (0 << 7)
#define EN_DMTRX_SUMR (1 << 7)
#define EN_DMTRX_LR (2 << 7)
#define EN_DMTRX_MONO (3 << 7)
#define EN_DMTRX_BYPASS (1 << 11)
-#endif
// Video
#define VID_CAPTURE_CONTROL 0x310180
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 46d78b1dc9b..91207f10bae 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -1,5 +1,5 @@
/*
- $Id: cx88-tvaudio.c,v 1.36 2005/06/05 05:53:45 mchehab Exp $
+ $Id: cx88-tvaudio.c,v 1.37 2005/07/07 13:58:38 mchehab Exp $
cx88x-audio.c - Conexant CX23880/23881 audio downstream driver driver
@@ -278,80 +278,6 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap)
set_audio_finish(core);
}
-#if 0
-static void set_audio_standard_NICAM(struct cx88_core *core)
-{
- static const struct rlist nicam_common[] = {
- /* from dscaler */
- { AUD_RATE_ADJ1, 0x00000010 },
- { AUD_RATE_ADJ2, 0x00000040 },
- { AUD_RATE_ADJ3, 0x00000100 },
- { AUD_RATE_ADJ4, 0x00000400 },
- { AUD_RATE_ADJ5, 0x00001000 },
- // { AUD_DMD_RA_DDS, 0x00c0d5ce },
-
- // Deemphasis 1:
- { AUD_DEEMPHGAIN_R, 0x000023c2 },
- { AUD_DEEMPHNUMER1_R, 0x0002a7bc },
- { AUD_DEEMPHNUMER2_R, 0x0003023e },
- { AUD_DEEMPHDENOM1_R, 0x0000f3d0 },
- { AUD_DEEMPHDENOM2_R, 0x00000000 },
-
-#if 0
- // Deemphasis 2: (other tv norm?)
- { AUD_DEEMPHGAIN_R, 0x0000c600 },
- { AUD_DEEMPHNUMER1_R, 0x00066738 },
- { AUD_DEEMPHNUMER2_R, 0x00066739 },
- { AUD_DEEMPHDENOM1_R, 0x0001e88c },
- { AUD_DEEMPHDENOM2_R, 0x0001e88c },
-#endif
-
- { AUD_DEEMPHDENOM2_R, 0x00000000 },
- { AUD_ERRLOGPERIOD_R, 0x00000fff },
- { AUD_ERRINTRPTTHSHLD1_R, 0x000003ff },
- { AUD_ERRINTRPTTHSHLD2_R, 0x000000ff },
- { AUD_ERRINTRPTTHSHLD3_R, 0x0000003f },
- { AUD_POLYPH80SCALEFAC, 0x00000003 },
-
- // setup QAM registers
- { AUD_PDF_DDS_CNST_BYTE2, 0x06 },
- { AUD_PDF_DDS_CNST_BYTE1, 0x82 },
- { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
- { AUD_QAM_MODE, 0x05 },
-
- { /* end of list */ },
- };
- static const struct rlist nicam_pal_i[] = {
- { AUD_PDF_DDS_CNST_BYTE0, 0x12 },
- { AUD_PHACC_FREQ_8MSB, 0x3a },
- { AUD_PHACC_FREQ_8LSB, 0x93 },
-
- { /* end of list */ },
- };
- static const struct rlist nicam_default[] = {
- { AUD_PDF_DDS_CNST_BYTE0, 0x16 },
- { AUD_PHACC_FREQ_8MSB, 0x34 },
- { AUD_PHACC_FREQ_8LSB, 0x4c },
-
- { /* end of list */ },
- };
-
- set_audio_start(core, 0x0010,
- EN_DMTRX_LR | EN_DMTRX_BYPASS | EN_NICAM_AUTO_STEREO);
- set_audio_registers(core, nicam_common);
- switch (core->tvaudio) {
- case WW_NICAM_I:
- dprintk("%s PAL-I NICAM (status: unknown)\n",__FUNCTION__);
- set_audio_registers(core, nicam_pal_i);
- break;
- case WW_NICAM_BGDKL:
- dprintk("%s PAL-BGDK NICAM (status: unknown)\n",__FUNCTION__);
- set_audio_registers(core, nicam_default);
- break;
- };
- set_audio_finish(core);
-}
-#endif
static void set_audio_standard_NICAM_L(struct cx88_core *core, int stereo)
{
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index dc997549b63..c44a079d08c 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1,5 +1,5 @@
/*
- * $Id: cx88-video.c,v 1.70 2005/06/20 03:36:00 mkrufky Exp $
+ * $Id: cx88-video.c,v 1.79 2005/07/07 14:17:47 mchehab Exp $
*
* device driver for Conexant 2388x based TV cards
* video4linux video interface
@@ -86,13 +86,6 @@ static struct cx88_tvnorm tvnorms[] = {
.id = V4L2_STD_NTSC_M_JP,
.cxiformat = VideoFormatNTSCJapan,
.cxoformat = 0x181f0008,
-#if 0
- },{
- .name = "NTSC-4.43",
- .id = FIXME,
- .cxiformat = VideoFormatNTSC443,
- .cxoformat = 0x181f0008,
-#endif
},{
.name = "PAL-BG",
.id = V4L2_STD_PAL_BG,
@@ -248,6 +241,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.default_value = 0,
.type = V4L2_CTRL_TYPE_INTEGER,
},
+ .off = 0,
.reg = MO_CONTR_BRIGHT,
.mask = 0xff00,
.shift = 8,
@@ -674,231 +668,6 @@ static struct videobuf_queue_ops cx8800_video_qops = {
/* ------------------------------------------------------------------ */
-#if 0 /* overlay support not finished yet */
-static u32* ov_risc_field(struct cx8800_dev *dev, struct cx8800_fh *fh,
- u32 *rp, struct btcx_skiplist *skips,
- u32 sync_line, int skip_even, int skip_odd)
-{
- int line,maxy,start,end,skip,nskips;
- u32 ri,ra;
- u32 addr;
-
- /* sync instruction */
- *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
-
- addr = (unsigned long)dev->fbuf.base;
- addr += dev->fbuf.fmt.bytesperline * fh->win.w.top;
- addr += (fh->fmt->depth >> 3) * fh->win.w.left;
-
- /* scan lines */
- for (maxy = -1, line = 0; line < fh->win.w.height;
- line++, addr += dev->fbuf.fmt.bytesperline) {
- if ((line%2) == 0 && skip_even)
- continue;
- if ((line%2) == 1 && skip_odd)
- continue;
-
- /* calculate clipping */
- if (line > maxy)
- btcx_calc_skips(line, fh->win.w.width, &maxy,
- skips, &nskips, fh->clips, fh->nclips);
-
- /* write out risc code */
- for (start = 0, skip = 0; start < fh->win.w.width; start = end) {
- if (skip >= nskips) {
- ri = RISC_WRITE;
- end = fh->win.w.width;
- } else if (start < skips[skip].start) {
- ri = RISC_WRITE;
- end = skips[skip].start;
- } else {
- ri = RISC_SKIP;
- end = skips[skip].end;
- skip++;
- }
- if (RISC_WRITE == ri)
- ra = addr + (fh->fmt->depth>>3)*start;
- else
- ra = 0;
-
- if (0 == start)
- ri |= RISC_SOL;
- if (fh->win.w.width == end)
- ri |= RISC_EOL;
- ri |= (fh->fmt->depth>>3) * (end-start);
-
- *(rp++)=cpu_to_le32(ri);
- if (0 != ra)
- *(rp++)=cpu_to_le32(ra);
- }
- }
- kfree(skips);
- return rp;
-}
-
-static int ov_risc_frame(struct cx8800_dev *dev, struct cx8800_fh *fh,
- struct cx88_buffer *buf)
-{
- struct btcx_skiplist *skips;
- u32 instructions,fields;
- u32 *rp;
- int rc;
-
- /* skip list for window clipping */
- if (NULL == (skips = kmalloc(sizeof(*skips) * fh->nclips,GFP_KERNEL)))
- return -ENOMEM;
-
- fields = 0;
- if (V4L2_FIELD_HAS_TOP(fh->win.field))
- fields++;
- if (V4L2_FIELD_HAS_BOTTOM(fh->win.field))
- fields++;
-
- /* estimate risc mem: worst case is (clip+1) * lines instructions
- + syncs + jump (all 2 dwords) */
- instructions = (fh->nclips+1) * fh->win.w.height;
- instructions += 3 + 4;
- if ((rc = btcx_riscmem_alloc(dev->pci,&buf->risc,instructions*8)) < 0) {
- kfree(skips);
- return rc;
- }
-
- /* write risc instructions */
- rp = buf->risc.cpu;
- switch (fh->win.field) {
- case V4L2_FIELD_TOP:
- rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 0);
- break;
- case V4L2_FIELD_BOTTOM:
- rp = ov_risc_field(dev, fh, rp, skips, 0x200, 0, 0);
- break;
- case V4L2_FIELD_INTERLACED:
- rp = ov_risc_field(dev, fh, rp, skips, 0, 0, 1);
- rp = ov_risc_field(dev, fh, rp, skips, 0x200, 1, 0);
- break;
- default:
- BUG();
- }
-
- /* save pointer to jmp instruction address */
- buf->risc.jmp = rp;
- kfree(skips);
- return 0;
-}
-
-static int verify_window(struct cx8800_dev *dev, struct v4l2_window *win)
-{
- enum v4l2_field field;
- int maxw, maxh;
-
- if (NULL == dev->fbuf.base)
- return -EINVAL;
- if (win->w.width < 48 || win->w.height < 32)
- return -EINVAL;
- if (win->clipcount > 2048)
- return -EINVAL;
-
- field = win->field;
- maxw = norm_maxw(core->tvnorm);
- maxh = norm_maxh(core->tvnorm);
-
- if (V4L2_FIELD_ANY == field) {
- field = (win->w.height > maxh/2)
- ? V4L2_FIELD_INTERLACED
- : V4L2_FIELD_TOP;
- }
- switch (field) {
- case V4L2_FIELD_TOP:
- case V4L2_FIELD_BOTTOM:
- maxh = maxh / 2;
- break;
- case V4L2_FIELD_INTERLACED:
- break;
- default:
- return -EINVAL;
- }
-
- win->field = field;
- if (win->w.width > maxw)
- win->w.width = maxw;
- if (win->w.height > maxh)
- win->w.height = maxh;
- return 0;
-}
-
-static int setup_window(struct cx8800_dev *dev, struct cx8800_fh *fh,
- struct v4l2_window *win)
-{
- struct v4l2_clip *clips = NULL;
- int n,size,retval = 0;
-
- if (NULL == fh->fmt)
- return -EINVAL;
- retval = verify_window(dev,win);
- if (0 != retval)
- return retval;
-
- /* copy clips -- luckily v4l1 + v4l2 are binary
- compatible here ...*/
- n = win->clipcount;
- size = sizeof(*clips)*(n+4);
- clips = kmalloc(size,GFP_KERNEL);
- if (NULL == clips)
- return -ENOMEM;
- if (n > 0) {
- if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) {
- kfree(clips);
- return -EFAULT;
- }
- }
-
- /* clip against screen */
- if (NULL != dev->fbuf.base)
- n = btcx_screen_clips(dev->fbuf.fmt.width, dev->fbuf.fmt.height,
- &win->w, clips, n);
- btcx_sort_clips(clips,n);
-
- /* 4-byte alignments */
- switch (fh->fmt->depth) {
- case 8:
- case 24:
- btcx_align(&win->w, clips, n, 3);
- break;
- case 16:
- btcx_align(&win->w, clips, n, 1);
- break;
- case 32:
- /* no alignment fixups needed */
- break;
- default:
- BUG();
- }
-
- down(&fh->vidq.lock);
- if (fh->clips)
- kfree(fh->clips);
- fh->clips = clips;
- fh->nclips = n;
- fh->win = *win;
-#if 0
- fh->ov.setup_ok = 1;
-#endif
-
- /* update overlay if needed */
- retval = 0;
-#if 0
- if (check_btres(fh, RESOURCE_OVERLAY)) {
- struct bttv_buffer *new;
-
- new = videobuf_alloc(sizeof(*new));
- bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new);
- retval = bttv_switch_overlay(btv,fh,new);
- }
-#endif
- up(&fh->vidq.lock);
- return retval;
-}
-#endif
/* ------------------------------------------------------------------ */
@@ -1327,9 +1096,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
struct cx8800_fh *fh = file->private_data;
struct cx8800_dev *dev = fh->dev;
struct cx88_core *core = dev->core;
-#if 0
- unsigned long flags;
-#endif
int err;
if (video_debug > 1)
@@ -1350,9 +1116,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
V4L2_CAP_READWRITE |
V4L2_CAP_STREAMING |
V4L2_CAP_VBI_CAPTURE |
-#if 0
- V4L2_CAP_VIDEO_OVERLAY |
-#endif
0;
if (UNSET != core->tuner_type)
cap->capabilities |= V4L2_CAP_TUNER;
@@ -1453,36 +1216,6 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
}
-#if 0
- /* needs review */
- case VIDIOC_G_AUDIO:
- {
- struct v4l2_audio *a = arg;
- unsigned int n = a->index;
-
- memset(a,0,sizeof(*a));
- a->index = n;
- switch (n) {
- case 0:
- if ((CX88_VMUX_TELEVISION == INPUT(n)->type)
- || (CX88_VMUX_CABLE == INPUT(n)->type)) {
- strcpy(a->name,"Television");
- // FIXME figure out if stereo received and set V4L2_AUDCAP_STEREO.
- return 0;
- }
- break;
- case 1:
- if (CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q == core->board) {
- strcpy(a->name,"Line In");
- a->capability = V4L2_AUDCAP_STEREO;
- return 0;
- }
- break;
- }
- // Audio input not available.
- return -EINVAL;
- }
-#endif
/* --- capture ioctls ---------------------------------------- */
case VIDIOC_ENUM_FMT:
@@ -1592,6 +1325,9 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->freq;
+
+ cx88_call_i2c_clients(dev->core,VIDIOC_G_FREQUENCY,f);
+
return 0;
}
case VIDIOC_S_FREQUENCY:
@@ -1846,6 +1582,14 @@ static void cx8800_vid_timeout(unsigned long data)
spin_unlock_irqrestore(&dev->slock,flags);
}
+static char *cx88_vid_irqs[32] = {
+ "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
+ "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
+ "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
+ "y_sync", "u_sync", "v_sync", "vbi_sync",
+ "opc_err", "par_err", "rip_err", "pci_abort",
+};
+
static void cx8800_vid_irq(struct cx8800_dev *dev)
{
struct cx88_core *core = dev->core;
@@ -2013,7 +1757,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
{
struct cx8800_dev *dev;
struct cx88_core *core;
- struct tuner_addr tun_addr;
int err;
dev = kmalloc(sizeof(*dev),GFP_KERNEL);
@@ -2087,22 +1830,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
request_module("tuner");
if (core->tda9887_conf)
request_module("tda9887");
- if (core->radio_type != UNSET) {
- tun_addr.v4l2_tuner = V4L2_TUNER_RADIO;
- tun_addr.type = core->radio_type;
- tun_addr.addr = core->radio_addr;
- cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
- }
- if (core->tuner_type != UNSET) {
- tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV;
- tun_addr.type = core->tuner_type;
- tun_addr.addr = core->tuner_addr;
- cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr);
- }
-
- if (core->tda9887_conf)
- cx88_call_i2c_clients(dev->core,TDA9887_SET_CONFIG,&core->tda9887_conf);
-
/* register v4l devices */
dev->video_dev = cx88_vdev_init(core,dev->pci,
&cx8800_video_template,"video");
@@ -2212,10 +1939,8 @@ static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
}
spin_unlock(&dev->slock);
-#if 1
/* FIXME -- shutdown device */
cx88_shutdown(dev->core);
-#endif
pci_save_state(pci_dev);
if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
@@ -2237,10 +1962,8 @@ static int cx8800_resume(struct pci_dev *pci_dev)
pci_set_power_state(pci_dev, PCI_D0);
pci_restore_state(pci_dev);
-#if 1
/* FIXME: re-initialize hardware */
cx88_reset(dev->core);
-#endif
/* restart video+vbi capture */
spin_lock(&dev->slock);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index bc5e038bc0f..307beae04f2 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
/*
- * $Id: cx88.h,v 1.67 2005/07/01 12:10:07 mkrufky Exp $
+ * $Id: cx88.h,v 1.68 2005/07/07 14:17:47 mchehab Exp $
*
* v4l2 device driver for cx2388x based TV cards
*
@@ -82,9 +82,9 @@ struct cx88_tvnorm {
static unsigned int inline norm_maxw(struct cx88_tvnorm *norm)
{
return (norm->id & V4L2_STD_625_50) ? 768 : 640;
-// return (norm->id & V4L2_STD_625_50) ? 720 : 640;
}
+
static unsigned int inline norm_maxh(struct cx88_tvnorm *norm)
{
return (norm->id & V4L2_STD_625_50) ? 576 : 480;
@@ -220,7 +220,6 @@ struct cx88_subid {
#define RESOURCE_VBI 4
#define BUFFER_TIMEOUT (HZ/2) /* 0.5 seconds */
-//#define BUFFER_TIMEOUT (HZ*2)
/* buffer for one video frame */
struct cx88_buffer {
@@ -336,11 +335,6 @@ struct cx8800_dev {
struct pci_dev *pci;
unsigned char pci_rev,pci_lat;
-#if 0
- /* video overlay */
- struct v4l2_framebuffer fbuf;
- struct cx88_buffer *screen;
-#endif
/* capture queues */
struct cx88_dmaqueue vidq;
@@ -435,8 +429,6 @@ struct cx8802_dev {
/* ----------------------------------------------------------- */
/* cx88-core.c */
-extern char *cx88_vid_irqs[32];
-extern char *cx88_mpeg_irqs[32];
extern void cx88_print_irqbits(char *name, char *tag, char **strings,
u32 bits, u32 mask);
extern void cx88_print_ioctl(char *name, unsigned int cmd);
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 92664f75d32..9fc5055e001 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -1,5 +1,5 @@
/*
- * $Id: ir-kbd-i2c.c,v 1.10 2004/12/09 12:51:35 kraxel Exp $
+ * $Id: ir-kbd-i2c.c,v 1.11 2005/07/07 16:42:11 mchehab Exp $
*
* keyboard input driver for i2c IR remote controls
*
@@ -66,26 +66,26 @@ static IR_KEYTAB_TYPE ir_codes_pv951[IR_KEYTAB_SIZE] = {
[ 29 ] = KEY_PAGEDOWN,
[ 19 ] = KEY_SOUND,
- [ 24 ] = KEY_KPPLUSMINUS, // CH +/-
- [ 22 ] = KEY_SUBTITLE, // CC
- [ 13 ] = KEY_TEXT, // TTX
- [ 11 ] = KEY_TV, // AIR/CBL
- [ 17 ] = KEY_PC, // PC/TV
- [ 23 ] = KEY_OK, // CH RTN
- [ 25 ] = KEY_MODE, // FUNC
- [ 12 ] = KEY_SEARCH, // AUTOSCAN
+ [ 24 ] = KEY_KPPLUSMINUS, /* CH +/- */
+ [ 22 ] = KEY_SUBTITLE, /* CC */
+ [ 13 ] = KEY_TEXT, /* TTX */
+ [ 11 ] = KEY_TV, /* AIR/CBL */
+ [ 17 ] = KEY_PC, /* PC/TV */
+ [ 23 ] = KEY_OK, /* CH RTN */
+ [ 25 ] = KEY_MODE, /* FUNC */
+ [ 12 ] = KEY_SEARCH, /* AUTOSCAN */
/* Not sure what to do with these ones! */
- [ 15 ] = KEY_SELECT, // SOURCE
- [ 10 ] = KEY_KPPLUS, // +100
- [ 20 ] = KEY_KPEQUAL, // SYNC
- [ 28 ] = KEY_MEDIA, // PC/TV
+ [ 15 ] = KEY_SELECT, /* SOURCE */
+ [ 10 ] = KEY_KPPLUS, /* +100 */
+ [ 20 ] = KEY_KPEQUAL, /* SYNC */
+ [ 28 ] = KEY_MEDIA, /* PC/TV */
};
static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
[ 0x3 ] = KEY_POWER,
[ 0x6f ] = KEY_MUTE,
- [ 0x10 ] = KEY_BACKSPACE, // Recall
+ [ 0x10 ] = KEY_BACKSPACE, /* Recall */
[ 0x11 ] = KEY_KP0,
[ 0x4 ] = KEY_KP1,
@@ -97,7 +97,7 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
[ 0xc ] = KEY_KP7,
[ 0xd ] = KEY_KP8,
[ 0xe ] = KEY_KP9,
- [ 0x12 ] = KEY_KPDOT, // 100+
+ [ 0x12 ] = KEY_KPDOT, /* 100+ */
[ 0x7 ] = KEY_VOLUMEUP,
[ 0xb ] = KEY_VOLUMEDOWN,
@@ -109,25 +109,16 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
[ 0x13 ] = KEY_CHANNELDOWN,
[ 0x48 ] = KEY_ZOOM,
- [ 0x1b ] = KEY_VIDEO, // Video source
-#if 0
- [ 0x1f ] = KEY_S, // Snapshot
-#endif
- [ 0x49 ] = KEY_LANGUAGE, // MTS Select
- [ 0x19 ] = KEY_SEARCH, // Auto Scan
+ [ 0x1b ] = KEY_VIDEO, /* Video source */
+ [ 0x49 ] = KEY_LANGUAGE, /* MTS Select */
+ [ 0x19 ] = KEY_SEARCH, /* Auto Scan */
[ 0x4b ] = KEY_RECORD,
[ 0x46 ] = KEY_PLAY,
- [ 0x45 ] = KEY_PAUSE, // Pause
+ [ 0x45 ] = KEY_PAUSE, /* Pause */
[ 0x44 ] = KEY_STOP,
-#if 0
- [ 0x43 ] = KEY_T, // Time Shift
- [ 0x47 ] = KEY_Y, // Time Shift OFF
- [ 0x4a ] = KEY_O, // TOP
- [ 0x17 ] = KEY_F, // SURF CH
-#endif
- [ 0x40 ] = KEY_FORWARD, // Forward ?
- [ 0x42 ] = KEY_REWIND, // Backward ?
+ [ 0x40 ] = KEY_FORWARD, /* Forward ? */
+ [ 0x42 ] = KEY_REWIND, /* Backward ? */
};
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index b4ee9dfe6d4..6239254db27 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -567,10 +567,6 @@ static void msp3400c_set_audmode(struct i2c_client *client, int audmode)
switch (audmode) {
case V4L2_TUNER_MODE_STEREO:
src = 0x0020 | nicam;
-#if 0
- /* spatial effect */
- msp3400c_write(client,I2C_MSP3400C_DFP, 0x0005,0x4000);
-#endif
break;
case V4L2_TUNER_MODE_MONO:
if (msp->mode == MSP_MODE_AM_NICAM) {
@@ -741,16 +737,14 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
set_current_state(TASK_INTERRUPTIBLE);
schedule();
} else {
-#if 0
- /* hmm, that one doesn't return on wakeup ... */
- msleep_interruptible(timeout);
-#else
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(timeout));
-#endif
}
}
- try_to_freeze();
+ if (current->flags & PF_FREEZE) {
+ refrigerator ();
+ }
+
remove_wait_queue(&msp->wq, &wait);
return msp->restart;
}
@@ -1154,17 +1148,10 @@ static int msp3410d_thread(void *data)
MSP_CARRIER(10.7));
/* scart routing */
msp3400c_set_scart(client,SCART_IN2,0);
-#if 0
- /* radio from SCART_IN2 */
- msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0220);
- msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0220);
- msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0220);
-#else
/* msp34xx does radio decoding */
msp3400c_write(client,I2C_MSP3400C_DFP, 0x08, 0x0020);
msp3400c_write(client,I2C_MSP3400C_DFP, 0x09, 0x0020);
msp3400c_write(client,I2C_MSP3400C_DFP, 0x0b, 0x0020);
-#endif
break;
case 0x0003:
case 0x0004:
@@ -1507,10 +1494,6 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
return -1;
}
-#if 0
- /* this will turn on a 1kHz beep - might be useful for debugging... */
- msp3400c_write(c,I2C_MSP3400C_DFP, 0x0014, 0x1040);
-#endif
msp3400c_setvolume(c, msp->muted, msp->volume, msp->balance);
snprintf(c->name, sizeof(c->name), "MSP34%02d%c-%c%d",
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index 9c005cb128d..2fb7c2d1787 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -511,22 +511,6 @@ int microtune_init(struct i2c_client *c)
tuner_info("microtune: companycode=%04x part=%02x rev=%02x\n",
company_code,buf[0x13],buf[0x14]);
-#if 0
- /* seems to cause more problems than it solves ... */
- switch (company_code) {
- case 0x30bf:
- case 0x3cbf:
- case 0x3dbf:
- case 0x4d54:
- case 0x8e81:
- case 0x8e91:
- /* ok (?) */
- break;
- default:
- tuner_warn("tuner: microtune: unknown companycode\n");
- return 0;
- }
-#endif
if (buf[0x13] < ARRAY_SIZE(microtune_part) &&
NULL != microtune_part[buf[0x13]])
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 70bf1f1fad5..486234d41b5 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -326,6 +326,7 @@ static int mxb_init_done(struct saa7146_dev* dev)
struct mxb* mxb = (struct mxb*)dev->ext_priv;
struct video_decoder_init init;
struct i2c_msg msg;
+ struct tuner_setup tun_setup;
int i = 0, err = 0;
struct tea6415c_multiplex vm;
@@ -349,8 +350,10 @@ static int mxb_init_done(struct saa7146_dev* dev)
mxb->saa7111a->driver->command(mxb->saa7111a,DECODER_SET_VBI_BYPASS, &i);
/* select a tuner type */
- i = 5;
- mxb->tuner->driver->command(mxb->tuner,TUNER_SET_TYPE, &i);
+ tun_setup.mode_mask = T_ANALOG_TV;
+ tun_setup.addr = ADDR_UNSET;
+ tun_setup.type = 5;
+ mxb->tuner->driver->command(mxb->tuner,TUNER_SET_TYPE_ADDR, &tun_setup);
/* mute audio on tea6420s */
mxb->tea6420_1->driver->command(mxb->tea6420_1,TEA6420_SWITCH, &TEA6420_line[6][0]);
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index e6d0a18833d..79d05ea1b69 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -155,10 +155,6 @@ static struct v4l2_mpeg_compression param_defaults =
.target = 256,
},
-#if 0
- /* FIXME: size? via S_FMT? */
- .video_format = MPEG_VIDEO_FORMAT_D1,
-#endif
};
/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 0c781e24c44..88b71a20b60 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1,6 +1,5 @@
-
/*
- * $Id: saa7134-cards.c,v 1.58 2005/06/07 18:05:00 nsh Exp $
+ * $Id: saa7134-cards.c,v 1.80 2005/07/07 01:49:30 mkrufky Exp $
*
* device driver for philips saa7134 based TV cards
* card-specific stuff.
@@ -47,6 +46,10 @@ struct saa7134_board saa7134_boards[] = {
.name = "UNKNOWN/GENERIC",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_ABSENT,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.inputs = {{
.name = "default",
.vmux = 0,
@@ -58,6 +61,10 @@ struct saa7134_board saa7134_boards[] = {
.name = "Proteus Pro [philips reference design]",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.inputs = {{
.name = name_comp1,
.vmux = 0,
@@ -83,6 +90,10 @@ struct saa7134_board saa7134_boards[] = {
.name = "LifeView FlyVIDEO3000",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.gpiomask = 0xe000,
.inputs = {{
.name = name_tv,
@@ -90,7 +101,7 @@ struct saa7134_board saa7134_boards[] = {
.amux = TV,
.gpio = 0x8000,
.tv = 1,
- },{
+ },{
.name = name_tv_mono,
.vmux = 1,
.amux = LINE2,
@@ -117,12 +128,21 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
.gpio = 0x2000,
},
+ .mute = {
+ .name = name_mute,
+ .amux = TV,
+ .gpio = 0x8000,
+ },
},
[SAA7134_BOARD_FLYVIDEO2000] = {
/* "TC Wan" <tcwan@cs.usm.my> */
.name = "LifeView FlyVIDEO2000",
.audio_clock = 0x00200000,
.tuner_type = TUNER_LG_PAL_NEW_TAPC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.gpiomask = 0xe000,
.inputs = {{
.name = name_tv,
@@ -146,14 +166,14 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
.gpio = 0x4000,
}},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
.gpio = 0x2000,
- },
+ },
.mute = {
.name = name_mute,
- .amux = LINE2,
+ .amux = LINE2,
.gpio = 0x8000,
},
},
@@ -162,6 +182,10 @@ struct saa7134_board saa7134_boards[] = {
.name = "LifeView FlyTV Platinum Mini",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.inputs = {{
.name = name_tv,
.vmux = 1,
@@ -183,6 +207,10 @@ struct saa7134_board saa7134_boards[] = {
.name = "LifeView FlyTV Platinum FM",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */
.inputs = {{
.name = name_tv,
@@ -190,7 +218,7 @@ struct saa7134_board saa7134_boards[] = {
.amux = TV,
.gpio = 0x10000, /* GP16=1 selects TV input */
.tv = 1,
- },{
+ },{
/* .name = name_tv_mono,
.vmux = 1,
.amux = LINE2,
@@ -200,29 +228,38 @@ struct saa7134_board saa7134_boards[] = {
*/ .name = name_comp1, /* Composite signal on S-Video input */
.vmux = 0,
.amux = LINE2,
-// .gpio = 0x4000,
+/* .gpio = 0x4000, */
},{
.name = name_comp2, /* Composite input */
.vmux = 3,
.amux = LINE2,
-// .gpio = 0x4000,
+/* .gpio = 0x4000, */
},{
.name = name_svideo, /* S-Video signal on S-Video input */
.vmux = 8,
.amux = LINE2,
-// .gpio = 0x4000,
+/* .gpio = 0x4000, */
}},
.radio = {
.name = name_radio,
.amux = TV,
.gpio = 0x00000, /* GP16=0 selects FM radio antenna */
},
+ .mute = {
+ .name = name_mute,
+ .amux = TV,
+ .gpio = 0x10000,
+ },
},
[SAA7134_BOARD_EMPRESS] = {
/* "Gert Vervoort" <gert.vervoort@philips.com> */
.name = "EMPRESS",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
.inputs = {{
.name = name_comp1,
.vmux = 0,
@@ -245,33 +282,40 @@ struct saa7134_board saa7134_boards[] = {
.video_out = CCIR656,
},
[SAA7134_BOARD_MONSTERTV] = {
- /* "K.Ohta" <alpha292@bremen.or.jp> */
- .name = "SKNet Monster TV",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_NTSC_M,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 0,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
- },
+ /* "K.Ohta" <alpha292@bremen.or.jp> */
+ .name = "SKNet Monster TV",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_NTSC_M,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 0,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
},
[SAA7134_BOARD_MD9717] = {
.name = "Tevion MD 9717",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_tv,
.vmux = 1,
@@ -302,10 +346,13 @@ struct saa7134_board saa7134_boards[] = {
},
},
[SAA7134_BOARD_TVSTATION_RDS] = {
- /* Typhoon TV Tuner RDS: Art.Nr. 50694 */
+ /* Typhoon TV Tuner RDS: Art.Nr. 50694 */
.name = "KNC One TV-Station RDS / Typhoon TV Tuner RDS",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -314,10 +361,10 @@ struct saa7134_board saa7134_boards[] = {
.tv = 1,
},{
.name = name_tv_mono,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- },{
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ },{
.name = name_svideo,
.vmux = 8,
@@ -328,10 +375,10 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE1,
},{
- .name = "CVid over SVid",
- .vmux = 0,
- .amux = LINE1,
- }},
+ .name = "CVid over SVid",
+ .vmux = 0,
+ .amux = LINE1,
+ }},
.radio = {
.name = name_radio,
.amux = LINE2,
@@ -341,6 +388,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "KNC One TV-Station DVR",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.gpiomask = 0x820000,
.inputs = {{
@@ -369,32 +419,38 @@ struct saa7134_board saa7134_boards[] = {
.video_out = CCIR656,
},
[SAA7134_BOARD_CINERGY400] = {
- .name = "Terratec Cinergy 400 TV",
- .audio_clock = 0x00200000,
- .tuner_type = TUNER_PHILIPS_PAL,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp2, // CVideo over SVideo Connector
- .vmux = 0,
- .amux = LINE1,
- }}
- },
+ .name = "Terratec Cinergy 400 TV",
+ .audio_clock = 0x00200000,
+ .tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp2, /* CVideo over SVideo Connector */
+ .vmux = 0,
+ .amux = LINE1,
+ }}
+ },
[SAA7134_BOARD_MD5044] = {
.name = "Medion 5044",
- .audio_clock = 0x00187de7, // was: 0x00200000,
+ .audio_clock = 0x00187de7, /* was: 0x00200000, */
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -426,57 +482,65 @@ struct saa7134_board saa7134_boards[] = {
},
},
[SAA7134_BOARD_KWORLD] = {
- .name = "Kworld/KuroutoShikou SAA7130-TVPCI",
+ .name = "Kworld/KuroutoShikou SAA7130-TVPCI",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
- .inputs = {{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- }},
- },
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ }},
+ },
[SAA7134_BOARD_CINERGY600] = {
- .name = "Terratec Cinergy 600 TV",
- .audio_clock = 0x00200000,
- .tuner_type = TUNER_PHILIPS_PAL,
+ .name = "Terratec Cinergy 600 TV",
+ .audio_clock = 0x00200000,
+ .tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp2, // CVideo over SVideo Connector
- .vmux = 0,
- .amux = LINE1,
- }},
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp2, /* CVideo over SVideo Connector */
+ .vmux = 0,
+ .amux = LINE1,
+ }},
.radio = {
.name = name_radio,
.amux = LINE2,
- },
- },
+ },
+ },
[SAA7134_BOARD_MD7134] = {
.name = "Medion 7134",
- //.audio_clock = 0x00200000,
.audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .tuner_type = TUNER_PHILIPS_FMD1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.mpeg = SAA7134_MPEG_DVB,
.inputs = {{
@@ -504,6 +568,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "Typhoon TV+Radio 90031",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -523,11 +590,14 @@ struct saa7134_board saa7134_boards[] = {
.name = name_radio,
.amux = LINE2,
},
- },
+ },
[SAA7134_BOARD_ELSA] = {
.name = "ELSA EX-VISION 300TV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_HITACHI_NTSC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_svideo,
.vmux = 8,
@@ -542,11 +612,14 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
.tv = 1,
}},
- },
+ },
[SAA7134_BOARD_ELSA_500TV] = {
.name = "ELSA EX-VISION 500TV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_HITACHI_NTSC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_svideo,
.vmux = 7,
@@ -562,83 +635,100 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
.tv = 1,
}},
- },
+ },
[SAA7134_BOARD_ASUSTeK_TVFM7134] = {
- .name = "ASUS TV-FM 7134",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
- .tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE2,
- },{
- .name = name_svideo,
- .vmux = 6,
- .amux = LINE2,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE1,
- },
- },
- [SAA7135_BOARD_ASUSTeK_TVFM7135] = {
- .name = "ASUS TV-FM 7135",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_TDA8290,
+ .name = "ASUS TV-FM 7134",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 6,
+ .amux = LINE2,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE1,
+ },
+ },
+ [SAA7134_BOARD_ASUSTeK_TVFM7135] = {
+ .name = "ASUS TV-FM 7135",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0x200000,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
.gpio = 0x0000,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE2,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE2,
.gpio = 0x0000,
- },{
- .name = name_svideo,
- .vmux = 6,
- .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 6,
+ .amux = LINE2,
.gpio = 0x0000,
- }},
- .radio = {
- .name = name_radio,
- .amux = TV,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = TV,
.gpio = 0x200000,
- },
+ },
+ .mute = {
+ .name = name_mute,
+ .gpio = 0x0000,
+ },
+
},
[SAA7134_BOARD_VA1000POWER] = {
- .name = "AOPEN VA1000 POWER",
+ .name = "AOPEN VA1000 POWER",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC,
- .inputs = {{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- }},
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ }},
},
[SAA7134_BOARD_10MOONSTVMASTER] = {
/* "lilicheng" <llc@linuxfans.org> */
.name = "10MOONS PCI TV CAPTURE CARD",
.audio_clock = 0x00200000,
.tuner_type = TUNER_LG_PAL_NEW_TAPC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0xe000,
.inputs = {{
.name = name_tv,
@@ -662,14 +752,14 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
.gpio = 0x4000,
}},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
.gpio = 0x2000,
- },
+ },
.mute = {
.name = name_mute,
- .amux = LINE2,
+ .amux = LINE2,
.gpio = 0x8000,
},
},
@@ -678,6 +768,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "BMK MPEX No Tuner",
.audio_clock = 0x200000,
.tuner_type = TUNER_ABSENT,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_comp1,
.vmux = 4,
@@ -706,80 +799,94 @@ struct saa7134_board saa7134_boards[] = {
.name = "Compro VideoMate TV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
- .inputs = {{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- }},
- },
- [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ }},
+ },
+ [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
.name = "Compro VideoMate TV Gold+",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
.gpiomask = 0x800c0000,
- .inputs = {{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- .gpio = 0x06c00012,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- .gpio = 0x0ac20012,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2,
- .gpio = 0x08c20012,
- .tv = 1,
- }},
- },
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ .gpio = 0x06c00012,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x0ac20012,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2,
+ .gpio = 0x08c20012,
+ .tv = 1,
+ }}, /* radio and probably mute is missing */
+ },
[SAA7134_BOARD_CRONOS_PLUS] = {
- /* gpio pins:
- 0 .. 3 BASE_ID
- 4 .. 7 PROTECT_ID
- 8 .. 11 USER_OUT
- 12 .. 13 USER_IN
- 14 .. 15 VIDIN_SEL */
+ /*
+ gpio pins:
+ 0 .. 3 BASE_ID
+ 4 .. 7 PROTECT_ID
+ 8 .. 11 USER_OUT
+ 12 .. 13 USER_IN
+ 14 .. 15 VIDIN_SEL
+ */
.name = "Matrox CronosPlus",
.tuner_type = TUNER_ABSENT,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0xcf00,
- .inputs = {{
- .name = name_comp1,
- .vmux = 0,
+ .inputs = {{
+ .name = name_comp1,
+ .vmux = 0,
.gpio = 2 << 14,
},{
- .name = name_comp2,
- .vmux = 0,
+ .name = name_comp2,
+ .vmux = 0,
.gpio = 1 << 14,
},{
- .name = name_comp3,
- .vmux = 0,
+ .name = name_comp3,
+ .vmux = 0,
.gpio = 0 << 14,
},{
- .name = name_comp4,
- .vmux = 0,
+ .name = name_comp4,
+ .vmux = 0,
.gpio = 3 << 14,
},{
.name = name_svideo,
.vmux = 8,
.gpio = 2 << 14,
- }},
- },
+ }},
+ },
[SAA7134_BOARD_MD2819] = {
.name = "AverMedia M156 / Medion 2819",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -809,6 +916,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "BMK MPEX Tuner",
.audio_clock = 0x200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_comp1,
.vmux = 1,
@@ -825,62 +935,72 @@ struct saa7134_board saa7134_boards[] = {
}},
.mpeg = SAA7134_MPEG_EMPRESS,
.video_out = CCIR656,
- },
- [SAA7134_BOARD_ASUSTEK_TVFM7133] = {
- .name = "ASUS TV-FM 7133",
- .audio_clock = 0x00187de7,
- // probably wrong, the 7133 one is the NTSC version ...
- // .tuner_type = TUNER_PHILIPS_FM1236_MK3
- .tuner_type = TUNER_LG_NTSC_NEW_TAPC,
- .tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE2,
- },{
- .name = name_svideo,
- .vmux = 6,
- .amux = LINE2,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE1,
- },
- },
+ },
+ [SAA7134_BOARD_ASUSTEK_TVFM7133] = {
+ .name = "ASUS TV-FM 7133",
+ .audio_clock = 0x00187de7,
+ /* probably wrong, the 7133 one is the NTSC version ...
+ * .tuner_type = TUNER_PHILIPS_FM1236_MK3 */
+ .tuner_type = TUNER_LG_NTSC_NEW_TAPC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 6,
+ .amux = LINE2,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE1,
+ },
+ },
[SAA7134_BOARD_PINNACLE_PCTV_STEREO] = {
- .name = "Pinnacle PCTV Stereo (saa7134)",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_MT2032,
- .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
- .inputs = {{
- .name = name_tv,
- .vmux = 3,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 0,
- .amux = LINE2,
- },{
- .name = name_comp2,
- .vmux = 1,
- .amux = LINE2,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE2,
- }},
- },
+ .name = "Pinnacle PCTV Stereo (saa7134)",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_MT2032,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 0,
+ .amux = LINE2,
+ },{
+ .name = name_comp2,
+ .vmux = 1,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE2,
+ }},
+ },
[SAA7134_BOARD_MANLI_MTV002] = {
/* Ognjen Nastic <ognjen@logosoft.ba> */
.name = "Manli MuchTV M-TV002/Behold TV 403 FM",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_svideo,
.vmux = 8,
@@ -905,6 +1025,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "Manli MuchTV M-TV001/Behold TV 401",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_svideo,
.vmux = 8,
@@ -921,14 +1044,17 @@ struct saa7134_board saa7134_boards[] = {
}},
.mute = {
.name = name_mute,
- .amux = LINE1,
+ .amux = LINE1,
},
- },
+ },
[SAA7134_BOARD_TG3000TV] = {
/* TransGear 3000TV */
.name = "Nagase Sangyo TransGear 3000TV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_tv,
.vmux = 1,
@@ -944,81 +1070,90 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
}},
},
- [SAA7134_BOARD_ECS_TVP3XP] = {
- .name = "Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) ",
- .audio_clock = 0x187de7, // xtal 32.1 MHz
- .tuner_type = TUNER_PHILIPS_PAL,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_tv_mono,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
+ [SAA7134_BOARD_ECS_TVP3XP] = {
+ .name = "Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) ",
+ .audio_clock = 0x187de7, /* xtal 32.1 MHz */
+ .tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_tv_mono,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
},{
.name = "CVid over SVid",
.vmux = 0,
.amux = LINE1,
}},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
- },
- },
- [SAA7134_BOARD_ECS_TVP3XP_4CB5] = {
- .name = "Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM)",
- .audio_clock = 0x187de7,
- .tuner_type = TUNER_PHILIPS_NTSC,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_tv_mono,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = "CVid over SVid",
- .vmux = 0,
- .amux = LINE1,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
- },
- },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
+ [SAA7134_BOARD_ECS_TVP3XP_4CB5] = {
+ .name = "Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM)",
+ .audio_clock = 0x187de7,
+ .tuner_type = TUNER_PHILIPS_NTSC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_tv_mono,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = "CVid over SVid",
+ .vmux = 0,
+ .amux = LINE1,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
[SAA7134_BOARD_AVACSSMARTTV] = {
/* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */
.name = "AVACS SmartTV",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_tv,
.vmux = 1,
.amux = TV,
.tv = 1,
- },{
+ },{
.name = name_tv_mono,
.vmux = 1,
.amux = LINE2,
@@ -1047,6 +1182,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "AVerMedia DVD EZMaker",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_ABSENT,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_comp1,
.vmux = 3,
@@ -1055,28 +1193,34 @@ struct saa7134_board saa7134_boards[] = {
.vmux = 8,
}},
},
- [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
- /* toshii@netbsd.org */
- .name = "Noval Prime TV 7133",
- .audio_clock = 0x00200000,
- .tuner_type = TUNER_ALPS_TSBH1_NTSC,
- .inputs = {{
- .name = name_comp1,
- .vmux = 3,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_svideo,
- .vmux = 8,
- }},
- },
+ [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
+ /* toshii@netbsd.org */
+ .name = "Noval Prime TV 7133",
+ .audio_clock = 0x00200000,
+ .tuner_type = TUNER_ALPS_TSBH1_NTSC,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_comp1,
+ .vmux = 3,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ }},
+ },
[SAA7134_BOARD_AVERMEDIA_STUDIO_305] = {
.name = "AverMedia AverTV Studio 305",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1256_IH3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -1097,35 +1241,41 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
}},
.radio = {
- .name = name_radio,
- .amux = LINE2,
- },
+ .name = name_radio,
+ .amux = LINE2,
+ },
.mute = {
- .name = name_mute,
- .amux = LINE1,
+ .name = name_mute,
+ .amux = LINE1,
},
},
- [SAA7133_BOARD_UPMOST_PURPLE_TV] = {
- .name = "UPMOST PURPLE TV",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_FM1236_MK3,
- .tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 7,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_svideo,
- .vmux = 7,
- .amux = LINE1,
- }},
+ [SAA7134_BOARD_UPMOST_PURPLE_TV] = {
+ .name = "UPMOST PURPLE TV",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FM1236_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 7,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_svideo,
+ .vmux = 7,
+ .amux = LINE1,
+ }},
},
[SAA7134_BOARD_ITEMS_MTV005] = {
/* Norman Jonas <normanjonas@arcor.de> */
.name = "Items MuchTV Plus / IT-005",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_tv,
.vmux = 3,
@@ -1149,27 +1299,30 @@ struct saa7134_board saa7134_boards[] = {
.name = "Terratec Cinergy 200 TV",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
- .name = name_tv,
+ .name = name_tv,
.vmux = 1,
.amux = LINE2,
.tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp2, // CVideo over SVideo Connector
- .vmux = 0,
- .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp2, /* CVideo over SVideo Connector */
+ .vmux = 0,
+ .amux = LINE1,
}},
.mute = {
- .name = name_mute,
- .amux = LINE2,
+ .name = name_mute,
+ .amux = LINE2,
},
},
[SAA7134_BOARD_VIDEOMATE_TV_PVR] = {
@@ -1177,84 +1330,96 @@ struct saa7134_board saa7134_boards[] = {
.name = "Compro VideoMate TV PVR/FM",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC_M,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0x808c0080,
- .inputs = {{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
.gpio = 0x00080,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
.gpio = 0x00080,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2_LEFT,
- .tv = 1,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2_LEFT,
+ .tv = 1,
.gpio = 0x00080,
- }},
+ }},
.radio = {
.name = name_radio,
.amux = LINE2,
.gpio = 0x80000,
- },
+ },
.mute = {
.name = name_mute,
- .amux = LINE2,
+ .amux = LINE2,
.gpio = 0x40000,
},
- },
- [SAA7134_BOARD_SABRENT_SBTTVFM] = {
+ },
+ [SAA7134_BOARD_SABRENT_SBTTVFM] = {
/* Michael Rodriguez-Torrent <mrtorrent@asu.edu> */
- .name = "Sabrent SBT-TVFM (saa7130)",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_NTSC_M,
- .inputs = {{
+ .name = "Sabrent SBT-TVFM (saa7130)",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_NTSC_M,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
.name = name_comp1,
.vmux = 1,
.amux = LINE2,
},{
- .name = name_tv,
- .vmux = 3,
- .amux = LINE2,
- .tv = 1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE2,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
- },
- },
+ .name = name_tv,
+ .vmux = 3,
+ .amux = LINE2,
+ .tv = 1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE2,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ },
[SAA7134_BOARD_ZOLID_XPERT_TV7134] = {
/* Helge Jensen <helge.jensen@slog.dk> */
- .name = ":Zolid Xpert TV7134",
+ .name = ":Zolid Xpert TV7134",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_NTSC,
- .inputs = {{
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
.name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = LINE2,
- .tv = 1,
- }},
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = LINE2,
+ .tv = 1,
+ }},
},
[SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = {
/* "Matteo Az" <matte.az@nospam.libero.it> ;-) */
.name = "Empire PCI TV-Radio LE",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0x4000,
.inputs = {{
.name = name_tv_mono,
@@ -1273,18 +1438,18 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE1,
.gpio = 0x8000,
}},
- .radio = {
- .name = name_radio,
- .amux = LINE1,
- .gpio = 0x8000,
- },
+ .radio = {
+ .name = name_radio,
+ .amux = LINE1,
+ .gpio = 0x8000,
+ },
.mute = {
- .name = name_mute,
- .amux = TV,
- .gpio =0x8000,
- }
+ .name = name_mute,
+ .amux = TV,
+ .gpio =0x8000,
+ }
},
- [SAA7134_BOARD_AVERMEDIA_STUDIO_307] = {
+ [SAA7134_BOARD_AVERMEDIA_STUDIO_307] = {
/*
Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Lots of thanks to Andrey Zolotarev <zolotarev_andrey@mail.ru>
@@ -1292,6 +1457,9 @@ struct saa7134_board saa7134_boards[] = {
.name = "Avermedia AVerTV Studio 307",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1256_IH3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.gpiomask = 0x03,
.inputs = {{
@@ -1321,13 +1489,21 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE1,
.gpio = 0x01,
},
- },
- [SAA7134_BOARD_AVERMEDIA_GO_007_FM] = {
+ .mute = {
+ .name = name_mute,
+ .amux = LINE1,
+ .gpio = 0x00,
+ },
+ },
+ [SAA7134_BOARD_AVERMEDIA_GO_007_FM] = {
.name = "Avermedia AVerTV GO 007 FM",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.gpiomask = 0x00300003,
-// .gpiomask = 0x8c240003,
+ /* .gpiomask = 0x8c240003, */
.inputs = {{
.name = name_tv,
.vmux = 1,
@@ -1350,16 +1526,24 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE1,
.gpio = 0x00300001,
},
- },
+ .mute = {
+ .name = name_mute,
+ .amux = TV,
+ .gpio = 0x01,
+ },
+ },
[SAA7134_BOARD_AVERMEDIA_CARDBUS] = {
- /* Jon Westgate <oryn@oryn.fsck.tv> */
- .name = "AVerMedia Cardbus TV/Radio",
- .audio_clock = 0x00200000,
- .tuner_type = TUNER_PHILIPS_PAL,
+ /* Kees.Blom@cwi.nl */
+ .name = "AVerMedia Cardbus TV/Radio (E500)",
+ .audio_clock = 0x187de7,
+ .tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.inputs = {{
.name = name_tv,
.vmux = 1,
- .amux = LINE2,
+ .amux = TV,
.tv = 1,
},{
.name = name_comp1,
@@ -1368,10 +1552,10 @@ struct saa7134_board saa7134_boards[] = {
},{
.name = name_svideo,
.vmux = 8,
- .amux = LINE2,
+ .amux = LINE1,
}},
.radio = {
- .name = name_radio,
+ .name = name_radio,
.amux = LINE1,
},
},
@@ -1379,119 +1563,134 @@ struct saa7134_board saa7134_boards[] = {
.name = "Terratec Cinergy 400 mobile",
.audio_clock = 0x187de7,
.tuner_type = TUNER_ALPS_TSBE5_PAL,
- .tda9887_conf = TDA9887_PRESENT,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
.inputs = {{
- .name = name_tv,
+ .name = name_tv,
.vmux = 1,
.amux = TV,
.tv = 1,
- },{
+ },{
.name = name_tv_mono,
.vmux = 1,
.amux = LINE2,
.tv = 1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
}},
},
[SAA7134_BOARD_CINERGY600_MK3] = {
- .name = "Terratec Cinergy 600 TV MK3",
- .audio_clock = 0x00200000,
+ .name = "Terratec Cinergy 600 TV MK3",
+ .audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
- .tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 4,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- },{
- .name = name_comp2, // CVideo over SVideo Connector
- .vmux = 0,
- .amux = LINE1,
- }},
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 4,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ },{
+ .name = name_comp2, /* CVideo over SVideo Connector */
+ .vmux = 0,
+ .amux = LINE1,
+ }},
.radio = {
.name = name_radio,
.amux = LINE2,
- },
- },
- [SAA7134_BOARD_VIDEOMATE_GOLD_PLUS] = {
- /* Dylan Walkden <dylan_walkden@hotmail.com> */
- .name = "Compro VideoMate Gold+ Pal",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_PAL,
- .gpiomask = 0x1ce780,
- .inputs = {{
- .name = name_svideo,
- .vmux = 0, // CVideo over SVideo Connector - ok?
- .amux = LINE1,
- .gpio = 0x008080,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- .gpio = 0x008080,
- },{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- .gpio = 0x008080,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE2,
- .gpio = 0x80000,
- },
- .mute = {
- .name = name_mute,
- .amux = LINE2,
- .gpio = 0x0c8000,
- },
- },
+ },
+ },
+ [SAA7134_BOARD_VIDEOMATE_GOLD_PLUS] = {
+ /* Dylan Walkden <dylan_walkden@hotmail.com> */
+ .name = "Compro VideoMate Gold+ Pal",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_PAL,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .gpiomask = 0x1ce780,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 0, /* CVideo over SVideo Connector - ok? */
+ .amux = LINE1,
+ .gpio = 0x008080,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x008080,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x008080,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ .gpio = 0x80000,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = LINE2,
+ .gpio = 0x0c8000,
+ },
+ },
[SAA7134_BOARD_PINNACLE_300I_DVBT_PAL] = {
- .name = "Pinnacle PCTV 300i DVB-T + PAL",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_MT2032,
- .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
+ .name = "Pinnacle PCTV 300i DVB-T + PAL",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_MT2032,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER,
.mpeg = SAA7134_MPEG_DVB,
- .inputs = {{
- .name = name_tv,
- .vmux = 3,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 0,
- .amux = LINE2,
- },{
- .name = name_comp2,
- .vmux = 1,
- .amux = LINE2,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE2,
- }},
- },
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 3,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 0,
+ .amux = LINE2,
+ },{
+ .name = name_comp2,
+ .vmux = 1,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE2,
+ }},
+ },
[SAA7134_BOARD_PROVIDEO_PV952] = {
/* andreas.kretschmer@web.de */
.name = "ProVideo PV952",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_comp1,
@@ -1515,10 +1714,13 @@ struct saa7134_board saa7134_boards[] = {
},
[SAA7134_BOARD_AVERMEDIA_305] = {
/* much like the "studio" version but without radio
- * and another tuner (sirspiritus@yandex.ru) */
+ * and another tuner (sirspiritus@yandex.ru) */
.name = "AverMedia AverTV/305",
.audio_clock = 0x00187de7,
.tuner_type = TUNER_PHILIPS_FQ1216ME,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
.tda9887_conf = TDA9887_PRESENT,
.inputs = {{
.name = name_tv,
@@ -1539,115 +1741,268 @@ struct saa7134_board saa7134_boards[] = {
.amux = LINE2,
}},
.mute = {
- .name = name_mute,
- .amux = LINE1,
+ .name = name_mute,
+ .amux = LINE1,
},
},
[SAA7134_BOARD_FLYDVBTDUO] = {
/* LifeView FlyDVB-T DUO */
- /* "Nico Sabbi <nsabbi@tiscali.it> */
+ /* "Nico Sabbi <nsabbi@tiscali.it> Hartmut Hackmann hartmut.hackmann@t-online.de*/
.name = "LifeView FlyDVB-T DUO",
.audio_clock = 0x00200000,
.tuner_type = TUNER_PHILIPS_TDA8290,
-// .gpiomask = 0xe000,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .mpeg = SAA7134_MPEG_DVB,
.inputs = {{
.name = name_tv,
.vmux = 1,
.amux = TV,
-// .gpio = 0x0000,
.tv = 1,
- },{
+ },{
.name = name_comp1, /* Composite signal on S-Video input */
.vmux = 0,
.amux = LINE2,
-// .gpio = 0x4000,
},{
.name = name_comp2, /* Composite input */
.vmux = 3,
.amux = LINE2,
-// .gpio = 0x4000,
},{
.name = name_svideo, /* S-Video signal on S-Video input */
.vmux = 8,
.amux = LINE2,
-// .gpio = 0x4000,
}},
},
- [SAA7134_BOARD_AVERMEDIA_307] = {
- /*
- Davydov Vladimir <vladimir@iqmedia.com>
- */
- .name = "Avermedia AVerTV 307",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_FQ1216ME,
- .tda9887_conf = TDA9887_PRESENT,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 0,
- .amux = LINE1,
- },{
- .name = name_comp2,
- .vmux = 3,
- .amux = LINE1,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE1,
- }},
- },
+ [SAA7134_BOARD_PHILIPS_TOUGH] = {
+ .name = "Philips TOUGH DVB-T reference design",
+ .tuner_type = TUNER_ABSENT,
+ .audio_clock = 0x00187de7,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .mpeg = SAA7134_MPEG_DVB,
+ .inputs = {{
+ .name = name_comp1,
+ .vmux = 0,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ }},
+ },
+ [SAA7134_BOARD_AVERMEDIA_307] = {
+ /*
+ Davydov Vladimir <vladimir@iqmedia.com>
+ */
+ .name = "Avermedia AVerTV 307",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_FQ1216ME,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .tda9887_conf = TDA9887_PRESENT,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 0,
+ .amux = LINE1,
+ },{
+ .name = name_comp2,
+ .vmux = 3,
+ .amux = LINE1,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE1,
+ }},
+ },
[SAA7134_BOARD_ADS_INSTANT_TV] = {
- .name = "ADS Tech Instant TV (saa7135)",
+ .name = "ADS Tech Instant TV (saa7135)",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE2,
+ },{
+ .name = name_svideo,
+ .vmux = 8,
+ .amux = LINE2,
+ }},
+ },
+ [SAA7134_BOARD_KWORLD_VSTREAM_XPERT] = {
+ .name = "Kworld/Tevion V-Stream Xpert TV PVR7134",
.audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_TDA8290,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE2,
- },{
- .name = name_svideo,
- .vmux = 8,
- .amux = LINE2,
- }},
- },
- [SAA7134_BOARD_KWORLD_VSTREAM_XPERT] = {
- .name = "Kworld/Tevion V-Stream Xpert TV PVR7134",
- .audio_clock = 0x00187de7,
- .tuner_type = TUNER_PHILIPS_PAL_I,
- .gpiomask = 0x0700,
- .inputs = {{
- .name = name_tv,
- .vmux = 1,
- .amux = TV,
- .tv = 1,
- .gpio = 0x000,
- },{
- .name = name_comp1,
- .vmux = 3,
- .amux = LINE1,
- .gpio = 0x200, //gpio by DScaler
- },{
- .name = name_svideo,
- .vmux = 0,
- .amux = LINE1,
- .gpio = 0x200,
- }},
- .radio = {
- .name = name_radio,
- .amux = LINE1,
- .gpio = 0x100,
- },
- },
- };
+ .tuner_type = TUNER_PHILIPS_PAL_I,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .gpiomask = 0x0700,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x000,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x200, /* gpio by DScaler */
+ },{
+ .name = name_svideo,
+ .vmux = 0,
+ .amux = LINE1,
+ .gpio = 0x200,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE1,
+ .gpio = 0x100,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = TV,
+ .gpio = 0x000,
+ },
+ },
+ [SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS] = {
+ .name = "Typhoon DVB-T Duo Digital/Analog Cardbus",
+ .audio_clock = 0x00200000,
+ .tuner_type = TUNER_PHILIPS_TDA8290,
+ .radio_type = UNSET,
+ .tuner_addr = ADDR_UNSET,
+ .radio_addr = ADDR_UNSET,
+ .mpeg = SAA7134_MPEG_DVB,
+ /* .gpiomask = 0xe000, */
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ /* .gpio = 0x0000, */
+ .tv = 1,
+ },{
+ .name = name_comp1, /* Composite signal on S-Video input */
+ .vmux = 0,
+ .amux = LINE2,
+ /* .gpio = 0x4000, */
+ },{
+ .name = name_comp2, /* Composite input */
+ .vmux = 3,
+ .amux = LINE2,
+ /* .gpio = 0x4000, */
+ },{
+ .name = name_svideo, /* S-Video signal on S-Video input */
+ .vmux = 8,
+ .amux = LINE2,
+ /* .gpio = 0x4000, */
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE2,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = LINE1,
+ },
+ },
+ [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII] = {
+ .name = "Compro VideoMate TV Gold+II",
+ .audio_clock = 0x002187de7,
+ .tuner_type = TUNER_LG_PAL_NEW_TAPC,
+ .radio_type = TUNER_TEA5767,
+ .tuner_addr = 0x63,
+ .radio_addr = 0x60,
+ .gpiomask = 0x8c1880,
+ .inputs = {{
+ .name = name_svideo,
+ .vmux = 0,
+ .amux = LINE1,
+ .gpio = 0x800800,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x801000,
+ },{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x800000,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = TV,
+ .gpio = 0x880000,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = LINE2,
+ .gpio = 0x840000,
+ },
+ },
+ [SAA7134_BOARD_KWORLD_XPERT] = {
+ /*
+ FIXME:
+ - Remote control doesn't initialize properly.
+ - Audio volume starts muted,
+ then gradually increases after channel change.
+ - Overlay scaling problems (application error?)
+ - Composite S-Video untested.
+ From: Konrad Rzepecki <hannibal@megapolis.pl>
+ */
+ .name = "Kworld Xpert TV PVR7134",
+ .audio_clock = 0x00187de7,
+ .tuner_type = TUNER_TENA_9533_DI,
+ .radio_type = TUNER_TEA5767,
+ .tuner_addr = 0x61,
+ .radio_addr = 0x60,
+ .gpiomask = 0x0700,
+ .inputs = {{
+ .name = name_tv,
+ .vmux = 1,
+ .amux = TV,
+ .tv = 1,
+ .gpio = 0x000,
+ },{
+ .name = name_comp1,
+ .vmux = 3,
+ .amux = LINE1,
+ .gpio = 0x200, /* gpio by DScaler */
+ },{
+ .name = name_svideo,
+ .vmux = 0,
+ .amux = LINE1,
+ .gpio = 0x200,
+ }},
+ .radio = {
+ .name = name_radio,
+ .amux = LINE1,
+ .gpio = 0x100,
+ },
+ .mute = {
+ .name = name_mute,
+ .amux = TV,
+ .gpio = 0x000,
+ },
+ },
+};
+
const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -1661,13 +2016,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subvendor = PCI_VENDOR_ID_PHILIPS,
.subdevice = 0x2001,
.driver_data = SAA7134_BOARD_PROTEUS_PRO,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = PCI_VENDOR_ID_PHILIPS,
.subdevice = 0x2001,
.driver_data = SAA7134_BOARD_PROTEUS_PRO,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = PCI_VENDOR_ID_PHILIPS,
@@ -1676,70 +2031,70 @@ struct pci_device_id saa7134_pci_tbl[] = {
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x1131,
- .subdevice = 0x4e85,
+ .subvendor = 0x1131,
+ .subdevice = 0x4e85,
.driver_data = SAA7134_BOARD_MONSTERTV,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x153B,
- .subdevice = 0x1142,
- .driver_data = SAA7134_BOARD_CINERGY400,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x153B,
- .subdevice = 0x1143,
- .driver_data = SAA7134_BOARD_CINERGY600,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x153B,
- .subdevice = 0x1158,
- .driver_data = SAA7134_BOARD_CINERGY600_MK3,
- },{
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x153B,
+ .subdevice = 0x1142,
+ .driver_data = SAA7134_BOARD_CINERGY400,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x153B,
+ .subdevice = 0x1143,
+ .driver_data = SAA7134_BOARD_CINERGY600,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x153B,
+ .subdevice = 0x1158,
+ .driver_data = SAA7134_BOARD_CINERGY600_MK3,
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x153b,
.subdevice = 0x1162,
.driver_data = SAA7134_BOARD_CINERGY400_CARDBUS,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x5168,
.subdevice = 0x0138,
.driver_data = SAA7134_BOARD_FLYVIDEO3000,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x4e42, //"Typhoon PCI Capture TV Card" Art.No. 50673
- .subdevice = 0x0138,
- .driver_data = SAA7134_BOARD_FLYVIDEO3000,
- },{
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x4e42, /* "Typhoon PCI Capture TV Card" Art.No. 50673 */
+ .subdevice = 0x0138,
+ .driver_data = SAA7134_BOARD_FLYVIDEO3000,
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
.subvendor = 0x5168,
.subdevice = 0x0138,
.driver_data = SAA7134_BOARD_FLYVIDEO2000,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7135,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5168,
.subdevice = 0x0212, /* minipci, LR212 */
.driver_data = SAA7134_BOARD_FLYTVPLATINUM_MINI,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5168, /* Animation Technologies (LifeView) */
.subdevice = 0x0214, /* Standard PCI, LR214WF */
.driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x1489, /* KYE */
.subdevice = 0x0214, /* Genius VideoWonder ProTV */
.driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, /* is an LR214WF actually */
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x16be,
@@ -1758,36 +2113,36 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice = 0x226b,
.driver_data = SAA7134_BOARD_ELSA_500TV,
},{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = PCI_VENDOR_ID_ASUSTEK,
- .subdevice = 0x4842,
- .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = PCI_VENDOR_ID_ASUSTEK,
+ .subdevice = 0x4842,
+ .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
},{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7135,
- .subvendor = PCI_VENDOR_ID_ASUSTEK,
- .subdevice = 0x4845,
- .driver_data = SAA7135_BOARD_ASUSTeK_TVFM7135,
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = PCI_VENDOR_ID_ASUSTEK,
+ .subdevice = 0x4845,
+ .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7135,
},{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = PCI_VENDOR_ID_ASUSTEK,
- .subdevice = 0x4830,
- .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = PCI_VENDOR_ID_ASUSTEK,
- .subdevice = 0x4843,
- .driver_data = SAA7134_BOARD_ASUSTEK_TVFM7133,
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = PCI_VENDOR_ID_ASUSTEK,
+ .subdevice = 0x4830,
+ .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = PCI_VENDOR_ID_ASUSTEK,
+ .subdevice = 0x4843,
+ .driver_data = SAA7134_BOARD_ASUSTEK_TVFM7133,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = PCI_VENDOR_ID_ASUSTEK,
+ .subdevice = 0x4840,
+ .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
},{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = PCI_VENDOR_ID_ASUSTEK,
- .subdevice = 0x4840,
- .driver_data = SAA7134_BOARD_ASUSTeK_TVFM7134,
- },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = PCI_VENDOR_ID_PHILIPS,
@@ -1808,118 +2163,118 @@ struct pci_device_id saa7134_pci_tbl[] = {
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x1131,
- .subdevice = 0x7133,
+ .subvendor = 0x1131,
+ .subdevice = 0x7133,
.driver_data = SAA7134_BOARD_VA1000POWER,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = PCI_VENDOR_ID_PHILIPS,
- .subdevice = 0x2001,
+ .subvendor = PCI_VENDOR_ID_PHILIPS,
+ .subdevice = 0x2001,
.driver_data = SAA7134_BOARD_10MOONSTVMASTER,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = 0x185b,
- .subdevice = 0xc100,
+ .subvendor = 0x185b,
+ .subdevice = 0xc100,
.driver_data = SAA7134_BOARD_VIDEOMATE_TV,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = 0x185b,
- .subdevice = 0xc100,
+ .subvendor = 0x185b,
+ .subdevice = 0xc100,
.driver_data = SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = PCI_VENDOR_ID_MATROX,
- .subdevice = 0x48d0,
+ .subvendor = PCI_VENDOR_ID_MATROX,
+ .subdevice = 0x48d0,
.driver_data = SAA7134_BOARD_CRONOS_PLUS,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0xa70b,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0xa70b,
.driver_data = SAA7134_BOARD_MD2819,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0x2115,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0x2115,
.driver_data = SAA7134_BOARD_AVERMEDIA_STUDIO_305,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0x2108,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0x2108,
.driver_data = SAA7134_BOARD_AVERMEDIA_305,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0x10ff,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0x10ff,
.driver_data = SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER,
- },{
+ },{
/* AVerMedia CardBus */
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0xd6ee,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0xd6ee,
.driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS,
},{
/* TransGear 3000TV */
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x1461, /* Avermedia Technologies Inc */
- .subdevice = 0x050c,
+ .subvendor = 0x1461, /* Avermedia Technologies Inc */
+ .subdevice = 0x050c,
.driver_data = SAA7134_BOARD_TG3000TV,
},{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x11bd,
- .subdevice = 0x002b,
- .driver_data = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x11bd,
- .subdevice = 0x002d,
- .driver_data = SAA7134_BOARD_PINNACLE_300I_DVBT_PAL,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = 0x1019,
- .subdevice = 0x4cb4,
- .driver_data = SAA7134_BOARD_ECS_TVP3XP,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = 0x1019,
- .subdevice = 0x4cb5,
- .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
- },{
.vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = 0x12ab,
- .subdevice = 0x0800,
- .driver_data = SAA7133_BOARD_UPMOST_PURPLE_TV,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x11bd,
+ .subdevice = 0x002b,
+ .driver_data = SAA7134_BOARD_PINNACLE_PCTV_STEREO,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x11bd,
+ .subdevice = 0x002d,
+ .driver_data = SAA7134_BOARD_PINNACLE_300I_DVBT_PAL,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = 0x1019,
+ .subdevice = 0x4cb4,
+ .driver_data = SAA7134_BOARD_ECS_TVP3XP,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = 0x1019,
+ .subdevice = 0x4cb5,
+ .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = 0x12ab,
+ .subdevice = 0x0800,
+ .driver_data = SAA7134_BOARD_UPMOST_PURPLE_TV,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
.subvendor = 0x153B,
.subdevice = 0x1152,
.driver_data = SAA7134_BOARD_CINERGY200,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x185b,
- .subdevice = 0xc100,
+ .subvendor = 0x185b,
+ .subdevice = 0xc100,
.driver_data = SAA7134_BOARD_VIDEOMATE_TV_PVR,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = 0x1131,
- .subdevice = 0,
+ .subvendor = 0x1131,
+ .subdevice = 0,
.driver_data = SAA7134_BOARD_SABRENT_SBTTVFM,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
@@ -1939,18 +2294,24 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subvendor = 0x185b,
.subdevice = 0xc200,
.driver_data = SAA7134_BOARD_VIDEOMATE_GOLD_PLUS,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
.subvendor = 0x1540,
.subdevice = 0x9524,
.driver_data = SAA7134_BOARD_PROVIDEO_PV952,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x5168,
- .subdevice = 0x0306,
+ .subdevice = 0x0502, /* Cardbus version */
+ .driver_data = SAA7134_BOARD_FLYDVBTDUO,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = 0x5168,
+ .subdevice = 0x0306, /* PCI version */
.driver_data = SAA7134_BOARD_FLYDVBTDUO,
},{
.vendor = PCI_VENDOR_ID_PHILIPS,
@@ -1959,31 +2320,44 @@ struct pci_device_id saa7134_pci_tbl[] = {
.subdevice = 0xf31f,
.driver_data = SAA7134_BOARD_AVERMEDIA_GO_007_FM,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7135,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
+ .subvendor = PCI_VENDOR_ID_PHILIPS,
+ .subdevice = 0x2004,
+ .driver_data = SAA7134_BOARD_PHILIPS_TOUGH,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x1421,
.subdevice = 0x0350, /* PCI version */
.driver_data = SAA7134_BOARD_ADS_INSTANT_TV,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7135,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
.subvendor = 0x1421,
.subdevice = 0x0370, /* cardbus version */
.driver_data = SAA7134_BOARD_ADS_INSTANT_TV,
- },{
+ },{ /* Typhoon DVB-T Duo Digital/Analog Cardbus */
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
+ .subvendor = 0x4e42,
+ .subdevice = 0x0502,
+ .driver_data = SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS,
+
+ },{
/* --- boards without eeprom + subsystem ID --- */
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = PCI_VENDOR_ID_PHILIPS,
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
+ .subvendor = PCI_VENDOR_ID_PHILIPS,
.subdevice = 0,
.driver_data = SAA7134_BOARD_NOAUTO,
- },{
- .vendor = PCI_VENDOR_ID_PHILIPS,
- .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = PCI_VENDOR_ID_PHILIPS,
+ },{
+ .vendor = PCI_VENDOR_ID_PHILIPS,
+ .device = PCI_DEVICE_ID_PHILIPS_SAA7130,
+ .subvendor = PCI_VENDOR_ID_PHILIPS,
.subdevice = 0,
.driver_data = SAA7134_BOARD_NOAUTO,
},{
@@ -1991,26 +2365,26 @@ struct pci_device_id saa7134_pci_tbl[] = {
/* --- default catch --- */
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7130,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
.driver_data = SAA7134_BOARD_UNKNOWN,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7133,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
.driver_data = SAA7134_BOARD_UNKNOWN,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7134,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
.driver_data = SAA7134_BOARD_UNKNOWN,
- },{
+ },{
.vendor = PCI_VENDOR_ID_PHILIPS,
.device = PCI_DEVICE_ID_PHILIPS_SAA7135,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
.driver_data = SAA7134_BOARD_UNKNOWN,
},{
/* --- end of list --- */
@@ -2021,46 +2395,9 @@ MODULE_DEVICE_TABLE(pci, saa7134_pci_tbl);
/* ----------------------------------------------------------- */
/* flyvideo tweaks */
-#if 0
-static struct {
- char *model;
- int tuner_type;
-} fly_list[0x20] = {
- /* default catch ... */
- [ 0 ... 0x1f ] = {
- .model = "UNKNOWN",
- .tuner_type = TUNER_ABSENT,
- },
- /* ... the ones known so far */
- [ 0x05 ] = {
- .model = "PAL-BG",
- .tuner_type = TUNER_LG_PAL_NEW_TAPC,
- },
- [ 0x10 ] = {
- .model = "PAL-BG / PAL-DK",
- .tuner_type = TUNER_PHILIPS_PAL,
- },
- [ 0x15 ] = {
- .model = "NTSC",
- .tuner_type = TUNER_ABSENT /* FIXME */,
- },
-};
-#endif
static void board_flyvideo(struct saa7134_dev *dev)
{
-#if 0
- /* non-working attempt to detect the correct tuner type ... */
- u32 value;
- int index;
-
- value = dev->gpio_value;
- index = (value & 0x1f00) >> 8;
- printk(KERN_INFO "%s: flyvideo: gpio is 0x%x [model=%s,tuner=%d]\n",
- dev->name, value, fly_list[index].model,
- fly_list[index].tuner_type);
- dev->tuner_type = fly_list[index].tuner_type;
-#endif
printk("%s: there are different flyvideo cards with different tuners\n"
"%s: out there, you might have to use the tuner=<nr> insmod\n"
"%s: option to override the default value.\n",
@@ -2071,7 +2408,7 @@ static void board_flyvideo(struct saa7134_dev *dev)
int saa7134_board_init1(struct saa7134_dev *dev)
{
- // Always print gpio, often manufacturers encode tuner type and other info.
+ /* Always print gpio, often manufacturers encode tuner type and other info. */
saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0);
dev->gpio_value = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
printk(KERN_INFO "%s: board init: gpio is %x\n", dev->name, dev->gpio_value);
@@ -2082,7 +2419,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
dev->has_remote = 1;
board_flyvideo(dev);
break;
- case SAA7134_BOARD_FLYTVPLATINUM_FM:
+ case SAA7134_BOARD_FLYTVPLATINUM_FM:
case SAA7134_BOARD_CINERGY400:
case SAA7134_BOARD_CINERGY600:
case SAA7134_BOARD_CINERGY600_MK3:
@@ -2090,23 +2427,25 @@ int saa7134_board_init1(struct saa7134_dev *dev)
case SAA7134_BOARD_ECS_TVP3XP_4CB5:
case SAA7134_BOARD_MD2819:
case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
+ case SAA7134_BOARD_KWORLD_XPERT:
case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
case SAA7134_BOARD_AVERMEDIA_305:
case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
case SAA7134_BOARD_AVERMEDIA_307:
case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
-// case SAA7134_BOARD_SABRENT_SBTTVFM: /* not finished yet */
+/* case SAA7134_BOARD_SABRENT_SBTTVFM: */ /* not finished yet */
case SAA7134_BOARD_VIDEOMATE_TV_PVR:
- case SAA7134_BOARD_MANLI_MTV001:
- case SAA7134_BOARD_MANLI_MTV002:
+ case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
+ case SAA7134_BOARD_MANLI_MTV001:
+ case SAA7134_BOARD_MANLI_MTV002:
case SAA7134_BOARD_AVACSSMARTTV:
dev->has_remote = 1;
break;
case SAA7134_BOARD_MD5044:
printk("%s: seems there are two different versions of the MD5044\n"
- "%s: (with the same ID) out there. If sound doesn't work for\n"
- "%s: you try the audio_clock_override=0x200000 insmod option.\n",
- dev->name,dev->name,dev->name);
+ "%s: (with the same ID) out there. If sound doesn't work for\n"
+ "%s: you try the audio_clock_override=0x200000 insmod option.\n",
+ dev->name,dev->name,dev->name);
break;
case SAA7134_BOARD_CINERGY400_CARDBUS:
/* power-up tuner chip */
@@ -2114,11 +2453,19 @@ int saa7134_board_init1(struct saa7134_dev *dev)
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x00040000, 0x00000000);
msleep(1);
break;
+ case SAA7134_BOARD_FLYDVBTDUO:
+ case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS:
+ /* turn the fan on Hac: static for the time being */
+ saa_writeb(SAA7134_GPIO_GPMODE3, 0x08);
+ saa_writeb(SAA7134_GPIO_GPSTATUS3, 0x06);
+ break;
+ case SAA7134_BOARD_AVERMEDIA_CARDBUS:
+ /* power-up tuner chip */
+ saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
+ saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff);
+ msleep(1);
+ break;
}
- if (dev->has_remote)
- dev->irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
- SAA7134_IRQ2_INTE_GPIO18A |
- SAA7134_IRQ2_INTE_GPIO16 );
return 0;
}
@@ -2139,10 +2486,85 @@ int saa7134_board_init2(struct saa7134_dev *dev)
break;
dev->board = board;
printk("%s: board type fixup: %s\n", dev->name,
- saa7134_boards[dev->board].name);
+ saa7134_boards[dev->board].name);
dev->tuner_type = saa7134_boards[dev->board].tuner_type;
- if (TUNER_ABSENT != dev->tuner_type)
- saa7134_i2c_call_clients(dev,TUNER_SET_TYPE,&dev->tuner_type);
+
+ if (TUNER_ABSENT != dev->tuner_type) {
+ struct tuner_setup tun_setup;
+
+ tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
+ tun_setup.type = dev->tuner_type;
+ tun_setup.addr = ADDR_UNSET;
+
+ saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
+ break;
+case SAA7134_BOARD_MD7134:
+ {
+ struct tuner_setup tun_setup;
+ u8 subaddr;
+ u8 data[3];
+ int ret, tuner_t;
+
+ struct i2c_msg msg[] = {{.addr=0x50, .flags=0, .buf=&subaddr, .len = 1},
+ {.addr=0x50, .flags=I2C_M_RD, .buf=data, .len = 3}};
+ subaddr= 0x14;
+ tuner_t = 0;
+ ret = i2c_transfer(&dev->i2c_adap, msg, 2);
+ if (ret != 2) {
+ printk(KERN_ERR "EEPROM read failure\n");
+ } else if ((data[0] != 0) && (data[0] != 0xff)) {
+ /* old config structure */
+ subaddr = data[0] + 2;
+ msg[1].len = 2;
+ i2c_transfer(&dev->i2c_adap, msg, 2);
+ tuner_t = (data[0] << 8) + data[1];
+ switch (tuner_t){
+ case 0x0103:
+ dev->tuner_type = TUNER_PHILIPS_PAL;
+ break;
+ case 0x010C:
+ dev->tuner_type = TUNER_PHILIPS_FM1216ME_MK3;
+ break;
+ default:
+ printk(KERN_ERR "%s Cant determine tuner type %x from EEPROM\n", dev->name, tuner_t);
+ }
+ } else if ((data[1] != 0) && (data[1] != 0xff)) {
+ /* new config structure */
+ subaddr = data[1] + 1;
+ msg[1].len = 1;
+ i2c_transfer(&dev->i2c_adap, msg, 2);
+ subaddr = data[0] + 1;
+ msg[1].len = 2;
+ i2c_transfer(&dev->i2c_adap, msg, 2);
+ tuner_t = (data[1] << 8) + data[0];
+ switch (tuner_t) {
+ case 0x0005:
+ dev->tuner_type = TUNER_PHILIPS_FM1216ME_MK3;
+ break;
+ case 0x001d:
+ dev->tuner_type = TUNER_PHILIPS_FMD1216ME_MK3;
+ printk(KERN_INFO "%s Board has DVB-T\n", dev->name);
+ break;
+ default:
+ printk(KERN_ERR "%s Cant determine tuner type %x from EEPROM\n", dev->name, tuner_t);
+ }
+ } else {
+ printk(KERN_ERR "%s unexpected config structure\n", dev->name);
+ }
+
+ printk(KERN_INFO "%s Tuner type is %d\n", dev->name, dev->tuner_type);
+ if (dev->tuner_type == TUNER_PHILIPS_FMD1216ME_MK3) {
+ dev->tda9887_conf = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE | TDA9887_PORT2_ACTIVE;
+ saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG, &dev->tda9887_conf);
+ }
+
+ tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
+ tun_setup.type = dev->tuner_type;
+ tun_setup.addr = ADDR_UNSET;
+
+ saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup);
+ }
break;
}
return 0;
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index f61ed1849a2..1dbe61755e9 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-core.c,v 1.30 2005/05/22 19:23:39 nsh Exp $
+ * $Id: saa7134-core.c,v 1.39 2005/07/05 17:37:35 nsh Exp $
*
* device driver for philips saa7134 based TV cards
* driver core
@@ -183,46 +183,6 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
/* ------------------------------------------------------------------ */
-#if 0
-static char *dec1_bits[8] = {
- "DCSTD0", "DCSCT1", "WIPA", "GLIMB",
- "GLIMT", "SLTCA", "HLCK"
-};
-static char *dec2_bits[8] = {
- "RDCAP", "COPRO", "COLSTR", "TYPE3",
- NULL, "FIDT", "HLVLN", "INTL"
-};
-static char *scale1_bits[8] = {
- "VID_A", "VBI_A", NULL, NULL, "VID_B", "VBI_B"
-};
-static char *scale2_bits[8] = {
- "TRERR", "CFERR", "LDERR", "WASRST",
- "FIDSCI", "FIDSCO", "D6^D5", "TASK"
-};
-
-static void dump_statusreg(struct saa7134_dev *dev, int reg,
- char *regname, char **bits)
-{
- int value,i;
-
- value = saa_readb(reg);
- printk(KERN_DEBUG "%s: %s:", dev->name, regname);
- for (i = 7; i >= 0; i--) {
- if (NULL == bits[i])
- continue;
- printk(" %s=%d", bits[i], (value & (1 << i)) ? 1 : 0);
- }
- printk("\n");
-}
-
-static void dump_statusregs(struct saa7134_dev *dev)
-{
- dump_statusreg(dev,SAA7134_STATUS_VIDEO1,"dec1",dec1_bits);
- dump_statusreg(dev,SAA7134_STATUS_VIDEO2,"dec2",dec2_bits);
- dump_statusreg(dev,SAA7134_SCALER_STATUS0,"scale0",scale1_bits);
- dump_statusreg(dev,SAA7134_SCALER_STATUS1,"scale1",scale2_bits);
-}
-#endif
/* ----------------------------------------------------------- */
/* delayed request_module */
@@ -616,10 +576,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
if (irq_debug)
print_irqstatus(dev,loop,report,status);
-#if 0
- if (report & SAA7134_IRQ_REPORT_CONF_ERR)
- dump_statusregs(dev);
-#endif
if (report & SAA7134_IRQ_REPORT_RDCAP /* _INTL */)
saa7134_irq_video_intl(dev);
@@ -711,7 +667,6 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
SAA7134_MAIN_CTRL_EVFE1 |
SAA7134_MAIN_CTRL_EVFE2 |
SAA7134_MAIN_CTRL_ESFE |
- SAA7134_MAIN_CTRL_EBADC |
SAA7134_MAIN_CTRL_EBDAC);
/* enable peripheral devices */
@@ -726,14 +681,28 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
/* late init (with i2c + irq) */
static int saa7134_hwinit2(struct saa7134_dev *dev)
{
+ unsigned int irq2_mask;
dprintk("hwinit2\n");
saa7134_video_init2(dev);
saa7134_tvaudio_init2(dev);
/* enable IRQ's */
+ irq2_mask =
+ SAA7134_IRQ2_INTE_DEC3 |
+ SAA7134_IRQ2_INTE_DEC2 |
+ SAA7134_IRQ2_INTE_DEC1 |
+ SAA7134_IRQ2_INTE_DEC0 |
+ SAA7134_IRQ2_INTE_PE |
+ SAA7134_IRQ2_INTE_AR;
+
+ if (dev->has_remote)
+ irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
+ SAA7134_IRQ2_INTE_GPIO18A |
+ SAA7134_IRQ2_INTE_GPIO16 );
+
saa_writel(SAA7134_IRQ1, 0);
- saa_writel(SAA7134_IRQ2, dev->irq2_mask);
+ saa_writel(SAA7134_IRQ2, irq2_mask);
return 0;
}
@@ -954,13 +923,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
}
/* initialize hardware #1 */
- dev->irq2_mask =
- SAA7134_IRQ2_INTE_DEC3 |
- SAA7134_IRQ2_INTE_DEC2 |
- SAA7134_IRQ2_INTE_DEC1 |
- SAA7134_IRQ2_INTE_DEC0 |
- SAA7134_IRQ2_INTE_PE |
- SAA7134_IRQ2_INTE_AR;
saa7134_board_init1(dev);
saa7134_hwinit1(dev);
@@ -990,6 +952,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
request_module("saa6752hs");
request_module_depend("saa7134-empress",&need_empress);
}
+
if (card_is_dvb(dev))
request_module_depend("saa7134-dvb",&need_dvb);
@@ -1144,9 +1107,6 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
release_mem_region(pci_resource_start(pci_dev,0),
pci_resource_len(pci_dev,0));
-#if 0 /* causes some trouble when reinserting the driver ... */
- pci_disable_device(pci_dev);
-#endif
pci_set_drvdata(pci_dev, NULL);
/* free memory */
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index aa8e2cf62d5..334bc185009 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1,8 +1,11 @@
/*
- * $Id: saa7134-dvb.c,v 1.13 2005/06/12 04:19:19 mchehab Exp $
+ * $Id: saa7134-dvb.c,v 1.18 2005/07/04 16:05:50 mkrufky Exp $
*
* (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
*
+ * Extended 3 / 2005 by Hartmut Hackmann to support various
+ * cards with the tda10046 DVB-T channel decoder
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -27,23 +30,31 @@
#include <linux/kthread.h>
#include <linux/suspend.h>
+#define CONFIG_DVB_MT352 1
+#define CONFIG_DVB_TDA1004X 1
+
#include "saa7134-reg.h"
#include "saa7134.h"
-#include "dvb-pll.h"
-#include "mt352.h"
-#include "mt352_priv.h" /* FIXME */
-#include "tda1004x.h"
+#if CONFIG_DVB_MT352
+# include "mt352.h"
+# include "mt352_priv.h" /* FIXME */
+#endif
+#if CONFIG_DVB_TDA1004X
+# include "tda1004x.h"
+#endif
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
MODULE_LICENSE("GPL");
static unsigned int antenna_pwr = 0;
+
module_param(antenna_pwr, int, 0444);
MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
/* ------------------------------------------------------------------ */
+#if CONFIG_DVB_MT352
static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
{
u32 ok;
@@ -138,51 +149,390 @@ static struct mt352_config pinnacle_300i = {
.demod_init = mt352_pinnacle_init,
.pll_set = mt352_pinnacle_pll_set,
};
+#endif
/* ------------------------------------------------------------------ */
-static int medion_cardbus_init(struct dvb_frontend* fe)
+#if CONFIG_DVB_TDA1004X
+static int philips_tu1216_pll_init(struct dvb_frontend *fe)
{
- /* anything to do here ??? */
+ struct saa7134_dev *dev = fe->dvb->priv;
+ static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
+ struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
+
+ /* setup PLL configuration */
+ if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
+ return -EIO;
+ msleep(1);
+
return 0;
}
-static int medion_cardbus_pll_set(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params)
+static int philips_tu1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
{
struct saa7134_dev *dev = fe->dvb->priv;
- struct v4l2_frequency f;
+ u8 tuner_buf[4];
+ struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
+ sizeof(tuner_buf) };
+ int tuner_frequency = 0;
+ u8 band, cp, filter;
+
+ /* determine charge pump */
+ tuner_frequency = params->frequency + 36166000;
+ if (tuner_frequency < 87000000)
+ return -EINVAL;
+ else if (tuner_frequency < 130000000)
+ cp = 3;
+ else if (tuner_frequency < 160000000)
+ cp = 5;
+ else if (tuner_frequency < 200000000)
+ cp = 6;
+ else if (tuner_frequency < 290000000)
+ cp = 3;
+ else if (tuner_frequency < 420000000)
+ cp = 5;
+ else if (tuner_frequency < 480000000)
+ cp = 6;
+ else if (tuner_frequency < 620000000)
+ cp = 3;
+ else if (tuner_frequency < 830000000)
+ cp = 5;
+ else if (tuner_frequency < 895000000)
+ cp = 7;
+ else
+ return -EINVAL;
+
+ /* determine band */
+ if (params->frequency < 49000000)
+ return -EINVAL;
+ else if (params->frequency < 161000000)
+ band = 1;
+ else if (params->frequency < 444000000)
+ band = 2;
+ else if (params->frequency < 861000000)
+ band = 4;
+ else
+ return -EINVAL;
+
+ /* setup PLL filter */
+ switch (params->u.ofdm.bandwidth) {
+ case BANDWIDTH_6_MHZ:
+ filter = 0;
+ break;
- /*
- * this instructs tuner.o to set the frequency, the call will
- * end up in tuner_command(), VIDIOC_S_FREQUENCY switch.
- * tda9887.o will see that as well.
+ case BANDWIDTH_7_MHZ:
+ filter = 0;
+ break;
+
+ case BANDWIDTH_8_MHZ:
+ filter = 1;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ /* calculate divisor
+ * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
*/
- f.tuner = 0;
- f.type = V4L2_TUNER_DIGITAL_TV;
- f.frequency = params->frequency / 1000 * 16 / 1000;
- saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
+ tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
+
+ /* setup tuner buffer */
+ tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
+ tuner_buf[1] = tuner_frequency & 0xff;
+ tuner_buf[2] = 0xca;
+ tuner_buf[3] = (cp << 5) | (filter << 3) | band;
+
+ if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
+ return -EIO;
+
+ msleep(1);
return 0;
}
-static int fe_request_firmware(struct dvb_frontend* fe,
- const struct firmware **fw, char* name)
+static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
+ const struct firmware **fw, char *name)
{
struct saa7134_dev *dev = fe->dvb->priv;
return request_firmware(fw, name, &dev->pci->dev);
}
+static struct tda1004x_config philips_tu1216_config = {
+
+ .demod_address = 0x8,
+ .invert = 1,
+ .invert_oclk = 1,
+ .xtal_freq = TDA10046_XTAL_4M,
+ .agc_config = TDA10046_AGC_DEFAULT,
+ .if_freq = TDA10046_FREQ_3617,
+ .pll_init = philips_tu1216_pll_init,
+ .pll_set = philips_tu1216_pll_set,
+ .pll_sleep = NULL,
+ .request_firmware = philips_tu1216_request_firmware,
+};
+
+/* ------------------------------------------------------------------ */
+
+
+static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
+{
+ struct saa7134_dev *dev = fe->dvb->priv;
+ /* this message is to set up ATC and ALC */
+ static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
+ struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
+
+ if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
+ return -EIO;
+ msleep(1);
+
+ return 0;
+}
+
+static void philips_fmd1216_analog(struct dvb_frontend *fe)
+{
+ struct saa7134_dev *dev = fe->dvb->priv;
+ /* this message actually turns the tuner back to analog mode */
+ static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
+ struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
+
+ i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
+ msleep(1);
+ fmd1216_init[2] = 0x86;
+ fmd1216_init[3] = 0x54;
+ i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
+ msleep(1);
+}
+
+static int philips_fmd1216_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+ struct saa7134_dev *dev = fe->dvb->priv;
+ u8 tuner_buf[4];
+ struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
+ sizeof(tuner_buf) };
+ int tuner_frequency = 0;
+ int divider = 0;
+ u8 band, mode, cp;
+
+ /* determine charge pump */
+ tuner_frequency = params->frequency + 36130000;
+ if (tuner_frequency < 87000000)
+ return -EINVAL;
+ /* low band */
+ else if (tuner_frequency < 180000000) {
+ band = 1;
+ mode = 7;
+ cp = 0;
+ } else if (tuner_frequency < 195000000) {
+ band = 1;
+ mode = 6;
+ cp = 1;
+ /* mid band */
+ } else if (tuner_frequency < 366000000) {
+ if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
+ band = 10;
+ } else {
+ band = 2;
+ }
+ mode = 7;
+ cp = 0;
+ } else if (tuner_frequency < 478000000) {
+ if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
+ band = 10;
+ } else {
+ band = 2;
+ }
+ mode = 6;
+ cp = 1;
+ /* high band */
+ } else if (tuner_frequency < 662000000) {
+ if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
+ band = 12;
+ } else {
+ band = 4;
+ }
+ mode = 7;
+ cp = 0;
+ } else if (tuner_frequency < 840000000) {
+ if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
+ band = 12;
+ } else {
+ band = 4;
+ }
+ mode = 6;
+ cp = 1;
+ } else {
+ if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
+ band = 12;
+ } else {
+ band = 4;
+ }
+ mode = 7;
+ cp = 1;
+
+ }
+ /* calculate divisor */
+ /* ((36166000 + Finput) / 166666) rounded! */
+ divider = (tuner_frequency + 83333) / 166667;
+
+ /* setup tuner buffer */
+ tuner_buf[0] = (divider >> 8) & 0x7f;
+ tuner_buf[1] = divider & 0xff;
+ tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
+ tuner_buf[3] = 0x40 | band;
+
+ if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
+ return -EIO;
+ return 0;
+}
+
+
static struct tda1004x_config medion_cardbus = {
- .demod_address = 0x08, /* not sure this is correct */
- .invert = 0,
- .invert_oclk = 0,
- .pll_init = medion_cardbus_init,
- .pll_set = medion_cardbus_pll_set,
- .request_firmware = fe_request_firmware,
+ .demod_address = 0x08,
+ .invert = 1,
+ .invert_oclk = 0,
+ .xtal_freq = TDA10046_XTAL_16M,
+ .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
+ .if_freq = TDA10046_FREQ_3613,
+ .pll_init = philips_fmd1216_pll_init,
+ .pll_set = philips_fmd1216_pll_set,
+ .pll_sleep = philips_fmd1216_analog,
+ .request_firmware = NULL,
};
/* ------------------------------------------------------------------ */
+struct tda827x_data {
+ u32 lomax;
+ u8 spd;
+ u8 bs;
+ u8 bp;
+ u8 cp;
+ u8 gc3;
+ u8 div1p5;
+};
+
+static struct tda827x_data tda827x_dvbt[] = {
+ { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
+ { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
+ { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
+ { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
+ { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
+ { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
+ { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
+ { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
+};
+
+static int philips_tda827x_pll_init(struct dvb_frontend *fe)
+{
+ return 0;
+}
+
+static int philips_tda827x_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
+{
+ struct saa7134_dev *dev = fe->dvb->priv;
+ u8 tuner_buf[14];
+
+ struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
+ .len = sizeof(tuner_buf) };
+ int i, tuner_freq, if_freq;
+ u32 N;
+ switch (params->u.ofdm.bandwidth) {
+ case BANDWIDTH_6_MHZ:
+ if_freq = 4000000;
+ break;
+ case BANDWIDTH_7_MHZ:
+ if_freq = 4500000;
+ break;
+ default: /* 8 MHz or Auto */
+ if_freq = 5000000;
+ break;
+ }
+ tuner_freq = params->frequency + if_freq;
+
+ i = 0;
+ while (tda827x_dvbt[i].lomax < tuner_freq) {
+ if(tda827x_dvbt[i + 1].lomax == 0)
+ break;
+ i++;
+ }
+
+ N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
+ tuner_buf[0] = 0;
+ tuner_buf[1] = (N>>8) | 0x40;
+ tuner_buf[2] = N & 0xff;
+ tuner_buf[3] = 0;
+ tuner_buf[4] = 0x52;
+ tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
+ (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
+ tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
+ tuner_buf[7] = 0xbf;
+ tuner_buf[8] = 0x2a;
+ tuner_buf[9] = 0x05;
+ tuner_buf[10] = 0xff;
+ tuner_buf[11] = 0x00;
+ tuner_buf[12] = 0x00;
+ tuner_buf[13] = 0x40;
+
+ tuner_msg.len = 14;
+ if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
+ return -EIO;
+
+ msleep(500);
+ /* correct CP value */
+ tuner_buf[0] = 0x30;
+ tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
+ tuner_msg.len = 2;
+ i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
+
+ return 0;
+}
+
+static void philips_tda827x_pll_sleep(struct dvb_frontend *fe)
+{
+ struct saa7134_dev *dev = fe->dvb->priv;
+ static u8 tda827x_sleep[] = { 0x30, 0xd0};
+ struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
+ .len = sizeof(tda827x_sleep) };
+ i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
+}
+
+static struct tda1004x_config tda827x_lifeview_config = {
+ .demod_address = 0x08,
+ .invert = 1,
+ .invert_oclk = 0,
+ .xtal_freq = TDA10046_XTAL_16M,
+ .agc_config = TDA10046_AGC_TDA827X,
+ .if_freq = TDA10046_FREQ_045,
+ .pll_init = philips_tda827x_pll_init,
+ .pll_set = philips_tda827x_pll_set,
+ .pll_sleep = philips_tda827x_pll_sleep,
+ .request_firmware = NULL,
+};
+#endif
+
+/* ------------------------------------------------------------------ */
+
static int dvb_init(struct saa7134_dev *dev)
{
/* init struct videobuf_dvb */
@@ -197,18 +547,31 @@ static int dvb_init(struct saa7134_dev *dev)
dev);
switch (dev->board) {
+#if CONFIG_DVB_MT352
case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
printk("%s: pinnacle 300i dvb setup\n",dev->name);
dev->dvb.frontend = mt352_attach(&pinnacle_300i,
&dev->i2c_adap);
break;
+#endif
+#if CONFIG_DVB_TDA1004X
case SAA7134_BOARD_MD7134:
dev->dvb.frontend = tda10046_attach(&medion_cardbus,
&dev->i2c_adap);
- if (NULL == dev->dvb.frontend)
- printk("%s: Hmm, looks like this is the old MD7134 "
- "version without DVB-T support\n",dev->name);
break;
+ case SAA7134_BOARD_PHILIPS_TOUGH:
+ dev->dvb.frontend = tda10046_attach(&philips_tu1216_config,
+ &dev->i2c_adap);
+ break;
+ case SAA7134_BOARD_FLYDVBTDUO:
+ dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
+ &dev->i2c_adap);
+ break;
+ case SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS:
+ dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
+ &dev->i2c_adap);
+ break;
+#endif
default:
printk("%s: Huh? unknown DVB card?\n",dev->name);
break;
@@ -227,8 +590,6 @@ static int dvb_fini(struct saa7134_dev *dev)
{
static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
- printk("%s: %s\n",dev->name,__FUNCTION__);
-
switch (dev->board) {
case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
/* otherwise we don't detect the tuner on next insmod */
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index b6f002e8421..93dd6197854 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-i2c.c,v 1.11 2005/06/12 01:36:14 mchehab Exp $
+ * $Id: saa7134-i2c.c,v 1.19 2005/07/07 01:49:30 mkrufky Exp $
*
* device driver for philips saa7134 based TV cards
* i2c interface support
@@ -197,10 +197,6 @@ static inline int i2c_send_byte(struct saa7134_dev *dev,
enum i2c_status status;
__u32 dword;
-#if 0
- i2c_set_attr(dev,attr);
- saa_writeb(SAA7134_I2C_DATA, data);
-#else
/* have to write both attr + data in one 32bit word */
dword = saa_readl(SAA7134_I2C_ATTR_STATUS >> 2);
dword &= 0x0f;
@@ -210,7 +206,6 @@ static inline int i2c_send_byte(struct saa7134_dev *dev,
// dword |= 0x40 << 16; /* 400 kHz */
dword |= 0xf0 << 24;
saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
-#endif
d2printk(KERN_DEBUG "%s: i2c data => 0x%x\n",dev->name,data);
if (!i2c_is_busy_wait(dev))
@@ -331,12 +326,44 @@ static u32 functionality(struct i2c_adapter *adap)
static int attach_inform(struct i2c_client *client)
{
- struct saa7134_dev *dev = client->adapter->algo_data;
+ struct saa7134_dev *dev = client->adapter->algo_data;
int tuner = dev->tuner_type;
int conf = dev->tda9887_conf;
+ struct tuner_setup tun_setup;
+
+ d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
+ client->driver->name,client->addr,i2c_clientname(client));
+
+ if (!client->driver->command)
+ return 0;
+
+ if (saa7134_boards[dev->board].radio_type != UNSET) {
+
+ tun_setup.type = saa7134_boards[dev->board].radio_type;
+ tun_setup.addr = saa7134_boards[dev->board].radio_addr;
+
+ if ((tun_setup.addr == ADDR_UNSET) || (tun_setup.addr == client->addr)) {
+ tun_setup.mode_mask = T_RADIO;
+
+ client->driver->command(client, TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
+ }
+
+ if (tuner != UNSET) {
+
+ tun_setup.type = tuner;
+ tun_setup.addr = saa7134_boards[dev->board].tuner_addr;
+
+ if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) {
+
+ tun_setup.mode_mask = T_ANALOG_TV;
+
+ client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_setup);
+ }
+ }
+
+ client->driver->command(client, TDA9887_SET_CONFIG, &conf);
- saa7134_i2c_call_clients(dev,TUNER_SET_TYPE,&tuner);
- saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&conf);
return 0;
}
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index aba2b9de60d..213740122fe 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-input.c,v 1.19 2005/06/07 18:02:26 nsh Exp $
+ * $Id: saa7134-input.c,v 1.21 2005/06/22 23:37:34 nsh Exp $
*
* handle saa7134 IR remotes via linux kernel input layer.
*
@@ -68,10 +68,8 @@ static IR_KEYTAB_TYPE flyvideo_codes[IR_KEYTAB_SIZE] = {
[ 6 ] = KEY_AGAIN, // Recal
[ 16 ] = KEY_KPENTER, // Enter
-#if 1 /* FIXME */
[ 26 ] = KEY_F22, // Stereo
[ 24 ] = KEY_EDIT, // AV Source
-#endif
};
static IR_KEYTAB_TYPE cinergy_codes[IR_KEYTAB_SIZE] = {
@@ -172,45 +170,45 @@ static IR_KEYTAB_TYPE eztv_codes[IR_KEYTAB_SIZE] = {
};
static IR_KEYTAB_TYPE avacssmart_codes[IR_KEYTAB_SIZE] = {
- [ 30 ] = KEY_POWER, // power
+ [ 30 ] = KEY_POWER, // power
[ 28 ] = KEY_SEARCH, // scan
- [ 7 ] = KEY_SELECT, // source
+ [ 7 ] = KEY_SELECT, // source
[ 22 ] = KEY_VOLUMEUP,
[ 20 ] = KEY_VOLUMEDOWN,
- [ 31 ] = KEY_CHANNELUP,
+ [ 31 ] = KEY_CHANNELUP,
[ 23 ] = KEY_CHANNELDOWN,
[ 24 ] = KEY_MUTE,
[ 2 ] = KEY_KP0,
- [ 1 ] = KEY_KP1,
- [ 11 ] = KEY_KP2,
- [ 27 ] = KEY_KP3,
- [ 5 ] = KEY_KP4,
- [ 9 ] = KEY_KP5,
- [ 21 ] = KEY_KP6,
+ [ 1 ] = KEY_KP1,
+ [ 11 ] = KEY_KP2,
+ [ 27 ] = KEY_KP3,
+ [ 5 ] = KEY_KP4,
+ [ 9 ] = KEY_KP5,
+ [ 21 ] = KEY_KP6,
[ 6 ] = KEY_KP7,
- [ 10 ] = KEY_KP8,
+ [ 10 ] = KEY_KP8,
[ 18 ] = KEY_KP9,
[ 16 ] = KEY_KPDOT,
[ 3 ] = KEY_TUNER, // tv/fm
- [ 4 ] = KEY_REWIND, // fm tuning left or function left
- [ 12 ] = KEY_FORWARD, // fm tuning right or function right
+ [ 4 ] = KEY_REWIND, // fm tuning left or function left
+ [ 12 ] = KEY_FORWARD, // fm tuning right or function right
[ 0 ] = KEY_RECORD,
- [ 8 ] = KEY_STOP,
- [ 17 ] = KEY_PLAY,
+ [ 8 ] = KEY_STOP,
+ [ 17 ] = KEY_PLAY,
[ 25 ] = KEY_ZOOM,
[ 14 ] = KEY_MENU, // function
[ 19 ] = KEY_AGAIN, // recall
[ 29 ] = KEY_RESTART, // reset
+ [ 26 ] = KEY_SHUFFLE, // snapshot/shuffle
// FIXME
[ 13 ] = KEY_F21, // mts
- [ 15 ] = KEY_F22, // min
- [ 26 ] = KEY_F23, // freeze
+ [ 15 ] = KEY_F22, // min
};
/* Alex Hermann <gaaf@gmx.net> */
@@ -489,13 +487,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
break;
case SAA7134_BOARD_ECS_TVP3XP:
case SAA7134_BOARD_ECS_TVP3XP_4CB5:
- ir_codes = eztv_codes;
- mask_keycode = 0x00017c;
- mask_keyup = 0x000002;
+ ir_codes = eztv_codes;
+ mask_keycode = 0x00017c;
+ mask_keyup = 0x000002;
polling = 50; // ms
- break;
+ break;
+ case SAA7134_BOARD_KWORLD_XPERT:
case SAA7134_BOARD_AVACSSMARTTV:
- ir_codes = avacssmart_codes;
+ ir_codes = avacssmart_codes;
mask_keycode = 0x00001F;
mask_keyup = 0x000020;
polling = 50; // ms
@@ -524,6 +523,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
polling = 50; // ms
break;
case SAA7134_BOARD_VIDEOMATE_TV_PVR:
+ case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
ir_codes = videomate_tv_pvr_codes;
mask_keycode = 0x00003F;
mask_keyup = 0x400000;
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 81732904623..b5bede95dbf 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-oss.c,v 1.14 2005/05/18 22:45:16 hhackmann Exp $
+ * $Id: saa7134-oss.c,v 1.17 2005/06/28 23:41:47 mkrufky Exp $
*
* device driver for philips saa7134 based TV cards
* oss dsp interface
@@ -556,21 +556,28 @@ mixer_recsrc_7134(struct saa7134_dev *dev)
static int
mixer_recsrc_7133(struct saa7134_dev *dev)
{
- u32 value = 0xbbbbbb;
+ u32 anabar, xbarin;
+ xbarin = 0x03; // adc
+ anabar = 0;
switch (dev->oss.input) {
case TV:
- value = 0xbbbb10; /* MAIN */
+ xbarin = 0; // Demodulator
+ anabar = 2; // DACs
break;
case LINE1:
- value = 0xbbbb32; /* AUX1 */
+ anabar = 0; // aux1, aux1
break;
case LINE2:
case LINE2_LEFT:
- value = 0xbbbb54; /* AUX2 */
+ anabar = 9; // aux2, aux2
break;
}
- saa_dsp_writel(dev, 0x46c >> 2, value);
+ /* output xbar always main channel */
+ saa_dsp_writel(dev, 0x46c >> 2, 0xbbbb10);
+ saa_dsp_writel(dev, 0x464 >> 2, xbarin);
+ saa_writel(0x594 >> 2, anabar);
+
return 0;
}
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 345eb2a8c28..4dd9f1b2392 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-ts.c,v 1.14 2005/02/03 10:24:33 kraxel Exp $
+ * $Id: saa7134-ts.c,v 1.15 2005/06/14 22:48:18 hhackmann Exp $
*
* device driver for philips saa7134 based TV cards
* video4linux video interface
@@ -221,10 +221,10 @@ void saa7134_irq_ts_done(struct saa7134_dev *dev, unsigned long status)
if (dev->ts_q.curr) {
field = dev->ts_q.curr->vb.field;
if (field == V4L2_FIELD_TOP) {
- if ((status & 0x100000) != 0x000000)
+ if ((status & 0x100000) != 0x100000)
goto done;
} else {
- if ((status & 0x100000) != 0x100000)
+ if ((status & 0x100000) != 0x000000)
goto done;
}
saa7134_buffer_finish(dev,&dev->ts_q,STATE_DONE);
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 3617e7f7a41..eeafa5a71d2 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-tvaudio.c,v 1.25 2005/06/07 19:00:38 nsh Exp $
+ * $Id: saa7134-tvaudio.c,v 1.30 2005/06/28 23:41:47 mkrufky Exp $
*
* device driver for philips saa7134 based TV cards
* tv audio decoder (fm stereo, nicam, ...)
@@ -169,7 +169,7 @@ static void tvaudio_init(struct saa7134_dev *dev)
int clock = saa7134_boards[dev->board].audio_clock;
if (UNSET != audio_clock_override)
- clock = audio_clock_override;
+ clock = audio_clock_override;
/* init all audio registers */
saa_writeb(SAA7134_AUDIO_PLL_CTRL, 0x00);
@@ -219,14 +219,17 @@ static void mute_input_7134(struct saa7134_dev *dev)
in = dev->input;
mute = (dev->ctl_mute ||
(dev->automute && (&card(dev).radio) != in));
- if (PCI_DEVICE_ID_PHILIPS_SAA7130 == dev->pci->device &&
- card(dev).mute.name) {
- /* 7130 - we'll mute using some unconnected audio input */
+ if (card(dev).mute.name) {
+ /*
+ * 7130 - we'll mute using some unconnected audio input
+ * 7134 - we'll probably should switch external mux with gpio
+ */
if (mute)
in = &card(dev).mute;
}
+
if (dev->hw_mute == mute &&
- dev->hw_input == in) {
+ dev->hw_input == in) {
dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
mute,in->name);
return;
@@ -260,6 +263,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
/* switch gpio-connected external audio mux */
if (0 == card(dev).gpiomask)
return;
+
mask = card(dev).gpiomask;
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
@@ -339,13 +343,8 @@ static int tvaudio_sleep(struct saa7134_dev *dev, int timeout)
set_current_state(TASK_INTERRUPTIBLE);
schedule();
} else {
-#if 0
- /* hmm, that one doesn't return on wakeup ... */
- msleep_interruptible(timeout);
-#else
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(msecs_to_jiffies(timeout));
-#endif
}
}
remove_wait_queue(&dev->thread.wq, &wait);
@@ -400,27 +399,10 @@ static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
return value;
}
-#if 0
-static void sifdebug_dump_regs(struct saa7134_dev *dev)
-{
- print_regb(AUDIO_STATUS);
- print_regb(IDENT_SIF);
- print_regb(LEVEL_READOUT1);
- print_regb(LEVEL_READOUT2);
- print_regb(DCXO_IDENT_CTRL);
- print_regb(DEMODULATOR);
- print_regb(AGC_GAIN_SELECT);
- print_regb(MONITOR_SELECT);
- print_regb(FM_DEEMPHASIS);
- print_regb(FM_DEMATRIX);
- print_regb(SIF_SAMPLE_FREQ);
- print_regb(ANALOG_IO_SELECT);
-}
-#endif
static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio)
{
- __u32 idp,nicam;
+ __u32 idp, nicam, nicam_status;
int retval = -1;
switch (audio->mode) {
@@ -442,18 +424,24 @@ static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
break;
case TVAUDIO_NICAM_FM:
case TVAUDIO_NICAM_AM:
- nicam = saa_readb(SAA7134_NICAM_STATUS);
+ nicam = saa_readb(SAA7134_AUDIO_STATUS);
dprintk("getstereo: nicam=0x%x\n",nicam);
- switch (nicam & 0x0b) {
- case 0x08:
- retval = V4L2_TUNER_SUB_MONO;
- break;
- case 0x09:
- retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
- break;
- case 0x0a:
- retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
- break;
+ if (nicam & 0x1) {
+ nicam_status = saa_readb(SAA7134_NICAM_STATUS);
+ dprintk("getstereo: nicam_status=0x%x\n", nicam_status);
+
+ switch (nicam_status & 0x03) {
+ case 0x01:
+ retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
+ break;
+ case 0x02:
+ retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
+ break;
+ default:
+ retval = V4L2_TUNER_SUB_MONO;
+ }
+ } else {
+ /* No nicam detected */
}
break;
}
@@ -489,15 +477,15 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
break;
case TVAUDIO_FM_K_STEREO:
case TVAUDIO_FM_BG_STEREO:
+ case TVAUDIO_NICAM_AM:
+ case TVAUDIO_NICAM_FM:
dprintk("setstereo [fm] => %s\n",
name[ mode % ARRAY_SIZE(name) ]);
reg = fm[ mode % ARRAY_SIZE(fm) ];
saa_writeb(SAA7134_FM_DEMATRIX, reg);
break;
case TVAUDIO_FM_SAT_STEREO:
- case TVAUDIO_NICAM_AM:
- case TVAUDIO_NICAM_FM:
- /* FIXME */
+ /* Not implemented */
break;
}
return 0;
@@ -596,7 +584,7 @@ static int tvaudio_thread(void *data)
/* find the exact tv audio norm */
for (audio = UNSET, i = 0; i < TVAUDIO; i++) {
if (dev->tvnorm->id != UNSET &&
- !(dev->tvnorm->id & tvaudio[i].std))
+ !(dev->tvnorm->id & tvaudio[i].std))
continue;
if (tvaudio[i].carr1 != carrier)
continue;
@@ -703,24 +691,6 @@ static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit)
return 0;
}
-#if 0
-static int saa_dsp_readl(struct saa7134_dev *dev, int reg, u32 *value)
-{
- int err;
-
- d2printk("dsp read reg 0x%x\n", reg<<2);
- saa_readl(reg);
- err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_RDB);
- if (err < 0)
- return err;
- *value = saa_readl(reg);
- d2printk("dsp read => 0x%06x\n", *value & 0xffffff);
- err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_IDA);
- if (err < 0)
- return err;
- return 0;
-}
-#endif
int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value)
{
@@ -753,31 +723,50 @@ static int getstereo_7133(struct saa7134_dev *dev)
static int mute_input_7133(struct saa7134_dev *dev)
{
u32 reg = 0;
+ u32 xbarin, xbarout;
int mask;
+ struct saa7134_input *in;
+ /* Hac 0506 route OSS sound simultanously */
+ xbarin = 0x03;
switch (dev->input->amux) {
case TV:
reg = 0x02;
+ xbarin = 0;
break;
case LINE1:
reg = 0x00;
break;
case LINE2:
case LINE2_LEFT:
- reg = 0x01;
+ reg = 0x09;
break;
}
- if (dev->ctl_mute)
+ saa_dsp_writel(dev, 0x464 >> 2, xbarin);
+ if (dev->ctl_mute) {
reg = 0x07;
+ xbarout = 0xbbbbbb;
+ } else
+ xbarout = 0xbbbb10;
+ saa_dsp_writel(dev, 0x46c >> 2, xbarout);
+
saa_writel(0x594 >> 2, reg);
+
/* switch gpio-connected external audio mux */
if (0 != card(dev).gpiomask) {
mask = card(dev).gpiomask;
+
+ if (card(dev).mute.name && dev->ctl_mute)
+ in = &card(dev).mute;
+ else
+ in = dev->input;
+
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
- saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, dev->input->gpio);
- saa7134_track_gpio(dev,dev->input->name);
+ saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
+ saa7134_track_gpio(dev,in->name);
}
+
return 0;
}
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index 3c33c591cc8..29e51cad2aa 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -130,13 +130,7 @@ static int buffer_prepare(struct videobuf_queue *q,
lines = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1;
if (lines > VBI_LINE_COUNT)
lines = VBI_LINE_COUNT;
-#if 1
llength = VBI_LINE_LENGTH;
-#else
- llength = (norm->h_stop - norm->h_start +1) * 2;
- if (llength > VBI_LINE_LENGTH)
- llength = VBI_LINE_LENGTH;
-#endif
size = lines * llength * 2;
if (0 != buf->vb.baddr && buf->vb.bsize < size)
return -EINVAL;
@@ -178,13 +172,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
int llength,lines;
lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1;
-#if 1
llength = VBI_LINE_LENGTH;
-#else
- llength = (norm->h_stop - norm->h_start +1) * 2;
- if (llength > VBI_LINE_LENGTH)
- llength = VBI_LINE_LENGTH;
-#endif
*size = lines * llength * 2;
if (0 == *count)
*count = vbibufs;
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index c0a2ee52053..a4c2f751d09 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134-video.c,v 1.30 2005/06/07 19:00:38 nsh Exp $
+ * $Id: saa7134-video.c,v 1.36 2005/06/28 23:41:47 mkrufky Exp $
*
* device driver for philips saa7134 based TV cards
* video4linux video interface
@@ -274,7 +274,7 @@ static struct saa7134_tvnorm tvnorms[] = {
.h_start = 0,
.h_stop = 719,
- .video_v_start = 23,
+ .video_v_start = 23,
.video_v_stop = 262,
.vbi_v_start_0 = 10,
.vbi_v_stop_0 = 21,
@@ -1204,7 +1204,6 @@ static int video_open(struct inode *inode, struct file *file)
struct list_head *list;
enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int radio = 0;
-
list_for_each(list,&saa7134_devlist) {
h = list_entry(list, struct saa7134_dev, devlist);
if (h->video_dev && (h->video_dev->minor == minor))
@@ -1256,12 +1255,12 @@ static int video_open(struct inode *inode, struct file *file)
if (fh->radio) {
/* switch to radio mode */
saa7134_tvaudio_setinput(dev,&card(dev).radio);
- saa7134_i2c_call_clients(dev,AUDC_SET_RADIO,NULL);
+ saa7134_i2c_call_clients(dev,AUDC_SET_RADIO, NULL);
} else {
/* switch to video/vbi mode */
video_mux(dev,dev->ctl_input);
}
- return 0;
+ return 0;
}
static ssize_t
@@ -1304,10 +1303,10 @@ video_poll(struct file *file, struct poll_table_struct *wait)
} else {
down(&fh->cap.lock);
if (UNSET == fh->cap.read_off) {
- /* need to capture a new frame */
+ /* need to capture a new frame */
if (res_locked(fh->dev,RESOURCE_VIDEO)) {
- up(&fh->cap.lock);
- return POLLERR;
+ up(&fh->cap.lock);
+ return POLLERR;
}
if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,fh->cap.field)) {
up(&fh->cap.lock);
@@ -1363,6 +1362,36 @@ static int video_release(struct inode *inode, struct file *file)
res_free(dev,fh,RESOURCE_VBI);
}
+ /* ts-capture will not work in planar mode, so turn it off Hac: 04.05*/
+ saa_andorb(SAA7134_OFMT_VIDEO_A, 0x1f, 0);
+ saa_andorb(SAA7134_OFMT_VIDEO_B, 0x1f, 0);
+ saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0);
+ saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
+
+ if (dev->tuner_type == TUNER_PHILIPS_TDA8290) {
+ u8 data[2];
+ int ret;
+ struct i2c_msg msg = {.addr=I2C_ADDR_TDA8290, .flags=0, .buf=data, .len = 2};
+ data[0] = 0x21;
+ data[1] = 0xc0;
+ ret = i2c_transfer(&dev->i2c_adap, &msg, 1);
+ if (ret != 1)
+ printk(KERN_ERR "TDA8290 access failure\n");
+ msg.addr = I2C_ADDR_TDA8275;
+ data[0] = 0x30;
+ data[1] = 0xd0;
+ ret = i2c_transfer(&dev->i2c_adap, &msg, 1);
+ if (ret != 1)
+ printk(KERN_ERR "TDA8275 access failure\n");
+ msg.addr = I2C_ADDR_TDA8290;
+ data[0] = 0x21;
+ data[1] = 0x80;
+ i2c_transfer(&dev->i2c_adap, &msg, 1);
+ data[0] = 0x00;
+ data[1] = 0x02;
+ i2c_transfer(&dev->i2c_adap, &msg, 1);
+ }
+
/* free stuff */
videobuf_mmap_free(&fh->cap);
videobuf_mmap_free(&fh->vbi);
@@ -1399,13 +1428,6 @@ static void saa7134_vbi_fmt(struct saa7134_dev *dev, struct v4l2_format *f)
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */
-#if 0
- if (V4L2_STD_PAL == norm->id) {
- /* FIXME */
- f->fmt.vbi.start[0] += 3;
- f->fmt.vbi.start[1] += 3*2;
- }
-#endif
}
static int saa7134_g_fmt(struct saa7134_dev *dev, struct saa7134_fh *fh,
@@ -2120,8 +2142,6 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
memset(t,0,sizeof(*t));
strcpy(t->name, "Radio");
- t->rangelow = (int)(65*16);
- t->rangehigh = (int)(108*16);
saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t);
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index d6b1c0d4d0f..6836c07794f 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -1,5 +1,5 @@
/*
- * $Id: saa7134.h,v 1.41 2005/06/07 18:02:26 nsh Exp $
+ * $Id: saa7134.h,v 1.48 2005/07/01 08:22:24 nsh Exp $
*
* v4l2 device driver for philips saa7134 based TV cards
*
@@ -46,8 +46,6 @@
#endif
#define UNSET (-1U)
-/* 2.4 / 2.5 driver compatibility stuff */
-
/* ----------------------------------------------------------- */
/* enums */
@@ -159,7 +157,7 @@ struct saa7134_format {
#define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33
#define SAA7134_BOARD_NOVAC_PRIMETV7133 34
#define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35
-#define SAA7133_BOARD_UPMOST_PURPLE_TV 36
+#define SAA7134_BOARD_UPMOST_PURPLE_TV 36
#define SAA7134_BOARD_ITEMS_MTV005 37
#define SAA7134_BOARD_CINERGY200 38
#define SAA7134_BOARD_FLYTVPLATINUM_MINI 39
@@ -176,13 +174,17 @@ struct saa7134_format {
#define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50
#define SAA7134_BOARD_PROVIDEO_PV952 51
#define SAA7134_BOARD_AVERMEDIA_305 52
-#define SAA7135_BOARD_ASUSTeK_TVFM7135 53
+#define SAA7134_BOARD_ASUSTeK_TVFM7135 53
#define SAA7134_BOARD_FLYTVPLATINUM_FM 54
#define SAA7134_BOARD_FLYDVBTDUO 55
#define SAA7134_BOARD_AVERMEDIA_307 56
#define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57
#define SAA7134_BOARD_ADS_INSTANT_TV 58
#define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59
+#define SAA7134_BOARD_THYPHOON_DVBT_DUO_CARDBUS 60
+#define SAA7134_BOARD_PHILIPS_TOUGH 61
+#define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62
+#define SAA7134_BOARD_KWORLD_XPERT 63
#define SAA7134_MAXBOARDS 8
#define SAA7134_INPUT_MAX 8
@@ -213,6 +215,10 @@ struct saa7134_board {
/* i2c chip info */
unsigned int tuner_type;
+ unsigned int radio_type;
+ unsigned char tuner_addr;
+ unsigned char radio_addr;
+
unsigned int tda9887_conf;
/* peripheral I/O */
@@ -403,9 +409,12 @@ struct saa7134_dev {
/* config info */
unsigned int board;
unsigned int tuner_type;
+ unsigned int radio_type;
+ unsigned char tuner_addr;
+ unsigned char radio_addr;
+
unsigned int tda9887_conf;
unsigned int gpio_value;
- unsigned int irq2_mask;
/* i2c i/o */
struct i2c_adapter i2c_adap;
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 07ba6d3ed08..7cb1fb3e66f 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -243,19 +243,6 @@ static int tda7432_write(struct i2c_client *client, int subaddr, int val)
}
/* I don't think we ever actually _read_ the chip... */
-#if 0
-static int tda7432_read(struct i2c_client *client)
-{
- unsigned char buffer;
- d2printk("tda7432: In tda7432_read\n");
- if (1 != i2c_master_recv(client,&buffer,1)) {
- printk(KERN_WARNING "tda7432: I/O error, trying (read)\n");
- return -1;
- }
- dprintk("tda7432: Read 0x%02x\n", buffer);
- return buffer;
-}
-#endif
static int tda7432_set(struct i2c_client *client)
{
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index f59d4601cc6..a8b6a8df510 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -1,5 +1,5 @@
/*
- * $Id: tda8290.c,v 1.11 2005/06/18 06:09:06 nsh Exp $
+ * $Id: tda8290.c,v 1.15 2005/07/08 20:21:33 mchehab Exp $
*
* i2c tv tuner chip device driver
* controls the philips tda8290+75 tuner chip combo.
@@ -136,15 +136,12 @@ static int tda8290_tune(struct i2c_client *c)
return 0;
}
-static void set_frequency(struct tuner *t, u16 ifc)
+static void set_frequency(struct tuner *t, u16 ifc, unsigned int freq)
{
- u32 freq;
u32 N;
if (t->mode == V4L2_TUNER_RADIO)
- freq = t->freq / 1000;
- else
- freq = t->freq;
+ freq = freq / 1000;
N = (((freq<<3)+ifc)&0x3fffc);
@@ -187,14 +184,14 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
set_audio(t);
- set_frequency(t, 864);
+ set_frequency(t, 864, freq);
tda8290_tune(c);
}
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
{
struct tuner *t = i2c_get_clientdata(c);
- set_frequency(t, 704);
+ set_frequency(t, 704, freq);
tda8290_tune(c);
}
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 97b113e070f..566e1a5ca13 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -123,19 +123,6 @@ static int tda9875_write(struct i2c_client *client, int subaddr, unsigned char v
return 0;
}
-#if 0
-static int tda9875_read(struct i2c_client *client)
-{
- unsigned char buffer;
- dprintk("In tda9875_read\n");
- if (1 != i2c_master_recv(client,&buffer,1)) {
- printk(KERN_WARNING "tda9875: I/O error, trying (read)\n");
- return -1;
- }
- dprintk("Read 0x%02x\n", buffer);
- return buffer;
-}
-#endif
static int i2c_read_register(struct i2c_adapter *adap, int addr, int reg)
{
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index ee35562f4d1..108c3ad7d62 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -569,15 +569,6 @@ static int tda9887_configure(struct tda9887 *t)
tda9887_set_config(t,buf);
tda9887_set_insmod(t,buf);
-#if 0
- /* This as-is breaks some cards, must be fixed in a
- * card-specific way, probably using TDA9887_SET_CONFIG to
- * turn on/off port2 */
- if (t->std & V4L2_STD_SECAM_L) {
- /* secam fixup (FIXME: move this to tvnorms array?) */
- buf[1] &= ~cOutputPort2Inactive;
- }
-#endif
dprintk(PREFIX "writing: b=0x%02x c=0x%02x e=0x%02x\n",
buf[1],buf[2],buf[3]);
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index a29f08f81f6..b53c748caf2 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -2,7 +2,7 @@
* For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview
* I2C address is allways 0xC0.
*
- * $Id: tea5767.c,v 1.11 2005/06/21 15:40:33 mchehab Exp $
+ * $Id: tea5767.c,v 1.18 2005/07/07 03:02:55 mchehab Exp $
*
* Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
* This code is placed under the terms of the GNU General Public License
@@ -11,23 +11,11 @@
* from their contributions on DScaler.
*/
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/videodev.h>
#include <linux/i2c.h>
-#include <linux/i2c-algo-bit.h>
-
+#include <linux/videodev.h>
+#include <linux/delay.h>
+#include <media/tuner.h>
#include <media/tuner.h>
-
-/* Declared at tuner-core.c */
-extern unsigned int tuner_debug;
#define PREFIX "TEA5767 "
@@ -38,8 +26,8 @@ extern unsigned int tuner_debug;
******************************/
/* First register */
-#define TEA5767_MUTE 0x80 /* Mutes output */
-#define TEA5767_SEARCH 0x40 /* Activates station search */
+#define TEA5767_MUTE 0x80 /* Mutes output */
+#define TEA5767_SEARCH 0x40 /* Activates station search */
/* Bits 0-5 for divider MSB */
/* Second register */
@@ -130,6 +118,14 @@ extern unsigned int tuner_debug;
/* Reserved for future extensions */
#define TEA5767_RESERVED_MASK 0xff
+enum tea5767_xtal_freq {
+ TEA5767_LOW_LO_32768 = 0,
+ TEA5767_HIGH_LO_32768 = 1,
+ TEA5767_LOW_LO_13MHz = 2,
+ TEA5767_HIGH_LO_13MHz = 3,
+};
+
+
/*****************************************************************************/
static void set_tv_freq(struct i2c_client *c, unsigned int freq)
@@ -153,103 +149,112 @@ static void tea5767_status_dump(unsigned char *buffer)
else
printk(PREFIX "Tuner not at band limit\n");
- div=((buffer[0]&0x3f)<<8) | buffer[1];
+ div = ((buffer[0] & 0x3f) << 8) | buffer[1];
switch (TEA5767_HIGH_LO_32768) {
case TEA5767_HIGH_LO_13MHz:
- frq = 1000*(div*50-700-225)/4; /* Freq in KHz */
+ frq = 1000 * (div * 50 - 700 - 225) / 4; /* Freq in KHz */
break;
case TEA5767_LOW_LO_13MHz:
- frq = 1000*(div*50+700+225)/4; /* Freq in KHz */
+ frq = 1000 * (div * 50 + 700 + 225) / 4; /* Freq in KHz */
break;
case TEA5767_LOW_LO_32768:
- frq = 1000*(div*32768/1000+700+225)/4; /* Freq in KHz */
+ frq = 1000 * (div * 32768 / 1000 + 700 + 225) / 4; /* Freq in KHz */
break;
case TEA5767_HIGH_LO_32768:
default:
- frq = 1000*(div*32768/1000-700-225)/4; /* Freq in KHz */
+ frq = 1000 * (div * 32768 / 1000 - 700 - 225) / 4; /* Freq in KHz */
break;
}
- buffer[0] = (div>>8) & 0x3f;
- buffer[1] = div & 0xff;
+ buffer[0] = (div >> 8) & 0x3f;
+ buffer[1] = div & 0xff;
printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n",
- frq/1000,frq%1000,div);
+ frq / 1000, frq % 1000, div);
if (TEA5767_STEREO_MASK & buffer[2])
printk(PREFIX "Stereo\n");
else
printk(PREFIX "Mono\n");
- printk(PREFIX "IF Counter = %d\n",buffer[2] & TEA5767_IF_CNTR_MASK);
+ printk(PREFIX "IF Counter = %d\n", buffer[2] & TEA5767_IF_CNTR_MASK);
- printk(PREFIX "ADC Level = %d\n",(buffer[3] & TEA5767_ADC_LEVEL_MASK)>>4);
+ printk(PREFIX "ADC Level = %d\n",
+ (buffer[3] & TEA5767_ADC_LEVEL_MASK) >> 4);
- printk(PREFIX "Chip ID = %d\n",(buffer[3] & TEA5767_CHIP_ID_MASK));
+ printk(PREFIX "Chip ID = %d\n", (buffer[3] & TEA5767_CHIP_ID_MASK));
- printk(PREFIX "Reserved = 0x%02x\n",(buffer[4] & TEA5767_RESERVED_MASK));
+ printk(PREFIX "Reserved = 0x%02x\n",
+ (buffer[4] & TEA5767_RESERVED_MASK));
}
/* Freq should be specifyed at 62.5 Hz */
static void set_radio_freq(struct i2c_client *c, unsigned int frq)
{
struct tuner *t = i2c_get_clientdata(c);
- unsigned char buffer[5];
+ unsigned char buffer[5];
unsigned div;
int rc;
- if ( tuner_debug )
- printk(PREFIX "radio freq counter %d\n",frq);
+ tuner_dbg (PREFIX "radio freq counter %d\n", frq);
/* Rounds freq to next decimal value - for 62.5 KHz step */
/* frq = 20*(frq/16)+radio_frq[frq%16]; */
buffer[2] = TEA5767_PORT1_HIGH;
- buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND;
- buffer[4]=0;
+ buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL |
+ TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND;
+ buffer[4] = 0;
+
+ if (t->mode == T_STANDBY) {
+ tuner_dbg("TEA5767 set to standby mode\n");
+ buffer[3] |= TEA5767_STDBY;
+ }
if (t->audmode == V4L2_TUNER_MODE_MONO) {
tuner_dbg("TEA5767 set to mono\n");
buffer[2] |= TEA5767_MONO;
- } else
- tuner_dbg("TEA5767 set to stereo\n");
+ } else {
+ tuner_dbg("TEA5767 set to stereo\n");
+ }
- switch (t->type) {
+ /* Should be replaced */
+ switch (TEA5767_HIGH_LO_32768) {
case TEA5767_HIGH_LO_13MHz:
- tuner_dbg("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n");
+ tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n");
buffer[2] |= TEA5767_HIGH_LO_INJECT;
buffer[4] |= TEA5767_PLLREF_ENABLE;
- div = (frq*4/16+700+225+25)/50;
+ div = (frq * 4 / 16 + 700 + 225 + 25) / 50;
break;
case TEA5767_LOW_LO_13MHz:
- tuner_dbg("TEA5767 radio LOW LO inject xtal @ 13 MHz\n");
+ tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n");
buffer[4] |= TEA5767_PLLREF_ENABLE;
- div = (frq*4/16-700-225+25)/50;
+ div = (frq * 4 / 16 - 700 - 225 + 25) / 50;
break;
case TEA5767_LOW_LO_32768:
- tuner_dbg("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n");
+ tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n");
buffer[3] |= TEA5767_XTAL_32768;
/* const 700=4000*175 Khz - to adjust freq to right value */
- div = (1000*(frq*4/16-700-225)+16384)>>15;
+ div = (1000 * (frq * 4 / 16 - 700 - 225) + 16384) >> 15;
break;
case TEA5767_HIGH_LO_32768:
default:
- tuner_dbg("TEA5767 radio HIGH LO inject xtal @ 32,768 MHz\n");
+ tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 32,768 MHz\n");
buffer[2] |= TEA5767_HIGH_LO_INJECT;
buffer[3] |= TEA5767_XTAL_32768;
- div = (1000*(frq*4/16+700+225)+16384)>>15;
+ div = (1000 * (frq * 4 / 16 + 700 + 225) + 16384) >> 15;
break;
}
- buffer[0] = (div>>8) & 0x3f;
- buffer[1] = div & 0xff;
+ buffer[0] = (div >> 8) & 0x3f;
+ buffer[1] = div & 0xff;
- if ( tuner_debug )
+ if (tuner_debug)
tea5767_status_dump(buffer);
- if (5 != (rc = i2c_master_send(c,buffer,5)))
- tuner_warn("i2c i/o error: rc == %d (should be 5)\n",rc);
+ if (5 != (rc = i2c_master_send(c, buffer, 5)))
+ tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
}
static int tea5767_signal(struct i2c_client *c)
@@ -258,11 +263,11 @@ static int tea5767_signal(struct i2c_client *c)
int rc;
struct tuner *t = i2c_get_clientdata(c);
- memset(buffer,0,sizeof(buffer));
- if (5 != (rc = i2c_master_recv(c,buffer,5)))
- tuner_warn ( "i2c i/o error: rc == %d (should be 5)\n",rc);
+ memset(buffer, 0, sizeof(buffer));
+ if (5 != (rc = i2c_master_recv(c, buffer, 5)))
+ tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
- return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) <<(13-4));
+ return ((buffer[3] & TEA5767_ADC_LEVEL_MASK) << (13 - 4));
}
static int tea5767_stereo(struct i2c_client *c)
@@ -271,47 +276,46 @@ static int tea5767_stereo(struct i2c_client *c)
int rc;
struct tuner *t = i2c_get_clientdata(c);
- memset(buffer,0,sizeof(buffer));
- if (5 != (rc = i2c_master_recv(c,buffer,5)))
- tuner_warn ( "i2c i/o error: rc == %d (should be 5)\n",rc);
+ memset(buffer, 0, sizeof(buffer));
+ if (5 != (rc = i2c_master_recv(c, buffer, 5)))
+ tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
rc = buffer[2] & TEA5767_STEREO_MASK;
- if ( tuner_debug )
- tuner_dbg("TEA5767 radio ST GET = %02x\n", rc);
+ tuner_dbg("TEA5767 radio ST GET = %02x\n", rc);
- return ( (buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO: 0);
+ return ((buffer[2] & TEA5767_STEREO_MASK) ? V4L2_TUNER_SUB_STEREO : 0);
}
-int tea_detection(struct i2c_client *c)
+int tea5767_autodetection(struct i2c_client *c)
{
- unsigned char buffer[5]= { 0xff, 0xff, 0xff, 0xff, 0xff };
+ unsigned char buffer[5] = { 0xff, 0xff, 0xff, 0xff, 0xff };
int rc;
struct tuner *t = i2c_get_clientdata(c);
- if (5 != (rc = i2c_master_recv(c,buffer,5))) {
- tuner_warn ( "it is not a TEA5767. Received %i chars.\n",rc );
+ if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
+ tuner_warn("it is not a TEA5767. Received %i chars.\n", rc);
return EINVAL;
}
/* If all bytes are the same then it's a TV tuner and not a tea5767 chip. */
- if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
- buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
- tuner_warn ( "All bytes are equal. It is not a TEA5767\n" );
+ if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
+ buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
+ tuner_warn("All bytes are equal. It is not a TEA5767\n");
return EINVAL;
}
/* Status bytes:
* Byte 4: bit 3:1 : CI (Chip Identification) == 0
- * bit 0 : internally set to 0
+ * bit 0 : internally set to 0
* Byte 5: bit 7:0 : == 0
*/
if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) {
- tuner_warn ( "Chip ID is not zero. It is not a TEA5767\n" );
+ tuner_warn("Chip ID is not zero. It is not a TEA5767\n");
return EINVAL;
}
- tuner_warn ( "TEA5767 detected.\n" );
+ tuner_warn("TEA5767 detected.\n");
return 0;
}
@@ -319,16 +323,16 @@ int tea5767_tuner_init(struct i2c_client *c)
{
struct tuner *t = i2c_get_clientdata(c);
- if (tea_detection(c)==EINVAL) return EINVAL;
+ if (tea5767_autodetection(c) == EINVAL)
+ return EINVAL;
- tuner_info("type set to %d (%s)\n",
- t->type, TEA5767_TUNER_NAME);
- strlcpy(c->name, TEA5767_TUNER_NAME, sizeof(c->name));
+ tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio");
+ strlcpy(c->name, "tea5767", sizeof(c->name));
- t->tv_freq = set_tv_freq;
+ t->tv_freq = set_tv_freq;
t->radio_freq = set_radio_freq;
t->has_signal = tea5767_signal;
- t->is_stereo = tea5767_stereo;
+ t->is_stereo = tea5767_stereo;
return (0);
}
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 51748c6578d..7d825e510ff 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -152,7 +152,7 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
switch (cmd)
{
- case TUNER_SET_TVFREQ:
+ case VIDIOCSFREQ:
set_tv_freq(client, *iarg);
break;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6f6bf4a633f..de190630bab 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
/*
- * $Id: tuner-core.c,v 1.29 2005/06/21 15:40:33 mchehab Exp $
+ * $Id: tuner-core.c,v 1.55 2005/07/08 13:20:33 mchehab Exp $
*
* i2c tv tuner chip device driver
* core core, i.e. kernel interfaces, registering and so on
@@ -23,42 +23,36 @@
#include <media/tuner.h>
#include <media/audiochip.h>
-/*
- * comment line bellow to return to old behavor, where only one I2C device is supported
- */
-
#define UNSET (-1U)
/* standard i2c insmod options */
static unsigned short normal_i2c[] = {
- 0x4b, /* tda8290 */
+ 0x4b, /* tda8290 */
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
I2C_CLIENT_END
};
+
I2C_CLIENT_INSMOD;
/* insmod options used at init time => read/only */
-static unsigned int addr = 0;
+static unsigned int addr = 0;
module_param(addr, int, 0444);
/* insmod options used at runtime => read/write */
-unsigned int tuner_debug = 0;
-module_param(tuner_debug, int, 0644);
+unsigned int tuner_debug = 0;
+module_param(tuner_debug, int, 0644);
-static unsigned int tv_range[2] = { 44, 958 };
+static unsigned int tv_range[2] = { 44, 958 };
static unsigned int radio_range[2] = { 65, 108 };
-module_param_array(tv_range, int, NULL, 0644);
+module_param_array(tv_range, int, NULL, 0644);
module_param_array(radio_range, int, NULL, 0644);
MODULE_DESCRIPTION("device driver for various TV and TV+FM radio tuners");
MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer");
MODULE_LICENSE("GPL");
-static int this_adap;
-static unsigned short first_tuner, tv_tuner, radio_tuner;
-
static struct i2c_driver driver;
static struct i2c_client client_template;
@@ -70,18 +64,19 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
if (t->type == UNSET) {
- tuner_info("tuner type not set\n");
+ tuner_warn ("tuner type not set\n");
return;
}
if (NULL == t->tv_freq) {
- tuner_info("Huh? tv_set is NULL?\n");
+ tuner_warn ("Tuner has no way to set tv freq\n");
return;
}
- if (freq < tv_range[0]*16 || freq > tv_range[1]*16) {
- tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n",
- freq/16,freq%16*100/16,tv_range[0],tv_range[1]);
+ if (freq < tv_range[0] * 16 || freq > tv_range[1] * 16) {
+ tuner_dbg ("TV freq (%d.%02d) out of range (%d-%d)\n",
+ freq / 16, freq % 16 * 100 / 16, tv_range[0],
+ tv_range[1]);
}
- t->tv_freq(c,freq);
+ t->tv_freq(c, freq);
}
static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -89,24 +84,20 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
struct tuner *t = i2c_get_clientdata(c);
if (t->type == UNSET) {
- tuner_info("tuner type not set\n");
+ tuner_warn ("tuner type not set\n");
return;
}
if (NULL == t->radio_freq) {
- tuner_info("no radio tuning for this one, sorry.\n");
+ tuner_warn ("tuner has no way to set radio frequency\n");
return;
}
- if (freq >= radio_range[0]*16000 && freq <= radio_range[1]*16000) {
- if (tuner_debug)
- tuner_info("radio freq step 62.5Hz (%d.%06d)\n",
- freq/16000,freq%16000*1000/16);
- t->radio_freq(c,freq);
- } else {
- tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n",
- freq/16,freq%16*100/16,
- radio_range[0],radio_range[1]);
+ if (freq <= radio_range[0] * 16000 || freq >= radio_range[1] * 16000) {
+ tuner_dbg ("radio freq (%d.%02d) out of range (%d-%d)\n",
+ freq / 16000, freq % 16000 * 100 / 16000,
+ radio_range[0], radio_range[1]);
}
+ t->radio_freq(c, freq);
return;
}
@@ -117,42 +108,45 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
switch (t->mode) {
case V4L2_TUNER_RADIO:
tuner_dbg("radio freq set to %lu.%02lu\n",
- freq/16,freq%16*100/16);
- set_radio_freq(c,freq);
+ freq / 16000, freq % 16000 * 100 / 16000);
+ set_radio_freq(c, freq);
break;
case V4L2_TUNER_ANALOG_TV:
case V4L2_TUNER_DIGITAL_TV:
tuner_dbg("tv freq set to %lu.%02lu\n",
- freq/16,freq%16*100/16);
+ freq / 16, freq % 16 * 100 / 16);
set_tv_freq(c, freq);
break;
}
t->freq = freq;
}
-static void set_type(struct i2c_client *c, unsigned int type)
+static void set_type(struct i2c_client *c, unsigned int type,
+ unsigned int new_mode_mask)
{
struct tuner *t = i2c_get_clientdata(c);
unsigned char buffer[4];
- /* sanity check */
- if (type == UNSET || type == TUNER_ABSENT)
+ if (type == UNSET || type == TUNER_ABSENT) {
+ tuner_dbg ("tuner 0x%02x: Tuner type absent\n",c->addr);
return;
- if (type >= tuner_count)
+ }
+
+ if (type >= tuner_count) {
+ tuner_warn ("tuner 0x%02x: Tuner count greater than %d\n",c->addr,tuner_count);
return;
+ }
+ /* This code detects calls by card attach_inform */
if (NULL == t->i2c.dev.driver) {
- /* not registered yet */
- t->type = type;
+ tuner_dbg ("tuner 0x%02x: called during i2c_client register by adapter's attach_inform\n", c->addr);
+
+ t->type=type;
return;
}
- if ((t->initialized) && (t->type == type))
- /* run only once except type change Hac 04/05*/
- return;
-
- t->initialized = 1;
t->type = type;
+
switch (t->type) {
case TUNER_MT2032:
microtune_init(c);
@@ -161,136 +155,194 @@ static void set_type(struct i2c_client *c, unsigned int type)
tda8290_init(c);
break;
case TUNER_TEA5767:
- if (tea5767_tuner_init(c)==EINVAL) t->type=TUNER_ABSENT;
+ if (tea5767_tuner_init(c) == EINVAL) {
+ t->type = TUNER_ABSENT;
+ t->mode_mask = T_UNINITIALIZED;
+ return;
+ }
+ t->mode_mask = T_RADIO;
break;
case TUNER_PHILIPS_FMD1216ME_MK3:
buffer[0] = 0x0b;
buffer[1] = 0xdc;
buffer[2] = 0x9c;
buffer[3] = 0x60;
- i2c_master_send(c,buffer,4);
+ i2c_master_send(c, buffer, 4);
mdelay(1);
buffer[2] = 0x86;
buffer[3] = 0x54;
- i2c_master_send(c,buffer,4);
+ i2c_master_send(c, buffer, 4);
default_tuner_init(c);
break;
default:
- /* TEA5767 autodetection code */
- if (tea5767_tuner_init(c)!=EINVAL) {
- t->type = TUNER_TEA5767;
- if (first_tuner == 0x60)
- first_tuner++;
- break;
- }
-
default_tuner_init(c);
break;
}
- tuner_dbg ("I2C addr 0x%02x with type %d\n",c->addr<<1,type);
+
+ if (t->mode_mask == T_UNINITIALIZED)
+ t->mode_mask = new_mode_mask;
+
+ set_freq(c, t->freq);
+ tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
+ c->adapter->name, c->driver->name, c->addr << 1, type,
+ t->mode_mask);
}
-#define CHECK_ADDR(tp,cmd,tun) if (client->addr!=tp) { \
- return 0; } else if (tuner_debug) \
- tuner_info ("Cmd %s accepted to "tun"\n",cmd);
-#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \
- CHECK_ADDR(radio_tuner,cmd,"radio") } else \
- { CHECK_ADDR(tv_tuner,cmd,"TV"); }
+/*
+ * This function apply tuner config to tuner specified
+ * by tun_setup structure. I addr is unset, then admin status
+ * and tun addr status is more precise then current status,
+ * it's applied. Otherwise status and type are applied only to
+ * tuner with exactly the same addr.
+*/
+
+static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
+{
+ struct tuner *t = i2c_get_clientdata(c);
+
+ if (tun_setup->addr == ADDR_UNSET) {
+ if (t->mode_mask & tun_setup->mode_mask)
+ set_type(c, tun_setup->type, tun_setup->mode_mask);
+ } else if (tun_setup->addr == c->addr) {
+ set_type(c, tun_setup->type, tun_setup->mode_mask);
+ }
+}
-static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr)
+static inline int check_mode(struct tuner *t, char *cmd)
{
- /* ADDR_UNSET defaults to first available tuner */
- if ( tun_addr->addr == ADDR_UNSET ) {
- if (first_tuner != c->addr)
- return;
- switch (tun_addr->v4l2_tuner) {
+ if (1 << t->mode & t->mode_mask) {
+ switch (t->mode) {
case V4L2_TUNER_RADIO:
- radio_tuner=c->addr;
+ tuner_dbg("Cmd %s accepted for radio\n", cmd);
break;
- default:
- tv_tuner=c->addr;
+ case V4L2_TUNER_ANALOG_TV:
+ tuner_dbg("Cmd %s accepted for analog TV\n", cmd);
+ break;
+ case V4L2_TUNER_DIGITAL_TV:
+ tuner_dbg("Cmd %s accepted for digital TV\n", cmd);
break;
}
- } else {
- /* Sets tuner to its configured value */
- switch (tun_addr->v4l2_tuner) {
- case V4L2_TUNER_RADIO:
- radio_tuner=tun_addr->addr;
- if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
- return;
- default:
- tv_tuner=tun_addr->addr;
- if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type);
- return;
- }
+ return 0;
}
- set_type(c,tun_addr->type);
+ return EINVAL;
}
static char pal[] = "-";
module_param_string(pal, pal, sizeof(pal), 0644);
+static char secam[] = "-";
+module_param_string(secam, secam, sizeof(secam), 0644);
+/* get more precise norm info from insmod option */
static int tuner_fixup_std(struct tuner *t)
{
if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) {
- /* get more precise norm info from insmod option */
switch (pal[0]) {
case 'b':
case 'B':
case 'g':
case 'G':
- tuner_dbg("insmod fixup: PAL => PAL-BG\n");
+ tuner_dbg ("insmod fixup: PAL => PAL-BG\n");
t->std = V4L2_STD_PAL_BG;
break;
case 'i':
case 'I':
- tuner_dbg("insmod fixup: PAL => PAL-I\n");
+ tuner_dbg ("insmod fixup: PAL => PAL-I\n");
t->std = V4L2_STD_PAL_I;
break;
case 'd':
case 'D':
case 'k':
case 'K':
- tuner_dbg("insmod fixup: PAL => PAL-DK\n");
+ tuner_dbg ("insmod fixup: PAL => PAL-DK\n");
t->std = V4L2_STD_PAL_DK;
break;
+ case 'M':
+ case 'm':
+ tuner_dbg ("insmod fixup: PAL => PAL-M\n");
+ t->std = V4L2_STD_PAL_M;
+ break;
+ case 'N':
+ case 'n':
+ tuner_dbg ("insmod fixup: PAL => PAL-N\n");
+ t->std = V4L2_STD_PAL_N;
+ break;
}
}
+ if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
+ switch (secam[0]) {
+ case 'd':
+ case 'D':
+ case 'k':
+ case 'K':
+ tuner_dbg ("insmod fixup: SECAM => SECAM-DK\n");
+ t->std = V4L2_STD_SECAM_DK;
+ break;
+ case 'l':
+ case 'L':
+ tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
+ t->std = V4L2_STD_SECAM_L;
+ break;
+ }
+ }
+
return 0;
}
/* ---------------------------------------------------------------------- */
+/* static var Used only in tuner_attach and tuner_probe */
+static unsigned default_mode_mask;
+
+/* During client attach, set_type is called by adapter's attach_inform callback.
+ set_type must then be completed by tuner_attach.
+ */
static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
{
struct tuner *t;
- /* by default, first I2C card is both tv and radio tuner */
- if (this_adap == 0) {
- first_tuner = addr;
- tv_tuner = addr;
- radio_tuner = addr;
- }
- this_adap++;
-
- client_template.adapter = adap;
- client_template.addr = addr;
+ client_template.adapter = adap;
+ client_template.addr = addr;
- t = kmalloc(sizeof(struct tuner),GFP_KERNEL);
- if (NULL == t)
- return -ENOMEM;
- memset(t,0,sizeof(struct tuner));
- memcpy(&t->i2c,&client_template,sizeof(struct i2c_client));
+ t = kmalloc(sizeof(struct tuner), GFP_KERNEL);
+ if (NULL == t)
+ return -ENOMEM;
+ memset(t, 0, sizeof(struct tuner));
+ memcpy(&t->i2c, &client_template, sizeof(struct i2c_client));
i2c_set_clientdata(&t->i2c, t);
- t->type = UNSET;
- t->radio_if2 = 10700*1000; /* 10.7MHz - FM radio */
- t->audmode = V4L2_TUNER_MODE_STEREO;
+ t->type = UNSET;
+ t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
+ t->audmode = V4L2_TUNER_MODE_STEREO;
+ t->mode_mask = T_UNINITIALIZED;
+
+
+ tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
+
+ /* TEA5767 autodetection code - only for addr = 0xc0 */
+ if (addr == 0x60) {
+ if (tea5767_autodetection(&t->i2c) != EINVAL) {
+ t->type = TUNER_TEA5767;
+ t->mode_mask = T_RADIO;
+ t->mode = T_STANDBY;
+ t->freq = 87.5 * 16; /* Sets freq to FM range */
+ default_mode_mask &= ~T_RADIO;
+
+ i2c_attach_client (&t->i2c);
+ set_type(&t->i2c,t->type, t->mode_mask);
+ return 0;
+ }
+ }
- i2c_attach_client(&t->i2c);
- tuner_info("chip found @ 0x%x (%s)\n",
- addr << 1, adap->name);
+ /* Initializes only the first adapter found */
+ if (default_mode_mask != T_UNINITIALIZED) {
+ tuner_dbg ("Setting mode_mask to 0x%02x\n", default_mode_mask);
+ t->mode_mask = default_mode_mask;
+ t->freq = 400 * 16; /* Sets freq to VHF High */
+ default_mode_mask = T_UNINITIALIZED;
+ }
- set_type(&t->i2c, t->type);
+ /* Should be just before return */
+ i2c_attach_client (&t->i2c);
+ set_type (&t->i2c,t->type, t->mode_mask);
return 0;
}
@@ -300,11 +352,8 @@ static int tuner_probe(struct i2c_adapter *adap)
normal_i2c[0] = addr;
normal_i2c[1] = I2C_CLIENT_END;
}
- this_adap = 0;
- first_tuner = 0;
- tv_tuner = 0;
- radio_tuner = 0;
+ default_mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV;
if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tuner_attach);
@@ -316,9 +365,10 @@ static int tuner_detach(struct i2c_client *client)
struct tuner *t = i2c_get_clientdata(client);
int err;
- err=i2c_detach_client(&t->i2c);
+ err = i2c_detach_client(&t->i2c);
if (err) {
- tuner_warn ("Client deregistration failed, client not detached.\n");
+ tuner_warn
+ ("Client deregistration failed, client not detached.\n");
return err;
}
@@ -326,37 +376,65 @@ static int tuner_detach(struct i2c_client *client)
return 0;
}
-#define SWITCH_V4L2 if (!t->using_v4l2 && tuner_debug) \
- tuner_info("switching to v4l2\n"); \
- t->using_v4l2 = 1;
-#define CHECK_V4L2 if (t->using_v4l2) { if (tuner_debug) \
- tuner_info("ignore v4l1 call\n"); \
- return 0; }
+/*
+ * Switch tuner to other mode. If tuner support both tv and radio,
+ * set another frequency to some value (This is needed for some pal
+ * tuners to avoid locking). Otherwise, just put second tuner in
+ * standby mode.
+ */
+
+static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode, char *cmd)
+{
+ if (mode != t->mode) {
+
+ t->mode = mode;
+ if (check_mode(t, cmd) == EINVAL) {
+ t->mode = T_STANDBY;
+ if (V4L2_TUNER_RADIO == mode) {
+ set_tv_freq(client, 400 * 16);
+ } else {
+ set_radio_freq(client, 87.5 * 16000);
+ }
+ return EINVAL;
+ }
+ }
+ return 0;
+}
+
+#define switch_v4l2() if (!t->using_v4l2) \
+ tuner_dbg("switching to v4l2\n"); \
+ t->using_v4l2 = 1;
+
+static inline int check_v4l2(struct tuner *t)
+{
+ if (t->using_v4l2) {
+ tuner_dbg ("ignore v4l1 call\n");
+ return EINVAL;
+ }
+ return 0;
+}
-static int
-tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
+static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
struct tuner *t = i2c_get_clientdata(client);
- unsigned int *iarg = (int*)arg;
+ unsigned int *iarg = (int *)arg;
- switch (cmd) {
+ switch (cmd) {
/* --- configuration --- */
- case TUNER_SET_TYPE:
- set_type(client,*iarg);
- break;
case TUNER_SET_TYPE_ADDR:
- set_addr(client,(struct tuner_addr *)arg);
+ tuner_dbg ("Calling set_type_addr for type=%d, addr=0x%02x, mode=0x%02x\n",
+ ((struct tuner_setup *)arg)->type,
+ ((struct tuner_setup *)arg)->addr,
+ ((struct tuner_setup *)arg)->mode_mask);
+
+ set_addr(client, (struct tuner_setup *)arg);
break;
case AUDC_SET_RADIO:
- t->mode = V4L2_TUNER_RADIO;
- CHECK_ADDR(tv_tuner,"AUDC_SET_RADIO","TV");
-
- if (V4L2_TUNER_RADIO != t->mode) {
- set_tv_freq(client,400 * 16);
- }
+ set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO");
break;
case AUDC_CONFIG_PINNACLE:
- CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE","TV");
+ if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL)
+ return 0;
switch (*iarg) {
case 2:
tuner_dbg("pinnacle pal\n");
@@ -368,219 +446,238 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
break;
}
break;
+ case TDA9887_SET_CONFIG:
+ break;
/* --- v4l ioctls --- */
/* take care: bttv does userspace copying, we'll get a
kernel pointer here... */
case VIDIOCSCHAN:
- {
- static const v4l2_std_id map[] = {
- [ VIDEO_MODE_PAL ] = V4L2_STD_PAL,
- [ VIDEO_MODE_NTSC ] = V4L2_STD_NTSC_M,
- [ VIDEO_MODE_SECAM ] = V4L2_STD_SECAM,
- [ 4 /* bttv */ ] = V4L2_STD_PAL_M,
- [ 5 /* bttv */ ] = V4L2_STD_PAL_N,
- [ 6 /* bttv */ ] = V4L2_STD_NTSC_M_JP,
- };
- struct video_channel *vc = arg;
-
- CHECK_V4L2;
- t->mode = V4L2_TUNER_ANALOG_TV;
- CHECK_ADDR(tv_tuner,"VIDIOCSCHAN","TV");
-
- if (vc->norm < ARRAY_SIZE(map))
- t->std = map[vc->norm];
- tuner_fixup_std(t);
- if (t->freq)
- set_tv_freq(client,t->freq);
- return 0;
- }
+ {
+ static const v4l2_std_id map[] = {
+ [VIDEO_MODE_PAL] = V4L2_STD_PAL,
+ [VIDEO_MODE_NTSC] = V4L2_STD_NTSC_M,
+ [VIDEO_MODE_SECAM] = V4L2_STD_SECAM,
+ [4 /* bttv */ ] = V4L2_STD_PAL_M,
+ [5 /* bttv */ ] = V4L2_STD_PAL_N,
+ [6 /* bttv */ ] = V4L2_STD_NTSC_M_JP,
+ };
+ struct video_channel *vc = arg;
+
+ if (check_v4l2(t) == EINVAL)
+ return 0;
+
+ if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL)
+ return 0;
+
+ if (vc->norm < ARRAY_SIZE(map))
+ t->std = map[vc->norm];
+ tuner_fixup_std(t);
+ if (t->freq)
+ set_tv_freq(client, t->freq);
+ return 0;
+ }
case VIDIOCSFREQ:
- {
- unsigned long *v = arg;
+ {
+ unsigned long *v = arg;
- CHECK_MODE("VIDIOCSFREQ");
- CHECK_V4L2;
- set_freq(client,*v);
- return 0;
- }
+ if (check_mode(t, "VIDIOCSFREQ") == EINVAL)
+ return 0;
+ if (check_v4l2(t) == EINVAL)
+ return 0;
+
+ set_freq(client, *v);
+ return 0;
+ }
case VIDIOCGTUNER:
- {
- struct video_tuner *vt = arg;
-
- CHECK_ADDR(radio_tuner,"VIDIOCGTUNER","radio");
- CHECK_V4L2;
- if (V4L2_TUNER_RADIO == t->mode) {
- if (t->has_signal)
- vt->signal = t->has_signal(client);
- if (t->is_stereo) {
- if (t->is_stereo(client))
- vt->flags |= VIDEO_TUNER_STEREO_ON;
- else
- vt->flags &= ~VIDEO_TUNER_STEREO_ON;
- }
- vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */
+ {
+ struct video_tuner *vt = arg;
+
+ if (check_mode(t, "VIDIOCGTUNER") == EINVAL)
+ return 0;
+ if (check_v4l2(t) == EINVAL)
+ return 0;
+
+ if (V4L2_TUNER_RADIO == t->mode) {
+ if (t->has_signal)
+ vt->signal = t->has_signal(client);
+ if (t->is_stereo) {
+ if (t->is_stereo(client))
+ vt->flags |=
+ VIDEO_TUNER_STEREO_ON;
+ else
+ vt->flags &=
+ ~VIDEO_TUNER_STEREO_ON;
+ }
+ vt->flags |= VIDEO_TUNER_LOW; /* Allow freqs at 62.5 Hz */
- vt->rangelow = radio_range[0] * 16000;
- vt->rangehigh = radio_range[1] * 16000;
+ vt->rangelow = radio_range[0] * 16000;
+ vt->rangehigh = radio_range[1] * 16000;
- } else {
- vt->rangelow = tv_range[0] * 16;
- vt->rangehigh = tv_range[1] * 16;
- }
+ } else {
+ vt->rangelow = tv_range[0] * 16;
+ vt->rangehigh = tv_range[1] * 16;
+ }
- return 0;
- }
+ return 0;
+ }
case VIDIOCGAUDIO:
- {
- struct video_audio *va = arg;
-
- CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO","radio");
- CHECK_V4L2;
- if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
- va->mode = t->is_stereo(client)
- ? VIDEO_SOUND_STEREO
- : VIDEO_SOUND_MONO;
- return 0;
- }
+ {
+ struct video_audio *va = arg;
+
+ if (check_mode(t, "VIDIOCGAUDIO") == EINVAL)
+ return 0;
+ if (check_v4l2(t) == EINVAL)
+ return 0;
+
+ if (V4L2_TUNER_RADIO == t->mode && t->is_stereo)
+ va->mode = t->is_stereo(client)
+ ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
+ return 0;
+ }
case VIDIOC_S_STD:
- {
- v4l2_std_id *id = arg;
+ {
+ v4l2_std_id *id = arg;
- SWITCH_V4L2;
- t->mode = V4L2_TUNER_ANALOG_TV;
- CHECK_ADDR(tv_tuner,"VIDIOC_S_STD","TV");
+ if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD")
+ == EINVAL)
+ return 0;
- t->std = *id;
- tuner_fixup_std(t);
- if (t->freq)
- set_freq(client,t->freq);
- break;
- }
+ switch_v4l2();
+
+ t->std = *id;
+ tuner_fixup_std(t);
+ if (t->freq)
+ set_freq(client, t->freq);
+ break;
+ }
case VIDIOC_S_FREQUENCY:
- {
- struct v4l2_frequency *f = arg;
-
- CHECK_MODE("VIDIOC_S_FREQUENCY");
- SWITCH_V4L2;
- if (V4L2_TUNER_RADIO == f->type &&
- V4L2_TUNER_RADIO != t->mode)
- set_tv_freq(client,400*16);
- t->mode = f->type;
- set_freq(client,f->frequency);
- break;
- }
- case VIDIOC_G_FREQUENCY:
- {
- struct v4l2_frequency *f = arg;
+ {
+ struct v4l2_frequency *f = arg;
+
+ t->freq = f->frequency;
+ switch_v4l2();
+ if (V4L2_TUNER_RADIO == f->type &&
+ V4L2_TUNER_RADIO != t->mode) {
+ if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
+ == EINVAL)
+ return 0;
+ }
+ set_freq(client,t->freq);
- CHECK_MODE("VIDIOC_G_FREQUENCY");
- SWITCH_V4L2;
- f->type = t->mode;
- f->frequency = t->freq;
- break;
- }
+ break;
+ }
+ case VIDIOC_G_FREQUENCY:
+ {
+ struct v4l2_frequency *f = arg;
+
+ if (check_mode(t, "VIDIOC_G_FREQUENCY") == EINVAL)
+ return 0;
+ switch_v4l2();
+ f->type = t->mode;
+ f->frequency = t->freq;
+ break;
+ }
case VIDIOC_G_TUNER:
- {
- struct v4l2_tuner *tuner = arg;
-
- CHECK_MODE("VIDIOC_G_TUNER");
- SWITCH_V4L2;
- if (V4L2_TUNER_RADIO == t->mode) {
- if (t->has_signal)
- tuner -> signal = t->has_signal(client);
- if (t->is_stereo) {
- if (t->is_stereo(client)) {
- tuner -> rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
- } else {
- tuner -> rxsubchans = V4L2_TUNER_SUB_MONO;
+ {
+ struct v4l2_tuner *tuner = arg;
+
+ if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL)
+ return 0;
+ switch_v4l2();
+
+ if (V4L2_TUNER_RADIO == t->mode) {
+
+ if (t->has_signal)
+ tuner->signal = t->has_signal(client);
+
+ if (t->is_stereo) {
+ if (t->is_stereo(client)) {
+ tuner->rxsubchans =
+ V4L2_TUNER_SUB_STEREO |
+ V4L2_TUNER_SUB_MONO;
+ } else {
+ tuner->rxsubchans =
+ V4L2_TUNER_SUB_MONO;
+ }
}
+
+ tuner->capability |=
+ V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
+
+ tuner->audmode = t->audmode;
+
+ tuner->rangelow = radio_range[0] * 16000;
+ tuner->rangehigh = radio_range[1] * 16000;
+ } else {
+ tuner->rangelow = tv_range[0] * 16;
+ tuner->rangehigh = tv_range[1] * 16;
}
- tuner->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
- tuner->audmode = t->audmode;
-
- tuner->rangelow = radio_range[0] * 16000;
- tuner->rangehigh = radio_range[1] * 16000;
- } else {
- tuner->rangelow = tv_range[0] * 16;
- tuner->rangehigh = tv_range[1] * 16;
+ break;
+ }
+ case VIDIOC_S_TUNER:
+ {
+ struct v4l2_tuner *tuner = arg;
+
+ if (check_mode(t, "VIDIOC_S_TUNER") == EINVAL)
+ return 0;
+
+ switch_v4l2();
+
+ if (V4L2_TUNER_RADIO == t->mode) {
+ t->audmode = tuner->audmode;
+ set_radio_freq(client, t->freq);
+ }
+ break;
}
- break;
- }
- case VIDIOC_S_TUNER: /* Allow changing radio range and audio mode */
- {
- struct v4l2_tuner *tuner = arg;
-
- CHECK_ADDR(radio_tuner,"VIDIOC_S_TUNER","radio");
- SWITCH_V4L2;
-
- /* To switch the audio mode, applications initialize the
- index and audmode fields and the reserved array and
- call the VIDIOC_S_TUNER ioctl. */
- /* rxsubchannels: V4L2_TUNER_MODE_MONO, V4L2_TUNER_MODE_STEREO,
- V4L2_TUNER_MODE_LANG1, V4L2_TUNER_MODE_LANG2,
- V4L2_TUNER_MODE_SAP */
-
- if (tuner->audmode == V4L2_TUNER_MODE_MONO)
- t->audmode = V4L2_TUNER_MODE_MONO;
- else
- t->audmode = V4L2_TUNER_MODE_STEREO;
-
- set_radio_freq(client, t->freq);
- break;
- }
- case TDA9887_SET_CONFIG: /* Nothing to do on tuner-core */
- break;
default:
- tuner_dbg ("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd);
- /* nothing */
+ tuner_dbg("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd);
break;
}
return 0;
}
-static int tuner_suspend(struct device * dev, u32 state, u32 level)
+static int tuner_suspend(struct device *dev, u32 state, u32 level)
{
- struct i2c_client *c = container_of(dev, struct i2c_client, dev);
- struct tuner *t = i2c_get_clientdata(c);
+ struct i2c_client *c = container_of (dev, struct i2c_client, dev);
+ struct tuner *t = i2c_get_clientdata (c);
- tuner_dbg("suspend\n");
+ tuner_dbg ("suspend\n");
/* FIXME: power down ??? */
return 0;
}
-static int tuner_resume(struct device * dev, u32 level)
+static int tuner_resume(struct device *dev, u32 level)
{
- struct i2c_client *c = container_of(dev, struct i2c_client, dev);
- struct tuner *t = i2c_get_clientdata(c);
+ struct i2c_client *c = container_of (dev, struct i2c_client, dev);
+ struct tuner *t = i2c_get_clientdata (c);
- tuner_dbg("resume\n");
+ tuner_dbg ("resume\n");
if (t->freq)
- set_freq(c,t->freq);
+ set_freq(c, t->freq);
return 0;
}
/* ----------------------------------------------------------------------- */
static struct i2c_driver driver = {
- .owner = THIS_MODULE,
- .name = "tuner",
- .id = I2C_DRIVERID_TUNER,
- .flags = I2C_DF_NOTIFY,
- .attach_adapter = tuner_probe,
- .detach_client = tuner_detach,
- .command = tuner_command,
+ .owner = THIS_MODULE,
+ .name = "tuner",
+ .id = I2C_DRIVERID_TUNER,
+ .flags = I2C_DF_NOTIFY,
+ .attach_adapter = tuner_probe,
+ .detach_client = tuner_detach,
+ .command = tuner_command,
.driver = {
- .suspend = tuner_suspend,
- .resume = tuner_resume,
- },
+ .suspend = tuner_suspend,
+ .resume = tuner_resume,
+ },
};
-static struct i2c_client client_template =
-{
+static struct i2c_client client_template = {
I2C_DEVNAME("(tuner unset)"),
- .flags = I2C_CLIENT_ALLOW_USE,
- .driver = &driver,
+ .flags = I2C_CLIENT_ALLOW_USE,
+ .driver = &driver,
};
static int __init tuner_init_module(void)
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index c39ed6226ee..a3f8e83f531 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -1,5 +1,5 @@
/*
- * $Id: tuner-simple.c,v 1.31 2005/06/21 16:02:25 mkrufky Exp $
+ * $Id: tuner-simple.c,v 1.39 2005/07/07 01:49:30 mkrufky Exp $
*
* i2c tv tuner chip device driver
* controls all those simple 4-control-bytes style tuners.
@@ -54,6 +54,27 @@
#define PHILIPS_MF_SET_PAL_L 0x03 // France
#define PHILIPS_MF_SET_PAL_L2 0x02 // L'
+/* Control byte */
+
+#define TUNER_RATIO_MASK 0x06 /* Bit cb1:cb2 */
+#define TUNER_RATIO_SELECT_50 0x00
+#define TUNER_RATIO_SELECT_32 0x02
+#define TUNER_RATIO_SELECT_166 0x04
+#define TUNER_RATIO_SELECT_62 0x06
+
+#define TUNER_CHARGE_PUMP 0x40 /* Bit cb6 */
+
+/* Status byte */
+
+#define TUNER_POR 0x80
+#define TUNER_FL 0x40
+#define TUNER_MODE 0x38
+#define TUNER_AFC 0x07
+#define TUNER_SIGNAL 0x07
+#define TUNER_STEREO 0x10
+
+#define TUNER_PLL_LOCKED 0x40
+#define TUNER_STEREO_MK3 0x04
/* ---------------------------------------------------------------------- */
@@ -211,21 +232,17 @@ static struct tunertype tuners[] = {
16*160.00,16*442.00,0x01,0x02,0x04,0xce,623 },
{ "Philips FQ1236A MK4", Philips, NTSC,
16*160.00,16*442.00,0x01,0x02,0x04,0x8e,732 },
-
- /* Should work for TVF8531MF, TVF8831MF, TVF8731MF */
- { "Ymec TVision TVF-8531MF", Philips, NTSC,
+ { "Ymec TVision TVF-8531MF/8831MF/8731MF", Philips, NTSC,
16*160.00,16*454.00,0xa0,0x90,0x30,0x8e,732},
{ "Ymec TVision TVF-5533MF", Philips, NTSC,
16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732},
+
{ "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
- /* Should work for TNF9533-D/IF, TNF9533-B/DF */
- { "Tena TNF9533-D/IF", Philips, PAL,
+ { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL,
16*160.25,16*464.25,0x01,0x02,0x04,0x8e,623},
-
- /* This entry is for TEA5767 FM radio only chip used on several boards w/TV tuner */
- { TEA5767_TUNER_NAME, Philips, RADIO,
- -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0},
+ { "Philips TEA5767HN FM Radio", Philips, RADIO,
+ /* see tea5767.c for details */},
{ "Philips FMD1216ME MK3 Hybrid Tuner", Philips, PAL,
16*160.00,16*442.00,0x51,0x52,0x54,0x86,623 },
};
@@ -244,15 +261,6 @@ static int tuner_getstatus(struct i2c_client *c)
return byte;
}
-#define TUNER_POR 0x80
-#define TUNER_FL 0x40
-#define TUNER_MODE 0x38
-#define TUNER_AFC 0x07
-
-#define TUNER_STEREO 0x10 /* radio mode */
-#define TUNER_STEREO_MK3 0x04 /* radio mode */
-#define TUNER_SIGNAL 0x07 /* radio mode */
-
static int tuner_signal(struct i2c_client *c)
{
return (tuner_getstatus(c) & TUNER_SIGNAL) << 13;
@@ -278,22 +286,6 @@ static int tuner_stereo(struct i2c_client *c)
return stereo;
}
-#if 0 /* unused */
-static int tuner_islocked (struct i2c_client *c)
-{
- return (tuner_getstatus (c) & TUNER_FL);
-}
-
-static int tuner_afcstatus (struct i2c_client *c)
-{
- return (tuner_getstatus (c) & TUNER_AFC) - 2;
-}
-
-static int tuner_mode (struct i2c_client *c)
-{
- return (tuner_getstatus (c) & TUNER_MODE) >> 3;
-}
-#endif
/* ---------------------------------------------------------------------- */
@@ -376,7 +368,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
case TUNER_MICROTUNE_4042FI5:
/* Set the charge pump for fast tuning */
- tun->config |= 0x40;
+ tun->config |= TUNER_CHARGE_PUMP;
break;
}
@@ -425,14 +417,13 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc);
break;
}
- /* bit 6 is PLL locked indicator */
- if (status_byte & 0x40)
+ if (status_byte & TUNER_PLL_LOCKED)
break;
udelay(10);
}
/* Set the charge pump for optimized phase noise figure */
- tun->config &= ~0x40;
+ tun->config &= ~TUNER_CHARGE_PUMP;
buffer[0] = (div>>8) & 0x7f;
buffer[1] = div & 0xff;
buffer[2] = tun->config;
@@ -453,26 +444,22 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
unsigned div;
int rc;
- tun=&tuners[t->type];
- div = (freq / 1000) + (int)(16*10.7);
- buffer[2] = tun->config;
+ tun = &tuners[t->type];
+ div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
+ buffer[2] = (tun->config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
switch (t->type) {
case TUNER_TENA_9533_DI:
case TUNER_YMEC_TVF_5533MF:
- /*These values are empirically determinated */
- div = (freq * 122) / 16000 - 20;
- buffer[2] = 0x88; /* could be also 0x80 */
- buffer[3] = 0x19; /* could be also 0x10, 0x18, 0x99 */
- break;
+ tuner_dbg ("This tuner doesn't have FM. Most cards has a TEA5767 for FM\n");
+ return;
case TUNER_PHILIPS_FM1216ME_MK3:
case TUNER_PHILIPS_FM1236_MK3:
case TUNER_PHILIPS_FMD1216ME_MK3:
buffer[3] = 0x19;
break;
case TUNER_PHILIPS_FM1256_IH3:
- div = (20 * freq) / 16000 + 333 * 2;
- buffer[2] = 0x80;
+ div = (20 * freq) / 16000 + (int)(33.3 * 20); /* IF 33.3 MHz */
buffer[3] = 0x19;
break;
case TUNER_LG_PAL_FM:
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 9a493bea76d..d8b78f1d686 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -864,13 +864,8 @@ static int tda9874a_getmode(struct CHIPSTATE *chip)
* But changing the mode to VIDEO_SOUND_MONO would switch
* external 4052 multiplexer in audio_hook().
*/
-#if 0
- if((nsr & 0x02) && !(dsr & 0x10)) /* NSR.S/MB=1 and DSR.AMSTAT=0 */
- mode |= VIDEO_SOUND_STEREO;
-#else
if(nsr & 0x02) /* NSR.S/MB=1 */
mode |= VIDEO_SOUND_STEREO;
-#endif
if(nsr & 0x01) /* NSR.D/SB=1 */
mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
} else {
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 0f03c25489f..e8d9440977c 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -400,14 +400,6 @@ void tveeprom_hauppauge_analog(struct tveeprom *tvee, unsigned char *eeprom_data
}
}
-#if 0
- if (t_format < sizeof(hauppauge_tuner_fmt)/sizeof(struct HAUPPAUGE_TUNER_FMT)) {
- tvee->tuner_formats = hauppauge_tuner_fmt[t_format].id;
- t_fmt_name = hauppauge_tuner_fmt[t_format].name;
- } else {
- t_fmt_name = "<unknown>";
- }
-#endif
TVEEPROM_KERN_INFO("Hauppauge: model = %d, rev = %s, serial# = %d\n",
tvee->model,
@@ -482,6 +474,7 @@ static unsigned short normal_i2c[] = {
0xa0 >> 1,
I2C_CLIENT_END,
};
+
I2C_CLIENT_INSMOD;
struct i2c_driver i2c_driver_tveeprom;
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4cecdafeb87..7fc692a8f5b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -6,8 +6,7 @@ menu "Misc devices"
config IBM_ASM
tristate "Device driver for IBM RSA service processor"
- depends on X86 && EXPERIMENTAL
- default n
+ depends on X86 && PCI && EXPERIMENTAL
---help---
This option enables device driver support for in-band access to the
IBM RSA (Condor) service processor in eServer xSeries systems.
@@ -22,7 +21,7 @@ config IBM_ASM
WARNING: This software may not be supported or function
correctly on your IBM server. Please consult the IBM ServerProven
- website <http://www.pc.ibm/ww/eserver/xseries/serverproven> for
+ website <http://www.pc.ibm.com/ww/eserver/xseries/serverproven> for
information on the specific driver level and support statement
for your IBM server.
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 2b55687f6ee..9a07ff7a777 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -3,6 +3,8 @@
# Network device configuration
#
+menu "Network device support"
+
config NETDEVICES
depends on NET
bool "Network device support"
@@ -2547,3 +2549,4 @@ config NETCONSOLE
If you want to log kernel messages over the network, enable this.
See <file:Documentation/networking/netconsole.txt> for details.
+endmenu
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 69c488d933a..b14e89004c3 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -1,6 +1,33 @@
#
# Appletalk driver configuration
#
+config ATALK
+ tristate "Appletalk protocol support"
+ select LLC
+ ---help---
+ AppleTalk is the protocol that Apple computers can use to communicate
+ on a network. If your Linux box is connected to such a network and you
+ wish to connect to it, say Y. You will need to use the netatalk package
+ so that your Linux box can act as a print and file server for Macs as
+ well as access AppleTalk printers. Check out
+ <http://www.zettabyte.net/netatalk/> on the WWW for details.
+ EtherTalk is the name used for AppleTalk over Ethernet and the
+ cheaper and slower LocalTalk is AppleTalk over a proprietary Apple
+ network using serial links. EtherTalk and LocalTalk are fully
+ supported by Linux.
+
+ General information about how to connect Linux, Windows machines and
+ Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>. The
+ NET-3-HOWTO, available from
+ <http://www.tldp.org/docs.html#howto>, contains valuable
+ information as well.
+
+ To compile this driver as a module, choose M here: the module will be
+ called appletalk. You almost certainly want to compile it as a
+ module so you can restart your AppleTalk stack without rebooting
+ your machine. I hear that the GNU boycott of Apple is over, so
+ even politically correct people are allowed to say Y here.
+
config DEV_APPLETALK
bool "Appletalk interfaces support"
depends on ATALK
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index f1bd45e3da3..94939f570f7 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1930,6 +1930,7 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
b44_free_rings(bp);
spin_unlock_irq(&bp->lock);
+ pci_disable_device(pdev);
return 0;
}
@@ -1939,6 +1940,8 @@ static int b44_resume(struct pci_dev *pdev)
struct b44 *bp = netdev_priv(dev);
pci_restore_state(pdev);
+ pci_enable_device(pdev);
+ pci_set_master(pdev);
if (!netif_running(dev))
return 0;
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index aad5494c83c..f0996ce5c26 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -369,7 +369,7 @@ static void myri_tx(struct myri_eth *mp, struct net_device *dev)
* assume 802.3 if the type field is short enough to be a length.
* This is normal practice and works for any 'now in use' protocol.
*/
-static unsigned short myri_type_trans(struct sk_buff *skb, struct net_device *dev)
+static __be16 myri_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct ethhdr *eth;
unsigned char *rawp;
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index a1a6c08e7dc..f1c01ac2910 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -660,6 +660,7 @@ static int ne2k_pci_suspend (struct pci_dev *pdev, pm_message_t state)
netif_device_detach(dev);
pci_save_state(pdev);
+ pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0;
@@ -671,6 +672,8 @@ static int ne2k_pci_resume (struct pci_dev *pdev)
pci_set_power_state(pdev, 0);
pci_restore_state(pdev);
+ pci_enable_device(pdev);
+ pci_set_master(pdev);
NS8390_init(dev, 1);
netif_device_attach(dev);
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index f4b62405d2e..21537ee3a6a 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -540,7 +540,7 @@ plip_receive(unsigned short nibble_timeout, struct net_device *dev,
* in far too many old systems not all even running Linux.
*/
-static unsigned short plip_type_trans(struct sk_buff *skb, struct net_device *dev)
+static __be16 plip_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct ethhdr *eth;
unsigned char *rawp;
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 7217d44e885..2c83cca34b8 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -861,8 +861,7 @@ fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port,
/*
* Mark it for our own raw sockets interface
*/
-static unsigned short farsync_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static __be16 farsync_type_trans(struct sk_buff *skb, struct net_device *dev)
{
skb->dev = dev;
skb->mac.raw = skb->data;
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index 87496843681..48c03c11cd9 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -91,8 +91,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
-static unsigned short cisco_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
{
hdlc_header *data = (hdlc_header*)skb->data;
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 7cd6195a2e4..b81263eaede 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -66,8 +66,7 @@ static void ppp_close(struct net_device *dev)
-static unsigned short ppp_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static __be16 ppp_type_trans(struct sk_buff *skb, struct net_device *dev)
{
return __constant_htons(ETH_P_WAN_PPP);
}
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index c41fb70b692..9456d31cb1c 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -24,8 +24,7 @@
#include <linux/hdlc.h>
-static unsigned short raw_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev)
{
return __constant_htons(ETH_P_IP);
}
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index bc01d34e263..e9e37abe1f7 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1,9 +1,10 @@
/*
* File: pci-acpi.c
- * Purpose: Provide PCI supports in ACPI
+ * Purpose: Provide PCI support in ACPI
*
- * Copyright (C) 2004 Intel
- * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
+ * Copyright (C) 2005 David Shaohua Li <shaohua.li@intel.com>
+ * Copyright (C) 2004 Tom Long Nguyen <tom.l.nguyen@intel.com>
+ * Copyright (C) 2004 Intel Corp.
*/
#include <linux/delay.h>
@@ -16,6 +17,7 @@
#include <acpi/acpi_bus.h>
#include <linux/pci-acpi.h>
+#include "pci.h"
static u32 ctrlset_buf[3] = {0, 0, 0};
static u32 global_ctrlsets = 0;
@@ -207,3 +209,105 @@ acpi_status pci_osc_control_set(u32 flags)
return status;
}
EXPORT_SYMBOL(pci_osc_control_set);
+
+/*
+ * _SxD returns the D-state with the highest power
+ * (lowest D-state number) supported in the S-state "x".
+ *
+ * If the devices does not have a _PRW
+ * (Power Resources for Wake) supporting system wakeup from "x"
+ * then the OS is free to choose a lower power (higher number
+ * D-state) than the return value from _SxD.
+ *
+ * But if _PRW is enabled at S-state "x", the OS
+ * must not choose a power lower than _SxD --
+ * unless the device has an _SxW method specifying
+ * the lowest power (highest D-state number) the device
+ * may enter while still able to wake the system.
+ *
+ * ie. depending on global OS policy:
+ *
+ * if (_PRW at S-state x)
+ * choose from highest power _SxD to lowest power _SxW
+ * else // no _PRW at S-state x
+ * choose highest power _SxD or any lower power
+ *
+ * currently we simply return _SxD, if present.
+ */
+
+static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state)
+{
+ /* TBD */
+
+ return -ENODEV;
+}
+
+static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
+{
+ acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
+ static int state_conv[] = {
+ [0] = 0,
+ [1] = 1,
+ [2] = 2,
+ [3] = 3,
+ [4] = 3
+ };
+ int acpi_state = state_conv[(int __force) state];
+
+ if (!handle)
+ return -ENODEV;
+ return acpi_bus_set_power(handle, acpi_state);
+}
+
+
+/* ACPI bus type */
+static int pci_acpi_find_device(struct device *dev, acpi_handle *handle)
+{
+ struct pci_dev * pci_dev;
+ acpi_integer addr;
+
+ pci_dev = to_pci_dev(dev);
+ /* Please ref to ACPI spec for the syntax of _ADR */
+ addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
+ *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static int pci_acpi_find_root_bridge(struct device *dev, acpi_handle *handle)
+{
+ int num;
+ unsigned int seg, bus;
+
+ /*
+ * The string should be the same as root bridge's name
+ * Please look at 'pci_scan_bus_parented'
+ */
+ num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus);
+ if (num != 2)
+ return -ENODEV;
+ *handle = acpi_get_pci_rootbridge_handle(seg, bus);
+ if (!*handle)
+ return -ENODEV;
+ return 0;
+}
+
+static struct acpi_bus_type pci_acpi_bus = {
+ .bus = &pci_bus_type,
+ .find_device = pci_acpi_find_device,
+ .find_bridge = pci_acpi_find_root_bridge,
+};
+
+static int __init pci_acpi_init(void)
+{
+ int ret;
+
+ ret = register_acpi_bus_type(&pci_acpi_bus);
+ if (ret)
+ return 0;
+ platform_pci_choose_state = acpi_pci_choose_state;
+ platform_pci_set_power_state = acpi_pci_set_power_state;
+ return 0;
+}
+arch_initcall(pci_acpi_init);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d382bdb7b56..1b34fc56067 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -235,7 +235,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
* -EIO if device does not support PCI PM.
* 0 if we can successfully change the power state.
*/
-
+int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t);
int
pci_set_power_state(struct pci_dev *dev, pci_power_t state)
{
@@ -299,11 +299,20 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
msleep(10);
else if (state == PCI_D2 || dev->current_state == PCI_D2)
udelay(200);
- dev->current_state = state;
+ /*
+ * Give firmware a chance to be called, such as ACPI _PRx, _PSx
+ * Firmware method after natice method ?
+ */
+ if (platform_pci_set_power_state)
+ platform_pci_set_power_state(dev, state);
+
+ dev->current_state = state;
return 0;
}
+int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
+
/**
* pci_choose_state - Choose the power state of a PCI device
* @dev: PCI device to be suspended
@@ -316,10 +325,17 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
{
+ int ret;
+
if (!pci_find_capability(dev, PCI_CAP_ID_PM))
return PCI_D0;
- switch (state) {
+ if (platform_pci_choose_state) {
+ ret = platform_pci_choose_state(dev, state);
+ if (ret >= 0)
+ state = ret;
+ }
+ switch (state) {
case 0: return PCI_D0;
case 3: return PCI_D3hot;
default:
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 744da0d4ae5..d94d7af4f7a 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -11,6 +11,10 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
void (*alignf)(void *, struct resource *,
unsigned long, unsigned long),
void *alignf_data);
+/* Firmware callbacks */
+extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
+extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
+
/* PCI /proc functions */
#ifdef CONFIG_PROC_FS
extern int pci_proc_attach_device(struct pci_dev *dev);
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 0e7aa817669..6837491f021 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -527,98 +527,144 @@ static int yenta_sock_suspend(struct pcmcia_socket *sock)
* Use an adaptive allocation for the memory resource,
* sometimes the memory behind pci bridges is limited:
* 1/8 of the size of the io window of the parent.
- * max 4 MB, min 16 kB.
+ * max 4 MB, min 16 kB. We try very hard to not get below
+ * the "ACC" values, though.
*/
#define BRIDGE_MEM_MAX 4*1024*1024
+#define BRIDGE_MEM_ACC 128*1024
#define BRIDGE_MEM_MIN 16*1024
-#define BRIDGE_IO_MAX 256
+#define BRIDGE_IO_MAX 512
+#define BRIDGE_IO_ACC 256
#define BRIDGE_IO_MIN 32
#ifndef PCIBIOS_MIN_CARDBUS_IO
#define PCIBIOS_MIN_CARDBUS_IO PCIBIOS_MIN_IO
#endif
-static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type)
+static int yenta_search_one_res(struct resource *root, struct resource *res,
+ u32 min)
+{
+ u32 align, size, start, end;
+
+ if (res->flags & IORESOURCE_IO) {
+ align = 1024;
+ size = BRIDGE_IO_MAX;
+ start = PCIBIOS_MIN_CARDBUS_IO;
+ end = ~0U;
+ } else {
+ unsigned long avail = root->end - root->start;
+ int i;
+ size = BRIDGE_MEM_MAX;
+ if (size > avail/8) {
+ size=(avail+1)/8;
+ /* round size down to next power of 2 */
+ i = 0;
+ while ((size /= 2) != 0)
+ i++;
+ size = 1 << i;
+ }
+ if (size < min)
+ size = min;
+ align = size;
+ start = PCIBIOS_MIN_MEM;
+ end = ~0U;
+ }
+
+ do {
+ if (allocate_resource(root, res, size, start, end, align,
+ NULL, NULL)==0) {
+ return 1;
+ }
+ size = size/2;
+ align = size;
+ } while (size >= min);
+
+ return 0;
+}
+
+
+static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
+ u32 min)
+{
+ int i;
+ for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
+ struct resource * root = socket->dev->bus->resource[i];
+ if (!root)
+ continue;
+
+ if ((res->flags ^ root->flags) &
+ (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH))
+ continue; /* Wrong type */
+
+ if (yenta_search_one_res(root, res, min))
+ return 1;
+ }
+ return 0;
+}
+
+static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
{
struct pci_bus *bus;
struct resource *root, *res;
u32 start, end;
- u32 align, size, min;
- unsigned offset;
unsigned mask;
res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr;
/* Already allocated? */
if (res->parent)
- return 0;
+ return;
/* The granularity of the memory limit is 4kB, on IO it's 4 bytes */
mask = ~0xfff;
if (type & IORESOURCE_IO)
mask = ~3;
- offset = 0x1c + 8*nr;
bus = socket->dev->subordinate;
res->name = bus->name;
res->flags = type;
- res->start = 0;
- res->end = 0;
- root = pci_find_parent_resource(socket->dev, res);
- if (!root)
- return;
-
- start = config_readl(socket, offset) & mask;
- end = config_readl(socket, offset+4) | ~mask;
+ start = config_readl(socket, addr_start) & mask;
+ end = config_readl(socket, addr_end) | ~mask;
if (start && end > start && !override_bios) {
res->start = start;
res->end = end;
- if (request_resource(root, res) == 0)
+ root = pci_find_parent_resource(socket->dev, res);
+ if (root && (request_resource(root, res) == 0))
return;
- printk(KERN_INFO "yenta %s: Preassigned resource %d busy, reconfiguring...\n",
+ printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n",
pci_name(socket->dev), nr);
- res->start = res->end = 0;
}
if (type & IORESOURCE_IO) {
- align = 1024;
- size = BRIDGE_IO_MAX;
- min = BRIDGE_IO_MIN;
- start = PCIBIOS_MIN_CARDBUS_IO;
- end = ~0U;
+ if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
+ (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
+ (yenta_search_res(socket, res, BRIDGE_IO_MIN))) {
+ config_writel(socket, addr_start, res->start);
+ config_writel(socket, addr_end, res->end);
+ }
} else {
- unsigned long avail = root->end - root->start;
- int i;
- size = BRIDGE_MEM_MAX;
- if (size > avail/8) {
- size=(avail+1)/8;
- /* round size down to next power of 2 */
- i = 0;
- while ((size /= 2) != 0)
- i++;
- size = 1 << i;
+ if (type & IORESOURCE_PREFETCH) {
+ if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
+ (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
+ (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
+ config_writel(socket, addr_start, res->start);
+ config_writel(socket, addr_end, res->end);
+ }
+ /* Approximating prefetchable by non-prefetchable */
+ res->flags = IORESOURCE_MEM;
}
- if (size < BRIDGE_MEM_MIN)
- size = BRIDGE_MEM_MIN;
- min = BRIDGE_MEM_MIN;
- align = size;
- start = PCIBIOS_MIN_MEM;
- end = ~0U;
- }
-
- do {
- if (allocate_resource(root, res, size, start, end, align, NULL, NULL)==0) {
- config_writel(socket, offset, res->start);
- config_writel(socket, offset+4, res->end);
- return;
+ if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
+ (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
+ (yenta_search_res(socket, res, BRIDGE_MEM_MIN))) {
+ config_writel(socket, addr_start, res->start);
+ config_writel(socket, addr_end, res->end);
}
- size = size/2;
- align = size;
- } while (size >= min);
+ }
+
printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n",
- pci_name(socket->dev), type);
- res->start = res->end = 0;
+ pci_name(socket->dev), type);
+ res->start = res->end = res->flags = 0;
}
/*
@@ -626,10 +672,14 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ
*/
static void yenta_allocate_resources(struct yenta_socket *socket)
{
- yenta_allocate_res(socket, 0, IORESOURCE_MEM|IORESOURCE_PREFETCH);
- yenta_allocate_res(socket, 1, IORESOURCE_MEM);
- yenta_allocate_res(socket, 2, IORESOURCE_IO);
- yenta_allocate_res(socket, 3, IORESOURCE_IO); /* PCI isn't clever enough to use this one yet */
+ yenta_allocate_res(socket, 0, IORESOURCE_IO,
+ PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0);
+ yenta_allocate_res(socket, 1, IORESOURCE_IO,
+ PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1);
+ yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH,
+ PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0);
+ yenta_allocate_res(socket, 3, IORESOURCE_MEM,
+ PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1);
}
@@ -1055,6 +1105,7 @@ static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
pci_save_state(dev);
pci_read_config_dword(dev, 16*4, &socket->saved_state[0]);
pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
+ pci_disable_device(dev);
/*
* Some laptops (IBM T22) do not like us putting the Cardbus
@@ -1078,6 +1129,8 @@ static int yenta_dev_resume (struct pci_dev *dev)
pci_restore_state(dev);
pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
+ pci_enable_device(dev);
+ pci_set_master(dev);
if (socket->type && socket->type->restore_state)
socket->type->restore_state(socket);
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index dd61e09029b..75575f6c349 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -160,7 +160,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
acpi_register_gsi(res->data.irq.interrupts[0],
res->data.irq.edge_level,
res->data.irq.active_high_low));
- pcibios_penalize_isa_irq(res->data.irq.interrupts[0]);
+ pcibios_penalize_isa_irq(res->data.irq.interrupts[0], 1);
}
break;
@@ -171,7 +171,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
acpi_register_gsi(res->data.extended_irq.interrupts[0],
res->data.extended_irq.edge_level,
res->data.extended_irq.active_high_low));
- pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0]);
+ pcibios_penalize_isa_irq(res->data.extended_irq.interrupts[0], 1);
}
break;
case ACPI_RSTYPE_DMA:
@@ -444,6 +444,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
struct acpipnp_parse_option_s {
struct pnp_option *option;
+ struct pnp_option *option_independent;
struct pnp_dev *dev;
};
@@ -507,7 +508,14 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
parse_data->option = option;
break;
case ACPI_RSTYPE_END_DPF:
- return AE_CTRL_TERMINATE;
+ /*only one EndDependentFn is allowed*/
+ if (!parse_data->option_independent) {
+ pnp_warn("PnPACPI: more than one EndDependentFn");
+ return AE_ERROR;
+ }
+ parse_data->option = parse_data->option_independent;
+ parse_data->option_independent = NULL;
+ break;
default:
pnp_warn("PnPACPI: unknown resource type %d", res->id);
return AE_ERROR;
@@ -525,6 +533,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
parse_data.option = pnp_register_independent_option(dev);
if (!parse_data.option)
return AE_ERROR;
+ parse_data.option_independent = parse_data.option;
parse_data.dev = dev;
status = acpi_walk_resources(handle, METHOD_NAME__PRS,
pnpacpi_option_resource, &parse_data);
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 79bce7b7574..9001b6f0204 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -64,7 +64,7 @@ pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq)
}
res->irq_resource[i].start =
res->irq_resource[i].end = (unsigned long) irq;
- pcibios_penalize_isa_irq(irq);
+ pcibios_penalize_isa_irq(irq, 1);
}
}
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 2d1322dd7e1..887ad893934 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -102,7 +102,7 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
for (i = 0; i < 16; i++)
if (test_bit(i, data->map))
- pcibios_penalize_isa_irq(i);
+ pcibios_penalize_isa_irq(i, 0);
}
#endif
return 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 3cb88c77003..8f4d2999af8 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -2210,7 +2210,7 @@ no_mem:
return NULL;
}
-static inline unsigned short
+static inline __be16
qeth_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct qeth_card *card;
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 1fef92d55de..390cd67c57c 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -469,7 +469,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
goto cleanup;
}
- user_srbcmd = kmalloc(GFP_KERNEL, fibsize);
+ user_srbcmd = kmalloc(fibsize, GFP_KERNEL);
if (!user_srbcmd) {
dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n"));
rcode = -ENOMEM;
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index d79cd218a55..df014c2a7c5 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -65,12 +65,14 @@ obj-$(CONFIG_USB_EMI26) += misc/
obj-$(CONFIG_USB_EMI62) += misc/
obj-$(CONFIG_USB_IDMOUSE) += misc/
obj-$(CONFIG_USB_LCD) += misc/
+obj-$(CONFIG_USB_LD) += misc/
obj-$(CONFIG_USB_LED) += misc/
obj-$(CONFIG_USB_LEGOTOWER) += misc/
obj-$(CONFIG_USB_RIO500) += misc/
obj-$(CONFIG_USB_TEST) += misc/
obj-$(CONFIG_USB_USS720) += misc/
obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
+obj-$(CONFIG_USB_SISUSBVGA) += misc/
obj-$(CONFIG_USB_ATM) += atm/
obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index cbd4a7d25d0..8e184e2641c 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -427,7 +427,7 @@ static void cxacru_poll_status(struct cxacru_data *instance)
atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
atm_dev->signal = ATM_PHY_SIG_FOUND;
- dev_info(dev, "ADSL line: up (%d Kib/s down | %d Kib/s up)\n",
+ dev_info(dev, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
break;
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 6a6eaa2a3b1..d0cbbb7f038 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -100,6 +100,8 @@ struct speedtch_instance_data {
struct work_struct status_checker;
+ unsigned char last_status;
+
int poll_delay; /* milliseconds */
struct timer_list resubmit_timer;
@@ -423,52 +425,48 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
struct usbatm_data *usbatm = instance->usbatm;
struct atm_dev *atm_dev = usbatm->atm_dev;
unsigned char *buf = instance->scratch_buffer;
- int ret;
+ int down_speed, up_speed, ret;
+ unsigned char status;
atm_dbg(usbatm, "%s entered\n", __func__);
ret = speedtch_read_status(instance);
if (ret < 0) {
atm_warn(usbatm, "error %d fetching device status\n", ret);
- if (instance->poll_delay < MAX_POLL_DELAY)
- instance->poll_delay *= 2;
+ instance->poll_delay = min(2 * instance->poll_delay, MAX_POLL_DELAY);
return;
}
- if (instance->poll_delay > MIN_POLL_DELAY)
- instance->poll_delay /= 2;
+ instance->poll_delay = max(instance->poll_delay / 2, MIN_POLL_DELAY);
- atm_dbg(usbatm, "%s: line state %02x\n", __func__, buf[OFFSET_7]);
+ status = buf[OFFSET_7];
- switch (buf[OFFSET_7]) {
- case 0:
- if (atm_dev->signal != ATM_PHY_SIG_LOST) {
+ atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
+
+ if ((status != instance->last_status) || !status) {
+ switch (status) {
+ case 0:
atm_dev->signal = ATM_PHY_SIG_LOST;
- atm_info(usbatm, "ADSL line is down\n");
- /* It'll never resync again unless we ask it to... */
+ if (instance->last_status)
+ atm_info(usbatm, "ADSL line is down\n");
+ /* It may never resync again unless we ask it to... */
ret = speedtch_start_synchro(instance);
- }
- break;
+ break;
- case 0x08:
- if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+ case 0x08:
atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
atm_info(usbatm, "ADSL line is blocked?\n");
- }
- break;
+ break;
- case 0x10:
- if (atm_dev->signal != ATM_PHY_SIG_LOST) {
+ case 0x10:
atm_dev->signal = ATM_PHY_SIG_LOST;
atm_info(usbatm, "ADSL line is synchronising\n");
- }
- break;
+ break;
- case 0x20:
- if (atm_dev->signal != ATM_PHY_SIG_FOUND) {
- int down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
+ case 0x20:
+ down_speed = buf[OFFSET_b] | (buf[OFFSET_b + 1] << 8)
| (buf[OFFSET_b + 2] << 16) | (buf[OFFSET_b + 3] << 24);
- int up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
+ up_speed = buf[OFFSET_b + 4] | (buf[OFFSET_b + 5] << 8)
| (buf[OFFSET_b + 6] << 16) | (buf[OFFSET_b + 7] << 24);
if (!(down_speed & 0x0000ffff) && !(up_speed & 0x0000ffff)) {
@@ -480,17 +478,17 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
atm_dev->signal = ATM_PHY_SIG_FOUND;
atm_info(usbatm,
- "ADSL line is up (%d Kib/s down | %d Kib/s up)\n",
+ "ADSL line is up (%d kb/s down | %d kb/s up)\n",
down_speed, up_speed);
- }
- break;
+ break;
- default:
- if (atm_dev->signal != ATM_PHY_SIG_UNKNOWN) {
+ default:
atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
- atm_info(usbatm, "Unknown line state %02x\n", buf[OFFSET_7]);
+ atm_info(usbatm, "Unknown line state %02x\n", status);
+ break;
}
- break;
+
+ instance->last_status = status;
}
}
@@ -730,6 +728,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
instance->status_checker.timer.function = speedtch_status_poll;
instance->status_checker.timer.data = (unsigned long)instance;
+ instance->last_status = 0xff;
instance->poll_delay = MIN_POLL_DELAY;
init_timer(&instance->resubmit_timer);
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 69e859e0f51..adff5a77e31 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -422,6 +422,17 @@ bail_out:
return -EIO;
}
+static void acm_tty_unregister(struct acm *acm)
+{
+ tty_unregister_device(acm_tty_driver, acm->minor);
+ usb_put_intf(acm->control);
+ acm_table[acm->minor] = NULL;
+ usb_free_urb(acm->ctrlurb);
+ usb_free_urb(acm->readurb);
+ usb_free_urb(acm->writeurb);
+ kfree(acm);
+}
+
static void acm_tty_close(struct tty_struct *tty, struct file *filp)
{
struct acm *acm = tty->driver_data;
@@ -436,14 +447,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
usb_kill_urb(acm->ctrlurb);
usb_kill_urb(acm->writeurb);
usb_kill_urb(acm->readurb);
- } else {
- tty_unregister_device(acm_tty_driver, acm->minor);
- acm_table[acm->minor] = NULL;
- usb_free_urb(acm->ctrlurb);
- usb_free_urb(acm->readurb);
- usb_free_urb(acm->writeurb);
- kfree(acm);
- }
+ } else
+ acm_tty_unregister(acm);
}
up(&open_sem);
}
@@ -905,7 +910,8 @@ skip_normal_probe:
usb_driver_claim_interface(&acm_driver, data_interface, acm);
- tty_register_device(acm_tty_driver, minor, &intf->dev);
+ usb_get_intf(control_interface);
+ tty_register_device(acm_tty_driver, minor, &control_interface->dev);
acm_table[minor] = acm;
usb_set_intfdata (intf, acm);
@@ -954,12 +960,7 @@ static void acm_disconnect(struct usb_interface *intf)
usb_driver_release_interface(&acm_driver, acm->data);
if (!acm->used) {
- tty_unregister_device(acm_tty_driver, acm->minor);
- acm_table[acm->minor] = NULL;
- usb_free_urb(acm->ctrlurb);
- usb_free_urb(acm->readurb);
- usb_free_urb(acm->writeurb);
- kfree(acm);
+ acm_tty_unregister(acm);
up(&open_sem);
return;
}
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index b7827df21f4..fc15b4acc8a 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -106,7 +106,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
void *hcd_buffer_alloc (
struct usb_bus *bus,
size_t size,
- int mem_flags,
+ unsigned mem_flags,
dma_addr_t *dma
)
{
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 71b4a8d6631..fc056062c96 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -380,6 +380,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
usb_hc_died (hcd);
}
+ pci_enable_device(dev);
return retval;
}
EXPORT_SYMBOL (usb_hcd_pci_resume);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 83e732a0d64..8616356f55e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1112,7 +1112,7 @@ static void urb_unlink (struct urb *urb)
* expects usb_submit_urb() to have sanity checked and conditioned all
* inputs in the urb
*/
-static int hcd_submit_urb (struct urb *urb, int mem_flags)
+static int hcd_submit_urb (struct urb *urb, unsigned mem_flags)
{
int status;
struct usb_hcd *hcd = urb->dev->bus->hcpriv;
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 8dc13cde2f7..67db4a999b9 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -142,12 +142,12 @@ struct hcd_timeout { /* timeouts we allocate */
struct usb_operations {
int (*get_frame_number) (struct usb_device *usb_dev);
- int (*submit_urb) (struct urb *urb, int mem_flags);
+ int (*submit_urb) (struct urb *urb, unsigned mem_flags);
int (*unlink_urb) (struct urb *urb, int status);
/* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
- int mem_flags,
+ unsigned mem_flags,
dma_addr_t *dma);
void (*buffer_free)(struct usb_bus *bus, size_t size,
void *addr, dma_addr_t dma);
@@ -200,7 +200,7 @@ struct hc_driver {
int (*urb_enqueue) (struct usb_hcd *hcd,
struct usb_host_endpoint *ep,
struct urb *urb,
- int mem_flags);
+ unsigned mem_flags);
int (*urb_dequeue) (struct usb_hcd *hcd, struct urb *urb);
/* hw synch, freeing endpoint resources that urb_dequeue can't */
@@ -247,7 +247,7 @@ int hcd_buffer_create (struct usb_hcd *hcd);
void hcd_buffer_destroy (struct usb_hcd *hcd);
void *hcd_buffer_alloc (struct usb_bus *bus, size_t size,
- int mem_flags, dma_addr_t *dma);
+ unsigned mem_flags, dma_addr_t *dma);
void hcd_buffer_free (struct usb_bus *bus, size_t size,
void *addr, dma_addr_t dma);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 32ff3218185..c3e46d24a37 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -26,6 +26,7 @@
#include <linux/ioctl.h>
#include <linux/usb.h>
#include <linux/usbdevice_fs.h>
+#include <linux/kthread.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
@@ -47,8 +48,7 @@ static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
/* Wakes up khubd */
static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
-static pid_t khubd_pid = 0; /* PID of khubd */
-static DECLARE_COMPLETION(khubd_exited);
+static struct task_struct *khubd_task;
/* cycle leds on hubs that aren't blinking for attention */
static int blinkenlights = 0;
@@ -2807,23 +2807,16 @@ loop:
static int hub_thread(void *__unused)
{
- /*
- * This thread doesn't need any user-level access,
- * so get rid of all our resources
- */
-
- daemonize("khubd");
- allow_signal(SIGKILL);
-
- /* Send me a signal to get me die (for debugging) */
do {
hub_events();
- wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
+ wait_event_interruptible(khubd_wait,
+ !list_empty(&hub_event_list) ||
+ kthread_should_stop());
try_to_freeze();
- } while (!signal_pending(current));
+ } while (!kthread_should_stop() || !list_empty(&hub_event_list));
- pr_debug ("%s: khubd exiting\n", usbcore_name);
- complete_and_exit(&khubd_exited, 0);
+ pr_debug("%s: khubd exiting\n", usbcore_name);
+ return 0;
}
static struct usb_device_id hub_id_table [] = {
@@ -2849,20 +2842,15 @@ static struct usb_driver hub_driver = {
int usb_hub_init(void)
{
- pid_t pid;
-
if (usb_register(&hub_driver) < 0) {
printk(KERN_ERR "%s: can't register hub driver\n",
usbcore_name);
return -1;
}
- pid = kernel_thread(hub_thread, NULL, CLONE_KERNEL);
- if (pid >= 0) {
- khubd_pid = pid;
-
+ khubd_task = kthread_run(hub_thread, NULL, "khubd");
+ if (!IS_ERR(khubd_task))
return 0;
- }
/* Fall through if kernel_thread failed */
usb_deregister(&hub_driver);
@@ -2873,12 +2861,7 @@ int usb_hub_init(void)
void usb_hub_cleanup(void)
{
- int ret;
-
- /* Kill the thread */
- ret = kill_proc(khubd_pid, SIGKILL, 1);
-
- wait_for_completion(&khubd_exited);
+ kthread_stop(khubd_task);
/*
* Hub resources are freed for us by usb_deregister. It calls
@@ -2890,7 +2873,6 @@ void usb_hub_cleanup(void)
usb_deregister(&hub_driver);
} /* usb_hub_cleanup() */
-
static int config_descriptors_changed(struct usb_device *udev)
{
unsigned index;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index f50aaf25c98..a428ef479bd 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -320,7 +320,7 @@ int usb_sg_init (
struct scatterlist *sg,
int nents,
size_t length,
- int mem_flags
+ unsigned mem_flags
)
{
int i;
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 740cb4c668d..00297f11384 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -196,6 +196,7 @@ usb_descriptor_attr (bDeviceClass, "%02x\n")
usb_descriptor_attr (bDeviceSubClass, "%02x\n")
usb_descriptor_attr (bDeviceProtocol, "%02x\n")
usb_descriptor_attr (bNumConfigurations, "%d\n")
+usb_descriptor_attr (bMaxPacketSize0, "%d\n")
static struct attribute *dev_attrs[] = {
/* current configuration's attributes */
@@ -211,6 +212,7 @@ static struct attribute *dev_attrs[] = {
&dev_attr_bDeviceSubClass.attr,
&dev_attr_bDeviceProtocol.attr,
&dev_attr_bNumConfigurations.attr,
+ &dev_attr_bMaxPacketSize0.attr,
&dev_attr_speed.attr,
&dev_attr_devnum.attr,
&dev_attr_version.attr,
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 0faf18d511d..c0feee25ff0 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -60,7 +60,7 @@ void usb_init_urb(struct urb *urb)
*
* The driver must call usb_free_urb() when it is finished with the urb.
*/
-struct urb *usb_alloc_urb(int iso_packets, int mem_flags)
+struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags)
{
struct urb *urb;
@@ -224,7 +224,7 @@ struct urb * usb_get_urb(struct urb *urb)
* GFP_NOIO, unless b) or c) apply
*
*/
-int usb_submit_urb(struct urb *urb, int mem_flags)
+int usb_submit_urb(struct urb *urb, unsigned mem_flags)
{
int pipe, temp, max;
struct usb_device *dev;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index a3c42203213..99c85d2f92d 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -1129,7 +1129,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
void *usb_buffer_alloc (
struct usb_device *dev,
size_t size,
- int mem_flags,
+ unsigned mem_flags,
dma_addr_t *dma
)
{
@@ -1532,6 +1532,9 @@ EXPORT_SYMBOL(usb_register);
EXPORT_SYMBOL(usb_deregister);
EXPORT_SYMBOL(usb_disabled);
+EXPORT_SYMBOL_GPL(usb_get_intf);
+EXPORT_SYMBOL_GPL(usb_put_intf);
+
EXPORT_SYMBOL(usb_alloc_dev);
EXPORT_SYMBOL(usb_put_dev);
EXPORT_SYMBOL(usb_get_dev);
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 4d692670f28..583db7c38cf 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -470,7 +470,7 @@ static int dummy_disable (struct usb_ep *_ep)
}
static struct usb_request *
-dummy_alloc_request (struct usb_ep *_ep, int mem_flags)
+dummy_alloc_request (struct usb_ep *_ep, unsigned mem_flags)
{
struct dummy_ep *ep;
struct dummy_request *req;
@@ -507,7 +507,7 @@ dummy_alloc_buffer (
struct usb_ep *_ep,
unsigned bytes,
dma_addr_t *dma,
- int mem_flags
+ unsigned mem_flags
) {
char *retval;
struct dummy_ep *ep;
@@ -540,7 +540,8 @@ fifo_complete (struct usb_ep *ep, struct usb_request *req)
}
static int
-dummy_queue (struct usb_ep *_ep, struct usb_request *_req, int mem_flags)
+dummy_queue (struct usb_ep *_ep, struct usb_request *_req,
+ unsigned mem_flags)
{
struct dummy_ep *ep;
struct dummy_request *req;
@@ -998,7 +999,7 @@ static int dummy_urb_enqueue (
struct usb_hcd *hcd,
struct usb_host_endpoint *ep,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
) {
struct dummy *dum;
struct urbp *urbp;
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 5bb53ae8896..8509e955007 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -945,15 +945,16 @@ config_buf (enum usb_device_speed speed,
/*-------------------------------------------------------------------------*/
-static void eth_start (struct eth_dev *dev, int gfp_flags);
-static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags);
+static void eth_start (struct eth_dev *dev, unsigned gfp_flags);
+static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags);
static int
-set_ether_config (struct eth_dev *dev, int gfp_flags)
+set_ether_config (struct eth_dev *dev, unsigned gfp_flags)
{
int result = 0;
struct usb_gadget *gadget = dev->gadget;
+#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
/* status endpoint used for RNDIS and (optionally) CDC */
if (!subset_active(dev) && dev->status_ep) {
dev->status = ep_desc (gadget, &hs_status_desc,
@@ -967,6 +968,7 @@ set_ether_config (struct eth_dev *dev, int gfp_flags)
goto done;
}
}
+#endif
dev->in = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc);
dev->in_ep->driver_data = dev;
@@ -1079,7 +1081,7 @@ static void eth_reset_config (struct eth_dev *dev)
* that returns config descriptors, and altsetting code.
*/
static int
-eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags)
+eth_set_config (struct eth_dev *dev, unsigned number, unsigned gfp_flags)
{
int result = 0;
struct usb_gadget *gadget = dev->gadget;
@@ -1596,7 +1598,7 @@ static void defer_kevent (struct eth_dev *dev, int flag)
static void rx_complete (struct usb_ep *ep, struct usb_request *req);
static int
-rx_submit (struct eth_dev *dev, struct usb_request *req, int gfp_flags)
+rx_submit (struct eth_dev *dev, struct usb_request *req, unsigned gfp_flags)
{
struct sk_buff *skb;
int retval = -ENOMEM;
@@ -1722,7 +1724,7 @@ clean:
}
static int prealloc (struct list_head *list, struct usb_ep *ep,
- unsigned n, int gfp_flags)
+ unsigned n, unsigned gfp_flags)
{
unsigned i;
struct usb_request *req;
@@ -1761,7 +1763,7 @@ extra:
return 0;
}
-static int alloc_requests (struct eth_dev *dev, unsigned n, int gfp_flags)
+static int alloc_requests (struct eth_dev *dev, unsigned n, unsigned gfp_flags)
{
int status;
@@ -1777,7 +1779,7 @@ fail:
return status;
}
-static void rx_fill (struct eth_dev *dev, int gfp_flags)
+static void rx_fill (struct eth_dev *dev, unsigned gfp_flags)
{
struct usb_request *req;
unsigned long flags;
@@ -2022,7 +2024,7 @@ static int rndis_control_ack (struct net_device *net)
#endif /* RNDIS */
-static void eth_start (struct eth_dev *dev, int gfp_flags)
+static void eth_start (struct eth_dev *dev, unsigned gfp_flags)
{
DEBUG (dev, "%s\n", __FUNCTION__);
@@ -2428,7 +2430,7 @@ autoconf_fail:
dev->req->complete = eth_setup_complete;
/* ... and maybe likewise for status transfer */
-#ifdef DEV_CONFIG_CDC
+#if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS)
if (dev->status_ep) {
dev->stat_req = eth_req_alloc (dev->status_ep,
STATUS_BYTECOUNT, GFP_KERNEL);
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index ed773a9111d..eaab26f4ed3 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -269,7 +269,7 @@ static int goku_ep_disable(struct usb_ep *_ep)
/*-------------------------------------------------------------------------*/
static struct usb_request *
-goku_alloc_request(struct usb_ep *_ep, int gfp_flags)
+goku_alloc_request(struct usb_ep *_ep, unsigned gfp_flags)
{
struct goku_request *req;
@@ -327,7 +327,7 @@ goku_free_request(struct usb_ep *_ep, struct usb_request *_req)
*/
static void *
goku_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
- dma_addr_t *dma, int gfp_flags)
+ dma_addr_t *dma, unsigned gfp_flags)
{
void *retval;
struct goku_ep *ep;
@@ -789,7 +789,7 @@ finished:
/*-------------------------------------------------------------------------*/
static int
-goku_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags)
+goku_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
{
struct goku_request *req;
struct goku_ep *ep;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index df75ab65a5e..4842577789c 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -1106,7 +1106,7 @@ static int lh7a40x_ep_disable(struct usb_ep *_ep)
}
static struct usb_request *lh7a40x_alloc_request(struct usb_ep *ep,
- int gfp_flags)
+ unsigned gfp_flags)
{
struct lh7a40x_request *req;
@@ -1134,7 +1134,7 @@ static void lh7a40x_free_request(struct usb_ep *ep, struct usb_request *_req)
}
static void *lh7a40x_alloc_buffer(struct usb_ep *ep, unsigned bytes,
- dma_addr_t * dma, int gfp_flags)
+ dma_addr_t * dma, unsigned gfp_flags)
{
char *retval;
@@ -1158,7 +1158,7 @@ static void lh7a40x_free_buffer(struct usb_ep *ep, void *buf, dma_addr_t dma,
* NOTE: Sets INDEX register
*/
static int lh7a40x_queue(struct usb_ep *_ep, struct usb_request *_req,
- int gfp_flags)
+ unsigned gfp_flags)
{
struct lh7a40x_request *req;
struct lh7a40x_ep *ep;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 13a3dbc9949..477fab2e74d 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -376,7 +376,7 @@ static int net2280_disable (struct usb_ep *_ep)
/*-------------------------------------------------------------------------*/
static struct usb_request *
-net2280_alloc_request (struct usb_ep *_ep, int gfp_flags)
+net2280_alloc_request (struct usb_ep *_ep, unsigned gfp_flags)
{
struct net2280_ep *ep;
struct net2280_request *req;
@@ -463,7 +463,7 @@ net2280_alloc_buffer (
struct usb_ep *_ep,
unsigned bytes,
dma_addr_t *dma,
- int gfp_flags
+ unsigned gfp_flags
)
{
void *retval;
@@ -897,7 +897,7 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status)
/*-------------------------------------------------------------------------*/
static int
-net2280_queue (struct usb_ep *_ep, struct usb_request *_req, int gfp_flags)
+net2280_queue (struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
{
struct net2280_request *req;
struct net2280_ep *ep;
@@ -1490,7 +1490,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
unsigned long flags;
int i;
u32 t1, t2;
- char *s;
+ const char *s;
dev = dev_get_drvdata (_dev);
next = buf;
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index a2b812af6e6..ff5533e6956 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -269,7 +269,7 @@ static int omap_ep_disable(struct usb_ep *_ep)
/*-------------------------------------------------------------------------*/
static struct usb_request *
-omap_alloc_request(struct usb_ep *ep, int gfp_flags)
+omap_alloc_request(struct usb_ep *ep, unsigned gfp_flags)
{
struct omap_req *req;
@@ -298,7 +298,7 @@ omap_alloc_buffer(
struct usb_ep *_ep,
unsigned bytes,
dma_addr_t *dma,
- int gfp_flags
+ unsigned gfp_flags
)
{
void *retval;
@@ -937,7 +937,7 @@ static void dma_channel_release(struct omap_ep *ep)
/*-------------------------------------------------------------------------*/
static int
-omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags)
+omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
{
struct omap_ep *ep = container_of(_ep, struct omap_ep, ep);
struct omap_req *req = container_of(_req, struct omap_req, req);
@@ -2908,6 +2908,7 @@ static int __exit omap_udc_remove(struct device *dev)
* make host resumes and VBUS detection trigger OMAP wakeup events; that
* may involve talking to an external transceiver (e.g. isp1301).
*/
+
static int omap_udc_suspend(struct device *dev, pm_message_t message, u32 level)
{
u32 devstat;
@@ -2936,8 +2937,6 @@ static int omap_udc_resume(struct device *dev, u32 level)
return 0;
DBG("resume + wakeup/SRP\n");
- udc->gadget.dev.parent->power.power_state = PMSG_ON;
- udc->gadget.dev.power.power_state = PMSG_ON;
omap_pullup(&udc->gadget, 1);
/* maybe the host would enumerate us if we nudged it */
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 6a0b957af33..1507738337c 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -332,7 +332,7 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
* pxa2xx_ep_alloc_request - allocate a request data structure
*/
static struct usb_request *
-pxa2xx_ep_alloc_request (struct usb_ep *_ep, int gfp_flags)
+pxa2xx_ep_alloc_request (struct usb_ep *_ep, unsigned gfp_flags)
{
struct pxa2xx_request *req;
@@ -367,7 +367,7 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req)
*/
static void *
pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
- dma_addr_t *dma, int gfp_flags)
+ dma_addr_t *dma, unsigned gfp_flags)
{
char *retval;
@@ -874,7 +874,7 @@ done:
/*-------------------------------------------------------------------------*/
static int
-pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, int gfp_flags)
+pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, unsigned gfp_flags)
{
struct pxa2xx_request *req;
struct pxa2xx_ep *ep;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index a6e035e2447..bb9b2d94eed 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -612,7 +612,7 @@ static void source_sink_complete (struct usb_ep *ep, struct usb_request *req)
}
static struct usb_request *
-source_sink_start_ep (struct usb_ep *ep, int gfp_flags)
+source_sink_start_ep (struct usb_ep *ep, unsigned gfp_flags)
{
struct usb_request *req;
int status;
@@ -640,7 +640,7 @@ source_sink_start_ep (struct usb_ep *ep, int gfp_flags)
}
static int
-set_source_sink_config (struct zero_dev *dev, int gfp_flags)
+set_source_sink_config (struct zero_dev *dev, unsigned gfp_flags)
{
int result = 0;
struct usb_ep *ep;
@@ -744,7 +744,7 @@ static void loopback_complete (struct usb_ep *ep, struct usb_request *req)
}
static int
-set_loopback_config (struct zero_dev *dev, int gfp_flags)
+set_loopback_config (struct zero_dev *dev, unsigned gfp_flags)
{
int result = 0;
struct usb_ep *ep;
@@ -845,7 +845,7 @@ static void zero_reset_config (struct zero_dev *dev)
* by limiting configuration choices (like the pxa2xx).
*/
static int
-zero_set_config (struct zero_dev *dev, unsigned number, int gfp_flags)
+zero_set_config (struct zero_dev *dev, unsigned number, unsigned gfp_flags)
{
int result = 0;
struct usb_gadget *gadget = dev->gadget;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 35248a37b71..149b13fc0a7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -960,7 +960,7 @@ static int ehci_urb_enqueue (
struct usb_hcd *hcd,
struct usb_host_endpoint *ep,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
) {
struct ehci_hcd *ehci = hcd_to_ehci (hcd);
struct list_head qtd_list;
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 45d89a7083b..d74b2d68a50 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -898,7 +898,7 @@ submit_async (
struct usb_host_endpoint *ep,
struct urb *urb,
struct list_head *qtd_list,
- int mem_flags
+ unsigned mem_flags
) {
struct ehci_qtd *qtd;
int epnum;
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index c2104cad403..9af4f64532a 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -588,7 +588,7 @@ static int intr_submit (
struct usb_host_endpoint *ep,
struct urb *urb,
struct list_head *qtd_list,
- int mem_flags
+ unsigned mem_flags
) {
unsigned epnum;
unsigned long flags;
@@ -633,7 +633,7 @@ done:
/* ehci_iso_stream ops work with both ITD and SITD */
static struct ehci_iso_stream *
-iso_stream_alloc (int mem_flags)
+iso_stream_alloc (unsigned mem_flags)
{
struct ehci_iso_stream *stream;
@@ -846,7 +846,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb)
/* ehci_iso_sched ops can be ITD-only or SITD-only */
static struct ehci_iso_sched *
-iso_sched_alloc (unsigned packets, int mem_flags)
+iso_sched_alloc (unsigned packets, unsigned mem_flags)
{
struct ehci_iso_sched *iso_sched;
int size = sizeof *iso_sched;
@@ -919,7 +919,7 @@ itd_urb_transaction (
struct ehci_iso_stream *stream,
struct ehci_hcd *ehci,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
)
{
struct ehci_itd *itd;
@@ -1412,7 +1412,8 @@ itd_complete (
/*-------------------------------------------------------------------------*/
-static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
+static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
+ unsigned mem_flags)
{
int status = -EINVAL;
unsigned long flags;
@@ -1523,7 +1524,7 @@ sitd_urb_transaction (
struct ehci_iso_stream *stream,
struct ehci_hcd *ehci,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
)
{
struct ehci_sitd *sitd;
@@ -1772,7 +1773,8 @@ sitd_complete (
}
-static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
+static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
+ unsigned mem_flags)
{
int status = -EINVAL;
unsigned long flags;
@@ -1822,7 +1824,8 @@ done:
#else
static inline int
-sitd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
+sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
+ unsigned mem_flags)
{
ehci_dbg (ehci, "split iso support is disabled\n");
return -ENOSYS;
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index d9883d774d3..81f8f6b7fdc 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -463,7 +463,8 @@ static void etrax_usb_free_epid(int epid);
static int etrax_remove_from_sb_list(struct urb *urb);
-static void* etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma);
+static void* etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size,
+ unsigned mem_flags, dma_addr_t *dma);
static void etrax_usb_buffer_free(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma);
static void etrax_usb_add_to_bulk_sb_list(struct urb *urb, int epid);
@@ -476,7 +477,7 @@ static int etrax_usb_submit_ctrl_urb(struct urb *urb);
static int etrax_usb_submit_intr_urb(struct urb *urb);
static int etrax_usb_submit_isoc_urb(struct urb *urb);
-static int etrax_usb_submit_urb(struct urb *urb, int mem_flags);
+static int etrax_usb_submit_urb(struct urb *urb, unsigned mem_flags);
static int etrax_usb_unlink_urb(struct urb *urb, int status);
static int etrax_usb_get_frame_number(struct usb_device *usb_dev);
@@ -1262,7 +1263,7 @@ static int etrax_usb_allocate_epid(void)
return -1;
}
-static int etrax_usb_submit_urb(struct urb *urb, int mem_flags)
+static int etrax_usb_submit_urb(struct urb *urb, unsigned mem_flags)
{
etrax_hc_t *hc;
int ret = -EINVAL;
@@ -4277,7 +4278,8 @@ etrax_usb_bulk_eot_timer_func(unsigned long dummy)
}
static void*
-etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size, int mem_flags, dma_addr_t *dma)
+etrax_usb_buffer_alloc(struct usb_bus* bus, size_t size,
+ unsigned mem_flags, dma_addr_t *dma)
{
return kmalloc(size, mem_flags);
}
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index ff0a168e8ee..50b1970fe6b 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -17,7 +17,7 @@
* The driver basically works. A number of people have used it with a range
* of devices.
*
- *The driver passes all usbtests 1-14.
+ * The driver passes all usbtests 1-14.
*
* Suspending/resuming of root hub via sysfs works. Remote wakeup works too.
* And suspending/resuming of platform device works too. Suspend/resume
@@ -229,7 +229,7 @@ static void preproc_atl_queue(struct isp116x *isp116x)
struct isp116x_ep *ep;
struct urb *urb;
struct ptd *ptd;
- u16 toggle, dir, len;
+ u16 toggle = 0, dir = PTD_DIR_SETUP, len;
for (ep = isp116x->atl_active; ep; ep = ep->active) {
BUG_ON(list_empty(&ep->hep->urb_list));
@@ -251,8 +251,6 @@ static void preproc_atl_queue(struct isp116x *isp116x)
dir = PTD_DIR_OUT;
break;
case USB_PID_SETUP:
- toggle = 0;
- dir = PTD_DIR_SETUP;
len = sizeof(struct usb_ctrlrequest);
ep->data = urb->setup_packet;
break;
@@ -264,11 +262,9 @@ static void preproc_atl_queue(struct isp116x *isp116x)
? PTD_DIR_OUT : PTD_DIR_IN;
break;
default:
- /* To please gcc */
- toggle = dir = 0;
ERR("%s %d: ep->nextpid %d\n", __func__, __LINE__,
ep->nextpid);
- BUG_ON(1);
+ BUG();
}
ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(toggle);
@@ -697,7 +693,7 @@ static int balance(struct isp116x *isp116x, u16 period, u16 load)
static int isp116x_urb_enqueue(struct usb_hcd *hcd,
struct usb_host_endpoint *hep, struct urb *urb,
- int mem_flags)
+ unsigned mem_flags)
{
struct isp116x *isp116x = hcd_to_isp116x(hcd);
struct usb_device *udev = urb->dev;
@@ -719,7 +715,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
}
/* avoid all allocations within spinlocks: request or endpoint */
if (!hep->hcpriv) {
- ep = kcalloc(1, sizeof *ep, (__force unsigned)mem_flags);
+ ep = kcalloc(1, sizeof *ep, mem_flags);
if (!ep)
return -ENOMEM;
}
@@ -1054,7 +1050,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
break;
case GetHubStatus:
DBG("GetHubStatus\n");
- *(__le32 *) buf = cpu_to_le32(0);
+ *(__le32 *) buf = 0;
break;
case GetPortStatus:
DBG("GetPortStatus\n");
@@ -1810,9 +1806,9 @@ static int isp116x_suspend(struct device *dev, pm_message_t state, u32 phase)
ret = usb_suspend_device(hcd->self.root_hub, state);
if (!ret) {
dev->power.power_state = state;
- INFO("%s suspended\n", (char *)hcd_name);
+ INFO("%s suspended\n", hcd_name);
} else
- ERR("%s suspend failed\n", (char *)hcd_name);
+ ERR("%s suspend failed\n", hcd_name);
return ret;
}
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 13cd2177b55..68decab280d 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -180,7 +180,7 @@ static int ohci_urb_enqueue (
struct usb_hcd *hcd,
struct usb_host_endpoint *ep,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
) {
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
struct ed *ed;
@@ -673,8 +673,10 @@ retry:
ohci_dump (ohci, 1);
- if (ohci_to_hcd(ohci)->self.root_hub == NULL)
+ if (ohci_to_hcd(ohci)->self.root_hub == NULL) {
+ register_reboot_notifier (&ohci->reboot_notifier);
create_debug_files (ohci);
+ }
return 0;
}
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index e2fc4129dfc..83ca4549a50 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -419,10 +419,11 @@ ohci_hub_descriptor (
/* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
rh = roothub_b (ohci);
+ memset(desc->bitmap, 0xff, sizeof(desc->bitmap));
desc->bitmap [0] = rh & RH_B_DR;
if (ports > 7) {
desc->bitmap [1] = (rh & RH_B_DR) >> 8;
- desc->bitmap [2] = desc->bitmap [3] = 0xff;
+ desc->bitmap [2] = 0xff;
} else
desc->bitmap [1] = 0xff;
}
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index 23735a36af0..fd3c4d3714b 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -84,7 +84,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma)
/* TDs ... */
static struct td *
-td_alloc (struct ohci_hcd *hc, int mem_flags)
+td_alloc (struct ohci_hcd *hc, unsigned mem_flags)
{
dma_addr_t dma;
struct td *td;
@@ -118,7 +118,7 @@ td_free (struct ohci_hcd *hc, struct td *td)
/* EDs ... */
static struct ed *
-ed_alloc (struct ohci_hcd *hc, int mem_flags)
+ed_alloc (struct ohci_hcd *hc, unsigned mem_flags)
{
dma_addr_t dma;
struct ed *ed;
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index b62d6993769..5cde76faab9 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -456,34 +456,22 @@ static int ohci_hcd_omap_drv_remove(struct device *dev)
#ifdef CONFIG_PM
-/* states match PCI usage, always suspending the root hub except that
- * 4 ~= D3cold (ACPI D3) with clock off (resume sees reset).
- *
- * FIXME: above comment is not right, and code is wrong, too :-(.
- */
-
-static int ohci_omap_suspend(struct device *dev, pm_message_t state, u32 level)
+static int ohci_omap_suspend(struct device *dev, pm_message_t message, u32 level)
{
struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev));
int status = -EINVAL;
if (level != SUSPEND_POWER_DOWN)
return 0;
- if (state <= dev->power.power_state)
- return 0;
- dev_dbg(dev, "suspend to %d\n", state);
down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
status = ohci_hub_suspend(ohci_to_hcd(ohci));
if (status == 0) {
- if (state >= 4) {
- omap_ohci_clock_power(0);
- ohci_to_hcd(ohci)->self.root_hub->state =
- USB_STATE_SUSPENDED;
- state = 4;
- }
+ omap_ohci_clock_power(0);
+ ohci_to_hcd(ohci)->self.root_hub->state =
+ USB_STATE_SUSPENDED;
ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
- dev->power.power_state = state;
+ dev->power.power_state = PMSG_SUSPEND;
}
up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
return status;
@@ -497,29 +485,20 @@ static int ohci_omap_resume(struct device *dev, u32 level)
if (level != RESUME_POWER_ON)
return 0;
- switch (dev->power.power_state) {
- case 0:
- break;
- case 4:
- if (time_before(jiffies, ohci->next_statechange))
- msleep(5);
- ohci->next_statechange = jiffies;
- omap_ohci_clock_power(1);
- /* FALLTHROUGH */
- default:
- dev_dbg(dev, "resume from %d\n", dev->power.power_state);
+ if (time_before(jiffies, ohci->next_statechange))
+ msleep(5);
+ ohci->next_statechange = jiffies;
+ omap_ohci_clock_power(1);
#ifdef CONFIG_USB_SUSPEND
- /* get extra cleanup even if remote wakeup isn't in use */
- status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub);
+ /* get extra cleanup even if remote wakeup isn't in use */
+ status = usb_resume_device(ohci_to_hcd(ohci)->self.root_hub);
#else
- down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
- status = ohci_hub_resume(ohci_to_hcd(ohci));
- up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
+ down(&ohci_to_hcd(ohci)->self.root_hub->serialize);
+ status = ohci_hub_resume(ohci_to_hcd(ohci));
+ up(&ohci_to_hcd(ohci)->self.root_hub->serialize);
#endif
- if (status == 0)
- dev->power.power_state = 0;
- break;
- }
+ if (status == 0)
+ dev->power.power_state = PMSG_ON;
return status;
}
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 6c3f910bc30..7a890a65f55 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -815,7 +815,7 @@ static int sl811h_urb_enqueue(
struct usb_hcd *hcd,
struct usb_host_endpoint *hep,
struct urb *urb,
- int mem_flags
+ unsigned mem_flags
) {
struct sl811 *sl811 = hcd_to_sl811(hcd);
struct usb_device *udev = urb->dev;
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 5f18084a116..bbb36cd6ed6 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -1164,7 +1164,7 @@ static struct urb *uhci_find_urb_ep(struct uhci_hcd *uhci, struct urb *urb)
static int uhci_urb_enqueue(struct usb_hcd *hcd,
struct usb_host_endpoint *ep,
- struct urb *urb, int mem_flags)
+ struct urb *urb, unsigned mem_flags)
{
int ret;
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index fd59f6bdd67..298e4a25e3d 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -259,3 +259,16 @@ config USB_ATI_REMOTE
To compile this driver as a module, choose M here: the module will be
called ati_remote.
+config USB_KEYSPAN_REMOTE
+ tristate "Keyspan DMR USB remote control (EXPERIMENTAL)"
+ depends on USB && INPUT && EXPERIMENTAL
+ ---help---
+ Say Y here if you want to use a Keyspan DMR USB remote control.
+ Currently only the UIA-11 type of receiver has been tested. The tag
+ on the receiver that connects to the USB port should have a P/N that
+ will tell you what type of DMR you have. The UIA-10 type is not
+ supported at this time. This driver maps all buttons to keypress
+ events.
+
+ To compile this driver as a module, choose M here: the module will
+ be called keyspan_remote.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 831b2b0f1f0..f1547be632d 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
obj-$(CONFIG_USB_HID) += usbhid.o
obj-$(CONFIG_USB_KBD) += usbkbd.o
obj-$(CONFIG_USB_KBTAB) += kbtab.o
+obj-$(CONFIG_USB_KEYSPAN_REMOTE) += keyspan_remote.o
obj-$(CONFIG_USB_MOUSE) += usbmouse.o
obj-$(CONFIG_USB_MTOUCH) += mtouchusb.o
obj-$(CONFIG_USB_ITMTOUCH) += itmtouch.o
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 100b49bd1d3..2350e7a5ad7 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1428,6 +1428,19 @@ void hid_init_reports(struct hid_device *hid)
#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
+#define USB_VENDOR_ID_LD 0x0f11
+#define USB_DEVICE_ID_CASSY 0x1000
+#define USB_DEVICE_ID_POCKETCASSY 0x1010
+#define USB_DEVICE_ID_MOBILECASSY 0x1020
+#define USB_DEVICE_ID_JWM 0x1080
+#define USB_DEVICE_ID_DMMP 0x1081
+#define USB_DEVICE_ID_UMIP 0x1090
+#define USB_DEVICE_ID_VIDEOCOM 0x1200
+#define USB_DEVICE_ID_COM3LAB 0x2000
+#define USB_DEVICE_ID_TELEPORT 0x2010
+#define USB_DEVICE_ID_NETWORKANALYSER 0x2020
+#define USB_DEVICE_ID_POWERCONTROL 0x2030
+
/*
* Alphabetically sorted blacklist by quirk type.
@@ -1463,6 +1476,17 @@ static struct hid_blacklist {
{ USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_CASSY, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_POCKETCASSY, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_MOBILECASSY, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_JWM, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_DMMP, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_UMIP, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_VIDEOCOM, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_COM3LAB, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_TELEPORT, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_NETWORKANALYSER, HID_QUIRK_IGNORE },
+ { USB_VENDOR_ID_LD, USB_DEVICE_ID_POWERCONTROL, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE },
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
new file mode 100644
index 00000000000..67dc9368520
--- /dev/null
+++ b/drivers/usb/input/keyspan_remote.c
@@ -0,0 +1,633 @@
+/*
+ * keyspan_remote: USB driver for the Keyspan DMR
+ *
+ * Copyright (C) 2005 Zymeta Corporation - Michael Downey (downey@zymeta.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ * This driver has been put together with the support of Innosys, Inc.
+ * and Keyspan, Inc the manufacturers of the Keyspan USB DMR product.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/input.h>
+#include <linux/usb.h>
+
+#define DRIVER_VERSION "v0.1"
+#define DRIVER_AUTHOR "Michael Downey <downey@zymeta.com>"
+#define DRIVER_DESC "Driver for the USB Keyspan remote control."
+#define DRIVER_LICENSE "GPL"
+
+/* Parameters that can be passed to the driver. */
+static int debug;
+module_param(debug, int, 0444);
+MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
+
+/* Vendor and product ids */
+#define USB_KEYSPAN_VENDOR_ID 0x06CD
+#define USB_KEYSPAN_PRODUCT_UIA11 0x0202
+
+/* Defines for converting the data from the remote. */
+#define ZERO 0x18
+#define ZERO_MASK 0x1F /* 5 bits for a 0 */
+#define ONE 0x3C
+#define ONE_MASK 0x3F /* 6 bits for a 1 */
+#define SYNC 0x3F80
+#define SYNC_MASK 0x3FFF /* 14 bits for a SYNC sequence */
+#define STOP 0x00
+#define STOP_MASK 0x1F /* 5 bits for the STOP sequence */
+#define GAP 0xFF
+
+#define RECV_SIZE 8 /* The UIA-11 type have a 8 byte limit. */
+
+/* table of devices that work with this driver */
+static struct usb_device_id keyspan_table[] = {
+ { USB_DEVICE(USB_KEYSPAN_VENDOR_ID, USB_KEYSPAN_PRODUCT_UIA11) },
+ { } /* Terminating entry */
+};
+
+/* Structure to store all the real stuff that a remote sends to us. */
+struct keyspan_message {
+ u16 system;
+ u8 button;
+ u8 toggle;
+};
+
+/* Structure used for all the bit testing magic needed to be done. */
+struct bit_tester {
+ u32 tester;
+ int len;
+ int pos;
+ int bits_left;
+ u8 buffer[32];
+};
+
+/* Structure to hold all of our driver specific stuff */
+struct usb_keyspan {
+ char name[128];
+ char phys[64];
+ struct usb_device* udev;
+ struct input_dev input;
+ struct usb_interface* interface;
+ struct usb_endpoint_descriptor* in_endpoint;
+ struct urb* irq_urb;
+ int open;
+ dma_addr_t in_dma;
+ unsigned char* in_buffer;
+
+ /* variables used to parse messages from remote. */
+ struct bit_tester data;
+ int stage;
+ int toggle;
+};
+
+/*
+ * Table that maps the 31 possible keycodes to input keys.
+ * Currently there are 15 and 17 button models so RESERVED codes
+ * are blank areas in the mapping.
+ */
+static int keyspan_key_table[] = {
+ KEY_RESERVED, /* 0 is just a place holder. */
+ KEY_RESERVED,
+ KEY_STOP,
+ KEY_PLAYCD,
+ KEY_RESERVED,
+ KEY_PREVIOUSSONG,
+ KEY_REWIND,
+ KEY_FORWARD,
+ KEY_NEXTSONG,
+ KEY_RESERVED,
+ KEY_RESERVED,
+ KEY_RESERVED,
+ KEY_PAUSE,
+ KEY_VOLUMEUP,
+ KEY_RESERVED,
+ KEY_RESERVED,
+ KEY_RESERVED,
+ KEY_VOLUMEDOWN,
+ KEY_RESERVED,
+ KEY_UP,
+ KEY_RESERVED,
+ KEY_MUTE,
+ KEY_LEFT,
+ KEY_ENTER,
+ KEY_RIGHT,
+ KEY_RESERVED,
+ KEY_RESERVED,
+ KEY_DOWN,
+ KEY_RESERVED,
+ KEY_KPASTERISK,
+ KEY_RESERVED,
+ KEY_MENU
+};
+
+static struct usb_driver keyspan_driver;
+
+/*
+ * Debug routine that prints out what we've received from the remote.
+ */
+static void keyspan_print(struct usb_keyspan* dev) /*unsigned char* data)*/
+{
+ char codes[4*RECV_SIZE];
+ int i;
+
+ for (i = 0; i < RECV_SIZE; i++) {
+ snprintf(codes+i*3, 4, "%02x ", dev->in_buffer[i]);
+ }
+
+ dev_info(&dev->udev->dev, "%s\n", codes);
+}
+
+/*
+ * Routine that manages the bit_tester structure. It makes sure that there are
+ * at least bits_needed bits loaded into the tester.
+ */
+static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
+{
+ if (dev->data.bits_left >= bits_needed)
+ return(0);
+
+ /*
+ * Somehow we've missed the last message. The message will be repeated
+ * though so it's not too big a deal
+ */
+ if (dev->data.pos >= dev->data.len) {
+ dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n",
+ __FUNCTION__, dev->data.pos, dev->data.len);
+ return(-1);
+ }
+
+ /* Load as much as we can into the tester. */
+ while ((dev->data.bits_left + 7 < (sizeof(dev->data.tester) * 8)) &&
+ (dev->data.pos < dev->data.len)) {
+ dev->data.tester += (dev->data.buffer[dev->data.pos++] << dev->data.bits_left);
+ dev->data.bits_left += 8;
+ }
+
+ return(0);
+}
+
+/*
+ * Routine that handles all the logic needed to parse out the message from the remote.
+ */
+static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs)
+{
+ int i;
+ int found = 0;
+ struct keyspan_message message;
+
+ switch(remote->stage) {
+ case 0:
+ /*
+ * In stage 0 we want to find the start of a message. The remote sends a 0xFF as filler.
+ * So the first byte that isn't a FF should be the start of a new message.
+ */
+ for (i = 0; i < RECV_SIZE && remote->in_buffer[i] == GAP; ++i);
+
+ if (i < RECV_SIZE) {
+ memcpy(remote->data.buffer, remote->in_buffer, RECV_SIZE);
+ remote->data.len = RECV_SIZE;
+ remote->data.pos = 0;
+ remote->data.tester = 0;
+ remote->data.bits_left = 0;
+ remote->stage = 1;
+ }
+ break;
+
+ case 1:
+ /*
+ * Stage 1 we should have 16 bytes and should be able to detect a
+ * SYNC. The SYNC is 14 bits, 7 0's and then 7 1's.
+ */
+ memcpy(remote->data.buffer + remote->data.len, remote->in_buffer, RECV_SIZE);
+ remote->data.len += RECV_SIZE;
+
+ found = 0;
+ while ((remote->data.bits_left >= 14 || remote->data.pos < remote->data.len) && !found) {
+ for (i = 0; i < 8; ++i) {
+ if (keyspan_load_tester(remote, 14) != 0) {
+ remote->stage = 0;
+ return;
+ }
+
+ if ((remote->data.tester & SYNC_MASK) == SYNC) {
+ remote->data.tester = remote->data.tester >> 14;
+ remote->data.bits_left -= 14;
+ found = 1;
+ break;
+ } else {
+ remote->data.tester = remote->data.tester >> 1;
+ --remote->data.bits_left;
+ }
+ }
+ }
+
+ if (!found) {
+ remote->stage = 0;
+ remote->data.len = 0;
+ } else {
+ remote->stage = 2;
+ }
+ break;
+
+ case 2:
+ /*
+ * Stage 2 we should have 24 bytes which will be enough for a full
+ * message. We need to parse out the system code, button code,
+ * toggle code, and stop.
+ */
+ memcpy(remote->data.buffer + remote->data.len, remote->in_buffer, RECV_SIZE);
+ remote->data.len += RECV_SIZE;
+
+ message.system = 0;
+ for (i = 0; i < 9; i++) {
+ keyspan_load_tester(remote, 6);
+
+ if ((remote->data.tester & ZERO_MASK) == ZERO) {
+ message.system = message.system << 1;
+ remote->data.tester = remote->data.tester >> 5;
+ remote->data.bits_left -= 5;
+ } else if ((remote->data.tester & ONE_MASK) == ONE) {
+ message.system = (message.system << 1) + 1;
+ remote->data.tester = remote->data.tester >> 6;
+ remote->data.bits_left -= 6;
+ } else {
+ err("%s - Unknown sequence found in system data.\n", __FUNCTION__);
+ remote->stage = 0;
+ return;
+ }
+ }
+
+ message.button = 0;
+ for (i = 0; i < 5; i++) {
+ keyspan_load_tester(remote, 6);
+
+ if ((remote->data.tester & ZERO_MASK) == ZERO) {
+ message.button = message.button << 1;
+ remote->data.tester = remote->data.tester >> 5;
+ remote->data.bits_left -= 5;
+ } else if ((remote->data.tester & ONE_MASK) == ONE) {
+ message.button = (message.button << 1) + 1;
+ remote->data.tester = remote->data.tester >> 6;
+ remote->data.bits_left -= 6;
+ } else {
+ err("%s - Unknown sequence found in button data.\n", __FUNCTION__);
+ remote->stage = 0;
+ return;
+ }
+ }
+
+ keyspan_load_tester(remote, 6);
+ if ((remote->data.tester & ZERO_MASK) == ZERO) {
+ message.toggle = 0;
+ remote->data.tester = remote->data.tester >> 5;
+ remote->data.bits_left -= 5;
+ } else if ((remote->data.tester & ONE_MASK) == ONE) {
+ message.toggle = 1;
+ remote->data.tester = remote->data.tester >> 6;
+ remote->data.bits_left -= 6;
+ } else {
+ err("%s - Error in message, invalid toggle.\n", __FUNCTION__);
+ }
+
+ keyspan_load_tester(remote, 5);
+ if ((remote->data.tester & STOP_MASK) == STOP) {
+ remote->data.tester = remote->data.tester >> 5;
+ remote->data.bits_left -= 5;
+ } else {
+ err("Bad message recieved, no stop bit found.\n");
+ }
+
+ dev_dbg(&remote->udev,
+ "%s found valid message: system: %d, button: %d, toggle: %d\n",
+ __FUNCTION__, message.system, message.button, message.toggle);
+
+ if (message.toggle != remote->toggle) {
+ input_regs(&remote->input, regs);
+ input_report_key(&remote->input, keyspan_key_table[message.button], 1);
+ input_report_key(&remote->input, keyspan_key_table[message.button], 0);
+ input_sync(&remote->input);
+ remote->toggle = message.toggle;
+ }
+
+ remote->stage = 0;
+ break;
+ }
+}
+
+/*
+ * Routine for sending all the initialization messages to the remote.
+ */
+static int keyspan_setup(struct usb_device* dev)
+{
+ int retval = 0;
+
+ retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+ 0x11, 0x40, 0x5601, 0x0, NULL, 0, 0);
+ if (retval) {
+ dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n",
+ __FUNCTION__, retval);
+ return(retval);
+ }
+
+ retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+ 0x44, 0x40, 0x0, 0x0, NULL, 0, 0);
+ if (retval) {
+ dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n",
+ __FUNCTION__, retval);
+ return(retval);
+ }
+
+ retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+ 0x22, 0x40, 0x0, 0x0, NULL, 0, 0);
+ if (retval) {
+ dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n",
+ __FUNCTION__, retval);
+ return(retval);
+ }
+
+ dev_dbg(&dev->dev, "%s - Setup complete.\n", __FUNCTION__);
+ return(retval);
+}
+
+/*
+ * Routine used to handle a new message that has come in.
+ */
+static void keyspan_irq_recv(struct urb *urb, struct pt_regs *regs)
+{
+ struct usb_keyspan *dev = urb->context;
+ int retval;
+
+ /* Check our status in case we need to bail out early. */
+ switch (urb->status) {
+ case 0:
+ break;
+
+ /* Device went away so don't keep trying to read from it. */
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ return;
+
+ default:
+ goto resubmit;
+ break;
+ }
+
+ if (debug)
+ keyspan_print(dev);
+
+ keyspan_check_data(dev, regs);
+
+resubmit:
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval)
+ err ("%s - usb_submit_urb failed with result: %d", __FUNCTION__, retval);
+}
+
+static int keyspan_open(struct input_dev *dev)
+{
+ struct usb_keyspan *remote = dev->private;
+
+ if (remote->open++)
+ return 0;
+
+ remote->irq_urb->dev = remote->udev;
+ if (usb_submit_urb(remote->irq_urb, GFP_KERNEL)) {
+ remote->open--;
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static void keyspan_close(struct input_dev *dev)
+{
+ struct usb_keyspan *remote = dev->private;
+
+ if (!--remote->open)
+ usb_kill_urb(remote->irq_urb);
+}
+
+/*
+ * Routine that sets up the driver to handle a specific USB device detected on the bus.
+ */
+static int keyspan_probe(struct usb_interface *interface, const struct usb_device_id *id)
+{
+ int i;
+ int retval = -ENOMEM;
+ char path[64];
+ char *buf;
+ struct usb_keyspan *remote = NULL;
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+ struct usb_device *udev = usb_get_dev(interface_to_usbdev(interface));
+
+ /* See if the offered device matches what we can accept */
+ if ((udev->descriptor.idVendor != USB_KEYSPAN_VENDOR_ID) ||
+ (udev->descriptor.idProduct != USB_KEYSPAN_PRODUCT_UIA11) )
+ return -ENODEV;
+
+ /* allocate memory for our device state and initialize it */
+ remote = kmalloc(sizeof(*remote), GFP_KERNEL);
+ if (remote == NULL) {
+ err("Out of memory\n");
+ goto error;
+ }
+ memset(remote, 0x00, sizeof(*remote));
+
+ remote->udev = udev;
+ remote->interface = interface;
+ remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
+
+ /* set up the endpoint information */
+ /* use only the first in interrupt endpoint */
+ iface_desc = interface->cur_altsetting;
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if (!remote->in_endpoint &&
+ (endpoint->bEndpointAddress & USB_DIR_IN) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
+ /* we found our interrupt in endpoint */
+ remote->in_endpoint = endpoint;
+
+ remote->in_buffer = usb_buffer_alloc(remote->udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma);
+ if (!remote->in_buffer) {
+ retval = -ENOMEM;
+ goto error;
+ }
+ }
+ }
+
+ if (!remote->in_endpoint) {
+ err("Could not find interrupt input endpoint.\n");
+ retval = -ENODEV;
+ goto error;
+ }
+
+ remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!remote->irq_urb) {
+ err("Failed to allocate urb.\n");
+ retval = -ENOMEM;
+ goto error;
+ }
+
+ retval = keyspan_setup(remote->udev);
+ if (retval) {
+ err("Failed to setup device.\n");
+ retval = -ENODEV;
+ goto error;
+ }
+
+ /*
+ * Setup the input system with the bits we are going to be reporting
+ */
+ remote->input.evbit[0] = BIT(EV_KEY); /* We will only report KEY events. */
+ for (i = 0; i < 32; ++i) {
+ if (keyspan_key_table[i] != KEY_RESERVED) {
+ set_bit(keyspan_key_table[i], remote->input.keybit);
+ }
+ }
+
+ remote->input.private = remote;
+ remote->input.open = keyspan_open;
+ remote->input.close = keyspan_close;
+
+ usb_make_path(remote->udev, path, 64);
+ sprintf(remote->phys, "%s/input0", path);
+
+ remote->input.name = remote->name;
+ remote->input.phys = remote->phys;
+ remote->input.id.bustype = BUS_USB;
+ remote->input.id.vendor = le16_to_cpu(remote->udev->descriptor.idVendor);
+ remote->input.id.product = le16_to_cpu(remote->udev->descriptor.idProduct);
+ remote->input.id.version = le16_to_cpu(remote->udev->descriptor.bcdDevice);
+
+ if (!(buf = kmalloc(63, GFP_KERNEL))) {
+ usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
+ kfree(remote);
+ return -ENOMEM;
+ }
+
+ if (remote->udev->descriptor.iManufacturer &&
+ usb_string(remote->udev, remote->udev->descriptor.iManufacturer, buf, 63) > 0)
+ strcat(remote->name, buf);
+
+ if (remote->udev->descriptor.iProduct &&
+ usb_string(remote->udev, remote->udev->descriptor.iProduct, buf, 63) > 0)
+ sprintf(remote->name, "%s %s", remote->name, buf);
+
+ if (!strlen(remote->name))
+ sprintf(remote->name, "USB Keyspan Remote %04x:%04x",
+ remote->input.id.vendor, remote->input.id.product);
+
+ kfree(buf);
+
+ /*
+ * Initialize the URB to access the device. The urb gets sent to the device in keyspan_open()
+ */
+ usb_fill_int_urb(remote->irq_urb,
+ remote->udev, usb_rcvintpipe(remote->udev, remote->in_endpoint->bEndpointAddress),
+ remote->in_buffer, RECV_SIZE, keyspan_irq_recv, remote,
+ remote->in_endpoint->bInterval);
+ remote->irq_urb->transfer_dma = remote->in_dma;
+ remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+ /* we can register the device now, as it is ready */
+ input_register_device(&remote->input);
+
+ /* save our data pointer in this interface device */
+ usb_set_intfdata(interface, remote);
+
+ /* let the user know what node this device is now attached to */
+ info("connected: %s on %s", remote->name, path);
+ return 0;
+
+error:
+ /*
+ * In case of error we need to clean up any allocated buffers
+ */
+ if (remote->irq_urb)
+ usb_free_urb(remote->irq_urb);
+
+ if (remote->in_buffer)
+ usb_buffer_free(remote->udev, RECV_SIZE, remote->in_buffer, remote->in_dma);
+
+ if (remote)
+ kfree(remote);
+
+ return retval;
+}
+
+/*
+ * Routine called when a device is disconnected from the USB.
+ */
+static void keyspan_disconnect(struct usb_interface *interface)
+{
+ struct usb_keyspan *remote;
+
+ /* prevent keyspan_open() from racing keyspan_disconnect() */
+ lock_kernel();
+
+ remote = usb_get_intfdata(interface);
+ usb_set_intfdata(interface, NULL);
+
+ if (remote) { /* We have a valid driver structure so clean up everything we allocated. */
+ input_unregister_device(&remote->input);
+ usb_kill_urb(remote->irq_urb);
+ usb_free_urb(remote->irq_urb);
+ usb_buffer_free(interface_to_usbdev(interface), RECV_SIZE, remote->in_buffer, remote->in_dma);
+ kfree(remote);
+ }
+
+ unlock_kernel();
+
+ info("USB Keyspan now disconnected");
+}
+
+/*
+ * Standard driver set up sections
+ */
+static struct usb_driver keyspan_driver =
+{
+ .owner = THIS_MODULE,
+ .name = "keyspan_remote",
+ .probe = keyspan_probe,
+ .disconnect = keyspan_disconnect,
+ .id_table = keyspan_table
+};
+
+static int __init usb_keyspan_init(void)
+{
+ int result;
+
+ /* register this driver with the USB subsystem */
+ result = usb_register(&keyspan_driver);
+ if (result)
+ err("usb_register failed. Error number %d\n", result);
+
+ return result;
+}
+
+static void __exit usb_keyspan_exit(void)
+{
+ /* deregister this driver with the USB subsystem */
+ usb_deregister(&keyspan_driver);
+}
+
+module_init(usb_keyspan_init);
+module_exit(usb_keyspan_exit);
+
+MODULE_DEVICE_TABLE(usb, keyspan_table);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE(DRIVER_LICENSE);
diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile
index 2b76df7005f..d83adffa925 100644
--- a/drivers/usb/media/Makefile
+++ b/drivers/usb/media/Makefile
@@ -2,7 +2,7 @@
# Makefile for USB Media drivers
#
-sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o
+sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bcb.o sn9c102_tas5110c1b.o sn9c102_tas5130d1b.o
obj-$(CONFIG_USB_DABUSB) += dabusb.o
obj-$(CONFIG_USB_DSBR) += dsbr100.o
diff --git a/drivers/usb/media/sn9c102.h b/drivers/usb/media/sn9c102.h
index 8b8a4c8743f..e5cea0e2eb5 100644
--- a/drivers/usb/media/sn9c102.h
+++ b/drivers/usb/media/sn9c102.h
@@ -56,7 +56,7 @@
#define SN9C102_MODULE_AUTHOR "(C) 2004-2005 Luca Risolia"
#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
#define SN9C102_MODULE_LICENSE "GPL"
-#define SN9C102_MODULE_VERSION "1:1.24"
+#define SN9C102_MODULE_VERSION "1:1.24a"
#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 24)
enum sn9c102_bridge {
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 31d57400d5b..cf8cfbabefd 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -429,7 +429,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
}
-static int
+int
sn9c102_i2c_try_write(struct sn9c102_device* cam,
struct sn9c102_sensor* sensor, u8 address, u8 value)
{
diff --git a/drivers/usb/media/sn9c102_ov7630.c b/drivers/usb/media/sn9c102_ov7630.c
new file mode 100644
index 00000000000..d27c5aedeaf
--- /dev/null
+++ b/drivers/usb/media/sn9c102_ov7630.c
@@ -0,0 +1,394 @@
+/***************************************************************************
+ * Plug-in for OV7630 image sensor connected to the SN9C10x PC Camera *
+ * Controllers *
+ * *
+ * Copyright (C) 2005 by Luca Risolia <luca.risolia@studio.unibo.it> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
+ ***************************************************************************/
+
+#include "sn9c102_sensor.h"
+
+
+static struct sn9c102_sensor ov7630;
+
+
+static int ov7630_init(struct sn9c102_device* cam)
+{
+ int err = 0;
+
+ err += sn9c102_write_reg(cam, 0x00, 0x14);
+ err += sn9c102_write_reg(cam, 0x60, 0x17);
+ err += sn9c102_write_reg(cam, 0x0f, 0x18);
+ err += sn9c102_write_reg(cam, 0x50, 0x19);
+
+ err += sn9c102_i2c_write(cam, 0x12, 0x8d);
+ err += sn9c102_i2c_write(cam, 0x11, 0x00);
+ err += sn9c102_i2c_write(cam, 0x15, 0x34);
+ err += sn9c102_i2c_write(cam, 0x16, 0x03);
+ err += sn9c102_i2c_write(cam, 0x17, 0x1c);
+ err += sn9c102_i2c_write(cam, 0x18, 0xbd);
+ err += sn9c102_i2c_write(cam, 0x19, 0x06);
+ err += sn9c102_i2c_write(cam, 0x1a, 0xf6);
+ err += sn9c102_i2c_write(cam, 0x1b, 0x04);
+ err += sn9c102_i2c_write(cam, 0x20, 0x44);
+ err += sn9c102_i2c_write(cam, 0x23, 0xee);
+ err += sn9c102_i2c_write(cam, 0x26, 0xa0);
+ err += sn9c102_i2c_write(cam, 0x27, 0x9a);
+ err += sn9c102_i2c_write(cam, 0x28, 0x20);
+ err += sn9c102_i2c_write(cam, 0x29, 0x30);
+ err += sn9c102_i2c_write(cam, 0x2f, 0x3d);
+ err += sn9c102_i2c_write(cam, 0x30, 0x24);
+ err += sn9c102_i2c_write(cam, 0x32, 0x86);
+ err += sn9c102_i2c_write(cam, 0x60, 0xa9);
+ err += sn9c102_i2c_write(cam, 0x61, 0x42);
+ err += sn9c102_i2c_write(cam, 0x65, 0x00);
+ err += sn9c102_i2c_write(cam, 0x69, 0x38);
+ err += sn9c102_i2c_write(cam, 0x6f, 0x88);
+ err += sn9c102_i2c_write(cam, 0x70, 0x0b);
+ err += sn9c102_i2c_write(cam, 0x71, 0x00);
+ err += sn9c102_i2c_write(cam, 0x74, 0x21);
+ err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
+
+ return err;
+}
+
+
+static int ov7630_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
+{
+ int err = 0;
+
+ switch (ctrl->id) {
+ case V4L2_CID_EXPOSURE:
+ err += sn9c102_i2c_write(cam, 0x10, ctrl->value >> 2);
+ err += sn9c102_i2c_write(cam, 0x76, ctrl->value & 0x03);
+ break;
+ case V4L2_CID_RED_BALANCE:
+ err += sn9c102_i2c_write(cam, 0x02, ctrl->value);
+ break;
+ case V4L2_CID_BLUE_BALANCE:
+ err += sn9c102_i2c_write(cam, 0x03, ctrl->value);
+ break;
+ case V4L2_CID_GAIN:
+ err += sn9c102_i2c_write(cam, 0x00, ctrl->value);
+ break;
+ case V4L2_CID_CONTRAST:
+ err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
+ (ctrl->value-1) | 0x20)
+ : sn9c102_i2c_write(cam, 0x05, 0x00);
+ break;
+ case V4L2_CID_BRIGHTNESS:
+ err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
+ break;
+ case V4L2_CID_SATURATION:
+ err += sn9c102_i2c_write(cam, 0x03, ctrl->value << 4);
+ break;
+ case V4L2_CID_HUE:
+ err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
+ (ctrl->value-1) | 0x20)
+ : sn9c102_i2c_write(cam, 0x04, 0x00);
+ break;
+ case V4L2_CID_DO_WHITE_BALANCE:
+ err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
+ break;
+ case V4L2_CID_WHITENESS:
+ err += sn9c102_i2c_write(cam, 0x0d, ctrl->value);
+ break;
+ case V4L2_CID_AUTO_WHITE_BALANCE:
+ err += sn9c102_i2c_write(cam, 0x12, (ctrl->value << 2) | 0x09);
+ break;
+ case V4L2_CID_AUTOGAIN:
+ err += sn9c102_i2c_write(cam, 0x13, ctrl->value);
+ break;
+ case V4L2_CID_VFLIP:
+ err += sn9c102_i2c_write(cam, 0x75, 0x0e | (ctrl->value << 7));
+ break;
+ case V4L2_CID_BLACK_LEVEL:
+ err += sn9c102_i2c_write(cam, 0x25, ctrl->value);
+ break;
+ case SN9C102_V4L2_CID_BRIGHT_LEVEL:
+ err += sn9c102_i2c_write(cam, 0x24, ctrl->value);
+ break;
+ case SN9C102_V4L2_CID_GAMMA:
+ err += sn9c102_i2c_write(cam, 0x14, (ctrl->value << 2) | 0x80);
+ break;
+ case SN9C102_V4L2_CID_BAND_FILTER:
+ err += sn9c102_i2c_write(cam, 0x2d, ctrl->value << 2);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return err ? -EIO : 0;
+}
+
+
+static int ov7630_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
+{
+ struct sn9c102_sensor* s = &ov7630;
+ int err = 0;
+ u8 v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1;
+
+ err += sn9c102_write_reg(cam, v_start, 0x13);
+
+ return err;
+}
+
+
+static int ov7630_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
+{
+ int err = 0;
+
+ if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
+ err += sn9c102_write_reg(cam, 0x20, 0x19);
+ else
+ err += sn9c102_write_reg(cam, 0x50, 0x19);
+
+ return err;
+}
+
+
+static struct sn9c102_sensor ov7630 = {
+ .name = "OV7630",
+ .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
+ .sysfs_ops = SN9C102_I2C_WRITE,
+ .frequency = SN9C102_I2C_100KHZ,
+ .interface = SN9C102_I2C_2WIRES,
+ .i2c_slave_id = 0x21,
+ .init = &ov7630_init,
+ .qctrl = {
+ {
+ .id = V4L2_CID_GAIN,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "global gain",
+ .minimum = 0x00,
+ .maximum = 0x3f,
+ .step = 0x01,
+ .default_value = 0x14,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_HUE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "hue",
+ .minimum = 0x00,
+ .maximum = 0x1f+1,
+ .step = 0x01,
+ .default_value = 0x00,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_SATURATION,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "saturation",
+ .minimum = 0x00,
+ .maximum = 0x0f,
+ .step = 0x01,
+ .default_value = 0x08,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_CONTRAST,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "contrast",
+ .minimum = 0x00,
+ .maximum = 0x1f+1,
+ .step = 0x01,
+ .default_value = 0x00,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_EXPOSURE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "exposure",
+ .minimum = 0x000,
+ .maximum = 0x3ff,
+ .step = 0x001,
+ .default_value = 0x83<<2,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_RED_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "red balance",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 0x01,
+ .default_value = 0x3a,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_BLUE_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "blue balance",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 0x01,
+ .default_value = 0x77,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "brightness",
+ .minimum = 0x00,
+ .maximum = 0xff,
+ .step = 0x01,
+ .default_value = 0xa0,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_DO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "white balance background: blue",
+ .minimum = 0x00,
+ .maximum = 0x3f,
+ .step = 0x01,
+ .default_value = 0x20,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_WHITENESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "white balance background: red",
+ .minimum = 0x00,
+ .maximum = 0x3f,
+ .step = 0x01,
+ .default_value = 0x20,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_AUTO_WHITE_BALANCE,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "auto white balance",
+ .minimum = 0x00,
+ .maximum = 0x01,
+ .step = 0x01,
+ .default_value = 0x01,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_AUTOGAIN,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "gain & exposure mode",
+ .minimum = 0x00,
+ .maximum = 0x03,
+ .step = 0x01,
+ .default_value = 0x00,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_VFLIP,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "vertical flip",
+ .minimum = 0x00,
+ .maximum = 0x01,
+ .step = 0x01,
+ .default_value = 0x01,
+ .flags = 0,
+ },
+ {
+ .id = V4L2_CID_BLACK_LEVEL,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "black pixel ratio",
+ .minimum = 0x01,
+ .maximum = 0x9a,
+ .step = 0x01,
+ .default_value = 0x8a,
+ .flags = 0,
+ },
+ {
+ .id = SN9C102_V4L2_CID_BRIGHT_LEVEL,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "bright pixel ratio",
+ .minimum = 0x01,
+ .maximum = 0x9a,
+ .step = 0x01,
+ .default_value = 0x10,
+ .flags = 0,
+ },
+ {
+ .id = SN9C102_V4L2_CID_BAND_FILTER,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "band filter",
+ .minimum = 0x00,
+ .maximum = 0x01,
+ .step = 0x01,
+ .default_value = 0x00,
+ .flags = 0,
+ },
+ {
+ .id = SN9C102_V4L2_CID_GAMMA,
+ .type = V4L2_CTRL_TYPE_BOOLEAN,
+ .name = "rgb gamma",
+ .minimum = 0x00,
+ .maximum = 0x01,
+ .step = 0x01,
+ .default_value = 0x00,
+ .flags = 0,
+ },
+ },
+ .set_ctrl = &ov7630_set_ctrl,
+ .cropcap = {
+ .bounds = {
+ .left = 0,
+ .top = 0,
+ .width = 640,
+ .height = 480,
+ },
+ .defrect = {
+ .left = 0,
+ .top = 0,
+ .width = 640,
+ .height = 480,
+ },
+ },
+ .set_crop = &ov7630_set_crop,
+ .pix_format = {
+ .width = 640,
+ .height = 480,
+ .pixelformat = V4L2_PIX_FMT_SBGGR8,
+ .priv = 8,
+ },
+ .set_pix_format = &ov7630_set_pix_format
+};
+
+
+int sn9c102_probe_ov7630(struct sn9c102_device* cam)
+{
+ int err = 0;
+
+ sn9c102_attach_sensor(cam, &ov7630);
+
+ if (le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x608f &&
+ le16_to_cpu(ov7630.usbdev->descriptor.idProduct) != 0x602c)
+ return -ENODEV;
+
+ err += sn9c102_write_reg(cam, 0x01, 0x01);
+ err += sn9c102_write_reg(cam, 0x00, 0x01);
+ err += sn9c102_write_reg(cam, 0x28, 0x17);
+
+ if (err)
+ return -EIO;
+
+ err += sn9c102_i2c_write(cam, 0x0b, 0);
+ if (err)
+ return -ENODEV;
+
+ return 0;
+}
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
index 6a7adebcb4b..a45166c3488 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/usb/media/sn9c102_sensor.h
@@ -64,6 +64,7 @@ struct sn9c102_sensor;
*/
extern int sn9c102_probe_hv7131d(struct sn9c102_device* cam);
extern int sn9c102_probe_mi0343(struct sn9c102_device* cam);
+extern int sn9c102_probe_ov7630(struct sn9c102_device* cam);
extern int sn9c102_probe_pas106b(struct sn9c102_device* cam);
extern int sn9c102_probe_pas202bcb(struct sn9c102_device* cam);
extern int sn9c102_probe_tas5110c1b(struct sn9c102_device* cam);
@@ -80,6 +81,7 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = { \
&sn9c102_probe_pas106b, /* strong detection based on SENSOR ids */ \
&sn9c102_probe_pas202bcb, /* strong detection based on SENSOR ids */ \
&sn9c102_probe_hv7131d, /* strong detection based on SENSOR ids */ \
+ &sn9c102_probe_ov7630, /* detection mostly based on USB pid/vid */ \
&sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ \
&sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ \
NULL, \
@@ -103,7 +105,8 @@ static const struct usb_device_id sn9c102_id_table[] = { \
{ USB_DEVICE(0x0c45, 0x6029), }, /* PAS106B */ \
{ USB_DEVICE(0x0c45, 0x602a), }, /* HV7131D */ \
{ USB_DEVICE(0x0c45, 0x602b), }, /* MI-0343 */ \
- { USB_DEVICE(0x0c45, 0x602c), }, /* OV7620 */ \
+ { USB_DEVICE(0x0c45, 0x602c), }, /* OV7630 */ \
+ { USB_DEVICE(0x0c45, 0x602d), }, \
{ USB_DEVICE(0x0c45, 0x6030), }, /* MI03x */ \
{ USB_DEVICE(0x0c45, 0x6080), }, \
{ USB_DEVICE(0x0c45, 0x6082), }, /* MI0343 and MI0360 */ \
@@ -145,6 +148,8 @@ static const struct usb_device_id sn9c102_id_table[] = { \
*/
/* The "try" I2C I/O versions are used when probing the sensor */
+extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
+ u8 address, u8 value);
extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
u8 address);
@@ -201,6 +206,8 @@ enum sn9c102_i2c_interface {
SN9C102_I2C_3WIRES,
};
+#define SN9C102_MAX_CTRLS V4L2_CID_LASTP1-V4L2_CID_BASE+10
+
struct sn9c102_sensor {
char name[32], /* sensor name */
maintainer[64]; /* name of the mantainer <email> */
@@ -243,7 +250,7 @@ struct sn9c102_sensor {
sensor according to the default configuration structures below.
*/
- struct v4l2_queryctrl qctrl[V4L2_CID_LASTP1-V4L2_CID_BASE];
+ struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
/*
Optional list of default controls, defined as indicated in the
V4L2 API. Menu type controls are not handled by this interface.
@@ -356,7 +363,7 @@ struct sn9c102_sensor {
core module to store successfully updated values of the above
settings, for rollbacks..etc..in case of errors during atomic I/O
*/
- struct v4l2_queryctrl _qctrl[V4L2_CID_LASTP1-V4L2_CID_BASE];
+ struct v4l2_queryctrl _qctrl[SN9C102_MAX_CTRLS];
struct v4l2_rect _rect;
};
@@ -367,5 +374,8 @@ struct sn9c102_sensor {
#define SN9C102_V4L2_CID_GREEN_BALANCE V4L2_CID_PRIVATE_BASE + 1
#define SN9C102_V4L2_CID_RESET_LEVEL V4L2_CID_PRIVATE_BASE + 2
#define SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE V4L2_CID_PRIVATE_BASE + 3
+#define SN9C102_V4L2_CID_GAMMA V4L2_CID_PRIVATE_BASE + 4
+#define SN9C102_V4L2_CID_BAND_FILTER V4L2_CID_PRIVATE_BASE + 5
+#define SN9C102_V4L2_CID_BRIGHT_LEVEL V4L2_CID_PRIVATE_BASE + 6
#endif /* _SN9C102_SENSOR_H_ */
diff --git a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/usb/media/sn9c102_tas5110c1b.c
index 690d6219227..8775999b5af 100644
--- a/drivers/usb/media/sn9c102_tas5110c1b.c
+++ b/drivers/usb/media/sn9c102_tas5110c1b.c
@@ -24,8 +24,6 @@
static struct sn9c102_sensor tas5110c1b;
-static struct v4l2_control tas5110c1b_gain;
-
static int tas5110c1b_init(struct sn9c102_device* cam)
{
@@ -46,21 +44,6 @@ static int tas5110c1b_init(struct sn9c102_device* cam)
}
-static int tas5110c1b_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
-{
- switch (ctrl->id) {
- case V4L2_CID_GAIN:
- ctrl->value = tas5110c1b_gain.value;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-
static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
const struct v4l2_control* ctrl)
{
@@ -68,8 +51,7 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
switch (ctrl->id) {
case V4L2_CID_GAIN:
- if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value)))
- tas5110c1b_gain.value = ctrl->value;
+ err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value);
break;
default:
return -EINVAL;
@@ -147,7 +129,6 @@ static struct sn9c102_sensor tas5110c1b = {
.height = 288,
},
},
- .get_ctrl = &tas5110c1b_get_ctrl,
.set_crop = &tas5110c1b_set_crop,
.pix_format = {
.width = 352,
diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/usb/media/sn9c102_tas5130d1b.c
index b378e941bbe..927eafdd8c7 100644
--- a/drivers/usb/media/sn9c102_tas5130d1b.c
+++ b/drivers/usb/media/sn9c102_tas5130d1b.c
@@ -24,8 +24,6 @@
static struct sn9c102_sensor tas5130d1b;
-static struct v4l2_control tas5130d1b_gain, tas5130d1b_exposure;
-
static int tas5130d1b_init(struct sn9c102_device* cam)
{
@@ -44,24 +42,6 @@ static int tas5130d1b_init(struct sn9c102_device* cam)
}
-static int tas5130d1b_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
-{
- switch (ctrl->id) {
- case V4L2_CID_GAIN:
- ctrl->value = tas5130d1b_gain.value;
- break;
- case V4L2_CID_EXPOSURE:
- ctrl->value = tas5130d1b_exposure.value;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-
static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
const struct v4l2_control* ctrl)
{
@@ -69,12 +49,10 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
switch (ctrl->id) {
case V4L2_CID_GAIN:
- if (!(err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value)))
- tas5130d1b_gain.value = ctrl->value;
+ err += sn9c102_i2c_write(cam, 0x20, 0xf6 - ctrl->value);
break;
case V4L2_CID_EXPOSURE:
- if (!(err += sn9c102_i2c_write(cam, 0x40, 0x47 - ctrl->value)))
- tas5130d1b_exposure.value = ctrl->value;
+ err += sn9c102_i2c_write(cam, 0x40, 0x47 - ctrl->value);
break;
default:
return -EINVAL;
@@ -147,7 +125,6 @@ static struct sn9c102_sensor tas5130d1b = {
.flags = 0,
},
},
- .get_ctrl = &tas5130d1b_get_ctrl,
.set_ctrl = &tas5130d1b_set_ctrl,
.cropcap = {
.bounds = {
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 3a896954b3a..6649531fa82 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -139,6 +139,16 @@ config USB_IDMOUSE
source "drivers/usb/misc/sisusbvga/Kconfig"
+config USB_LD
+ tristate "USB LD driver"
+ depends on USB && EXPERIMENTAL
+ help
+ This driver is for generic USB devices that use interrupt transfers,
+ like LD Didactic's USB devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ldusb.
+
config USB_TEST
tristate "USB testing driver (DEVELOPMENT)"
depends on USB && USB_DEVICEFS && EXPERIMENTAL
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 4a3814cbd48..862e40a8368 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_EMI26) += emi26.o
obj-$(CONFIG_USB_EMI62) += emi62.o
obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
obj-$(CONFIG_USB_LCD) += usblcd.o
+obj-$(CONFIG_USB_LD) += ldusb.o
obj-$(CONFIG_USB_LED) += usbled.o
obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
new file mode 100644
index 00000000000..66ec88354b9
--- /dev/null
+++ b/drivers/usb/misc/ldusb.c
@@ -0,0 +1,794 @@
+/**
+ * Generic USB driver for report based interrupt in/out devices
+ * like LD Didactic's USB devices. LD Didactic's USB devices are
+ * HID devices which do not use HID report definitons (they use
+ * raw interrupt in and our reports only for communication).
+ *
+ * This driver uses a ring buffer for time critical reading of
+ * interrupt in reports and provides read and write methods for
+ * raw interrupt reports (similar to the Windows HID driver).
+ * Devices based on the book USB COMPLETE by Jan Axelson may need
+ * such a compatibility to the Windows HID driver.
+ *
+ * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * Derived from Lego USB Tower driver
+ * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net>
+ * 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
+ *
+ * V0.1 (mh) Initial version
+ * V0.11 (mh) Added raw support for HID 1.0 devices (no interrupt out endpoint)
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+
+#include <asm/uaccess.h>
+#include <linux/input.h>
+#include <linux/usb.h>
+#include <linux/poll.h>
+
+/* Define these values to match your devices */
+#define USB_VENDOR_ID_LD 0x0f11 /* USB Vendor ID of LD Didactic GmbH */
+#define USB_DEVICE_ID_CASSY 0x1000 /* USB Product ID for all CASSY-S modules */
+#define USB_DEVICE_ID_POCKETCASSY 0x1010 /* USB Product ID for Pocket-CASSY */
+#define USB_DEVICE_ID_MOBILECASSY 0x1020 /* USB Product ID for Mobile-CASSY */
+#define USB_DEVICE_ID_JWM 0x1080 /* USB Product ID for Joule and Wattmeter */
+#define USB_DEVICE_ID_DMMP 0x1081 /* USB Product ID for Digital Multimeter P (reserved) */
+#define USB_DEVICE_ID_UMIP 0x1090 /* USB Product ID for UMI P */
+#define USB_DEVICE_ID_VIDEOCOM 0x1200 /* USB Product ID for VideoCom */
+#define USB_DEVICE_ID_COM3LAB 0x2000 /* USB Product ID for COM3LAB */
+#define USB_DEVICE_ID_TELEPORT 0x2010 /* USB Product ID for Terminal Adapter */
+#define USB_DEVICE_ID_NETWORKANALYSER 0x2020 /* USB Product ID for Network Analyser */
+#define USB_DEVICE_ID_POWERCONTROL 0x2030 /* USB Product ID for Controlling device for Power Electronics */
+
+#define USB_VENDOR_ID_VERNIER 0x08f7
+#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001
+#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
+#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
+#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
+
+
+#ifdef CONFIG_USB_DYNAMIC_MINORS
+#define USB_LD_MINOR_BASE 0
+#else
+#define USB_LD_MINOR_BASE 176
+#endif
+
+/* table of devices that work with this driver */
+static struct usb_device_id ld_usb_table [] = {
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_CASSY) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_POCKETCASSY) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_MOBILECASSY) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_JWM) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_DMMP) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_UMIP) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_VIDEOCOM) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_COM3LAB) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_TELEPORT) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_NETWORKANALYSER) },
+ { USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_POWERCONTROL) },
+ { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) },
+ { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
+ { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
+ { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
+ { } /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, ld_usb_table);
+MODULE_VERSION("V0.11");
+MODULE_AUTHOR("Michael Hund <mhund@ld-didactic.de>");
+MODULE_DESCRIPTION("LD USB Driver");
+MODULE_LICENSE("GPL");
+MODULE_SUPPORTED_DEVICE("LD USB Devices");
+
+#ifdef CONFIG_USB_DEBUG
+ static int debug = 1;
+#else
+ static int debug = 0;
+#endif
+
+/* Use our own dbg macro */
+#define dbg_info(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
+
+/* Module parameters */
+module_param(debug, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug enabled or not");
+
+/* All interrupt in transfers are collected in a ring buffer to
+ * avoid racing conditions and get better performance of the driver.
+ */
+static int ring_buffer_size = 128;
+module_param(ring_buffer_size, int, 0);
+MODULE_PARM_DESC(ring_buffer_size, "Read ring buffer size in reports");
+
+/* The write_buffer can contain more than one interrupt out transfer.
+ */
+static int write_buffer_size = 10;
+module_param(write_buffer_size, int, 0);
+MODULE_PARM_DESC(write_buffer_size, "Write buffer size in reports");
+
+/* As of kernel version 2.6.4 ehci-hcd uses an
+ * "only one interrupt transfer per frame" shortcut
+ * to simplify the scheduling of periodic transfers.
+ * This conflicts with our standard 1ms intervals for in and out URBs.
+ * We use default intervals of 2ms for in and 2ms for out transfers,
+ * which should be fast enough.
+ * Increase the interval to allow more devices that do interrupt transfers,
+ * or set to 1 to use the standard interval from the endpoint descriptors.
+ */
+static int min_interrupt_in_interval = 2;
+module_param(min_interrupt_in_interval, int, 0);
+MODULE_PARM_DESC(min_interrupt_in_interval, "Minimum interrupt in interval in ms");
+
+static int min_interrupt_out_interval = 2;
+module_param(min_interrupt_out_interval, int, 0);
+MODULE_PARM_DESC(min_interrupt_out_interval, "Minimum interrupt out interval in ms");
+
+/* Structure to hold all of our device specific stuff */
+struct ld_usb {
+ struct semaphore sem; /* locks this structure */
+ struct usb_interface* intf; /* save off the usb interface pointer */
+
+ int open_count; /* number of times this port has been opened */
+
+ char* ring_buffer;
+ unsigned int ring_head;
+ unsigned int ring_tail;
+
+ wait_queue_head_t read_wait;
+ wait_queue_head_t write_wait;
+
+ char* interrupt_in_buffer;
+ struct usb_endpoint_descriptor* interrupt_in_endpoint;
+ struct urb* interrupt_in_urb;
+ int interrupt_in_interval;
+ size_t interrupt_in_endpoint_size;
+ int interrupt_in_running;
+ int interrupt_in_done;
+
+ char* interrupt_out_buffer;
+ struct usb_endpoint_descriptor* interrupt_out_endpoint;
+ struct urb* interrupt_out_urb;
+ int interrupt_out_interval;
+ size_t interrupt_out_endpoint_size;
+ int interrupt_out_busy;
+};
+
+/* prevent races between open() and disconnect() */
+static DECLARE_MUTEX(disconnect_sem);
+
+static struct usb_driver ld_usb_driver;
+
+/**
+ * ld_usb_abort_transfers
+ * aborts transfers and frees associated data structures
+ */
+static void ld_usb_abort_transfers(struct ld_usb *dev)
+{
+ /* shutdown transfer */
+ if (dev->interrupt_in_running) {
+ dev->interrupt_in_running = 0;
+ if (dev->intf)
+ usb_kill_urb(dev->interrupt_in_urb);
+ }
+ if (dev->interrupt_out_busy)
+ if (dev->intf)
+ usb_kill_urb(dev->interrupt_out_urb);
+}
+
+/**
+ * ld_usb_delete
+ */
+static void ld_usb_delete(struct ld_usb *dev)
+{
+ ld_usb_abort_transfers(dev);
+
+ /* free data structures */
+ usb_free_urb(dev->interrupt_in_urb);
+ usb_free_urb(dev->interrupt_out_urb);
+ kfree(dev->ring_buffer);
+ kfree(dev->interrupt_in_buffer);
+ kfree(dev->interrupt_out_buffer);
+ kfree(dev);
+}
+
+/**
+ * ld_usb_interrupt_in_callback
+ */
+static void ld_usb_interrupt_in_callback(struct urb *urb, struct pt_regs *regs)
+{
+ struct ld_usb *dev = urb->context;
+ size_t *actual_buffer;
+ unsigned int next_ring_head;
+ int retval;
+
+ if (urb->status) {
+ if (urb->status == -ENOENT ||
+ urb->status == -ECONNRESET ||
+ urb->status == -ESHUTDOWN) {
+ goto exit;
+ } else {
+ dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
+ __FUNCTION__, urb->status);
+ goto resubmit; /* maybe we can recover */
+ }
+ }
+
+ if (urb->actual_length > 0) {
+ next_ring_head = (dev->ring_head+1) % ring_buffer_size;
+ if (next_ring_head != dev->ring_tail) {
+ actual_buffer = (size_t*)(dev->ring_buffer + dev->ring_head*(sizeof(size_t)+dev->interrupt_in_endpoint_size));
+ /* actual_buffer gets urb->actual_length + interrupt_in_buffer */
+ *actual_buffer = urb->actual_length;
+ memcpy(actual_buffer+1, dev->interrupt_in_buffer, urb->actual_length);
+ dev->ring_head = next_ring_head;
+ dbg_info(&dev->intf->dev, "%s: received %d bytes\n",
+ __FUNCTION__, urb->actual_length);
+ } else
+ dev_warn(&dev->intf->dev,
+ "Ring buffer overflow, %d bytes dropped\n",
+ urb->actual_length);
+ }
+
+resubmit:
+ /* resubmit if we're still running */
+ if (dev->interrupt_in_running && dev->intf) {
+ retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
+ if (retval)
+ dev_err(&dev->intf->dev,
+ "usb_submit_urb failed (%d)\n", retval);
+ }
+
+exit:
+ dev->interrupt_in_done = 1;
+ wake_up_interruptible(&dev->read_wait);
+}
+
+/**
+ * ld_usb_interrupt_out_callback
+ */
+static void ld_usb_interrupt_out_callback(struct urb *urb, struct pt_regs *regs)
+{
+ struct ld_usb *dev = urb->context;
+
+ /* sync/async unlink faults aren't errors */
+ if (urb->status && !(urb->status == -ENOENT ||
+ urb->status == -ECONNRESET ||
+ urb->status == -ESHUTDOWN))
+ dbg_info(&dev->intf->dev,
+ "%s - nonzero write interrupt status received: %d\n",
+ __FUNCTION__, urb->status);
+
+ dev->interrupt_out_busy = 0;
+ wake_up_interruptible(&dev->write_wait);
+}
+
+/**
+ * ld_usb_open
+ */
+static int ld_usb_open(struct inode *inode, struct file *file)
+{
+ struct ld_usb *dev;
+ int subminor;
+ int retval = 0;
+ struct usb_interface *interface;
+
+ nonseekable_open(inode, file);
+ subminor = iminor(inode);
+
+ down(&disconnect_sem);
+
+ interface = usb_find_interface(&ld_usb_driver, subminor);
+
+ if (!interface) {
+ err("%s - error, can't find device for minor %d\n",
+ __FUNCTION__, subminor);
+ retval = -ENODEV;
+ goto unlock_disconnect_exit;
+ }
+
+ dev = usb_get_intfdata(interface);
+
+ if (!dev) {
+ retval = -ENODEV;
+ goto unlock_disconnect_exit;
+ }
+
+ /* lock this device */
+ if (down_interruptible(&dev->sem)) {
+ retval = -ERESTARTSYS;
+ goto unlock_disconnect_exit;
+ }
+
+ /* allow opening only once */
+ if (dev->open_count) {
+ retval = -EBUSY;
+ goto unlock_exit;
+ }
+ dev->open_count = 1;
+
+ /* initialize in direction */
+ dev->ring_head = 0;
+ dev->ring_tail = 0;
+ usb_fill_int_urb(dev->interrupt_in_urb,
+ interface_to_usbdev(interface),
+ usb_rcvintpipe(interface_to_usbdev(interface),
+ dev->interrupt_in_endpoint->bEndpointAddress),
+ dev->interrupt_in_buffer,
+ dev->interrupt_in_endpoint_size,
+ ld_usb_interrupt_in_callback,
+ dev,
+ dev->interrupt_in_interval);
+
+ dev->interrupt_in_running = 1;
+ dev->interrupt_in_done = 0;
+
+ retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
+ if (retval) {
+ dev_err(&interface->dev, "Couldn't submit interrupt_in_urb %d\n", retval);
+ dev->interrupt_in_running = 0;
+ dev->open_count = 0;
+ goto unlock_exit;
+ }
+
+ /* save device in the file's private structure */
+ file->private_data = dev;
+
+unlock_exit:
+ up(&dev->sem);
+
+unlock_disconnect_exit:
+ up(&disconnect_sem);
+
+ return retval;
+}
+
+/**
+ * ld_usb_release
+ */
+static int ld_usb_release(struct inode *inode, struct file *file)
+{
+ struct ld_usb *dev;
+ int retval = 0;
+
+ dev = file->private_data;
+
+ if (dev == NULL) {
+ retval = -ENODEV;
+ goto exit;
+ }
+
+ if (down_interruptible(&dev->sem)) {
+ retval = -ERESTARTSYS;
+ goto exit;
+ }
+
+ if (dev->open_count != 1) {
+ retval = -ENODEV;
+ goto unlock_exit;
+ }
+ if (dev->intf == NULL) {
+ /* the device was unplugged before the file was released */
+ up(&dev->sem);
+ /* unlock here as ld_usb_delete frees dev */
+ ld_usb_delete(dev);
+ goto exit;
+ }
+
+ /* wait until write transfer is finished */
+ if (dev->interrupt_out_busy)
+ wait_event_interruptible_timeout(dev->write_wait, !dev->interrupt_out_busy, 2 * HZ);
+ ld_usb_abort_transfers(dev);
+ dev->open_count = 0;
+
+unlock_exit:
+ up(&dev->sem);
+
+exit:
+ return retval;
+}
+
+/**
+ * ld_usb_poll
+ */
+static unsigned int ld_usb_poll(struct file *file, poll_table *wait)
+{
+ struct ld_usb *dev;
+ unsigned int mask = 0;
+
+ dev = file->private_data;
+
+ poll_wait(file, &dev->read_wait, wait);
+ poll_wait(file, &dev->write_wait, wait);
+
+ if (dev->ring_head != dev->ring_tail)
+ mask |= POLLIN | POLLRDNORM;
+ if (!dev->interrupt_out_busy)
+ mask |= POLLOUT | POLLWRNORM;
+
+ return mask;
+}
+
+/**
+ * ld_usb_read
+ */
+static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
+ loff_t *ppos)
+{
+ struct ld_usb *dev;
+ size_t *actual_buffer;
+ size_t bytes_to_read;
+ int retval = 0;
+
+ dev = file->private_data;
+
+ /* verify that we actually have some data to read */
+ if (count == 0)
+ goto exit;
+
+ /* lock this object */
+ if (down_interruptible(&dev->sem)) {
+ retval = -ERESTARTSYS;
+ goto exit;
+ }
+
+ /* verify that the device wasn't unplugged */
+ if (dev->intf == NULL) {
+ retval = -ENODEV;
+ err("No device or device unplugged %d\n", retval);
+ goto unlock_exit;
+ }
+
+ /* wait for data */
+ if (dev->ring_head == dev->ring_tail) {
+ if (file->f_flags & O_NONBLOCK) {
+ retval = -EAGAIN;
+ goto unlock_exit;
+ }
+ retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done);
+ if (retval < 0)
+ goto unlock_exit;
+ }
+
+ /* actual_buffer contains actual_length + interrupt_in_buffer */
+ actual_buffer = (size_t*)(dev->ring_buffer + dev->ring_tail*(sizeof(size_t)+dev->interrupt_in_endpoint_size));
+ bytes_to_read = min(count, *actual_buffer);
+ if (bytes_to_read < *actual_buffer)
+ dev_warn(&dev->intf->dev, "Read buffer overflow, %d bytes dropped\n",
+ *actual_buffer-bytes_to_read);
+
+ /* copy one interrupt_in_buffer from ring_buffer into userspace */
+ if (copy_to_user(buffer, actual_buffer+1, bytes_to_read)) {
+ retval = -EFAULT;
+ goto unlock_exit;
+ }
+ dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
+
+ retval = bytes_to_read;
+
+unlock_exit:
+ /* unlock the device */
+ up(&dev->sem);
+
+exit:
+ return retval;
+}
+
+/**
+ * ld_usb_write
+ */
+static ssize_t ld_usb_write(struct file *file, const char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct ld_usb *dev;
+ size_t bytes_to_write;
+ int retval = 0;
+
+ dev = file->private_data;
+
+ /* verify that we actually have some data to write */
+ if (count == 0)
+ goto exit;
+
+ /* lock this object */
+ if (down_interruptible(&dev->sem)) {
+ retval = -ERESTARTSYS;
+ goto exit;
+ }
+
+ /* verify that the device wasn't unplugged */
+ if (dev->intf == NULL) {
+ retval = -ENODEV;
+ err("No device or device unplugged %d\n", retval);
+ goto unlock_exit;
+ }
+
+ /* wait until previous transfer is finished */
+ if (dev->interrupt_out_busy) {
+ if (file->f_flags & O_NONBLOCK) {
+ retval = -EAGAIN;
+ goto unlock_exit;
+ }
+ retval = wait_event_interruptible(dev->write_wait, !dev->interrupt_out_busy);
+ if (retval < 0) {
+ goto unlock_exit;
+ }
+ }
+
+ /* write the data into interrupt_out_buffer from userspace */
+ bytes_to_write = min(count, write_buffer_size*dev->interrupt_out_endpoint_size);
+ if (bytes_to_write < count)
+ dev_warn(&dev->intf->dev, "Write buffer overflow, %d bytes dropped\n",count-bytes_to_write);
+ dbg_info(&dev->intf->dev, "%s: count = %d, bytes_to_write = %d\n", __FUNCTION__, count, bytes_to_write);
+
+ if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
+ retval = -EFAULT;
+ goto unlock_exit;
+ }
+
+ if (dev->interrupt_out_endpoint == NULL) {
+ /* try HID_REQ_SET_REPORT=9 on control_endpoint instead of interrupt_out_endpoint */
+ retval = usb_control_msg(interface_to_usbdev(dev->intf),
+ usb_sndctrlpipe(interface_to_usbdev(dev->intf), 0),
+ 9,
+ USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
+ 1 << 8, 0,
+ dev->interrupt_out_buffer,
+ bytes_to_write,
+ USB_CTRL_SET_TIMEOUT * HZ);
+ if (retval < 0)
+ err("Couldn't submit HID_REQ_SET_REPORT %d\n", retval);
+ goto unlock_exit;
+ }
+
+ /* send off the urb */
+ usb_fill_int_urb(dev->interrupt_out_urb,
+ interface_to_usbdev(dev->intf),
+ usb_sndintpipe(interface_to_usbdev(dev->intf),
+ dev->interrupt_out_endpoint->bEndpointAddress),
+ dev->interrupt_out_buffer,
+ bytes_to_write,
+ ld_usb_interrupt_out_callback,
+ dev,
+ dev->interrupt_out_interval);
+
+ dev->interrupt_out_busy = 1;
+ wmb();
+
+ retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
+ if (retval) {
+ dev->interrupt_out_busy = 0;
+ err("Couldn't submit interrupt_out_urb %d\n", retval);
+ goto unlock_exit;
+ }
+ retval = bytes_to_write;
+
+unlock_exit:
+ /* unlock the device */
+ up(&dev->sem);
+
+exit:
+ return retval;
+}
+
+/* file operations needed when we register this driver */
+static struct file_operations ld_usb_fops = {
+ .owner = THIS_MODULE,
+ .read = ld_usb_read,
+ .write = ld_usb_write,
+ .open = ld_usb_open,
+ .release = ld_usb_release,
+ .poll = ld_usb_poll,
+};
+
+/*
+ * usb class driver info in order to get a minor number from the usb core,
+ * and to have the device registered with devfs and the driver core
+ */
+static struct usb_class_driver ld_usb_class = {
+ .name = "ldusb%d",
+ .fops = &ld_usb_fops,
+ .minor_base = USB_LD_MINOR_BASE,
+};
+
+/**
+ * ld_usb_probe
+ *
+ * Called by the usb core when a new device is connected that it thinks
+ * this driver might be interested in.
+ */
+static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ struct usb_device *udev = interface_to_usbdev(intf);
+ struct ld_usb *dev = NULL;
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+ char *buffer;
+ int i;
+ int retval = -ENOMEM;
+
+ /* allocate memory for our device state and intialize it */
+
+ dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+ if (dev == NULL) {
+ dev_err(&intf->dev, "Out of memory\n");
+ goto exit;
+ }
+ memset(dev, 0x00, sizeof(*dev));
+ init_MUTEX(&dev->sem);
+ dev->intf = intf;
+ init_waitqueue_head(&dev->read_wait);
+ init_waitqueue_head(&dev->write_wait);
+
+ /* workaround for early firmware versions on fast computers */
+ if ((le16_to_cpu(udev->descriptor.idVendor) == USB_VENDOR_ID_LD) &&
+ ((le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_CASSY) ||
+ (le16_to_cpu(udev->descriptor.idProduct) == USB_DEVICE_ID_COM3LAB)) &&
+ (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x103)) {
+ buffer = kmalloc(256, GFP_KERNEL);
+ /* usb_string makes SETUP+STALL to leave always ControlReadLoop */
+ usb_string(udev, 255, buffer, 256);
+ kfree(buffer);
+ }
+
+ iface_desc = intf->cur_altsetting;
+
+ /* set up the endpoint information */
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
+ dev->interrupt_in_endpoint = endpoint;
+ }
+
+ if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
+ ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
+ dev->interrupt_out_endpoint = endpoint;
+ }
+ }
+ if (dev->interrupt_in_endpoint == NULL) {
+ dev_err(&intf->dev, "Interrupt in endpoint not found\n");
+ goto error;
+ }
+ if (dev->interrupt_out_endpoint == NULL)
+ dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
+
+ dev->interrupt_in_endpoint_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
+ dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
+ if (!dev->ring_buffer) {
+ dev_err(&intf->dev, "Couldn't allocate ring_buffer\n");
+ goto error;
+ }
+ dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
+ if (!dev->interrupt_in_buffer) {
+ dev_err(&intf->dev, "Couldn't allocate interrupt_in_buffer\n");
+ goto error;
+ }
+ dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->interrupt_in_urb) {
+ dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
+ goto error;
+ }
+ dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :
+ udev->descriptor.bMaxPacketSize0;
+ dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
+ if (!dev->interrupt_out_buffer) {
+ dev_err(&intf->dev, "Couldn't allocate interrupt_out_buffer\n");
+ goto error;
+ }
+ dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->interrupt_out_urb) {
+ dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
+ goto error;
+ }
+ dev->interrupt_in_interval = min_interrupt_in_interval > dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->bInterval;
+ if (dev->interrupt_out_endpoint)
+ dev->interrupt_out_interval = min_interrupt_out_interval > dev->interrupt_out_endpoint->bInterval ? min_interrupt_out_interval : dev->interrupt_out_endpoint->bInterval;
+
+ /* we can register the device now, as it is ready */
+ usb_set_intfdata(intf, dev);
+
+ retval = usb_register_dev(intf, &ld_usb_class);
+ if (retval) {
+ /* something prevented us from registering this driver */
+ dev_err(&intf->dev, "Not able to get a minor for this device.\n");
+ usb_set_intfdata(intf, NULL);
+ goto error;
+ }
+
+ /* let the user know what node this device is now attached to */
+ dev_info(&intf->dev, "LD USB Device #%d now attached to major %d minor %d\n",
+ (intf->minor - USB_LD_MINOR_BASE), USB_MAJOR, intf->minor);
+
+exit:
+ return retval;
+
+error:
+ ld_usb_delete(dev);
+
+ return retval;
+}
+
+/**
+ * ld_usb_disconnect
+ *
+ * Called by the usb core when the device is removed from the system.
+ */
+static void ld_usb_disconnect(struct usb_interface *intf)
+{
+ struct ld_usb *dev;
+ int minor;
+
+ down(&disconnect_sem);
+
+ dev = usb_get_intfdata(intf);
+ usb_set_intfdata(intf, NULL);
+
+ down(&dev->sem);
+
+ minor = intf->minor;
+
+ /* give back our minor */
+ usb_deregister_dev(intf, &ld_usb_class);
+
+ /* if the device is not opened, then we clean up right now */
+ if (!dev->open_count) {
+ up(&dev->sem);
+ ld_usb_delete(dev);
+ } else {
+ dev->intf = NULL;
+ up(&dev->sem);
+ }
+
+ up(&disconnect_sem);
+
+ dev_info(&intf->dev, "LD USB Device #%d now disconnected\n",
+ (minor - USB_LD_MINOR_BASE));
+}
+
+/* usb specific object needed to register this driver with the usb subsystem */
+static struct usb_driver ld_usb_driver = {
+ .owner = THIS_MODULE,
+ .name = "ldusb",
+ .probe = ld_usb_probe,
+ .disconnect = ld_usb_disconnect,
+ .id_table = ld_usb_table,
+};
+
+/**
+ * ld_usb_init
+ */
+static int __init ld_usb_init(void)
+{
+ int retval;
+
+ /* register this driver with the USB subsystem */
+ retval = usb_register(&ld_usb_driver);
+ if (retval)
+ err("usb_register failed for the "__FILE__" driver. Error number %d\n", retval);
+
+ return retval;
+}
+
+/**
+ * ld_usb_exit
+ */
+static void __exit ld_usb_exit(void)
+{
+ /* deregister this driver with the USB subsystem */
+ usb_deregister(&ld_usb_driver);
+}
+
+module_init(ld_usb_init);
+module_exit(ld_usb_exit);
+
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 755a4570477..26266b30028 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -19,11 +19,16 @@
#define DATA_MAX 32
/*
+ * Defined by USB 2.0 clause 9.3, table 9.2.
+ */
+#define SETUP_MAX 8
+
+/*
* This limit exists to prevent OOMs when the user process stops reading.
*/
#define EVENT_MAX 25
-#define PRINTF_DFL 120
+#define PRINTF_DFL 130
struct mon_event_text {
struct list_head e_link;
@@ -33,7 +38,9 @@ struct mon_event_text {
unsigned int tstamp;
int length; /* Depends on type: xfer length or act length */
int status;
+ char setup_flag;
char data_flag;
+ unsigned char setup[SETUP_MAX];
unsigned char data[DATA_MAX];
};
@@ -64,6 +71,22 @@ static void mon_text_dtor(void *, kmem_cache_t *, unsigned long);
* This is called with the whole mon_bus locked, so no additional lock.
*/
+static inline char mon_text_get_setup(struct mon_event_text *ep,
+ struct urb *urb, char ev_type)
+{
+
+ if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
+ return '-';
+
+ if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP)
+ return 'D';
+ if (urb->setup_packet == NULL)
+ return 'Z'; /* '0' would be not as pretty. */
+
+ memcpy(ep->setup, urb->setup_packet, SETUP_MAX);
+ return 0;
+}
+
static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
int len, char ev_type)
{
@@ -90,7 +113,6 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
/*
* Bulk is easy to shortcut reliably.
- * XXX Control needs setup packet taken.
* XXX Other pipe types need consideration. Currently, we overdo it
* and collect garbage for them: better more than less.
*/
@@ -144,6 +166,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
/* Collecting status makes debugging sense for submits, too */
ep->status = urb->status;
+ ep->setup_flag = mon_text_get_setup(ep, urb, ev_type);
ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type);
rp->nevents++;
@@ -299,10 +322,25 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
default: /* PIPE_BULK */ utype = 'B';
}
cnt += snprintf(pbuf + cnt, limit - cnt,
- "%lx %u %c %c%c:%03u:%02u %d %d",
+ "%lx %u %c %c%c:%03u:%02u",
ep->id, ep->tstamp, ep->type,
- utype, udir, usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe),
- ep->status, ep->length);
+ utype, udir, usb_pipedevice(ep->pipe), usb_pipeendpoint(ep->pipe));
+
+ if (ep->setup_flag == 0) { /* Setup packet is present and captured */
+ cnt += snprintf(pbuf + cnt, limit - cnt,
+ " s %02x %02x %04x %04x %04x",
+ ep->setup[0],
+ ep->setup[1],
+ (ep->setup[3] << 8) | ep->setup[2],
+ (ep->setup[5] << 8) | ep->setup[4],
+ (ep->setup[7] << 8) | ep->setup[6]);
+ } else if (ep->setup_flag != '-') { /* Unable to capture setup packet */
+ cnt += snprintf(pbuf + cnt, limit - cnt,
+ " %c __ __ ____ ____ ____", ep->setup_flag);
+ } else { /* No setup for this kind of URB */
+ cnt += snprintf(pbuf + cnt, limit - cnt, " %d", ep->status);
+ }
+ cnt += snprintf(pbuf + cnt, limit - cnt, " %d", ep->length);
if ((data_len = ep->length) > 0) {
if (ep->data_flag == 0) {
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index fd6ff4cb2c6..7ffa99b9760 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -477,7 +477,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
}
static void kaweth_usb_receive(struct urb *, struct pt_regs *regs);
-static int kaweth_resubmit_rx_urb(struct kaweth_device *, int);
+static int kaweth_resubmit_rx_urb(struct kaweth_device *, unsigned);
/****************************************************************
int_callback
@@ -550,7 +550,7 @@ static void kaweth_resubmit_tl(void *d)
* kaweth_resubmit_rx_urb
****************************************************************/
static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
- int mem_flags)
+ unsigned mem_flags)
{
int result;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d882fa3ad19..0b03ddab53d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -264,16 +264,26 @@
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.4.2"
+#define DRIVER_VERSION "v1.4.3"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>"
#define DRIVER_DESC "USB FTDI Serial Converters Driver"
static int debug;
-static struct usb_device_id id_table_sio [] = {
- { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
- { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
- { } /* Terminating entry */
+/* struct ftdi_sio_quirk is used by devices requiring special attention. */
+struct ftdi_sio_quirk {
+ void (*setup)(struct usb_serial *); /* Special settings during startup. */
+};
+
+static void ftdi_USB_UIRT_setup (struct usb_serial *serial);
+static void ftdi_HE_TIRA1_setup (struct usb_serial *serial);
+
+static struct ftdi_sio_quirk ftdi_USB_UIRT_quirk = {
+ .setup = ftdi_USB_UIRT_setup,
+};
+
+static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = {
+ .setup = ftdi_HE_TIRA1_setup,
};
/*
@@ -288,237 +298,11 @@ static struct usb_device_id id_table_sio [] = {
* the bcdDevice value is used to differentiate FT232BM and FT245BM from
* the earlier FT8U232AM and FT8U232BM. For now, include all known VID/PID
* combinations in both tables.
- * FIXME: perhaps bcdDevice can also identify 12MHz devices, but I don't know
- * if those ever went into mass production. [Ian Abbott]
+ * FIXME: perhaps bcdDevice can also identify 12MHz FT8U232AM devices,
+ * but I don't know if those ever went into mass production. [Ian Abbott]
*/
-static struct usb_device_id id_table_8U232AM [] = {
- { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) },
- { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
- { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
- { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_634_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_547_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_633_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_631_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_635_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_640_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_642_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_VNHCPCUSB_D_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_DSS20_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2101_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2102_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2103_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2104_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_5_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_6_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_7_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_8_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_5_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_6_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_7_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_8_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_3_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_5_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_6_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_7_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_8_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(IDTECH_VID, IDTECH_IDT1221U_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(OCT_VID, OCT_US101_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_1, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_R2X0, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0, 0x3ff) },
- { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0, 0x3ff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0, 0x3ff) },
- { } /* Terminating entry */
-};
-
-
-static struct usb_device_id id_table_FT232BM [] = {
- { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_634_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_547_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_633_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_631_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_635_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_640_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_XF_642_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_VNHCPCUSB_D_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_DSS20_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_0_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_5_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_6_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_PIEGROUP_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2101_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2102_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2103_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2104_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2201_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2202_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2203_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2401_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2402_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2403_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_5_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_6_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_7_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2801_8_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_5_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_6_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_7_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2802_8_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_5_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_6_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_7_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(SEALEVEL_VID, SEALEVEL_2803_8_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(IDTECH_VID, IDTECH_IDT1221U_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(OCT_VID, OCT_US101_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_1, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_R2X0, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_3, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, PROTEGO_SPECIAL_4, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UO100_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ELV_UM100_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_2_PID, 0x400, 0xffff) },
- { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
- { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
- { USB_DEVICE_VER(FTDI_VID, INSIDE_ACCESSO, 0x400, 0xffff) },
- { USB_DEVICE_VER(INTREPID_VID, INTREPID_VALUECAN_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
- { } /* Terminating entry */
-};
-
-
-static struct usb_device_id id_table_USB_UIRT [] = {
- { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID) },
- { } /* Terminating entry */
-};
-
-
-static struct usb_device_id id_table_HE_TIRA1 [] = {
- { USB_DEVICE_VER(FTDI_VID, FTDI_HE_TIRA1_PID, 0x400, 0xffff) },
- { } /* Terminating entry */
-};
-
-
-static struct usb_device_id id_table_FT2232C[] = {
- { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
- { } /* Terminating entry */
-};
-
static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
@@ -540,14 +324,14 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_DSS20_PID) },
{ USB_DEVICE(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_VNHCPCUSB_D_PID) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_0_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_3_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_4_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_5_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_MTXORB_6_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID, 0x400, 0xffff) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_0_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_1_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_2_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_3_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2101_PID) },
{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2102_PID) },
@@ -597,35 +381,37 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
{ USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
{ USB_DEVICE(OCT_VID, OCT_US101_PID) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_HE_TIRA1_PID, 0x400, 0xffff) },
- { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_HE_TIRA1_PID),
+ .driver_info = (kernel_ulong_t)&ftdi_HE_TIRA1_quirk },
+ { USB_DEVICE(FTDI_VID, FTDI_USB_UIRT_PID),
+ .driver_info = (kernel_ulong_t)&ftdi_USB_UIRT_quirk },
{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_1) },
{ USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
{ USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E808_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E809_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80A_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80B_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80C_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80D_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80E_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E80F_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E888_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E889_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88A_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88B_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88C_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88D_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88E_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_GUDEADS_E88F_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_ELV_UM100_PID) },
- { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_0_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_1_PID, 0x400, 0xffff) },
- { USB_DEVICE_VER(FTDI_VID, LINX_FUTURE_2_PID, 0x400, 0xffff) },
+ { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
+ { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
+ { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
+ { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
+ { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
{ USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
@@ -642,7 +428,7 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
{ USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
- { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
+ { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
{ } /* Terminating entry */
};
@@ -705,12 +491,8 @@ struct ftdi_private {
ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP )
/* function prototypes for a FTDI serial converter */
-static int ftdi_SIO_startup (struct usb_serial *serial);
-static int ftdi_8U232AM_startup (struct usb_serial *serial);
-static int ftdi_FT232BM_startup (struct usb_serial *serial);
-static int ftdi_FT2232C_startup (struct usb_serial *serial);
-static int ftdi_USB_UIRT_startup (struct usb_serial *serial);
-static int ftdi_HE_TIRA1_startup (struct usb_serial *serial);
+static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id);
+static int ftdi_sio_attach (struct usb_serial *serial);
static void ftdi_shutdown (struct usb_serial *serial);
static int ftdi_open (struct usb_serial_port *port, struct file *filp);
static void ftdi_close (struct usb_serial_port *port, struct file *filp);
@@ -733,14 +515,16 @@ static unsigned short int ftdi_232am_baud_to_divisor (int baud);
static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base);
static __u32 ftdi_232bm_baud_to_divisor (int baud);
-static struct usb_serial_device_type ftdi_SIO_device = {
+static struct usb_serial_device_type ftdi_sio_device = {
.owner = THIS_MODULE,
- .name = "FTDI SIO",
- .id_table = id_table_sio,
+ .name = "FTDI USB Serial Device",
+ .short_name = "ftdi_sio",
+ .id_table = id_table_combined,
.num_interrupt_in = 0,
.num_bulk_in = 1,
.num_bulk_out = 1,
.num_ports = 1,
+ .probe = ftdi_sio_probe,
.open = ftdi_open,
.close = ftdi_close,
.throttle = ftdi_throttle,
@@ -755,143 +539,10 @@ static struct usb_serial_device_type ftdi_SIO_device = {
.ioctl = ftdi_ioctl,
.set_termios = ftdi_set_termios,
.break_ctl = ftdi_break_ctl,
- .attach = ftdi_SIO_startup,
+ .attach = ftdi_sio_attach,
.shutdown = ftdi_shutdown,
};
-static struct usb_serial_device_type ftdi_8U232AM_device = {
- .owner = THIS_MODULE,
- .name = "FTDI 8U232AM Compatible",
- .id_table = id_table_8U232AM,
- .num_interrupt_in = 0,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
- .num_ports = 1,
- .open = ftdi_open,
- .close = ftdi_close,
- .throttle = ftdi_throttle,
- .unthrottle = ftdi_unthrottle,
- .write = ftdi_write,
- .write_room = ftdi_write_room,
- .chars_in_buffer = ftdi_chars_in_buffer,
- .read_bulk_callback = ftdi_read_bulk_callback,
- .write_bulk_callback = ftdi_write_bulk_callback,
- .tiocmget = ftdi_tiocmget,
- .tiocmset = ftdi_tiocmset,
- .ioctl = ftdi_ioctl,
- .set_termios = ftdi_set_termios,
- .break_ctl = ftdi_break_ctl,
- .attach = ftdi_8U232AM_startup,
- .shutdown = ftdi_shutdown,
-};
-
-static struct usb_serial_device_type ftdi_FT232BM_device = {
- .owner = THIS_MODULE,
- .name = "FTDI FT232BM Compatible",
- .id_table = id_table_FT232BM,
- .num_interrupt_in = 0,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
- .num_ports = 1,
- .open = ftdi_open,
- .close = ftdi_close,
- .throttle = ftdi_throttle,
- .unthrottle = ftdi_unthrottle,
- .write = ftdi_write,
- .write_room = ftdi_write_room,
- .chars_in_buffer = ftdi_chars_in_buffer,
- .read_bulk_callback = ftdi_read_bulk_callback,
- .write_bulk_callback = ftdi_write_bulk_callback,
- .tiocmget = ftdi_tiocmget,
- .tiocmset = ftdi_tiocmset,
- .ioctl = ftdi_ioctl,
- .set_termios = ftdi_set_termios,
- .break_ctl = ftdi_break_ctl,
- .attach = ftdi_FT232BM_startup,
- .shutdown = ftdi_shutdown,
-};
-
-static struct usb_serial_device_type ftdi_FT2232C_device = {
- .owner = THIS_MODULE,
- .name = "FTDI FT2232C Compatible",
- .id_table = id_table_FT2232C,
- .num_interrupt_in = 0,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
- .num_ports = 1,
- .open = ftdi_open,
- .close = ftdi_close,
- .throttle = ftdi_throttle,
- .unthrottle = ftdi_unthrottle,
- .write = ftdi_write,
- .write_room = ftdi_write_room,
- .chars_in_buffer = ftdi_chars_in_buffer,
- .read_bulk_callback = ftdi_read_bulk_callback,
- .write_bulk_callback = ftdi_write_bulk_callback,
- .tiocmget = ftdi_tiocmget,
- .tiocmset = ftdi_tiocmset,
- .ioctl = ftdi_ioctl,
- .set_termios = ftdi_set_termios,
- .break_ctl = ftdi_break_ctl,
- .attach = ftdi_FT2232C_startup,
- .shutdown = ftdi_shutdown,
-};
-
-static struct usb_serial_device_type ftdi_USB_UIRT_device = {
- .owner = THIS_MODULE,
- .name = "USB-UIRT Infrared Tranceiver",
- .id_table = id_table_USB_UIRT,
- .num_interrupt_in = 0,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
- .num_ports = 1,
- .open = ftdi_open,
- .close = ftdi_close,
- .throttle = ftdi_throttle,
- .unthrottle = ftdi_unthrottle,
- .write = ftdi_write,
- .write_room = ftdi_write_room,
- .chars_in_buffer = ftdi_chars_in_buffer,
- .read_bulk_callback = ftdi_read_bulk_callback,
- .write_bulk_callback = ftdi_write_bulk_callback,
- .tiocmget = ftdi_tiocmget,
- .tiocmset = ftdi_tiocmset,
- .ioctl = ftdi_ioctl,
- .set_termios = ftdi_set_termios,
- .break_ctl = ftdi_break_ctl,
- .attach = ftdi_USB_UIRT_startup,
- .shutdown = ftdi_shutdown,
-};
-
-/* The TIRA1 is based on a FT232BM which requires a fixed baud rate of 100000
- * and which requires RTS-CTS to be enabled. */
-static struct usb_serial_device_type ftdi_HE_TIRA1_device = {
- .owner = THIS_MODULE,
- .name = "Home-Electronics TIRA-1 IR Transceiver",
- .id_table = id_table_HE_TIRA1,
- .num_interrupt_in = 0,
- .num_bulk_in = 1,
- .num_bulk_out = 1,
- .num_ports = 1,
- .open = ftdi_open,
- .close = ftdi_close,
- .throttle = ftdi_throttle,
- .unthrottle = ftdi_unthrottle,
- .write = ftdi_write,
- .write_room = ftdi_write_room,
- .chars_in_buffer = ftdi_chars_in_buffer,
- .read_bulk_callback = ftdi_read_bulk_callback,
- .write_bulk_callback = ftdi_write_bulk_callback,
- .tiocmget = ftdi_tiocmget,
- .tiocmset = ftdi_tiocmset,
- .ioctl = ftdi_ioctl,
- .set_termios = ftdi_set_termios,
- .break_ctl = ftdi_break_ctl,
- .attach = ftdi_HE_TIRA1_startup,
- .shutdown = ftdi_shutdown,
-};
-
-
#define WDR_TIMEOUT 5000 /* default urb timeout */
@@ -1212,6 +863,59 @@ check_and_exit:
} /* set_serial_info */
+/* Determine type of FTDI chip based on USB config and descriptor. */
+static void ftdi_determine_type(struct usb_serial_port *port)
+{
+ struct ftdi_private *priv = usb_get_serial_port_data(port);
+ struct usb_serial *serial = port->serial;
+ struct usb_device *udev = serial->dev;
+ unsigned version;
+ unsigned interfaces;
+
+ /* Assume it is not the original SIO device for now. */
+ priv->baud_base = 48000000 / 16;
+ priv->write_offset = 0;
+
+ version = le16_to_cpu(udev->descriptor.bcdDevice);
+ interfaces = udev->actconfig->desc.bNumInterfaces;
+ dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __FUNCTION__,
+ version, interfaces);
+ if (interfaces > 1) {
+ int inter;
+
+ /* Multiple interfaces. Assume FT2232C. */
+ priv->chip_type = FT2232C;
+ /* Determine interface code. */
+ inter = serial->interface->altsetting->desc.bInterfaceNumber;
+ if (inter == 0) {
+ priv->interface = PIT_SIOA;
+ } else {
+ priv->interface = PIT_SIOB;
+ }
+ /* BM-type devices have a bug where bcdDevice gets set
+ * to 0x200 when iSerialNumber is 0. */
+ if (version < 0x500) {
+ dbg("%s: something fishy - bcdDevice too low for multi-interface device",
+ __FUNCTION__);
+ }
+ } else if (version < 0x200) {
+ /* Old device. Assume its the original SIO. */
+ priv->chip_type = SIO;
+ priv->baud_base = 12000000 / 16;
+ priv->write_offset = 1;
+ } else if (version < 0x400) {
+ /* Assume its an FT8U232AM (or FT8U245AM) */
+ /* (It might be a BM because of the iSerialNumber bug,
+ * but it will still work as an AM device.) */
+ priv->chip_type = FT8U232AM;
+ } else {
+ /* Assume its an FT232BM (or FT245BM) */
+ priv->chip_type = FT232BM;
+ }
+ info("Detected %s", ftdi_chip_name[priv->chip_type]);
+}
+
+
/*
* ***************************************************************************
* Sysfs Attribute
@@ -1355,12 +1059,20 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
* ***************************************************************************
*/
-/* Common startup subroutine */
-/* Called from ftdi_SIO_startup, etc. */
-static int ftdi_common_startup (struct usb_serial *serial)
+/* Probe function to check for special devices */
+static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id)
+{
+ usb_set_serial_data(serial, (void *)id->driver_info);
+
+ return (0);
+}
+
+/* attach subroutine */
+static int ftdi_sio_attach (struct usb_serial *serial)
{
struct usb_serial_port *port = serial->port[0];
struct ftdi_private *priv;
+ struct ftdi_sio_quirk *quirk;
dbg("%s",__FUNCTION__);
@@ -1400,150 +1112,49 @@ static int ftdi_common_startup (struct usb_serial *serial)
port->bulk_out_buffer = NULL;
usb_set_serial_port_data(serial->port[0], priv);
-
- return (0);
-}
-
-
-/* Startup for the SIO chip */
-/* Called from usbserial:serial_probe */
-static int ftdi_SIO_startup (struct usb_serial *serial)
-{
- struct ftdi_private *priv;
- int err;
-
- dbg("%s",__FUNCTION__);
-
- err = ftdi_common_startup(serial);
- if (err){
- return (err);
- }
-
- priv = usb_get_serial_port_data(serial->port[0]);
- priv->chip_type = SIO;
- priv->baud_base = 12000000 / 16;
- priv->write_offset = 1;
-
- return (0);
-}
-
-/* Startup for the 8U232AM chip */
-/* Called from usbserial:serial_probe */
-static int ftdi_8U232AM_startup (struct usb_serial *serial)
-{ /* ftdi_8U232AM_startup */
- struct ftdi_private *priv;
- int err;
-
- dbg("%s",__FUNCTION__);
- err = ftdi_common_startup(serial);
- if (err){
- return (err);
- }
- priv = usb_get_serial_port_data(serial->port[0]);
- priv->chip_type = FT8U232AM;
- priv->baud_base = 48000000 / 2; /* Would be / 16, but FTDI supports 0.125, 0.25 and 0.5 divisor fractions! */
-
+ ftdi_determine_type (serial->port[0]);
create_sysfs_attrs(serial);
-
- return (0);
-} /* ftdi_8U232AM_startup */
-/* Startup for the FT232BM chip */
-/* Called from usbserial:serial_probe */
-static int ftdi_FT232BM_startup (struct usb_serial *serial)
-{ /* ftdi_FT232BM_startup */
- struct ftdi_private *priv;
- int err;
-
- dbg("%s",__FUNCTION__);
- err = ftdi_common_startup(serial);
- if (err){
- return (err);
+ /* Check for device requiring special set up. */
+ quirk = (struct ftdi_sio_quirk *)usb_get_serial_data(serial);
+ if (quirk && quirk->setup) {
+ quirk->setup(serial);
}
-
- priv = usb_get_serial_port_data(serial->port[0]);
- priv->chip_type = FT232BM;
- priv->baud_base = 48000000 / 2; /* Would be / 16, but FT232BM supports multiple of 0.125 divisor fractions! */
- create_sysfs_attrs(serial);
-
return (0);
-} /* ftdi_FT232BM_startup */
-
-/* Startup for the FT2232C chip */
-/* Called from usbserial:serial_probe */
-static int ftdi_FT2232C_startup (struct usb_serial *serial)
-{ /* ftdi_FT2232C_startup */
- struct ftdi_private *priv;
- int err;
- int inter;
-
- dbg("%s",__FUNCTION__);
- err = ftdi_common_startup(serial);
- if (err){
- return (err);
- }
+} /* ftdi_sio_attach */
- priv = usb_get_serial_port_data(serial->port[0]);
- priv->chip_type = FT2232C;
- inter = serial->interface->altsetting->desc.bInterfaceNumber;
- if (inter) {
- priv->interface = PIT_SIOB;
- }
- else {
- priv->interface = PIT_SIOA;
- }
- priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */
-
- create_sysfs_attrs(serial);
-
- return (0);
-} /* ftdi_FT2232C_startup */
-
-/* Startup for the USB-UIRT device, which requires hardwired baudrate (38400 gets mapped to 312500) */
+/* Setup for the USB-UIRT device, which requires hardwired
+ * baudrate (38400 gets mapped to 312500) */
/* Called from usbserial:serial_probe */
-static int ftdi_USB_UIRT_startup (struct usb_serial *serial)
-{ /* ftdi_USB_UIRT_startup */
+static void ftdi_USB_UIRT_setup (struct usb_serial *serial)
+{
struct ftdi_private *priv;
- int err;
dbg("%s",__FUNCTION__);
- err = ftdi_8U232AM_startup(serial);
- if (err){
- return (err);
- }
priv = usb_get_serial_port_data(serial->port[0]);
priv->flags |= ASYNC_SPD_CUST;
priv->custom_divisor = 77;
priv->force_baud = B38400;
-
- return (0);
-} /* ftdi_USB_UIRT_startup */
+} /* ftdi_USB_UIRT_setup */
-/* Startup for the HE-TIRA1 device, which requires hardwired
- * baudrate (38400 gets mapped to 100000) */
-static int ftdi_HE_TIRA1_startup (struct usb_serial *serial)
-{ /* ftdi_HE_TIRA1_startup */
+/* Setup for the HE-TIRA1 device, which requires hardwired
+ * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
+static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
+{
struct ftdi_private *priv;
- int err;
dbg("%s",__FUNCTION__);
- err = ftdi_FT232BM_startup(serial);
- if (err){
- return (err);
- }
priv = usb_get_serial_port_data(serial->port[0]);
priv->flags |= ASYNC_SPD_CUST;
priv->custom_divisor = 240;
priv->force_baud = B38400;
priv->force_rtscts = 1;
-
- return (0);
-} /* ftdi_HE_TIRA1_startup */
+} /* ftdi_HE_TIRA1_setup */
/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
@@ -2367,60 +1978,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
{
struct ftdi_private *priv = usb_get_serial_port_data(port);
- int ret, mask;
-
dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
/* Based on code from acm.c and others */
switch (cmd) {
- case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
- dbg("%s TIOCMBIS", __FUNCTION__);
- if (get_user(mask, (unsigned long __user *) arg))
- return -EFAULT;
- if (mask & TIOCM_DTR){
- if ((ret = set_dtr(port, HIGH)) < 0) {
- err("Urb to set DTR failed");
- return(ret);
- }
- }
- if (mask & TIOCM_RTS) {
- if ((ret = set_rts(port, HIGH)) < 0){
- err("Urb to set RTS failed");
- return(ret);
- }
- }
- return(0);
- break;
-
- case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
- dbg("%s TIOCMBIC", __FUNCTION__);
- if (get_user(mask, (unsigned long __user *) arg))
- return -EFAULT;
- if (mask & TIOCM_DTR){
- if ((ret = set_dtr(port, LOW)) < 0){
- err("Urb to unset DTR failed");
- return(ret);
- }
- }
- if (mask & TIOCM_RTS) {
- if ((ret = set_rts(port, LOW)) < 0){
- err("Urb to unset RTS failed");
- return(ret);
- }
- }
- return(0);
- break;
-
- /*
- * I had originally implemented TCSET{A,S}{,F,W} and
- * TCGET{A,S} here separately, however when testing I
- * found that the higher layers actually do the termios
- * conversions themselves and pass the call onto
- * ftdi_sio_set_termios.
- *
- */
-
case TIOCGSERIAL: /* gets serial port data */
return get_serial_info(port, (struct serial_struct __user *) arg);
@@ -2516,24 +2078,9 @@ static int __init ftdi_init (void)
int retval;
dbg("%s", __FUNCTION__);
- retval = usb_serial_register(&ftdi_SIO_device);
- if (retval)
- goto failed_SIO_register;
- retval = usb_serial_register(&ftdi_8U232AM_device);
- if (retval)
- goto failed_8U232AM_register;
- retval = usb_serial_register(&ftdi_FT232BM_device);
- if (retval)
- goto failed_FT232BM_register;
- retval = usb_serial_register(&ftdi_FT2232C_device);
- if (retval)
- goto failed_FT2232C_register;
- retval = usb_serial_register(&ftdi_USB_UIRT_device);
- if (retval)
- goto failed_USB_UIRT_register;
- retval = usb_serial_register(&ftdi_HE_TIRA1_device);
+ retval = usb_serial_register(&ftdi_sio_device);
if (retval)
- goto failed_HE_TIRA1_register;
+ goto failed_sio_register;
retval = usb_register(&ftdi_driver);
if (retval)
goto failed_usb_register;
@@ -2541,18 +2088,8 @@ static int __init ftdi_init (void)
info(DRIVER_VERSION ":" DRIVER_DESC);
return 0;
failed_usb_register:
- usb_serial_deregister(&ftdi_HE_TIRA1_device);
-failed_HE_TIRA1_register:
- usb_serial_deregister(&ftdi_USB_UIRT_device);
-failed_USB_UIRT_register:
- usb_serial_deregister(&ftdi_FT2232C_device);
-failed_FT2232C_register:
- usb_serial_deregister(&ftdi_FT232BM_device);
-failed_FT232BM_register:
- usb_serial_deregister(&ftdi_8U232AM_device);
-failed_8U232AM_register:
- usb_serial_deregister(&ftdi_SIO_device);
-failed_SIO_register:
+ usb_serial_deregister(&ftdi_sio_device);
+failed_sio_register:
return retval;
}
@@ -2563,12 +2100,7 @@ static void __exit ftdi_exit (void)
dbg("%s", __FUNCTION__);
usb_deregister (&ftdi_driver);
- usb_serial_deregister (&ftdi_HE_TIRA1_device);
- usb_serial_deregister (&ftdi_USB_UIRT_device);
- usb_serial_deregister (&ftdi_FT2232C_device);
- usb_serial_deregister (&ftdi_FT232BM_device);
- usb_serial_deregister (&ftdi_8U232AM_device);
- usb_serial_deregister (&ftdi_SIO_device);
+ usb_serial_deregister (&ftdi_sio_device);
}
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 9fcc7bd1fbe..bd0ab3039bd 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -697,7 +697,7 @@ UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133,
UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
"Microtech",
"USB-SCSI-HD50",
- US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
+ US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
#ifdef CONFIG_USB_STORAGE_DPCM
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 312cf3220f1..8a9c4282250 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -516,6 +516,7 @@ static void w1_slave_found(unsigned long data, u64 rn)
struct w1_reg_num *tmp;
int family_found = 0;
struct w1_master *dev;
+ u64 rn_le = cpu_to_le64(rn);
dev = w1_search_master(data);
if (!dev) {
@@ -544,10 +545,8 @@ static void w1_slave_found(unsigned long data, u64 rn)
slave_count++;
}
- rn = cpu_to_le64(rn);
-
if (slave_count == dev->slave_count &&
- rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) {
+ rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn_le, 7)) {
w1_attach_slave_device(dev, tmp);
}
diff --git a/fs/Kconfig b/fs/Kconfig
index f93fd41b025..5d0c4be43db 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -359,6 +359,19 @@ config ROMFS_FS
If you don't know whether you need it, then you don't need it:
answer N.
+config INOTIFY
+ bool "Inotify file change notification support"
+ default y
+ ---help---
+ Say Y here to enable inotify support and the /dev/inotify character
+ device. Inotify is a file change notification system and a
+ replacement for dnotify. Inotify fixes numerous shortcomings in
+ dnotify and introduces several new features. It allows monitoring
+ of both files and directories via a single open fd. Multiple file
+ events are supported.
+
+ If unsure, say Y.
+
config QUOTA
bool "Quota support"
help
diff --git a/fs/Makefile b/fs/Makefile
index 20edcf28bfd..cf95eb894fd 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -12,6 +12,7 @@ obj-y := open.o read_write.o file_table.o buffer.o bio.o super.o \
seq_file.o xattr.o libfs.o fs-writeback.o mpage.o direct-io.o \
ioprio.o
+obj-$(CONFIG_INOTIFY) += inotify.o
obj-$(CONFIG_EPOLL) += eventpoll.o
obj-$(CONFIG_COMPAT) += compat.o
diff --git a/fs/attr.c b/fs/attr.c
index c3c76fe7834..b1796fb9e52 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -10,7 +10,7 @@
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/fcntl.h>
#include <linux/quotaops.h>
#include <linux/security.h>
@@ -107,31 +107,8 @@ int inode_setattr(struct inode * inode, struct iattr * attr)
out:
return error;
}
-
EXPORT_SYMBOL(inode_setattr);
-int setattr_mask(unsigned int ia_valid)
-{
- unsigned long dn_mask = 0;
-
- if (ia_valid & ATTR_UID)
- dn_mask |= DN_ATTRIB;
- if (ia_valid & ATTR_GID)
- dn_mask |= DN_ATTRIB;
- if (ia_valid & ATTR_SIZE)
- dn_mask |= DN_MODIFY;
- /* both times implies a utime(s) call */
- if ((ia_valid & (ATTR_ATIME|ATTR_MTIME)) == (ATTR_ATIME|ATTR_MTIME))
- dn_mask |= DN_ATTRIB;
- else if (ia_valid & ATTR_ATIME)
- dn_mask |= DN_ACCESS;
- else if (ia_valid & ATTR_MTIME)
- dn_mask |= DN_MODIFY;
- if (ia_valid & ATTR_MODE)
- dn_mask |= DN_ATTRIB;
- return dn_mask;
-}
-
int notify_change(struct dentry * dentry, struct iattr * attr)
{
struct inode *inode = dentry->d_inode;
@@ -197,11 +174,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
if (ia_valid & ATTR_SIZE)
up_write(&dentry->d_inode->i_alloc_sem);
- if (!error) {
- unsigned long dn_mask = setattr_mask(ia_valid);
- if (dn_mask)
- dnotify_parent(dentry, dn_mask);
- }
+ if (!error)
+ fsnotify_change(dentry, ia_valid);
+
return error;
}
diff --git a/fs/char_dev.c b/fs/char_dev.c
index a69a5d8a406..3b1b1eefdbb 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -277,8 +277,9 @@ static struct kobject *cdev_get(struct cdev *p)
void cdev_put(struct cdev *p)
{
if (p) {
+ struct module *owner = p->owner;
kobject_put(&p->kobj);
- module_put(p->owner);
+ module_put(owner);
}
}
diff --git a/fs/compat.c b/fs/compat.c
index 728cd836538..6b06b6bae35 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -37,7 +37,7 @@
#include <linux/ctype.h>
#include <linux/module.h>
#include <linux/dirent.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/highuid.h>
#include <linux/sunrpc/svc.h>
#include <linux/nfsd/nfsd.h>
@@ -1307,9 +1307,13 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
out:
if (iov != iovstack)
kfree(iov);
- if ((ret + (type == READ)) > 0)
- dnotify_parent(file->f_dentry,
- (type == READ) ? DN_ACCESS : DN_MODIFY);
+ if ((ret + (type == READ)) > 0) {
+ struct dentry *dentry = file->f_dentry;
+ if (type == READ)
+ fsnotify_access(dentry);
+ else
+ fsnotify_modify(dentry);
+ }
return ret;
}
diff --git a/fs/exec.c b/fs/exec.c
index 48871917d36..222ab1c572d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -642,6 +642,18 @@ static inline int de_thread(struct task_struct *tsk)
count = 2;
if (thread_group_leader(current))
count = 1;
+ else {
+ /*
+ * The SIGALRM timer survives the exec, but needs to point
+ * at us as the new group leader now. We have a race with
+ * a timer firing now getting the old leader, so we need to
+ * synchronize with any firing (by calling del_timer_sync)
+ * before we can safely let the old group leader die.
+ */
+ sig->real_timer.data = (unsigned long)current;
+ if (del_timer_sync(&sig->real_timer))
+ add_timer(&sig->real_timer);
+ }
while (atomic_read(&sig->count) > count) {
sig->group_exit_task = current;
sig->notify_count = count;
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index eed521d22cf..e977f8566d1 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -2,6 +2,15 @@
#include <linux/ext2_fs.h>
/*
+ * ext2 mount options
+ */
+struct ext2_mount_options {
+ unsigned long s_mount_opt;
+ uid_t s_resuid;
+ gid_t s_resgid;
+};
+
+/*
* second extended file system inode data in memory
*/
struct ext2_inode_info {
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 876e391f287..dcfe331dc4c 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -936,12 +936,23 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
struct ext2_sb_info * sbi = EXT2_SB(sb);
struct ext2_super_block * es;
unsigned long old_mount_opt = sbi->s_mount_opt;
+ struct ext2_mount_options old_opts;
+ unsigned long old_sb_flags;
+ int err;
+
+ /* Store the old options */
+ old_sb_flags = sb->s_flags;
+ old_opts.s_mount_opt = sbi->s_mount_opt;
+ old_opts.s_resuid = sbi->s_resuid;
+ old_opts.s_resgid = sbi->s_resgid;
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options (data, sbi))
- return -EINVAL;
+ if (!parse_options (data, sbi)) {
+ err = -EINVAL;
+ goto restore_opts;
+ }
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
@@ -971,7 +982,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
printk("EXT2-fs: %s: couldn't remount RDWR because of "
"unsupported optional features (%x).\n",
sb->s_id, le32_to_cpu(ret));
- return -EROFS;
+ err = -EROFS;
+ goto restore_opts;
}
/*
* Mounting a RDONLY partition read-write, so reread and
@@ -984,6 +996,12 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
}
ext2_sync_super(sb, es);
return 0;
+restore_opts:
+ sbi->s_mount_opt = old_opts.s_mount_opt;
+ sbi->s_resuid = old_opts.s_resuid;
+ sbi->s_resgid = old_opts.s_resgid;
+ sb->s_flags = old_sb_flags;
+ return err;
}
static int ext2_statfs (struct super_block * sb, struct kstatfs * buf)
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index a6d1779d7de..3c3c6e399fb 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -890,7 +890,10 @@ clear_qf_name:
"quota turned on.\n");
return 0;
}
- kfree(sbi->s_qf_names[qtype]);
+ /*
+ * The space will be released later when all options
+ * are confirmed to be correct
+ */
sbi->s_qf_names[qtype] = NULL;
break;
case Opt_jqfmt_vfsold:
@@ -939,7 +942,7 @@ clear_qf_name:
case Opt_ignore:
break;
case Opt_resize:
- if (!n_blocks_count) {
+ if (!is_remount) {
printk("EXT3-fs: resize option only available "
"for remount\n");
return 0;
@@ -2109,14 +2112,33 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
{
struct ext3_super_block * es;
struct ext3_sb_info *sbi = EXT3_SB(sb);
- unsigned long tmp;
unsigned long n_blocks_count = 0;
+ unsigned long old_sb_flags;
+ struct ext3_mount_options old_opts;
+ int err;
+#ifdef CONFIG_QUOTA
+ int i;
+#endif
+
+ /* Store the original options */
+ old_sb_flags = sb->s_flags;
+ old_opts.s_mount_opt = sbi->s_mount_opt;
+ old_opts.s_resuid = sbi->s_resuid;
+ old_opts.s_resgid = sbi->s_resgid;
+ old_opts.s_commit_interval = sbi->s_commit_interval;
+#ifdef CONFIG_QUOTA
+ old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
+ for (i = 0; i < MAXQUOTAS; i++)
+ old_opts.s_qf_names[i] = sbi->s_qf_names[i];
+#endif
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options(data, sb, &tmp, &n_blocks_count, 1))
- return -EINVAL;
+ if (!parse_options(data, sb, NULL, &n_blocks_count, 1)) {
+ err = -EINVAL;
+ goto restore_opts;
+ }
if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
ext3_abort(sb, __FUNCTION__, "Abort forced by user");
@@ -2130,8 +2152,10 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
n_blocks_count > le32_to_cpu(es->s_blocks_count)) {
- if (sbi->s_mount_opt & EXT3_MOUNT_ABORT)
- return -EROFS;
+ if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) {
+ err = -EROFS;
+ goto restore_opts;
+ }
if (*flags & MS_RDONLY) {
/*
@@ -2158,7 +2182,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
"remount RDWR because of unsupported "
"optional features (%x).\n",
sb->s_id, le32_to_cpu(ret));
- return -EROFS;
+ err = -EROFS;
+ goto restore_opts;
}
/*
* Mounting a RDONLY partition read-write, so reread
@@ -2168,13 +2193,38 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
*/
ext3_clear_journal_err(sb, es);
sbi->s_mount_state = le16_to_cpu(es->s_state);
- if ((ret = ext3_group_extend(sb, es, n_blocks_count)))
- return ret;
+ if ((ret = ext3_group_extend(sb, es, n_blocks_count))) {
+ err = ret;
+ goto restore_opts;
+ }
if (!ext3_setup_super (sb, es, 0))
sb->s_flags &= ~MS_RDONLY;
}
}
+#ifdef CONFIG_QUOTA
+ /* Release old quota file names */
+ for (i = 0; i < MAXQUOTAS; i++)
+ if (old_opts.s_qf_names[i] &&
+ old_opts.s_qf_names[i] != sbi->s_qf_names[i])
+ kfree(old_opts.s_qf_names[i]);
+#endif
return 0;
+restore_opts:
+ sb->s_flags = old_sb_flags;
+ sbi->s_mount_opt = old_opts.s_mount_opt;
+ sbi->s_resuid = old_opts.s_resuid;
+ sbi->s_resgid = old_opts.s_resgid;
+ sbi->s_commit_interval = old_opts.s_commit_interval;
+#ifdef CONFIG_QUOTA
+ sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
+ for (i = 0; i < MAXQUOTAS; i++) {
+ if (sbi->s_qf_names[i] &&
+ old_opts.s_qf_names[i] != sbi->s_qf_names[i])
+ kfree(sbi->s_qf_names[i]);
+ sbi->s_qf_names[i] = old_opts.s_qf_names[i];
+ }
+#endif
+ return err;
}
static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
diff --git a/fs/file_table.c b/fs/file_table.c
index fa7849fae13..1d3de78e6bc 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -16,6 +16,7 @@
#include <linux/eventpoll.h>
#include <linux/mount.h>
#include <linux/cdev.h>
+#include <linux/fsnotify.h>
/* sysctl tunables... */
struct files_stat_struct files_stat = {
@@ -126,6 +127,8 @@ void fastcall __fput(struct file *file)
struct inode *inode = dentry->d_inode;
might_sleep();
+
+ fsnotify_close(file);
/*
* The function eventpoll_release() should be the first called
* in the file cleanup chain.
diff --git a/fs/inode.c b/fs/inode.c
index 6d695037a0a..96364fae084 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -21,6 +21,7 @@
#include <linux/pagemap.h>
#include <linux/cdev.h>
#include <linux/bootmem.h>
+#include <linux/inotify.h>
/*
* This is needed for the following functions:
@@ -202,6 +203,10 @@ void inode_init_once(struct inode *inode)
INIT_LIST_HEAD(&inode->i_data.i_mmap_nonlinear);
spin_lock_init(&inode->i_lock);
i_size_ordered_init(inode);
+#ifdef CONFIG_INOTIFY
+ INIT_LIST_HEAD(&inode->inotify_watches);
+ sema_init(&inode->inotify_sem, 1);
+#endif
}
EXPORT_SYMBOL(inode_init_once);
@@ -282,6 +287,13 @@ static void dispose_list(struct list_head *head)
if (inode->i_data.nrpages)
truncate_inode_pages(&inode->i_data, 0);
clear_inode(inode);
+
+ spin_lock(&inode_lock);
+ hlist_del_init(&inode->i_hash);
+ list_del_init(&inode->i_sb_list);
+ spin_unlock(&inode_lock);
+
+ wake_up_inode(inode);
destroy_inode(inode);
nr_disposed++;
}
@@ -317,8 +329,6 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
inode = list_entry(tmp, struct inode, i_sb_list);
invalidate_inode_buffers(inode);
if (!atomic_read(&inode->i_count)) {
- hlist_del_init(&inode->i_hash);
- list_del(&inode->i_sb_list);
list_move(&inode->i_list, dispose);
inode->i_state |= I_FREEING;
count++;
@@ -346,6 +356,7 @@ int invalidate_inodes(struct super_block * sb)
down(&iprune_sem);
spin_lock(&inode_lock);
+ inotify_unmount_inodes(&sb->s_inodes);
busy = invalidate_list(&sb->s_inodes, &throw_away);
spin_unlock(&inode_lock);
@@ -439,8 +450,6 @@ static void prune_icache(int nr_to_scan)
if (!can_unuse(inode))
continue;
}
- hlist_del_init(&inode->i_hash);
- list_del_init(&inode->i_sb_list);
list_move(&inode->i_list, &freeable);
inode->i_state |= I_FREEING;
nr_pruned++;
@@ -1244,29 +1253,21 @@ int inode_wait(void *word)
}
/*
- * If we try to find an inode in the inode hash while it is being deleted, we
- * have to wait until the filesystem completes its deletion before reporting
- * that it isn't found. This is because iget will immediately call
- * ->read_inode, and we want to be sure that evidence of the deletion is found
- * by ->read_inode.
+ * If we try to find an inode in the inode hash while it is being
+ * deleted, we have to wait until the filesystem completes its
+ * deletion before reporting that it isn't found. This function waits
+ * until the deletion _might_ have completed. Callers are responsible
+ * to recheck inode state.
+ *
+ * It doesn't matter if I_LOCK is not set initially, a call to
+ * wake_up_inode() after removing from the hash list will DTRT.
+ *
* This is called with inode_lock held.
*/
static void __wait_on_freeing_inode(struct inode *inode)
{
wait_queue_head_t *wq;
DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK);
-
- /*
- * I_FREEING and I_CLEAR are cleared in process context under
- * inode_lock, so we have to give the tasks who would clear them
- * a chance to run and acquire inode_lock.
- */
- if (!(inode->i_state & I_LOCK)) {
- spin_unlock(&inode_lock);
- yield();
- spin_lock(&inode_lock);
- return;
- }
wq = bit_waitqueue(&inode->i_state, __I_LOCK);
prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
spin_unlock(&inode_lock);
diff --git a/fs/inotify.c b/fs/inotify.c
new file mode 100644
index 00000000000..e423bfe0c86
--- /dev/null
+++ b/fs/inotify.c
@@ -0,0 +1,999 @@
+/*
+ * fs/inotify.c - inode-based file event notifications
+ *
+ * Authors:
+ * John McCutchan <ttb@tentacle.dhs.org>
+ * Robert Love <rml@novell.com>
+ *
+ * Copyright (C) 2005 John McCutchan
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/idr.h>
+#include <linux/slab.h>
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/mount.h>
+#include <linux/namei.h>
+#include <linux/poll.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/writeback.h>
+#include <linux/inotify.h>
+
+#include <asm/ioctls.h>
+
+static atomic_t inotify_cookie;
+
+static kmem_cache_t *watch_cachep;
+static kmem_cache_t *event_cachep;
+
+static struct vfsmount *inotify_mnt;
+
+/* These are configurable via /proc/sys/inotify */
+int inotify_max_user_devices;
+int inotify_max_user_watches;
+int inotify_max_queued_events;
+
+/*
+ * Lock ordering:
+ *
+ * dentry->d_lock (used to keep d_move() away from dentry->d_parent)
+ * iprune_sem (synchronize shrink_icache_memory())
+ * inode_lock (protects the super_block->s_inodes list)
+ * inode->inotify_sem (protects inode->inotify_watches and watches->i_list)
+ * inotify_dev->sem (protects inotify_device and watches->d_list)
+ */
+
+/*
+ * Lifetimes of the three main data structures--inotify_device, inode, and
+ * inotify_watch--are managed by reference count.
+ *
+ * inotify_device: Lifetime is from open until release. Additional references
+ * can bump the count via get_inotify_dev() and drop the count via
+ * put_inotify_dev().
+ *
+ * inotify_watch: Lifetime is from create_watch() to destory_watch().
+ * Additional references can bump the count via get_inotify_watch() and drop
+ * the count via put_inotify_watch().
+ *
+ * inode: Pinned so long as the inode is associated with a watch, from
+ * create_watch() to put_inotify_watch().
+ */
+
+/*
+ * struct inotify_device - represents an open instance of an inotify device
+ *
+ * This structure is protected by the semaphore 'sem'.
+ */
+struct inotify_device {
+ wait_queue_head_t wq; /* wait queue for i/o */
+ struct idr idr; /* idr mapping wd -> watch */
+ struct semaphore sem; /* protects this bad boy */
+ struct list_head events; /* list of queued events */
+ struct list_head watches; /* list of watches */
+ atomic_t count; /* reference count */
+ struct user_struct *user; /* user who opened this dev */
+ unsigned int queue_size; /* size of the queue (bytes) */
+ unsigned int event_count; /* number of pending events */
+ unsigned int max_events; /* maximum number of events */
+};
+
+/*
+ * struct inotify_kernel_event - An inotify event, originating from a watch and
+ * queued for user-space. A list of these is attached to each instance of the
+ * device. In read(), this list is walked and all events that can fit in the
+ * buffer are returned.
+ *
+ * Protected by dev->sem of the device in which we are queued.
+ */
+struct inotify_kernel_event {
+ struct inotify_event event; /* the user-space event */
+ struct list_head list; /* entry in inotify_device's list */
+ char *name; /* filename, if any */
+};
+
+/*
+ * struct inotify_watch - represents a watch request on a specific inode
+ *
+ * d_list is protected by dev->sem of the associated watch->dev.
+ * i_list and mask are protected by inode->inotify_sem of the associated inode.
+ * dev, inode, and wd are never written to once the watch is created.
+ */
+struct inotify_watch {
+ struct list_head d_list; /* entry in inotify_device's list */
+ struct list_head i_list; /* entry in inode's list */
+ atomic_t count; /* reference count */
+ struct inotify_device *dev; /* associated device */
+ struct inode *inode; /* associated inode */
+ s32 wd; /* watch descriptor */
+ u32 mask; /* event mask for this watch */
+};
+
+static inline void get_inotify_dev(struct inotify_device *dev)
+{
+ atomic_inc(&dev->count);
+}
+
+static inline void put_inotify_dev(struct inotify_device *dev)
+{
+ if (atomic_dec_and_test(&dev->count)) {
+ atomic_dec(&dev->user->inotify_devs);
+ free_uid(dev->user);
+ kfree(dev);
+ }
+}
+
+static inline void get_inotify_watch(struct inotify_watch *watch)
+{
+ atomic_inc(&watch->count);
+}
+
+/*
+ * put_inotify_watch - decrements the ref count on a given watch. cleans up
+ * the watch and its references if the count reaches zero.
+ */
+static inline void put_inotify_watch(struct inotify_watch *watch)
+{
+ if (atomic_dec_and_test(&watch->count)) {
+ put_inotify_dev(watch->dev);
+ iput(watch->inode);
+ kmem_cache_free(watch_cachep, watch);
+ }
+}
+
+/*
+ * kernel_event - create a new kernel event with the given parameters
+ *
+ * This function can sleep.
+ */
+static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
+ const char *name)
+{
+ struct inotify_kernel_event *kevent;
+
+ kevent = kmem_cache_alloc(event_cachep, GFP_KERNEL);
+ if (unlikely(!kevent))
+ return NULL;
+
+ /* we hand this out to user-space, so zero it just in case */
+ memset(&kevent->event, 0, sizeof(struct inotify_event));
+
+ kevent->event.wd = wd;
+ kevent->event.mask = mask;
+ kevent->event.cookie = cookie;
+
+ INIT_LIST_HEAD(&kevent->list);
+
+ if (name) {
+ size_t len, rem, event_size = sizeof(struct inotify_event);
+
+ /*
+ * We need to pad the filename so as to properly align an
+ * array of inotify_event structures. Because the structure is
+ * small and the common case is a small filename, we just round
+ * up to the next multiple of the structure's sizeof. This is
+ * simple and safe for all architectures.
+ */
+ len = strlen(name) + 1;
+ rem = event_size - len;
+ if (len > event_size) {
+ rem = event_size - (len % event_size);
+ if (len % event_size == 0)
+ rem = 0;
+ }
+
+ kevent->name = kmalloc(len + rem, GFP_KERNEL);
+ if (unlikely(!kevent->name)) {
+ kmem_cache_free(event_cachep, kevent);
+ return NULL;
+ }
+ memcpy(kevent->name, name, len);
+ if (rem)
+ memset(kevent->name + len, 0, rem);
+ kevent->event.len = len + rem;
+ } else {
+ kevent->event.len = 0;
+ kevent->name = NULL;
+ }
+
+ return kevent;
+}
+
+/*
+ * inotify_dev_get_event - return the next event in the given dev's queue
+ *
+ * Caller must hold dev->sem.
+ */
+static inline struct inotify_kernel_event *
+inotify_dev_get_event(struct inotify_device *dev)
+{
+ return list_entry(dev->events.next, struct inotify_kernel_event, list);
+}
+
+/*
+ * inotify_dev_queue_event - add a new event to the given device
+ *
+ * Caller must hold dev->sem. Can sleep (calls kernel_event()).
+ */
+static void inotify_dev_queue_event(struct inotify_device *dev,
+ struct inotify_watch *watch, u32 mask,
+ u32 cookie, const char *name)
+{
+ struct inotify_kernel_event *kevent, *last;
+
+ /* coalescing: drop this event if it is a dupe of the previous */
+ last = inotify_dev_get_event(dev);
+ if (last && last->event.mask == mask && last->event.wd == watch->wd &&
+ last->event.cookie == cookie) {
+ const char *lastname = last->name;
+
+ if (!name && !lastname)
+ return;
+ if (name && lastname && !strcmp(lastname, name))
+ return;
+ }
+
+ /* the queue overflowed and we already sent the Q_OVERFLOW event */
+ if (unlikely(dev->event_count > dev->max_events))
+ return;
+
+ /* if the queue overflows, we need to notify user space */
+ if (unlikely(dev->event_count == dev->max_events))
+ kevent = kernel_event(-1, IN_Q_OVERFLOW, cookie, NULL);
+ else
+ kevent = kernel_event(watch->wd, mask, cookie, name);
+
+ if (unlikely(!kevent))
+ return;
+
+ /* queue the event and wake up anyone waiting */
+ dev->event_count++;
+ dev->queue_size += sizeof(struct inotify_event) + kevent->event.len;
+ list_add_tail(&kevent->list, &dev->events);
+ wake_up_interruptible(&dev->wq);
+}
+
+/*
+ * remove_kevent - cleans up and ultimately frees the given kevent
+ *
+ * Caller must hold dev->sem.
+ */
+static void remove_kevent(struct inotify_device *dev,
+ struct inotify_kernel_event *kevent)
+{
+ list_del(&kevent->list);
+
+ dev->event_count--;
+ dev->queue_size -= sizeof(struct inotify_event) + kevent->event.len;
+
+ kfree(kevent->name);
+ kmem_cache_free(event_cachep, kevent);
+}
+
+/*
+ * inotify_dev_event_dequeue - destroy an event on the given device
+ *
+ * Caller must hold dev->sem.
+ */
+static void inotify_dev_event_dequeue(struct inotify_device *dev)
+{
+ if (!list_empty(&dev->events)) {
+ struct inotify_kernel_event *kevent;
+ kevent = inotify_dev_get_event(dev);
+ remove_kevent(dev, kevent);
+ }
+}
+
+/*
+ * inotify_dev_get_wd - returns the next WD for use by the given dev
+ *
+ * Callers must hold dev->sem. This function can sleep.
+ */
+static int inotify_dev_get_wd(struct inotify_device *dev,
+ struct inotify_watch *watch)
+{
+ int ret;
+
+ do {
+ if (unlikely(!idr_pre_get(&dev->idr, GFP_KERNEL)))
+ return -ENOSPC;
+ ret = idr_get_new(&dev->idr, watch, &watch->wd);
+ } while (ret == -EAGAIN);
+
+ return ret;
+}
+
+/*
+ * find_inode - resolve a user-given path to a specific inode and return a nd
+ */
+static int find_inode(const char __user *dirname, struct nameidata *nd)
+{
+ int error;
+
+ error = __user_walk(dirname, LOOKUP_FOLLOW, nd);
+ if (error)
+ return error;
+ /* you can only watch an inode if you have read permissions on it */
+ error = permission(nd->dentry->d_inode, MAY_READ, NULL);
+ if (error)
+ path_release (nd);
+ return error;
+}
+
+/*
+ * create_watch - creates a watch on the given device.
+ *
+ * Callers must hold dev->sem. Calls inotify_dev_get_wd() so may sleep.
+ * Both 'dev' and 'inode' (by way of nameidata) need to be pinned.
+ */
+static struct inotify_watch *create_watch(struct inotify_device *dev,
+ u32 mask, struct inode *inode)
+{
+ struct inotify_watch *watch;
+ int ret;
+
+ if (atomic_read(&dev->user->inotify_watches) >= inotify_max_user_watches)
+ return ERR_PTR(-ENOSPC);
+
+ watch = kmem_cache_alloc(watch_cachep, GFP_KERNEL);
+ if (unlikely(!watch))
+ return ERR_PTR(-ENOMEM);
+
+ ret = inotify_dev_get_wd(dev, watch);
+ if (unlikely(ret)) {
+ kmem_cache_free(watch_cachep, watch);
+ return ERR_PTR(ret);
+ }
+
+ watch->mask = mask;
+ atomic_set(&watch->count, 0);
+ INIT_LIST_HEAD(&watch->d_list);
+ INIT_LIST_HEAD(&watch->i_list);
+
+ /* save a reference to device and bump the count to make it official */
+ get_inotify_dev(dev);
+ watch->dev = dev;
+
+ /*
+ * Save a reference to the inode and bump the ref count to make it
+ * official. We hold a reference to nameidata, which makes this safe.
+ */
+ watch->inode = igrab(inode);
+
+ /* bump our own count, corresponding to our entry in dev->watches */
+ get_inotify_watch(watch);
+
+ atomic_inc(&dev->user->inotify_watches);
+
+ return watch;
+}
+
+/*
+ * inotify_find_dev - find the watch associated with the given inode and dev
+ *
+ * Callers must hold inode->inotify_sem.
+ */
+static struct inotify_watch *inode_find_dev(struct inode *inode,
+ struct inotify_device *dev)
+{
+ struct inotify_watch *watch;
+
+ list_for_each_entry(watch, &inode->inotify_watches, i_list) {
+ if (watch->dev == dev)
+ return watch;
+ }
+
+ return NULL;
+}
+
+/*
+ * remove_watch_no_event - remove_watch() without the IN_IGNORED event.
+ */
+static void remove_watch_no_event(struct inotify_watch *watch,
+ struct inotify_device *dev)
+{
+ list_del(&watch->i_list);
+ list_del(&watch->d_list);
+
+ atomic_dec(&dev->user->inotify_watches);
+ idr_remove(&dev->idr, watch->wd);
+ put_inotify_watch(watch);
+}
+
+/*
+ * remove_watch - Remove a watch from both the device and the inode. Sends
+ * the IN_IGNORED event to the given device signifying that the inode is no
+ * longer watched.
+ *
+ * Callers must hold both inode->inotify_sem and dev->sem. We drop a
+ * reference to the inode before returning.
+ *
+ * The inode is not iput() so as to remain atomic. If the inode needs to be
+ * iput(), the call returns one. Otherwise, it returns zero.
+ */
+static void remove_watch(struct inotify_watch *watch,struct inotify_device *dev)
+{
+ inotify_dev_queue_event(dev, watch, IN_IGNORED, 0, NULL);
+ remove_watch_no_event(watch, dev);
+}
+
+/*
+ * inotify_inode_watched - returns nonzero if there are watches on this inode
+ * and zero otherwise. We call this lockless, we do not care if we race.
+ */
+static inline int inotify_inode_watched(struct inode *inode)
+{
+ return !list_empty(&inode->inotify_watches);
+}
+
+/* Kernel API */
+
+/**
+ * inotify_inode_queue_event - queue an event to all watches on this inode
+ * @inode: inode event is originating from
+ * @mask: event mask describing this event
+ * @cookie: cookie for synchronization, or zero
+ * @name: filename, if any
+ */
+void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
+ const char *name)
+{
+ struct inotify_watch *watch, *next;
+
+ if (!inotify_inode_watched(inode))
+ return;
+
+ down(&inode->inotify_sem);
+ list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
+ u32 watch_mask = watch->mask;
+ if (watch_mask & mask) {
+ struct inotify_device *dev = watch->dev;
+ get_inotify_watch(watch);
+ down(&dev->sem);
+ inotify_dev_queue_event(dev, watch, mask, cookie, name);
+ if (watch_mask & IN_ONESHOT)
+ remove_watch_no_event(watch, dev);
+ up(&dev->sem);
+ put_inotify_watch(watch);
+ }
+ }
+ up(&inode->inotify_sem);
+}
+EXPORT_SYMBOL_GPL(inotify_inode_queue_event);
+
+/**
+ * inotify_dentry_parent_queue_event - queue an event to a dentry's parent
+ * @dentry: the dentry in question, we queue against this dentry's parent
+ * @mask: event mask describing this event
+ * @cookie: cookie for synchronization, or zero
+ * @name: filename, if any
+ */
+void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
+ u32 cookie, const char *name)
+{
+ struct dentry *parent;
+ struct inode *inode;
+
+ spin_lock(&dentry->d_lock);
+ parent = dentry->d_parent;
+ inode = parent->d_inode;
+
+ if (inotify_inode_watched(inode)) {
+ dget(parent);
+ spin_unlock(&dentry->d_lock);
+ inotify_inode_queue_event(inode, mask, cookie, name);
+ dput(parent);
+ } else
+ spin_unlock(&dentry->d_lock);
+}
+EXPORT_SYMBOL_GPL(inotify_dentry_parent_queue_event);
+
+/**
+ * inotify_get_cookie - return a unique cookie for use in synchronizing events.
+ */
+u32 inotify_get_cookie(void)
+{
+ return atomic_inc_return(&inotify_cookie);
+}
+EXPORT_SYMBOL_GPL(inotify_get_cookie);
+
+/**
+ * inotify_unmount_inodes - an sb is unmounting. handle any watched inodes.
+ * @list: list of inodes being unmounted (sb->s_inodes)
+ *
+ * Called with inode_lock held, protecting the unmounting super block's list
+ * of inodes, and with iprune_sem held, keeping shrink_icache_memory() at bay.
+ * We temporarily drop inode_lock, however, and CAN block.
+ */
+void inotify_unmount_inodes(struct list_head *list)
+{
+ struct inode *inode, *next_i, *need_iput = NULL;
+
+ list_for_each_entry_safe(inode, next_i, list, i_sb_list) {
+ struct inotify_watch *watch, *next_w;
+ struct inode *need_iput_tmp;
+ struct list_head *watches;
+
+ /*
+ * If i_count is zero, the inode cannot have any watches and
+ * doing an __iget/iput with MS_ACTIVE clear would actually
+ * evict all inodes with zero i_count from icache which is
+ * unnecessarily violent and may in fact be illegal to do.
+ */
+ if (!atomic_read(&inode->i_count))
+ continue;
+
+ /*
+ * We cannot __iget() an inode in state I_CLEAR, I_FREEING, or
+ * I_WILL_FREE which is fine because by that point the inode
+ * cannot have any associated watches.
+ */
+ if (inode->i_state & (I_CLEAR | I_FREEING | I_WILL_FREE))
+ continue;
+
+ need_iput_tmp = need_iput;
+ need_iput = NULL;
+ /* In case the remove_watch() drops a reference. */
+ if (inode != need_iput_tmp)
+ __iget(inode);
+ else
+ need_iput_tmp = NULL;
+ /* In case the dropping of a reference would nuke next_i. */
+ if ((&next_i->i_sb_list != list) &&
+ atomic_read(&next_i->i_count) &&
+ !(next_i->i_state & (I_CLEAR | I_FREEING |
+ I_WILL_FREE))) {
+ __iget(next_i);
+ need_iput = next_i;
+ }
+
+ /*
+ * We can safely drop inode_lock here because we hold
+ * references on both inode and next_i. Also no new inodes
+ * will be added since the umount has begun. Finally,
+ * iprune_sem keeps shrink_icache_memory() away.
+ */
+ spin_unlock(&inode_lock);
+
+ if (need_iput_tmp)
+ iput(need_iput_tmp);
+
+ /* for each watch, send IN_UNMOUNT and then remove it */
+ down(&inode->inotify_sem);
+ watches = &inode->inotify_watches;
+ list_for_each_entry_safe(watch, next_w, watches, i_list) {
+ struct inotify_device *dev = watch->dev;
+ down(&dev->sem);
+ inotify_dev_queue_event(dev, watch, IN_UNMOUNT,0,NULL);
+ remove_watch(watch, dev);
+ up(&dev->sem);
+ }
+ up(&inode->inotify_sem);
+ iput(inode);
+
+ spin_lock(&inode_lock);
+ }
+}
+EXPORT_SYMBOL_GPL(inotify_unmount_inodes);
+
+/**
+ * inotify_inode_is_dead - an inode has been deleted, cleanup any watches
+ * @inode: inode that is about to be removed
+ */
+void inotify_inode_is_dead(struct inode *inode)
+{
+ struct inotify_watch *watch, *next;
+
+ down(&inode->inotify_sem);
+ list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
+ struct inotify_device *dev = watch->dev;
+ down(&dev->sem);
+ remove_watch(watch, dev);
+ up(&dev->sem);
+ }
+ up(&inode->inotify_sem);
+}
+EXPORT_SYMBOL_GPL(inotify_inode_is_dead);
+
+/* Device Interface */
+
+static unsigned int inotify_poll(struct file *file, poll_table *wait)
+{
+ struct inotify_device *dev = file->private_data;
+ int ret = 0;
+
+ poll_wait(file, &dev->wq, wait);
+ down(&dev->sem);
+ if (!list_empty(&dev->events))
+ ret = POLLIN | POLLRDNORM;
+ up(&dev->sem);
+
+ return ret;
+}
+
+static ssize_t inotify_read(struct file *file, char __user *buf,
+ size_t count, loff_t *pos)
+{
+ size_t event_size = sizeof (struct inotify_event);
+ struct inotify_device *dev;
+ char __user *start;
+ int ret;
+ DEFINE_WAIT(wait);
+
+ start = buf;
+ dev = file->private_data;
+
+ while (1) {
+ int events;
+
+ prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE);
+
+ down(&dev->sem);
+ events = !list_empty(&dev->events);
+ up(&dev->sem);
+ if (events) {
+ ret = 0;
+ break;
+ }
+
+ if (file->f_flags & O_NONBLOCK) {
+ ret = -EAGAIN;
+ break;
+ }
+
+ if (signal_pending(current)) {
+ ret = -EINTR;
+ break;
+ }
+
+ schedule();
+ }
+
+ finish_wait(&dev->wq, &wait);
+ if (ret)
+ return ret;
+
+ down(&dev->sem);
+ while (1) {
+ struct inotify_kernel_event *kevent;
+
+ ret = buf - start;
+ if (list_empty(&dev->events))
+ break;
+
+ kevent = inotify_dev_get_event(dev);
+ if (event_size + kevent->event.len > count)
+ break;
+
+ if (copy_to_user(buf, &kevent->event, event_size)) {
+ ret = -EFAULT;
+ break;
+ }
+ buf += event_size;
+ count -= event_size;
+
+ if (kevent->name) {
+ if (copy_to_user(buf, kevent->name, kevent->event.len)){
+ ret = -EFAULT;
+ break;
+ }
+ buf += kevent->event.len;
+ count -= kevent->event.len;
+ }
+
+ remove_kevent(dev, kevent);
+ }
+ up(&dev->sem);
+
+ return ret;
+}
+
+static int inotify_release(struct inode *ignored, struct file *file)
+{
+ struct inotify_device *dev = file->private_data;
+
+ /*
+ * Destroy all of the watches on this device. Unfortunately, not very
+ * pretty. We cannot do a simple iteration over the list, because we
+ * do not know the inode until we iterate to the watch. But we need to
+ * hold inode->inotify_sem before dev->sem. The following works.
+ */
+ while (1) {
+ struct inotify_watch *watch;
+ struct list_head *watches;
+ struct inode *inode;
+
+ down(&dev->sem);
+ watches = &dev->watches;
+ if (list_empty(watches)) {
+ up(&dev->sem);
+ break;
+ }
+ watch = list_entry(watches->next, struct inotify_watch, d_list);
+ get_inotify_watch(watch);
+ up(&dev->sem);
+
+ inode = watch->inode;
+ down(&inode->inotify_sem);
+ down(&dev->sem);
+ remove_watch_no_event(watch, dev);
+ up(&dev->sem);
+ up(&inode->inotify_sem);
+ put_inotify_watch(watch);
+ }
+
+ /* destroy all of the events on this device */
+ down(&dev->sem);
+ while (!list_empty(&dev->events))
+ inotify_dev_event_dequeue(dev);
+ up(&dev->sem);
+
+ /* free this device: the put matching the get in inotify_open() */
+ put_inotify_dev(dev);
+
+ return 0;
+}
+
+/*
+ * inotify_ignore - handle the INOTIFY_IGNORE ioctl, asking that a given wd be
+ * removed from the device.
+ *
+ * Can sleep.
+ */
+static int inotify_ignore(struct inotify_device *dev, s32 wd)
+{
+ struct inotify_watch *watch;
+ struct inode *inode;
+
+ down(&dev->sem);
+ watch = idr_find(&dev->idr, wd);
+ if (unlikely(!watch)) {
+ up(&dev->sem);
+ return -EINVAL;
+ }
+ get_inotify_watch(watch);
+ inode = watch->inode;
+ up(&dev->sem);
+
+ down(&inode->inotify_sem);
+ down(&dev->sem);
+
+ /* make sure that we did not race */
+ watch = idr_find(&dev->idr, wd);
+ if (likely(watch))
+ remove_watch(watch, dev);
+
+ up(&dev->sem);
+ up(&inode->inotify_sem);
+ put_inotify_watch(watch);
+
+ return 0;
+}
+
+static long inotify_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ struct inotify_device *dev;
+ void __user *p;
+ int ret = -ENOTTY;
+
+ dev = file->private_data;
+ p = (void __user *) arg;
+
+ switch (cmd) {
+ case FIONREAD:
+ ret = put_user(dev->queue_size, (int __user *) p);
+ break;
+ }
+
+ return ret;
+}
+
+static struct file_operations inotify_fops = {
+ .poll = inotify_poll,
+ .read = inotify_read,
+ .release = inotify_release,
+ .unlocked_ioctl = inotify_ioctl,
+ .compat_ioctl = inotify_ioctl,
+};
+
+asmlinkage long sys_inotify_init(void)
+{
+ struct inotify_device *dev;
+ struct user_struct *user;
+ int ret = -ENOTTY;
+ int fd;
+ struct file *filp;
+
+ fd = get_unused_fd();
+ if (fd < 0) {
+ ret = fd;
+ goto out;
+ }
+
+ filp = get_empty_filp();
+ if (!filp) {
+ put_unused_fd(fd);
+ ret = -ENFILE;
+ goto out;
+ }
+ filp->f_op = &inotify_fops;
+ filp->f_vfsmnt = mntget(inotify_mnt);
+ filp->f_dentry = dget(inotify_mnt->mnt_root);
+ filp->f_mapping = filp->f_dentry->d_inode->i_mapping;
+ filp->f_mode = FMODE_READ;
+ filp->f_flags = O_RDONLY;
+
+ user = get_uid(current->user);
+
+ if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_devices)) {
+ ret = -EMFILE;
+ goto out_err;
+ }
+
+ dev = kmalloc(sizeof(struct inotify_device), GFP_KERNEL);
+ if (unlikely(!dev)) {
+ ret = -ENOMEM;
+ goto out_err;
+ }
+
+ idr_init(&dev->idr);
+ INIT_LIST_HEAD(&dev->events);
+ INIT_LIST_HEAD(&dev->watches);
+ init_waitqueue_head(&dev->wq);
+ sema_init(&dev->sem, 1);
+ dev->event_count = 0;
+ dev->queue_size = 0;
+ dev->max_events = inotify_max_queued_events;
+ dev->user = user;
+ atomic_set(&dev->count, 0);
+
+ get_inotify_dev(dev);
+ atomic_inc(&user->inotify_devs);
+
+ filp->private_data = dev;
+ fd_install (fd, filp);
+ return fd;
+out_err:
+ put_unused_fd (fd);
+ put_filp (filp);
+ free_uid(user);
+out:
+ return ret;
+}
+
+asmlinkage long sys_inotify_add_watch(int fd, const char *path, u32 mask)
+{
+ struct inotify_watch *watch, *old;
+ struct inode *inode;
+ struct inotify_device *dev;
+ struct nameidata nd;
+ struct file *filp;
+ int ret;
+
+ filp = fget(fd);
+ if (!filp)
+ return -EBADF;
+
+ dev = filp->private_data;
+
+ ret = find_inode ((const char __user*)path, &nd);
+ if (ret)
+ goto fput_and_out;
+
+ /* Held in place by reference in nd */
+ inode = nd.dentry->d_inode;
+
+ down(&inode->inotify_sem);
+ down(&dev->sem);
+
+ /* don't let user-space set invalid bits: we don't want flags set */
+ mask &= IN_ALL_EVENTS;
+ if (!mask) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /*
+ * Handle the case of re-adding a watch on an (inode,dev) pair that we
+ * are already watching. We just update the mask and return its wd.
+ */
+ old = inode_find_dev(inode, dev);
+ if (unlikely(old)) {
+ old->mask = mask;
+ ret = old->wd;
+ goto out;
+ }
+
+ watch = create_watch(dev, mask, inode);
+ if (unlikely(IS_ERR(watch))) {
+ ret = PTR_ERR(watch);
+ goto out;
+ }
+
+ /* Add the watch to the device's and the inode's list */
+ list_add(&watch->d_list, &dev->watches);
+ list_add(&watch->i_list, &inode->inotify_watches);
+ ret = watch->wd;
+out:
+ path_release (&nd);
+ up(&dev->sem);
+ up(&inode->inotify_sem);
+fput_and_out:
+ fput(filp);
+ return ret;
+}
+
+asmlinkage long sys_inotify_rm_watch(int fd, u32 wd)
+{
+ struct file *filp;
+ struct inotify_device *dev;
+ int ret;
+
+ filp = fget(fd);
+ if (!filp)
+ return -EBADF;
+ dev = filp->private_data;
+ ret = inotify_ignore (dev, wd);
+ fput(filp);
+ return ret;
+}
+
+static struct super_block *
+inotify_get_sb(struct file_system_type *fs_type, int flags,
+ const char *dev_name, void *data)
+{
+ return get_sb_pseudo(fs_type, "inotify", NULL, 0xBAD1DEA);
+}
+
+static struct file_system_type inotify_fs_type = {
+ .name = "inotifyfs",
+ .get_sb = inotify_get_sb,
+ .kill_sb = kill_anon_super,
+};
+
+/*
+ * inotify_init - Our initialization function. Note that we cannnot return
+ * error because we have compiled-in VFS hooks. So an (unlikely) failure here
+ * must result in panic().
+ */
+static int __init inotify_init(void)
+{
+ register_filesystem(&inotify_fs_type);
+ inotify_mnt = kern_mount(&inotify_fs_type);
+
+ inotify_max_queued_events = 8192;
+ inotify_max_user_devices = 128;
+ inotify_max_user_watches = 8192;
+
+ atomic_set(&inotify_cookie, 0);
+
+ watch_cachep = kmem_cache_create("inotify_watch_cache",
+ sizeof(struct inotify_watch),
+ 0, SLAB_PANIC, NULL, NULL);
+ event_cachep = kmem_cache_create("inotify_event_cache",
+ sizeof(struct inotify_kernel_event),
+ 0, SLAB_PANIC, NULL, NULL);
+
+ printk(KERN_INFO "inotify syscall\n");
+
+ return 0;
+}
+
+module_init(inotify_init);
diff --git a/fs/namei.c b/fs/namei.c
index 1d93cb4f7c5..02a824cd3c5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -21,7 +21,7 @@
#include <linux/namei.h>
#include <linux/quotaops.h>
#include <linux/pagemap.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/smp_lock.h>
#include <linux/personality.h>
#include <linux/security.h>
@@ -1312,7 +1312,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
DQUOT_INIT(dir);
error = dir->i_op->create(dir, dentry, mode, nd);
if (!error) {
- inode_dir_notify(dir, DN_CREATE);
+ fsnotify_create(dir, dentry->d_name.name);
security_inode_post_create(dir, dentry, mode);
}
return error;
@@ -1637,7 +1637,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
DQUOT_INIT(dir);
error = dir->i_op->mknod(dir, dentry, mode, dev);
if (!error) {
- inode_dir_notify(dir, DN_CREATE);
+ fsnotify_create(dir, dentry->d_name.name);
security_inode_post_mknod(dir, dentry, mode, dev);
}
return error;
@@ -1710,7 +1710,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
DQUOT_INIT(dir);
error = dir->i_op->mkdir(dir, dentry, mode);
if (!error) {
- inode_dir_notify(dir, DN_CREATE);
+ fsnotify_mkdir(dir, dentry->d_name.name);
security_inode_post_mkdir(dir,dentry, mode);
}
return error;
@@ -1801,7 +1801,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
}
up(&dentry->d_inode->i_sem);
if (!error) {
- inode_dir_notify(dir, DN_DELETE);
+ fsnotify_rmdir(dentry, dentry->d_inode, dir);
d_delete(dentry);
}
dput(dentry);
@@ -1874,9 +1874,10 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
/* We don't d_delete() NFS sillyrenamed files--they still exist. */
if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
+ fsnotify_unlink(dentry, dir);
d_delete(dentry);
- inode_dir_notify(dir, DN_DELETE);
}
+
return error;
}
@@ -1950,7 +1951,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, i
DQUOT_INIT(dir);
error = dir->i_op->symlink(dir, dentry, oldname);
if (!error) {
- inode_dir_notify(dir, DN_CREATE);
+ fsnotify_create(dir, dentry->d_name.name);
security_inode_post_symlink(dir, dentry, oldname);
}
return error;
@@ -2023,7 +2024,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
error = dir->i_op->link(old_dentry, dir, new_dentry);
up(&old_dentry->d_inode->i_sem);
if (!error) {
- inode_dir_notify(dir, DN_CREATE);
+ fsnotify_create(dir, new_dentry->d_name.name);
security_inode_post_link(old_dentry, dir, new_dentry);
}
return error;
@@ -2187,6 +2188,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
{
int error;
int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
+ const char *old_name;
if (old_dentry->d_inode == new_dentry->d_inode)
return 0;
@@ -2208,18 +2210,18 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
DQUOT_INIT(old_dir);
DQUOT_INIT(new_dir);
+ old_name = fsnotify_oldname_init(old_dentry->d_name.name);
+
if (is_dir)
error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
else
error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
if (!error) {
- if (old_dir == new_dir)
- inode_dir_notify(old_dir, DN_RENAME);
- else {
- inode_dir_notify(old_dir, DN_DELETE);
- inode_dir_notify(new_dir, DN_CREATE);
- }
+ const char *new_name = old_dentry->d_name.name;
+ fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir);
}
+ fsnotify_oldname_free(old_name);
+
return error;
}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 5e0bf391760..4f2cd3d2756 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -45,7 +45,7 @@
#endif /* CONFIG_NFSD_V3 */
#include <linux/nfsd/nfsfh.h>
#include <linux/quotaops.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/posix_acl.h>
#include <linux/posix_acl_xattr.h>
#ifdef CONFIG_NFSD_V4
@@ -860,7 +860,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
nfsdstats.io_read += err;
*count = err;
err = 0;
- dnotify_parent(file->f_dentry, DN_ACCESS);
+ fsnotify_access(file->f_dentry);
} else
err = nfserrno(err);
out:
@@ -916,7 +916,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
set_fs(oldfs);
if (err >= 0) {
nfsdstats.io_write += cnt;
- dnotify_parent(file->f_dentry, DN_MODIFY);
+ fsnotify_modify(file->f_dentry);
}
/* clear setuid/setgid flag after write */
diff --git a/fs/open.c b/fs/open.c
index 3f4a4286fdc..32bf05e2996 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -10,7 +10,7 @@
#include <linux/file.h>
#include <linux/smp_lock.h>
#include <linux/quotaops.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/tty.h>
@@ -951,6 +951,7 @@ asmlinkage long sys_open(const char __user * filename, int flags, int mode)
put_unused_fd(fd);
fd = PTR_ERR(f);
} else {
+ fsnotify_open(f->f_dentry);
fd_install(fd, f);
}
}
diff --git a/fs/read_write.c b/fs/read_write.c
index 9292f5fa4d6..563abd09b5c 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -10,7 +10,7 @@
#include <linux/file.h>
#include <linux/uio.h>
#include <linux/smp_lock.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/security.h>
#include <linux/module.h>
#include <linux/syscalls.h>
@@ -252,7 +252,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
else
ret = do_sync_read(file, buf, count, pos);
if (ret > 0) {
- dnotify_parent(file->f_dentry, DN_ACCESS);
+ fsnotify_access(file->f_dentry);
current->rchar += ret;
}
current->syscr++;
@@ -303,7 +303,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
else
ret = do_sync_write(file, buf, count, pos);
if (ret > 0) {
- dnotify_parent(file->f_dentry, DN_MODIFY);
+ fsnotify_modify(file->f_dentry);
current->wchar += ret;
}
current->syscw++;
@@ -539,9 +539,12 @@ static ssize_t do_readv_writev(int type, struct file *file,
out:
if (iov != iovstack)
kfree(iov);
- if ((ret + (type == READ)) > 0)
- dnotify_parent(file->f_dentry,
- (type == READ) ? DN_ACCESS : DN_MODIFY);
+ if ((ret + (type == READ)) > 0) {
+ if (type == READ)
+ fsnotify_access(file->f_dentry);
+ else
+ fsnotify_modify(file->f_dentry);
+ }
return ret;
Efault:
ret = -EFAULT;
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index 49c479c9454..909f71e9a30 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -46,1125 +46,1221 @@
#define TEST_OPTION(optname, s) \
test_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s))
-static inline void get_bit_address (struct super_block * s,
- b_blocknr_t block, int * bmap_nr, int * offset)
+static inline void get_bit_address(struct super_block *s,
+ b_blocknr_t block, int *bmap_nr, int *offset)
{
- /* It is in the bitmap block number equal to the block
- * number divided by the number of bits in a block. */
- *bmap_nr = block / (s->s_blocksize << 3);
- /* Within that bitmap block it is located at bit offset *offset. */
- *offset = block & ((s->s_blocksize << 3) - 1 );
- return;
+ /* It is in the bitmap block number equal to the block
+ * number divided by the number of bits in a block. */
+ *bmap_nr = block / (s->s_blocksize << 3);
+ /* Within that bitmap block it is located at bit offset *offset. */
+ *offset = block & ((s->s_blocksize << 3) - 1);
+ return;
}
#ifdef CONFIG_REISERFS_CHECK
-int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value)
+int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
{
- int i, j;
+ int i, j;
- if (block == 0 || block >= SB_BLOCK_COUNT (s)) {
- reiserfs_warning (s, "vs-4010: is_reusable: block number is out of range %lu (%u)",
- block, SB_BLOCK_COUNT (s));
- return 0;
- }
-
- /* it can't be one of the bitmap blocks */
- for (i = 0; i < SB_BMAP_NR (s); i ++)
- if (block == SB_AP_BITMAP (s)[i].bh->b_blocknr) {
- reiserfs_warning (s, "vs: 4020: is_reusable: "
- "bitmap block %lu(%u) can't be freed or reused",
- block, SB_BMAP_NR (s));
- return 0;
+ if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
+ reiserfs_warning(s,
+ "vs-4010: is_reusable: block number is out of range %lu (%u)",
+ block, SB_BLOCK_COUNT(s));
+ return 0;
}
-
- get_bit_address (s, block, &i, &j);
- if (i >= SB_BMAP_NR (s)) {
- reiserfs_warning (s, "vs-4030: is_reusable: there is no so many bitmap blocks: "
- "block=%lu, bitmap_nr=%d", block, i);
- return 0;
- }
+ /* it can't be one of the bitmap blocks */
+ for (i = 0; i < SB_BMAP_NR(s); i++)
+ if (block == SB_AP_BITMAP(s)[i].bh->b_blocknr) {
+ reiserfs_warning(s, "vs: 4020: is_reusable: "
+ "bitmap block %lu(%u) can't be freed or reused",
+ block, SB_BMAP_NR(s));
+ return 0;
+ }
- if ((bit_value == 0 &&
- reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) ||
- (bit_value == 1 &&
- reiserfs_test_le_bit(j, SB_AP_BITMAP (s)[i].bh->b_data) == 0)) {
- reiserfs_warning (s, "vs-4040: is_reusable: corresponding bit of block %lu does not "
- "match required value (i==%d, j==%d) test_bit==%d",
- block, i, j, reiserfs_test_le_bit (j, SB_AP_BITMAP (s)[i].bh->b_data));
+ get_bit_address(s, block, &i, &j);
- return 0;
- }
+ if (i >= SB_BMAP_NR(s)) {
+ reiserfs_warning(s,
+ "vs-4030: is_reusable: there is no so many bitmap blocks: "
+ "block=%lu, bitmap_nr=%d", block, i);
+ return 0;
+ }
- if (bit_value == 0 && block == SB_ROOT_BLOCK (s)) {
- reiserfs_warning (s, "vs-4050: is_reusable: this is root block (%u), "
- "it must be busy", SB_ROOT_BLOCK (s));
- return 0;
- }
+ if ((bit_value == 0 &&
+ reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data)) ||
+ (bit_value == 1 &&
+ reiserfs_test_le_bit(j, SB_AP_BITMAP(s)[i].bh->b_data) == 0)) {
+ reiserfs_warning(s,
+ "vs-4040: is_reusable: corresponding bit of block %lu does not "
+ "match required value (i==%d, j==%d) test_bit==%d",
+ block, i, j, reiserfs_test_le_bit(j,
+ SB_AP_BITMAP
+ (s)[i].bh->
+ b_data));
+
+ return 0;
+ }
- return 1;
+ if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
+ reiserfs_warning(s,
+ "vs-4050: is_reusable: this is root block (%u), "
+ "it must be busy", SB_ROOT_BLOCK(s));
+ return 0;
+ }
+
+ return 1;
}
-#endif /* CONFIG_REISERFS_CHECK */
+#endif /* CONFIG_REISERFS_CHECK */
/* searches in journal structures for a given block number (bmap, off). If block
is found in reiserfs journal it suggests next free block candidate to test. */
-static inline int is_block_in_journal (struct super_block * s, int bmap, int
-off, int *next)
+static inline int is_block_in_journal(struct super_block *s, int bmap, int
+ off, int *next)
{
- b_blocknr_t tmp;
-
- if (reiserfs_in_journal (s, bmap, off, 1, &tmp)) {
- if (tmp) { /* hint supplied */
- *next = tmp;
- PROC_INFO_INC( s, scan_bitmap.in_journal_hint );
- } else {
- (*next) = off + 1; /* inc offset to avoid looping. */
- PROC_INFO_INC( s, scan_bitmap.in_journal_nohint );
+ b_blocknr_t tmp;
+
+ if (reiserfs_in_journal(s, bmap, off, 1, &tmp)) {
+ if (tmp) { /* hint supplied */
+ *next = tmp;
+ PROC_INFO_INC(s, scan_bitmap.in_journal_hint);
+ } else {
+ (*next) = off + 1; /* inc offset to avoid looping. */
+ PROC_INFO_INC(s, scan_bitmap.in_journal_nohint);
+ }
+ PROC_INFO_INC(s, scan_bitmap.retry);
+ return 1;
}
- PROC_INFO_INC( s, scan_bitmap.retry );
- return 1;
- }
- return 0;
+ return 0;
}
/* it searches for a window of zero bits with given minimum and maximum lengths in one bitmap
* block; */
-static int scan_bitmap_block (struct reiserfs_transaction_handle *th,
- int bmap_n, int *beg, int boundary, int min, int max, int unfm)
+static int scan_bitmap_block(struct reiserfs_transaction_handle *th,
+ int bmap_n, int *beg, int boundary, int min,
+ int max, int unfm)
{
- struct super_block *s = th->t_super;
- struct reiserfs_bitmap_info *bi=&SB_AP_BITMAP(s)[bmap_n];
- int end, next;
- int org = *beg;
+ struct super_block *s = th->t_super;
+ struct reiserfs_bitmap_info *bi = &SB_AP_BITMAP(s)[bmap_n];
+ int end, next;
+ int org = *beg;
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- RFALSE(bmap_n >= SB_BMAP_NR (s), "Bitmap %d is out of range (0..%d)",bmap_n, SB_BMAP_NR (s) - 1);
- PROC_INFO_INC( s, scan_bitmap.bmap );
+ RFALSE(bmap_n >= SB_BMAP_NR(s), "Bitmap %d is out of range (0..%d)",
+ bmap_n, SB_BMAP_NR(s) - 1);
+ PROC_INFO_INC(s, scan_bitmap.bmap);
/* this is unclear and lacks comments, explain how journal bitmaps
work here for the reader. Convey a sense of the design here. What
is a window? */
/* - I mean `a window of zero bits' as in description of this function - Zam. */
-
- if ( !bi ) {
- reiserfs_warning (s, "NULL bitmap info pointer for bitmap %d", bmap_n);
- return 0;
- }
- if (buffer_locked (bi->bh)) {
- PROC_INFO_INC( s, scan_bitmap.wait );
- __wait_on_buffer (bi->bh);
- }
-
- while (1) {
- cont:
- if (bi->free_count < min)
- return 0; // No free blocks in this bitmap
-
- /* search for a first zero bit -- beggining of a window */
- *beg = reiserfs_find_next_zero_le_bit
- ((unsigned long*)(bi->bh->b_data), boundary, *beg);
-
- if (*beg + min > boundary) { /* search for a zero bit fails or the rest of bitmap block
- * cannot contain a zero window of minimum size */
- return 0;
- }
- if (unfm && is_block_in_journal(s,bmap_n, *beg, beg))
- continue;
- /* first zero bit found; we check next bits */
- for (end = *beg + 1;; end ++) {
- if (end >= *beg + max || end >= boundary || reiserfs_test_le_bit (end, bi->bh->b_data)) {
- next = end;
- break;
- }
- /* finding the other end of zero bit window requires looking into journal structures (in
- * case of searching for free blocks for unformatted nodes) */
- if (unfm && is_block_in_journal(s, bmap_n, end, &next))
- break;
+ if (!bi) {
+ reiserfs_warning(s, "NULL bitmap info pointer for bitmap %d",
+ bmap_n);
+ return 0;
+ }
+ if (buffer_locked(bi->bh)) {
+ PROC_INFO_INC(s, scan_bitmap.wait);
+ __wait_on_buffer(bi->bh);
}
- /* now (*beg) points to beginning of zero bits window,
- * (end) points to one bit after the window end */
- if (end - *beg >= min) { /* it seems we have found window of proper size */
- int i;
- reiserfs_prepare_for_journal (s, bi->bh, 1);
- /* try to set all blocks used checking are they still free */
- for (i = *beg; i < end; i++) {
- /* It seems that we should not check in journal again. */
- if (reiserfs_test_and_set_le_bit (i, bi->bh->b_data)) {
- /* bit was set by another process
- * while we slept in prepare_for_journal() */
- PROC_INFO_INC( s, scan_bitmap.stolen );
- if (i >= *beg + min) { /* we can continue with smaller set of allocated blocks,
- * if length of this set is more or equal to `min' */
- end = i;
- break;
- }
- /* otherwise we clear all bit were set ... */
- while (--i >= *beg)
- reiserfs_test_and_clear_le_bit (i, bi->bh->b_data);
- reiserfs_restore_prepared_buffer (s, bi->bh);
- *beg = org;
- /* ... and search again in current block from beginning */
- goto cont;
+ while (1) {
+ cont:
+ if (bi->free_count < min)
+ return 0; // No free blocks in this bitmap
+
+ /* search for a first zero bit -- beggining of a window */
+ *beg = reiserfs_find_next_zero_le_bit
+ ((unsigned long *)(bi->bh->b_data), boundary, *beg);
+
+ if (*beg + min > boundary) { /* search for a zero bit fails or the rest of bitmap block
+ * cannot contain a zero window of minimum size */
+ return 0;
}
- }
- bi->free_count -= (end - *beg);
- journal_mark_dirty (th, s, bi->bh);
- /* free block count calculation */
- reiserfs_prepare_for_journal (s, SB_BUFFER_WITH_SB(s), 1);
- PUT_SB_FREE_BLOCKS(s, SB_FREE_BLOCKS(s) - (end - *beg));
- journal_mark_dirty (th, s, SB_BUFFER_WITH_SB(s));
+ if (unfm && is_block_in_journal(s, bmap_n, *beg, beg))
+ continue;
+ /* first zero bit found; we check next bits */
+ for (end = *beg + 1;; end++) {
+ if (end >= *beg + max || end >= boundary
+ || reiserfs_test_le_bit(end, bi->bh->b_data)) {
+ next = end;
+ break;
+ }
+ /* finding the other end of zero bit window requires looking into journal structures (in
+ * case of searching for free blocks for unformatted nodes) */
+ if (unfm && is_block_in_journal(s, bmap_n, end, &next))
+ break;
+ }
- return end - (*beg);
- } else {
- *beg = next;
+ /* now (*beg) points to beginning of zero bits window,
+ * (end) points to one bit after the window end */
+ if (end - *beg >= min) { /* it seems we have found window of proper size */
+ int i;
+ reiserfs_prepare_for_journal(s, bi->bh, 1);
+ /* try to set all blocks used checking are they still free */
+ for (i = *beg; i < end; i++) {
+ /* It seems that we should not check in journal again. */
+ if (reiserfs_test_and_set_le_bit
+ (i, bi->bh->b_data)) {
+ /* bit was set by another process
+ * while we slept in prepare_for_journal() */
+ PROC_INFO_INC(s, scan_bitmap.stolen);
+ if (i >= *beg + min) { /* we can continue with smaller set of allocated blocks,
+ * if length of this set is more or equal to `min' */
+ end = i;
+ break;
+ }
+ /* otherwise we clear all bit were set ... */
+ while (--i >= *beg)
+ reiserfs_test_and_clear_le_bit
+ (i, bi->bh->b_data);
+ reiserfs_restore_prepared_buffer(s,
+ bi->
+ bh);
+ *beg = org;
+ /* ... and search again in current block from beginning */
+ goto cont;
+ }
+ }
+ bi->free_count -= (end - *beg);
+ journal_mark_dirty(th, s, bi->bh);
+
+ /* free block count calculation */
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
+ 1);
+ PUT_SB_FREE_BLOCKS(s, SB_FREE_BLOCKS(s) - (end - *beg));
+ journal_mark_dirty(th, s, SB_BUFFER_WITH_SB(s));
+
+ return end - (*beg);
+ } else {
+ *beg = next;
+ }
}
- }
}
-static int bmap_hash_id(struct super_block *s, u32 id) {
- char * hash_in = NULL;
- unsigned long hash;
- unsigned bm;
-
- if (id <= 2) {
- bm = 1;
- } else {
- hash_in = (char *)(&id);
- hash = keyed_hash(hash_in, 4);
- bm = hash % SB_BMAP_NR(s);
- if (!bm)
- bm = 1;
- }
- /* this can only be true when SB_BMAP_NR = 1 */
- if (bm >= SB_BMAP_NR(s))
- bm = 0;
- return bm;
+static int bmap_hash_id(struct super_block *s, u32 id)
+{
+ char *hash_in = NULL;
+ unsigned long hash;
+ unsigned bm;
+
+ if (id <= 2) {
+ bm = 1;
+ } else {
+ hash_in = (char *)(&id);
+ hash = keyed_hash(hash_in, 4);
+ bm = hash % SB_BMAP_NR(s);
+ if (!bm)
+ bm = 1;
+ }
+ /* this can only be true when SB_BMAP_NR = 1 */
+ if (bm >= SB_BMAP_NR(s))
+ bm = 0;
+ return bm;
}
/*
* hashes the id and then returns > 0 if the block group for the
* corresponding hash is full
*/
-static inline int block_group_used(struct super_block *s, u32 id) {
- int bm;
- bm = bmap_hash_id(s, id);
- if (SB_AP_BITMAP(s)[bm].free_count > ((s->s_blocksize << 3) * 60 / 100) ) {
- return 0;
- }
- return 1;
+static inline int block_group_used(struct super_block *s, u32 id)
+{
+ int bm;
+ bm = bmap_hash_id(s, id);
+ if (SB_AP_BITMAP(s)[bm].free_count > ((s->s_blocksize << 3) * 60 / 100)) {
+ return 0;
+ }
+ return 1;
}
/*
* the packing is returned in disk byte order
*/
-__le32 reiserfs_choose_packing(struct inode *dir)
+__le32 reiserfs_choose_packing(struct inode * dir)
{
- __le32 packing;
- if (TEST_OPTION(packing_groups, dir->i_sb)) {
- u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id);
- /*
- * some versions of reiserfsck expect packing locality 1 to be
- * special
- */
- if (parent_dir == 1 || block_group_used(dir->i_sb,parent_dir))
- packing = INODE_PKEY(dir)->k_objectid;
- else
- packing = INODE_PKEY(dir)->k_dir_id;
- } else
- packing = INODE_PKEY(dir)->k_objectid;
- return packing;
+ __le32 packing;
+ if (TEST_OPTION(packing_groups, dir->i_sb)) {
+ u32 parent_dir = le32_to_cpu(INODE_PKEY(dir)->k_dir_id);
+ /*
+ * some versions of reiserfsck expect packing locality 1 to be
+ * special
+ */
+ if (parent_dir == 1 || block_group_used(dir->i_sb, parent_dir))
+ packing = INODE_PKEY(dir)->k_objectid;
+ else
+ packing = INODE_PKEY(dir)->k_dir_id;
+ } else
+ packing = INODE_PKEY(dir)->k_objectid;
+ return packing;
}
-
+
/* Tries to find contiguous zero bit window (given size) in given region of
* bitmap and place new blocks there. Returns number of allocated blocks. */
-static int scan_bitmap (struct reiserfs_transaction_handle *th,
- b_blocknr_t *start, b_blocknr_t finish,
- int min, int max, int unfm, unsigned long file_block)
+static int scan_bitmap(struct reiserfs_transaction_handle *th,
+ b_blocknr_t * start, b_blocknr_t finish,
+ int min, int max, int unfm, unsigned long file_block)
{
- int nr_allocated=0;
- struct super_block * s = th->t_super;
- /* find every bm and bmap and bmap_nr in this file, and change them all to bitmap_blocknr
- * - Hans, it is not a block number - Zam. */
-
- int bm, off;
- int end_bm, end_off;
- int off_max = s->s_blocksize << 3;
-
- BUG_ON (!th->t_trans_id);
-
- PROC_INFO_INC( s, scan_bitmap.call );
- if ( SB_FREE_BLOCKS(s) <= 0)
- return 0; // No point in looking for more free blocks
-
- get_bit_address (s, *start, &bm, &off);
- get_bit_address (s, finish, &end_bm, &end_off);
- if (bm > SB_BMAP_NR(s))
- return 0;
- if (end_bm > SB_BMAP_NR(s))
- end_bm = SB_BMAP_NR(s);
-
- /* When the bitmap is more than 10% free, anyone can allocate.
- * When it's less than 10% free, only files that already use the
- * bitmap are allowed. Once we pass 80% full, this restriction
- * is lifted.
- *
- * We do this so that files that grow later still have space close to
- * their original allocation. This improves locality, and presumably
- * performance as a result.
- *
- * This is only an allocation policy and does not make up for getting a
- * bad hint. Decent hinting must be implemented for this to work well.
- */
- if ( TEST_OPTION(skip_busy, s) && SB_FREE_BLOCKS(s) > SB_BLOCK_COUNT(s)/20 ) {
- for (;bm < end_bm; bm++, off = 0) {
- if ( ( off && (!unfm || (file_block != 0))) || SB_AP_BITMAP(s)[bm].free_count > (s->s_blocksize << 3) / 10 )
- nr_allocated = scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
- if (nr_allocated)
- goto ret;
- }
- /* we know from above that start is a reasonable number */
- get_bit_address (s, *start, &bm, &off);
- }
-
- for (;bm < end_bm; bm++, off = 0) {
- nr_allocated = scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
- if (nr_allocated)
- goto ret;
- }
-
- nr_allocated = scan_bitmap_block(th, bm, &off, end_off + 1, min, max, unfm);
-
- ret:
- *start = bm * off_max + off;
- return nr_allocated;
+ int nr_allocated = 0;
+ struct super_block *s = th->t_super;
+ /* find every bm and bmap and bmap_nr in this file, and change them all to bitmap_blocknr
+ * - Hans, it is not a block number - Zam. */
+
+ int bm, off;
+ int end_bm, end_off;
+ int off_max = s->s_blocksize << 3;
+
+ BUG_ON(!th->t_trans_id);
+
+ PROC_INFO_INC(s, scan_bitmap.call);
+ if (SB_FREE_BLOCKS(s) <= 0)
+ return 0; // No point in looking for more free blocks
+
+ get_bit_address(s, *start, &bm, &off);
+ get_bit_address(s, finish, &end_bm, &end_off);
+ if (bm > SB_BMAP_NR(s))
+ return 0;
+ if (end_bm > SB_BMAP_NR(s))
+ end_bm = SB_BMAP_NR(s);
+
+ /* When the bitmap is more than 10% free, anyone can allocate.
+ * When it's less than 10% free, only files that already use the
+ * bitmap are allowed. Once we pass 80% full, this restriction
+ * is lifted.
+ *
+ * We do this so that files that grow later still have space close to
+ * their original allocation. This improves locality, and presumably
+ * performance as a result.
+ *
+ * This is only an allocation policy and does not make up for getting a
+ * bad hint. Decent hinting must be implemented for this to work well.
+ */
+ if (TEST_OPTION(skip_busy, s)
+ && SB_FREE_BLOCKS(s) > SB_BLOCK_COUNT(s) / 20) {
+ for (; bm < end_bm; bm++, off = 0) {
+ if ((off && (!unfm || (file_block != 0)))
+ || SB_AP_BITMAP(s)[bm].free_count >
+ (s->s_blocksize << 3) / 10)
+ nr_allocated =
+ scan_bitmap_block(th, bm, &off, off_max,
+ min, max, unfm);
+ if (nr_allocated)
+ goto ret;
+ }
+ /* we know from above that start is a reasonable number */
+ get_bit_address(s, *start, &bm, &off);
+ }
+
+ for (; bm < end_bm; bm++, off = 0) {
+ nr_allocated =
+ scan_bitmap_block(th, bm, &off, off_max, min, max, unfm);
+ if (nr_allocated)
+ goto ret;
+ }
+
+ nr_allocated =
+ scan_bitmap_block(th, bm, &off, end_off + 1, min, max, unfm);
+
+ ret:
+ *start = bm * off_max + off;
+ return nr_allocated;
}
-static void _reiserfs_free_block (struct reiserfs_transaction_handle *th,
- struct inode *inode, b_blocknr_t block,
- int for_unformatted)
+static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
+ struct inode *inode, b_blocknr_t block,
+ int for_unformatted)
{
- struct super_block * s = th->t_super;
- struct reiserfs_super_block * rs;
- struct buffer_head * sbh;
- struct reiserfs_bitmap_info *apbi;
- int nr, offset;
+ struct super_block *s = th->t_super;
+ struct reiserfs_super_block *rs;
+ struct buffer_head *sbh;
+ struct reiserfs_bitmap_info *apbi;
+ int nr, offset;
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- PROC_INFO_INC( s, free_block );
+ PROC_INFO_INC(s, free_block);
- rs = SB_DISK_SUPER_BLOCK (s);
- sbh = SB_BUFFER_WITH_SB (s);
- apbi = SB_AP_BITMAP(s);
+ rs = SB_DISK_SUPER_BLOCK(s);
+ sbh = SB_BUFFER_WITH_SB(s);
+ apbi = SB_AP_BITMAP(s);
- get_bit_address (s, block, &nr, &offset);
+ get_bit_address(s, block, &nr, &offset);
- if (nr >= sb_bmap_nr (rs)) {
- reiserfs_warning (s, "vs-4075: reiserfs_free_block: "
- "block %lu is out of range on %s",
- block, reiserfs_bdevname (s));
- return;
- }
-
- reiserfs_prepare_for_journal(s, apbi[nr].bh, 1 ) ;
-
- /* clear bit for the given block in bit map */
- if (!reiserfs_test_and_clear_le_bit (offset, apbi[nr].bh->b_data)) {
- reiserfs_warning (s, "vs-4080: reiserfs_free_block: "
- "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
- reiserfs_bdevname (s), block);
- }
- apbi[nr].free_count ++;
- journal_mark_dirty (th, s, apbi[nr].bh);
-
- reiserfs_prepare_for_journal(s, sbh, 1) ;
- /* update super block */
- set_sb_free_blocks( rs, sb_free_blocks(rs) + 1 );
-
- journal_mark_dirty (th, s, sbh);
- if (for_unformatted)
- DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
+ if (nr >= sb_bmap_nr(rs)) {
+ reiserfs_warning(s, "vs-4075: reiserfs_free_block: "
+ "block %lu is out of range on %s",
+ block, reiserfs_bdevname(s));
+ return;
+ }
+
+ reiserfs_prepare_for_journal(s, apbi[nr].bh, 1);
+
+ /* clear bit for the given block in bit map */
+ if (!reiserfs_test_and_clear_le_bit(offset, apbi[nr].bh->b_data)) {
+ reiserfs_warning(s, "vs-4080: reiserfs_free_block: "
+ "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
+ reiserfs_bdevname(s), block);
+ }
+ apbi[nr].free_count++;
+ journal_mark_dirty(th, s, apbi[nr].bh);
+
+ reiserfs_prepare_for_journal(s, sbh, 1);
+ /* update super block */
+ set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
+
+ journal_mark_dirty(th, s, sbh);
+ if (for_unformatted)
+ DQUOT_FREE_BLOCK_NODIRTY(inode, 1);
}
-void reiserfs_free_block (struct reiserfs_transaction_handle *th,
- struct inode *inode, b_blocknr_t block,
- int for_unformatted)
+void reiserfs_free_block(struct reiserfs_transaction_handle *th,
+ struct inode *inode, b_blocknr_t block,
+ int for_unformatted)
{
- struct super_block * s = th->t_super;
+ struct super_block *s = th->t_super;
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
- RFALSE(is_reusable (s, block, 1) == 0, "vs-4071: can not free such block");
- /* mark it before we clear it, just in case */
- journal_mark_freed(th, s, block) ;
- _reiserfs_free_block(th, inode, block, for_unformatted) ;
+ RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
+ RFALSE(is_reusable(s, block, 1) == 0,
+ "vs-4071: can not free such block");
+ /* mark it before we clear it, just in case */
+ journal_mark_freed(th, s, block);
+ _reiserfs_free_block(th, inode, block, for_unformatted);
}
/* preallocated blocks don't need to be run through journal_mark_freed */
-static void reiserfs_free_prealloc_block (struct reiserfs_transaction_handle *th,
- struct inode *inode, b_blocknr_t block) {
- RFALSE(!th->t_super, "vs-4060: trying to free block on nonexistent device");
- RFALSE(is_reusable (th->t_super, block, 1) == 0, "vs-4070: can not free such block");
- BUG_ON (!th->t_trans_id);
- _reiserfs_free_block(th, inode, block, 1) ;
+static void reiserfs_free_prealloc_block(struct reiserfs_transaction_handle *th,
+ struct inode *inode, b_blocknr_t block)
+{
+ RFALSE(!th->t_super,
+ "vs-4060: trying to free block on nonexistent device");
+ RFALSE(is_reusable(th->t_super, block, 1) == 0,
+ "vs-4070: can not free such block");
+ BUG_ON(!th->t_trans_id);
+ _reiserfs_free_block(th, inode, block, 1);
}
-static void __discard_prealloc (struct reiserfs_transaction_handle * th,
- struct reiserfs_inode_info *ei)
+static void __discard_prealloc(struct reiserfs_transaction_handle *th,
+ struct reiserfs_inode_info *ei)
{
- unsigned long save = ei->i_prealloc_block ;
- int dirty = 0;
- struct inode *inode = &ei->vfs_inode;
- BUG_ON (!th->t_trans_id);
+ unsigned long save = ei->i_prealloc_block;
+ int dirty = 0;
+ struct inode *inode = &ei->vfs_inode;
+ BUG_ON(!th->t_trans_id);
#ifdef CONFIG_REISERFS_CHECK
- if (ei->i_prealloc_count < 0)
- reiserfs_warning (th->t_super, "zam-4001:%s: inode has negative prealloc blocks count.", __FUNCTION__ );
+ if (ei->i_prealloc_count < 0)
+ reiserfs_warning(th->t_super,
+ "zam-4001:%s: inode has negative prealloc blocks count.",
+ __FUNCTION__);
#endif
- while (ei->i_prealloc_count > 0) {
- reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
- ei->i_prealloc_block++;
- ei->i_prealloc_count --;
- dirty = 1;
- }
- if (dirty)
- reiserfs_update_sd(th, inode);
- ei->i_prealloc_block = save;
- list_del_init(&(ei->i_prealloc_list));
+ while (ei->i_prealloc_count > 0) {
+ reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
+ ei->i_prealloc_block++;
+ ei->i_prealloc_count--;
+ dirty = 1;
+ }
+ if (dirty)
+ reiserfs_update_sd(th, inode);
+ ei->i_prealloc_block = save;
+ list_del_init(&(ei->i_prealloc_list));
}
/* FIXME: It should be inline function */
-void reiserfs_discard_prealloc (struct reiserfs_transaction_handle *th,
- struct inode *inode)
+void reiserfs_discard_prealloc(struct reiserfs_transaction_handle *th,
+ struct inode *inode)
{
- struct reiserfs_inode_info *ei = REISERFS_I(inode);
- BUG_ON (!th->t_trans_id);
- if (ei->i_prealloc_count)
- __discard_prealloc(th, ei);
+ struct reiserfs_inode_info *ei = REISERFS_I(inode);
+ BUG_ON(!th->t_trans_id);
+ if (ei->i_prealloc_count)
+ __discard_prealloc(th, ei);
}
-void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th)
+void reiserfs_discard_all_prealloc(struct reiserfs_transaction_handle *th)
{
- struct list_head * plist = &SB_JOURNAL(th->t_super)->j_prealloc_list;
+ struct list_head *plist = &SB_JOURNAL(th->t_super)->j_prealloc_list;
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- while (!list_empty(plist)) {
- struct reiserfs_inode_info *ei;
- ei = list_entry(plist->next, struct reiserfs_inode_info, i_prealloc_list);
+ while (!list_empty(plist)) {
+ struct reiserfs_inode_info *ei;
+ ei = list_entry(plist->next, struct reiserfs_inode_info,
+ i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
- if (!ei->i_prealloc_count) {
- reiserfs_warning (th->t_super, "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.", __FUNCTION__);
- }
+ if (!ei->i_prealloc_count) {
+ reiserfs_warning(th->t_super,
+ "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.",
+ __FUNCTION__);
+ }
#endif
- __discard_prealloc(th, ei);
- }
+ __discard_prealloc(th, ei);
+ }
}
-void reiserfs_init_alloc_options (struct super_block *s)
+void reiserfs_init_alloc_options(struct super_block *s)
{
- set_bit (_ALLOC_skip_busy, &SB_ALLOC_OPTS(s));
- set_bit (_ALLOC_dirid_groups, &SB_ALLOC_OPTS(s));
- set_bit (_ALLOC_packing_groups, &SB_ALLOC_OPTS(s));
+ set_bit(_ALLOC_skip_busy, &SB_ALLOC_OPTS(s));
+ set_bit(_ALLOC_dirid_groups, &SB_ALLOC_OPTS(s));
+ set_bit(_ALLOC_packing_groups, &SB_ALLOC_OPTS(s));
}
/* block allocator related options are parsed here */
-int reiserfs_parse_alloc_options(struct super_block * s, char * options)
+int reiserfs_parse_alloc_options(struct super_block *s, char *options)
{
- char * this_char, * value;
-
- REISERFS_SB(s)->s_alloc_options.bits = 0; /* clear default settings */
-
- while ( (this_char = strsep (&options, ":")) != NULL ) {
- if ((value = strchr (this_char, '=')) != NULL)
- *value++ = 0;
-
- if (!strcmp(this_char, "concentrating_formatted_nodes")) {
- int temp;
- SET_OPTION(concentrating_formatted_nodes);
- temp = (value && *value) ? simple_strtoul (value, &value, 0) : 10;
- if (temp <= 0 || temp > 100) {
- REISERFS_SB(s)->s_alloc_options.border = 10;
- } else {
- REISERFS_SB(s)->s_alloc_options.border = 100 / temp;
- }
- continue;
- }
- if (!strcmp(this_char, "displacing_large_files")) {
- SET_OPTION(displacing_large_files);
- REISERFS_SB(s)->s_alloc_options.large_file_size =
- (value && *value) ? simple_strtoul (value, &value, 0) : 16;
- continue;
- }
- if (!strcmp(this_char, "displacing_new_packing_localities")) {
- SET_OPTION(displacing_new_packing_localities);
- continue;
- };
-
- if (!strcmp(this_char, "old_hashed_relocation")) {
- SET_OPTION(old_hashed_relocation);
- continue;
- }
+ char *this_char, *value;
+
+ REISERFS_SB(s)->s_alloc_options.bits = 0; /* clear default settings */
+
+ while ((this_char = strsep(&options, ":")) != NULL) {
+ if ((value = strchr(this_char, '=')) != NULL)
+ *value++ = 0;
+
+ if (!strcmp(this_char, "concentrating_formatted_nodes")) {
+ int temp;
+ SET_OPTION(concentrating_formatted_nodes);
+ temp = (value
+ && *value) ? simple_strtoul(value, &value,
+ 0) : 10;
+ if (temp <= 0 || temp > 100) {
+ REISERFS_SB(s)->s_alloc_options.border = 10;
+ } else {
+ REISERFS_SB(s)->s_alloc_options.border =
+ 100 / temp;
+ }
+ continue;
+ }
+ if (!strcmp(this_char, "displacing_large_files")) {
+ SET_OPTION(displacing_large_files);
+ REISERFS_SB(s)->s_alloc_options.large_file_size =
+ (value
+ && *value) ? simple_strtoul(value, &value, 0) : 16;
+ continue;
+ }
+ if (!strcmp(this_char, "displacing_new_packing_localities")) {
+ SET_OPTION(displacing_new_packing_localities);
+ continue;
+ };
+
+ if (!strcmp(this_char, "old_hashed_relocation")) {
+ SET_OPTION(old_hashed_relocation);
+ continue;
+ }
- if (!strcmp(this_char, "new_hashed_relocation")) {
- SET_OPTION(new_hashed_relocation);
- continue;
- }
+ if (!strcmp(this_char, "new_hashed_relocation")) {
+ SET_OPTION(new_hashed_relocation);
+ continue;
+ }
- if (!strcmp(this_char, "dirid_groups")) {
- SET_OPTION(dirid_groups);
- continue;
- }
- if (!strcmp(this_char, "oid_groups")) {
- SET_OPTION(oid_groups);
- continue;
- }
- if (!strcmp(this_char, "packing_groups")) {
- SET_OPTION(packing_groups);
- continue;
- }
- if (!strcmp(this_char, "hashed_formatted_nodes")) {
- SET_OPTION(hashed_formatted_nodes);
- continue;
- }
+ if (!strcmp(this_char, "dirid_groups")) {
+ SET_OPTION(dirid_groups);
+ continue;
+ }
+ if (!strcmp(this_char, "oid_groups")) {
+ SET_OPTION(oid_groups);
+ continue;
+ }
+ if (!strcmp(this_char, "packing_groups")) {
+ SET_OPTION(packing_groups);
+ continue;
+ }
+ if (!strcmp(this_char, "hashed_formatted_nodes")) {
+ SET_OPTION(hashed_formatted_nodes);
+ continue;
+ }
- if (!strcmp(this_char, "skip_busy")) {
- SET_OPTION(skip_busy);
- continue;
- }
+ if (!strcmp(this_char, "skip_busy")) {
+ SET_OPTION(skip_busy);
+ continue;
+ }
- if (!strcmp(this_char, "hundredth_slices")) {
- SET_OPTION(hundredth_slices);
- continue;
- }
+ if (!strcmp(this_char, "hundredth_slices")) {
+ SET_OPTION(hundredth_slices);
+ continue;
+ }
- if (!strcmp(this_char, "old_way")) {
- SET_OPTION(old_way);
- continue;
- }
+ if (!strcmp(this_char, "old_way")) {
+ SET_OPTION(old_way);
+ continue;
+ }
- if (!strcmp(this_char, "displace_based_on_dirid")) {
- SET_OPTION(displace_based_on_dirid);
- continue;
- }
+ if (!strcmp(this_char, "displace_based_on_dirid")) {
+ SET_OPTION(displace_based_on_dirid);
+ continue;
+ }
- if (!strcmp(this_char, "preallocmin")) {
- REISERFS_SB(s)->s_alloc_options.preallocmin =
- (value && *value) ? simple_strtoul (value, &value, 0) : 4;
- continue;
- }
+ if (!strcmp(this_char, "preallocmin")) {
+ REISERFS_SB(s)->s_alloc_options.preallocmin =
+ (value
+ && *value) ? simple_strtoul(value, &value, 0) : 4;
+ continue;
+ }
+
+ if (!strcmp(this_char, "preallocsize")) {
+ REISERFS_SB(s)->s_alloc_options.preallocsize =
+ (value
+ && *value) ? simple_strtoul(value, &value,
+ 0) :
+ PREALLOCATION_SIZE;
+ continue;
+ }
- if (!strcmp(this_char, "preallocsize")) {
- REISERFS_SB(s)->s_alloc_options.preallocsize =
- (value && *value) ? simple_strtoul (value, &value, 0) : PREALLOCATION_SIZE;
- continue;
+ reiserfs_warning(s, "zam-4001: %s : unknown option - %s",
+ __FUNCTION__, this_char);
+ return 1;
}
- reiserfs_warning (s, "zam-4001: %s : unknown option - %s",
- __FUNCTION__ , this_char);
- return 1;
- }
-
- reiserfs_warning (s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
- return 0;
+ reiserfs_warning(s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
+ return 0;
}
-
-static inline void new_hashed_relocation (reiserfs_blocknr_hint_t * hint)
+
+static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint)
{
- char * hash_in;
- if (hint->formatted_node) {
- hash_in = (char*)&hint->key.k_dir_id;
- } else {
- if (!hint->inode) {
- //hint->search_start = hint->beg;
- hash_in = (char*)&hint->key.k_dir_id;
- } else
- if ( TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
- hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
- else
- hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
- }
+ char *hash_in;
+ if (hint->formatted_node) {
+ hash_in = (char *)&hint->key.k_dir_id;
+ } else {
+ if (!hint->inode) {
+ //hint->search_start = hint->beg;
+ hash_in = (char *)&hint->key.k_dir_id;
+ } else
+ if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
+ hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
+ else
+ hash_in =
+ (char *)(&INODE_PKEY(hint->inode)->k_objectid);
+ }
- hint->search_start = hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
+ hint->search_start =
+ hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
}
/*
* Relocation based on dirid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
-static void
-dirid_groups (reiserfs_blocknr_hint_t *hint)
+static void dirid_groups(reiserfs_blocknr_hint_t * hint)
{
- unsigned long hash;
- __u32 dirid = 0;
- int bm = 0;
- struct super_block *sb = hint->th->t_super;
- if (hint->inode)
- dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
- else if (hint->formatted_node)
- dirid = hint->key.k_dir_id;
-
- if (dirid) {
- bm = bmap_hash_id(sb, dirid);
- hash = bm * (sb->s_blocksize << 3);
- /* give a portion of the block group to metadata */
+ unsigned long hash;
+ __u32 dirid = 0;
+ int bm = 0;
+ struct super_block *sb = hint->th->t_super;
if (hint->inode)
- hash += sb->s_blocksize/2;
- hint->search_start = hash;
- }
+ dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
+ else if (hint->formatted_node)
+ dirid = hint->key.k_dir_id;
+
+ if (dirid) {
+ bm = bmap_hash_id(sb, dirid);
+ hash = bm * (sb->s_blocksize << 3);
+ /* give a portion of the block group to metadata */
+ if (hint->inode)
+ hash += sb->s_blocksize / 2;
+ hint->search_start = hash;
+ }
}
/*
* Relocation based on oid, hashing them into a given bitmap block
* files. Formatted nodes are unaffected, a seperate policy covers them
*/
-static void
-oid_groups (reiserfs_blocknr_hint_t *hint)
+static void oid_groups(reiserfs_blocknr_hint_t * hint)
{
- if (hint->inode) {
- unsigned long hash;
- __u32 oid;
- __u32 dirid;
- int bm;
-
- dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
-
- /* keep the root dir and it's first set of subdirs close to
- * the start of the disk
- */
- if (dirid <= 2)
- hash = (hint->inode->i_sb->s_blocksize << 3);
- else {
- oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid);
- bm = bmap_hash_id(hint->inode->i_sb, oid);
- hash = bm * (hint->inode->i_sb->s_blocksize << 3);
+ if (hint->inode) {
+ unsigned long hash;
+ __u32 oid;
+ __u32 dirid;
+ int bm;
+
+ dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id);
+
+ /* keep the root dir and it's first set of subdirs close to
+ * the start of the disk
+ */
+ if (dirid <= 2)
+ hash = (hint->inode->i_sb->s_blocksize << 3);
+ else {
+ oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid);
+ bm = bmap_hash_id(hint->inode->i_sb, oid);
+ hash = bm * (hint->inode->i_sb->s_blocksize << 3);
+ }
+ hint->search_start = hash;
}
- hint->search_start = hash;
- }
}
/* returns 1 if it finds an indirect item and gets valid hint info
* from it, otherwise 0
*/
-static int get_left_neighbor(reiserfs_blocknr_hint_t *hint)
+static int get_left_neighbor(reiserfs_blocknr_hint_t * hint)
{
- struct path * path;
- struct buffer_head * bh;
- struct item_head * ih;
- int pos_in_item;
- __le32 * item;
- int ret = 0;
-
- if (!hint->path) /* reiserfs code can call this function w/o pointer to path
+ struct path *path;
+ struct buffer_head *bh;
+ struct item_head *ih;
+ int pos_in_item;
+ __le32 *item;
+ int ret = 0;
+
+ if (!hint->path) /* reiserfs code can call this function w/o pointer to path
* structure supplied; then we rely on supplied search_start */
- return 0;
-
- path = hint->path;
- bh = get_last_bh(path);
- RFALSE( !bh, "green-4002: Illegal path specified to get_left_neighbor");
- ih = get_ih(path);
- pos_in_item = path->pos_in_item;
- item = get_item (path);
-
- hint->search_start = bh->b_blocknr;
-
- if (!hint->formatted_node && is_indirect_le_ih (ih)) {
- /* for indirect item: go to left and look for the first non-hole entry
- in the indirect item */
- if (pos_in_item == I_UNFM_NUM (ih))
- pos_in_item--;
-// pos_in_item = I_UNFM_NUM (ih) - 1;
- while (pos_in_item >= 0) {
- int t=get_block_num(item,pos_in_item);
- if (t) {
- hint->search_start = t;
- ret = 1;
- break;
- }
- pos_in_item --;
+ return 0;
+
+ path = hint->path;
+ bh = get_last_bh(path);
+ RFALSE(!bh, "green-4002: Illegal path specified to get_left_neighbor");
+ ih = get_ih(path);
+ pos_in_item = path->pos_in_item;
+ item = get_item(path);
+
+ hint->search_start = bh->b_blocknr;
+
+ if (!hint->formatted_node && is_indirect_le_ih(ih)) {
+ /* for indirect item: go to left and look for the first non-hole entry
+ in the indirect item */
+ if (pos_in_item == I_UNFM_NUM(ih))
+ pos_in_item--;
+// pos_in_item = I_UNFM_NUM (ih) - 1;
+ while (pos_in_item >= 0) {
+ int t = get_block_num(item, pos_in_item);
+ if (t) {
+ hint->search_start = t;
+ ret = 1;
+ break;
+ }
+ pos_in_item--;
+ }
}
- }
- /* does result value fit into specified region? */
- return ret;
+ /* does result value fit into specified region? */
+ return ret;
}
/* should be, if formatted node, then try to put on first part of the device
specified as number of percent with mount option device, else try to put
on last of device. This is not to say it is good code to do so,
but the effect should be measured. */
-static inline void set_border_in_hint(struct super_block *s, reiserfs_blocknr_hint_t *hint)
+static inline void set_border_in_hint(struct super_block *s,
+ reiserfs_blocknr_hint_t * hint)
{
- b_blocknr_t border = SB_BLOCK_COUNT(s) / REISERFS_SB(s)->s_alloc_options.border;
+ b_blocknr_t border =
+ SB_BLOCK_COUNT(s) / REISERFS_SB(s)->s_alloc_options.border;
- if (hint->formatted_node)
- hint->end = border - 1;
- else
- hint->beg = border;
+ if (hint->formatted_node)
+ hint->end = border - 1;
+ else
+ hint->beg = border;
}
-static inline void displace_large_file(reiserfs_blocknr_hint_t *hint)
+static inline void displace_large_file(reiserfs_blocknr_hint_t * hint)
{
- if ( TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
- hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id), 4) % (hint->end - hint->beg);
- else
- hint->search_start = hint->beg + keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid), 4) % (hint->end - hint->beg);
+ if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
+ hint->search_start =
+ hint->beg +
+ keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id),
+ 4) % (hint->end - hint->beg);
+ else
+ hint->search_start =
+ hint->beg +
+ keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid),
+ 4) % (hint->end - hint->beg);
}
-static inline void hash_formatted_node(reiserfs_blocknr_hint_t *hint)
+static inline void hash_formatted_node(reiserfs_blocknr_hint_t * hint)
{
- char * hash_in;
+ char *hash_in;
- if (!hint->inode)
- hash_in = (char*)&hint->key.k_dir_id;
- else if ( TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
- hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
- else
- hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
+ if (!hint->inode)
+ hash_in = (char *)&hint->key.k_dir_id;
+ else if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super))
+ hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id);
+ else
+ hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid);
- hint->search_start = hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
+ hint->search_start =
+ hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg);
}
-static inline int this_blocknr_allocation_would_make_it_a_large_file(reiserfs_blocknr_hint_t *hint)
+static inline int
+this_blocknr_allocation_would_make_it_a_large_file(reiserfs_blocknr_hint_t *
+ hint)
{
- return hint->block == REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size;
+ return hint->block ==
+ REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size;
}
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
-static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint)
+static inline void displace_new_packing_locality(reiserfs_blocknr_hint_t * hint)
{
- struct in_core_key * key = &hint->key;
+ struct in_core_key *key = &hint->key;
- hint->th->displace_new_blocks = 0;
- hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg);
+ hint->th->displace_new_blocks = 0;
+ hint->search_start =
+ hint->beg + keyed_hash((char *)(&key->k_objectid),
+ 4) % (hint->end - hint->beg);
}
- #endif
+#endif
-static inline int old_hashed_relocation (reiserfs_blocknr_hint_t * hint)
+static inline int old_hashed_relocation(reiserfs_blocknr_hint_t * hint)
{
- b_blocknr_t border;
- u32 hash_in;
-
- if (hint->formatted_node || hint->inode == NULL) {
- return 0;
- }
+ b_blocknr_t border;
+ u32 hash_in;
- hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id);
- border = hint->beg + (u32) keyed_hash(((char *) (&hash_in)), 4) % (hint->end - hint->beg - 1);
- if (border > hint->search_start)
- hint->search_start = border;
+ if (hint->formatted_node || hint->inode == NULL) {
+ return 0;
+ }
- return 1;
- }
-
-static inline int old_way (reiserfs_blocknr_hint_t * hint)
-{
- b_blocknr_t border;
-
- if (hint->formatted_node || hint->inode == NULL) {
- return 0;
- }
-
- border = hint->beg + le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end - hint->beg);
- if (border > hint->search_start)
- hint->search_start = border;
+ hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id);
+ border =
+ hint->beg + (u32) keyed_hash(((char *)(&hash_in)),
+ 4) % (hint->end - hint->beg - 1);
+ if (border > hint->search_start)
+ hint->search_start = border;
- return 1;
+ return 1;
}
-static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint)
+static inline int old_way(reiserfs_blocknr_hint_t * hint)
{
- struct in_core_key * key = &hint->key;
- b_blocknr_t slice_start;
+ b_blocknr_t border;
+
+ if (hint->formatted_node || hint->inode == NULL) {
+ return 0;
+ }
+
+ border =
+ hint->beg +
+ le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end -
+ hint->beg);
+ if (border > hint->search_start)
+ hint->search_start = border;
- slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100);
- if ( slice_start > hint->search_start || slice_start + (hint->end / 100) <= hint->search_start) {
- hint->search_start = slice_start;
- }
+ return 1;
+}
+
+static inline void hundredth_slices(reiserfs_blocknr_hint_t * hint)
+{
+ struct in_core_key *key = &hint->key;
+ b_blocknr_t slice_start;
+
+ slice_start =
+ (keyed_hash((char *)(&key->k_dir_id), 4) % 100) * (hint->end / 100);
+ if (slice_start > hint->search_start
+ || slice_start + (hint->end / 100) <= hint->search_start) {
+ hint->search_start = slice_start;
+ }
}
-
-static void determine_search_start(reiserfs_blocknr_hint_t *hint,
- int amount_needed)
+
+static void determine_search_start(reiserfs_blocknr_hint_t * hint,
+ int amount_needed)
{
- struct super_block *s = hint->th->t_super;
- int unfm_hint;
+ struct super_block *s = hint->th->t_super;
+ int unfm_hint;
- hint->beg = 0;
- hint->end = SB_BLOCK_COUNT(s) - 1;
+ hint->beg = 0;
+ hint->end = SB_BLOCK_COUNT(s) - 1;
- /* This is former border algorithm. Now with tunable border offset */
- if (concentrating_formatted_nodes(s))
- set_border_in_hint(s, hint);
+ /* This is former border algorithm. Now with tunable border offset */
+ if (concentrating_formatted_nodes(s))
+ set_border_in_hint(s, hint);
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- /* whenever we create a new directory, we displace it. At first we will
- hash for location, later we might look for a moderately empty place for
- it */
- if (displacing_new_packing_localities(s)
- && hint->th->displace_new_blocks) {
- displace_new_packing_locality(hint);
-
- /* we do not continue determine_search_start,
- * if new packing locality is being displaced */
- return;
- }
+ /* whenever we create a new directory, we displace it. At first we will
+ hash for location, later we might look for a moderately empty place for
+ it */
+ if (displacing_new_packing_localities(s)
+ && hint->th->displace_new_blocks) {
+ displace_new_packing_locality(hint);
+
+ /* we do not continue determine_search_start,
+ * if new packing locality is being displaced */
+ return;
+ }
#endif
-
- /* all persons should feel encouraged to add more special cases here and
- * test them */
- if (displacing_large_files(s) && !hint->formatted_node
- && this_blocknr_allocation_would_make_it_a_large_file(hint)) {
- displace_large_file(hint);
- return;
- }
-
- /* if none of our special cases is relevant, use the left neighbor in the
- tree order of the new node we are allocating for */
- if (hint->formatted_node && TEST_OPTION(hashed_formatted_nodes,s)) {
- hash_formatted_node(hint);
- return;
- }
+ /* all persons should feel encouraged to add more special cases here and
+ * test them */
- unfm_hint = get_left_neighbor(hint);
+ if (displacing_large_files(s) && !hint->formatted_node
+ && this_blocknr_allocation_would_make_it_a_large_file(hint)) {
+ displace_large_file(hint);
+ return;
+ }
- /* Mimic old block allocator behaviour, that is if VFS allowed for preallocation,
- new blocks are displaced based on directory ID. Also, if suggested search_start
- is less than last preallocated block, we start searching from it, assuming that
- HDD dataflow is faster in forward direction */
- if ( TEST_OPTION(old_way, s)) {
- if (!hint->formatted_node) {
- if ( !reiserfs_hashed_relocation(s))
- old_way(hint);
- else if (!reiserfs_no_unhashed_relocation(s))
- old_hashed_relocation(hint);
+ /* if none of our special cases is relevant, use the left neighbor in the
+ tree order of the new node we are allocating for */
+ if (hint->formatted_node && TEST_OPTION(hashed_formatted_nodes, s)) {
+ hash_formatted_node(hint);
+ return;
+ }
- if ( hint->inode && hint->search_start < REISERFS_I(hint->inode)->i_prealloc_block)
- hint->search_start = REISERFS_I(hint->inode)->i_prealloc_block;
+ unfm_hint = get_left_neighbor(hint);
+
+ /* Mimic old block allocator behaviour, that is if VFS allowed for preallocation,
+ new blocks are displaced based on directory ID. Also, if suggested search_start
+ is less than last preallocated block, we start searching from it, assuming that
+ HDD dataflow is faster in forward direction */
+ if (TEST_OPTION(old_way, s)) {
+ if (!hint->formatted_node) {
+ if (!reiserfs_hashed_relocation(s))
+ old_way(hint);
+ else if (!reiserfs_no_unhashed_relocation(s))
+ old_hashed_relocation(hint);
+
+ if (hint->inode
+ && hint->search_start <
+ REISERFS_I(hint->inode)->i_prealloc_block)
+ hint->search_start =
+ REISERFS_I(hint->inode)->i_prealloc_block;
+ }
+ return;
}
- return;
- }
- /* This is an approach proposed by Hans */
- if ( TEST_OPTION(hundredth_slices, s) && ! (displacing_large_files(s) && !hint->formatted_node)) {
- hundredth_slices(hint);
- return;
- }
-
- /* old_hashed_relocation only works on unformatted */
- if (!unfm_hint && !hint->formatted_node &&
- TEST_OPTION(old_hashed_relocation, s))
- {
- old_hashed_relocation(hint);
- }
- /* new_hashed_relocation works with both formatted/unformatted nodes */
- if ((!unfm_hint || hint->formatted_node) &&
- TEST_OPTION(new_hashed_relocation, s))
- {
- new_hashed_relocation(hint);
- }
- /* dirid grouping works only on unformatted nodes */
- if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups,s))
- {
- dirid_groups(hint);
- }
+ /* This is an approach proposed by Hans */
+ if (TEST_OPTION(hundredth_slices, s)
+ && !(displacing_large_files(s) && !hint->formatted_node)) {
+ hundredth_slices(hint);
+ return;
+ }
+ /* old_hashed_relocation only works on unformatted */
+ if (!unfm_hint && !hint->formatted_node &&
+ TEST_OPTION(old_hashed_relocation, s)) {
+ old_hashed_relocation(hint);
+ }
+ /* new_hashed_relocation works with both formatted/unformatted nodes */
+ if ((!unfm_hint || hint->formatted_node) &&
+ TEST_OPTION(new_hashed_relocation, s)) {
+ new_hashed_relocation(hint);
+ }
+ /* dirid grouping works only on unformatted nodes */
+ if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups, s)) {
+ dirid_groups(hint);
+ }
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- if (hint->formatted_node && TEST_OPTION(dirid_groups,s))
- {
- dirid_groups(hint);
- }
+ if (hint->formatted_node && TEST_OPTION(dirid_groups, s)) {
+ dirid_groups(hint);
+ }
#endif
- /* oid grouping works only on unformatted nodes */
- if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups,s))
- {
- oid_groups(hint);
- }
- return;
+ /* oid grouping works only on unformatted nodes */
+ if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups, s)) {
+ oid_groups(hint);
+ }
+ return;
}
static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint)
{
- /* make minimum size a mount option and benchmark both ways */
- /* we preallocate blocks only for regular files, specific size */
- /* benchmark preallocating always and see what happens */
-
- hint->prealloc_size = 0;
-
- if (!hint->formatted_node && hint->preallocate) {
- if (S_ISREG(hint->inode->i_mode)
- && hint->inode->i_size >= REISERFS_SB(hint->th->t_super)->s_alloc_options.preallocmin * hint->inode->i_sb->s_blocksize)
- hint->prealloc_size = REISERFS_SB(hint->th->t_super)->s_alloc_options.preallocsize - 1;
- }
- return CARRY_ON;
+ /* make minimum size a mount option and benchmark both ways */
+ /* we preallocate blocks only for regular files, specific size */
+ /* benchmark preallocating always and see what happens */
+
+ hint->prealloc_size = 0;
+
+ if (!hint->formatted_node && hint->preallocate) {
+ if (S_ISREG(hint->inode->i_mode)
+ && hint->inode->i_size >=
+ REISERFS_SB(hint->th->t_super)->s_alloc_options.
+ preallocmin * hint->inode->i_sb->s_blocksize)
+ hint->prealloc_size =
+ REISERFS_SB(hint->th->t_super)->s_alloc_options.
+ preallocsize - 1;
+ }
+ return CARRY_ON;
}
/* XXX I know it could be merged with upper-level function;
but may be result function would be too complex. */
-static inline int allocate_without_wrapping_disk (reiserfs_blocknr_hint_t * hint,
- b_blocknr_t * new_blocknrs,
- b_blocknr_t start, b_blocknr_t finish,
- int min,
- int amount_needed, int prealloc_size)
+static inline int allocate_without_wrapping_disk(reiserfs_blocknr_hint_t * hint,
+ b_blocknr_t * new_blocknrs,
+ b_blocknr_t start,
+ b_blocknr_t finish, int min,
+ int amount_needed,
+ int prealloc_size)
{
- int rest = amount_needed;
- int nr_allocated;
-
- while (rest > 0 && start <= finish) {
- nr_allocated = scan_bitmap (hint->th, &start, finish, min,
- rest + prealloc_size, !hint->formatted_node,
- hint->block);
-
- if (nr_allocated == 0) /* no new blocks allocated, return */
- break;
-
- /* fill free_blocknrs array first */
- while (rest > 0 && nr_allocated > 0) {
- * new_blocknrs ++ = start ++;
- rest --; nr_allocated --;
- }
+ int rest = amount_needed;
+ int nr_allocated;
+
+ while (rest > 0 && start <= finish) {
+ nr_allocated = scan_bitmap(hint->th, &start, finish, min,
+ rest + prealloc_size,
+ !hint->formatted_node, hint->block);
+
+ if (nr_allocated == 0) /* no new blocks allocated, return */
+ break;
+
+ /* fill free_blocknrs array first */
+ while (rest > 0 && nr_allocated > 0) {
+ *new_blocknrs++ = start++;
+ rest--;
+ nr_allocated--;
+ }
- /* do we have something to fill prealloc. array also ? */
- if (nr_allocated > 0) {
- /* it means prealloc_size was greater that 0 and we do preallocation */
- list_add(&REISERFS_I(hint->inode)->i_prealloc_list,
- &SB_JOURNAL(hint->th->t_super)->j_prealloc_list);
- REISERFS_I(hint->inode)->i_prealloc_block = start;
- REISERFS_I(hint->inode)->i_prealloc_count = nr_allocated;
- break;
+ /* do we have something to fill prealloc. array also ? */
+ if (nr_allocated > 0) {
+ /* it means prealloc_size was greater that 0 and we do preallocation */
+ list_add(&REISERFS_I(hint->inode)->i_prealloc_list,
+ &SB_JOURNAL(hint->th->t_super)->
+ j_prealloc_list);
+ REISERFS_I(hint->inode)->i_prealloc_block = start;
+ REISERFS_I(hint->inode)->i_prealloc_count =
+ nr_allocated;
+ break;
+ }
}
- }
- return (amount_needed - rest);
+ return (amount_needed - rest);
}
static inline int blocknrs_and_prealloc_arrays_from_search_start
- (reiserfs_blocknr_hint_t *hint, b_blocknr_t *new_blocknrs, int amount_needed)
-{
- struct super_block *s = hint->th->t_super;
- b_blocknr_t start = hint->search_start;
- b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
- int passno = 0;
- int nr_allocated = 0;
- int bigalloc = 0;
-
- determine_prealloc_size(hint);
- if (!hint->formatted_node) {
- int quota_ret;
+ (reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs,
+ int amount_needed) {
+ struct super_block *s = hint->th->t_super;
+ b_blocknr_t start = hint->search_start;
+ b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
+ int passno = 0;
+ int nr_allocated = 0;
+ int bigalloc = 0;
+
+ determine_prealloc_size(hint);
+ if (!hint->formatted_node) {
+ int quota_ret;
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: allocating %d blocks id=%u", amount_needed, hint->inode->i_uid);
+ reiserfs_debug(s, REISERFS_DEBUG_CODE,
+ "reiserquota: allocating %d blocks id=%u",
+ amount_needed, hint->inode->i_uid);
#endif
- quota_ret = DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
- if (quota_ret) /* Quota exceeded? */
- return QUOTA_EXCEEDED;
- if (hint->preallocate && hint->prealloc_size ) {
+ quota_ret =
+ DQUOT_ALLOC_BLOCK_NODIRTY(hint->inode, amount_needed);
+ if (quota_ret) /* Quota exceeded? */
+ return QUOTA_EXCEEDED;
+ if (hint->preallocate && hint->prealloc_size) {
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: allocating (prealloc) %d blocks id=%u", hint->prealloc_size, hint->inode->i_uid);
+ reiserfs_debug(s, REISERFS_DEBUG_CODE,
+ "reiserquota: allocating (prealloc) %d blocks id=%u",
+ hint->prealloc_size, hint->inode->i_uid);
#endif
- quota_ret = DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode, hint->prealloc_size);
- if (quota_ret)
- hint->preallocate=hint->prealloc_size=0;
+ quota_ret =
+ DQUOT_PREALLOC_BLOCK_NODIRTY(hint->inode,
+ hint->prealloc_size);
+ if (quota_ret)
+ hint->preallocate = hint->prealloc_size = 0;
+ }
+ /* for unformatted nodes, force large allocations */
+ bigalloc = amount_needed;
}
- /* for unformatted nodes, force large allocations */
- bigalloc = amount_needed;
- }
- do {
- /* in bigalloc mode, nr_allocated should stay zero until
- * the entire allocation is filled
- */
- if (unlikely(bigalloc && nr_allocated)) {
- reiserfs_warning(s, "bigalloc is %d, nr_allocated %d\n",
- bigalloc, nr_allocated);
- /* reset things to a sane value */
- bigalloc = amount_needed - nr_allocated;
- }
- /*
- * try pass 0 and pass 1 looking for a nice big
- * contiguous allocation. Then reset and look
- * for anything you can find.
- */
- if (passno == 2 && bigalloc) {
- passno = 0;
- bigalloc = 0;
- }
- switch (passno++) {
- case 0: /* Search from hint->search_start to end of disk */
- start = hint->search_start;
- finish = SB_BLOCK_COUNT(s) - 1;
- break;
- case 1: /* Search from hint->beg to hint->search_start */
- start = hint->beg;
- finish = hint->search_start;
- break;
- case 2: /* Last chance: Search from 0 to hint->beg */
- start = 0;
- finish = hint->beg;
- break;
- default: /* We've tried searching everywhere, not enough space */
- /* Free the blocks */
- if (!hint->formatted_node) {
+ do {
+ /* in bigalloc mode, nr_allocated should stay zero until
+ * the entire allocation is filled
+ */
+ if (unlikely(bigalloc && nr_allocated)) {
+ reiserfs_warning(s, "bigalloc is %d, nr_allocated %d\n",
+ bigalloc, nr_allocated);
+ /* reset things to a sane value */
+ bigalloc = amount_needed - nr_allocated;
+ }
+ /*
+ * try pass 0 and pass 1 looking for a nice big
+ * contiguous allocation. Then reset and look
+ * for anything you can find.
+ */
+ if (passno == 2 && bigalloc) {
+ passno = 0;
+ bigalloc = 0;
+ }
+ switch (passno++) {
+ case 0: /* Search from hint->search_start to end of disk */
+ start = hint->search_start;
+ finish = SB_BLOCK_COUNT(s) - 1;
+ break;
+ case 1: /* Search from hint->beg to hint->search_start */
+ start = hint->beg;
+ finish = hint->search_start;
+ break;
+ case 2: /* Last chance: Search from 0 to hint->beg */
+ start = 0;
+ finish = hint->beg;
+ break;
+ default: /* We've tried searching everywhere, not enough space */
+ /* Free the blocks */
+ if (!hint->formatted_node) {
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: freeing (nospace) %d blocks id=%u", amount_needed + hint->prealloc_size - nr_allocated, hint->inode->i_uid);
+ reiserfs_debug(s, REISERFS_DEBUG_CODE,
+ "reiserquota: freeing (nospace) %d blocks id=%u",
+ amount_needed +
+ hint->prealloc_size -
+ nr_allocated,
+ hint->inode->i_uid);
#endif
- DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
- }
- while (nr_allocated --)
- reiserfs_free_block(hint->th, hint->inode, new_blocknrs[nr_allocated], !hint->formatted_node);
-
- return NO_DISK_SPACE;
- }
- } while ((nr_allocated += allocate_without_wrapping_disk (hint,
- new_blocknrs + nr_allocated, start, finish,
- bigalloc ? bigalloc : 1,
- amount_needed - nr_allocated,
- hint->prealloc_size))
- < amount_needed);
- if ( !hint->formatted_node &&
- amount_needed + hint->prealloc_size >
- nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) {
- /* Some of preallocation blocks were not allocated */
+ DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated); /* Free not allocated blocks */
+ }
+ while (nr_allocated--)
+ reiserfs_free_block(hint->th, hint->inode,
+ new_blocknrs[nr_allocated],
+ !hint->formatted_node);
+
+ return NO_DISK_SPACE;
+ }
+ } while ((nr_allocated += allocate_without_wrapping_disk(hint,
+ new_blocknrs +
+ nr_allocated,
+ start, finish,
+ bigalloc ?
+ bigalloc : 1,
+ amount_needed -
+ nr_allocated,
+ hint->
+ prealloc_size))
+ < amount_needed);
+ if (!hint->formatted_node &&
+ amount_needed + hint->prealloc_size >
+ nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) {
+ /* Some of preallocation blocks were not allocated */
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (s, REISERFS_DEBUG_CODE, "reiserquota: freeing (failed prealloc) %d blocks id=%u", amount_needed + hint->prealloc_size - nr_allocated - REISERFS_I(hint->inode)->i_prealloc_count, hint->inode->i_uid);
+ reiserfs_debug(s, REISERFS_DEBUG_CODE,
+ "reiserquota: freeing (failed prealloc) %d blocks id=%u",
+ amount_needed + hint->prealloc_size -
+ nr_allocated -
+ REISERFS_I(hint->inode)->i_prealloc_count,
+ hint->inode->i_uid);
#endif
- DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
- hint->prealloc_size - nr_allocated -
- REISERFS_I(hint->inode)->i_prealloc_count);
- }
+ DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed +
+ hint->prealloc_size - nr_allocated -
+ REISERFS_I(hint->inode)->
+ i_prealloc_count);
+ }
- return CARRY_ON;
+ return CARRY_ON;
}
/* grab new blocknrs from preallocated list */
/* return amount still needed after using them */
-static int use_preallocated_list_if_available (reiserfs_blocknr_hint_t *hint,
- b_blocknr_t *new_blocknrs, int amount_needed)
+static int use_preallocated_list_if_available(reiserfs_blocknr_hint_t * hint,
+ b_blocknr_t * new_blocknrs,
+ int amount_needed)
{
- struct inode * inode = hint->inode;
+ struct inode *inode = hint->inode;
- if (REISERFS_I(inode)->i_prealloc_count > 0) {
- while (amount_needed) {
+ if (REISERFS_I(inode)->i_prealloc_count > 0) {
+ while (amount_needed) {
- *new_blocknrs ++ = REISERFS_I(inode)->i_prealloc_block ++;
- REISERFS_I(inode)->i_prealloc_count --;
+ *new_blocknrs++ = REISERFS_I(inode)->i_prealloc_block++;
+ REISERFS_I(inode)->i_prealloc_count--;
- amount_needed --;
+ amount_needed--;
- if (REISERFS_I(inode)->i_prealloc_count <= 0) {
- list_del(&REISERFS_I(inode)->i_prealloc_list);
- break;
- }
+ if (REISERFS_I(inode)->i_prealloc_count <= 0) {
+ list_del(&REISERFS_I(inode)->i_prealloc_list);
+ break;
+ }
+ }
}
- }
- /* return amount still needed after using preallocated blocks */
- return amount_needed;
+ /* return amount still needed after using preallocated blocks */
+ return amount_needed;
}
-int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint,
- b_blocknr_t * new_blocknrs, int amount_needed,
- int reserved_by_us /* Amount of blocks we have
- already reserved */)
+int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs, int amount_needed, int reserved_by_us /* Amount of blocks we have
+ already reserved */ )
{
- int initial_amount_needed = amount_needed;
- int ret;
- struct super_block *s = hint->th->t_super;
-
- /* Check if there is enough space, taking into account reserved space */
- if ( SB_FREE_BLOCKS(s) - REISERFS_SB(s)->reserved_blocks <
- amount_needed - reserved_by_us)
- return NO_DISK_SPACE;
- /* should this be if !hint->inode && hint->preallocate? */
- /* do you mean hint->formatted_node can be removed ? - Zam */
- /* hint->formatted_node cannot be removed because we try to access
- inode information here, and there is often no inode assotiated with
- metadata allocations - green */
-
- if (!hint->formatted_node && hint->preallocate) {
- amount_needed = use_preallocated_list_if_available
+ int initial_amount_needed = amount_needed;
+ int ret;
+ struct super_block *s = hint->th->t_super;
+
+ /* Check if there is enough space, taking into account reserved space */
+ if (SB_FREE_BLOCKS(s) - REISERFS_SB(s)->reserved_blocks <
+ amount_needed - reserved_by_us)
+ return NO_DISK_SPACE;
+ /* should this be if !hint->inode && hint->preallocate? */
+ /* do you mean hint->formatted_node can be removed ? - Zam */
+ /* hint->formatted_node cannot be removed because we try to access
+ inode information here, and there is often no inode assotiated with
+ metadata allocations - green */
+
+ if (!hint->formatted_node && hint->preallocate) {
+ amount_needed = use_preallocated_list_if_available
+ (hint, new_blocknrs, amount_needed);
+ if (amount_needed == 0) /* all blocknrs we need we got from
+ prealloc. list */
+ return CARRY_ON;
+ new_blocknrs += (initial_amount_needed - amount_needed);
+ }
+
+ /* find search start and save it in hint structure */
+ determine_search_start(hint, amount_needed);
+ if (hint->search_start >= SB_BLOCK_COUNT(s))
+ hint->search_start = SB_BLOCK_COUNT(s) - 1;
+
+ /* allocation itself; fill new_blocknrs and preallocation arrays */
+ ret = blocknrs_and_prealloc_arrays_from_search_start
(hint, new_blocknrs, amount_needed);
- if (amount_needed == 0) /* all blocknrs we need we got from
- prealloc. list */
- return CARRY_ON;
- new_blocknrs += (initial_amount_needed - amount_needed);
- }
-
- /* find search start and save it in hint structure */
- determine_search_start(hint, amount_needed);
- if (hint->search_start >= SB_BLOCK_COUNT(s))
- hint->search_start = SB_BLOCK_COUNT(s) - 1;
-
- /* allocation itself; fill new_blocknrs and preallocation arrays */
- ret = blocknrs_and_prealloc_arrays_from_search_start
- (hint, new_blocknrs, amount_needed);
-
- /* we used prealloc. list to fill (partially) new_blocknrs array. If final allocation fails we
- * need to return blocks back to prealloc. list or just free them. -- Zam (I chose second
- * variant) */
-
- if (ret != CARRY_ON) {
- while (amount_needed ++ < initial_amount_needed) {
- reiserfs_free_block(hint->th, hint->inode, *(--new_blocknrs), 1);
+
+ /* we used prealloc. list to fill (partially) new_blocknrs array. If final allocation fails we
+ * need to return blocks back to prealloc. list or just free them. -- Zam (I chose second
+ * variant) */
+
+ if (ret != CARRY_ON) {
+ while (amount_needed++ < initial_amount_needed) {
+ reiserfs_free_block(hint->th, hint->inode,
+ *(--new_blocknrs), 1);
+ }
}
- }
- return ret;
+ return ret;
}
/* These 2 functions are here to provide blocks reservation to the rest of kernel */
/* Reserve @blocks amount of blocks in fs pointed by @sb. Caller must make sure
there are actually this much blocks on the FS available */
-void reiserfs_claim_blocks_to_be_allocated(
- struct super_block *sb, /* super block of
- filesystem where
- blocks should be
- reserved */
- int blocks /* How much to reserve */
- )
+void reiserfs_claim_blocks_to_be_allocated(struct super_block *sb, /* super block of
+ filesystem where
+ blocks should be
+ reserved */
+ int blocks /* How much to reserve */
+ )
{
- /* Fast case, if reservation is zero - exit immediately. */
- if ( !blocks )
- return;
+ /* Fast case, if reservation is zero - exit immediately. */
+ if (!blocks)
+ return;
- spin_lock(&REISERFS_SB(sb)->bitmap_lock);
- REISERFS_SB(sb)->reserved_blocks += blocks;
- spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
+ spin_lock(&REISERFS_SB(sb)->bitmap_lock);
+ REISERFS_SB(sb)->reserved_blocks += blocks;
+ spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
}
/* Unreserve @blocks amount of blocks in fs pointed by @sb */
-void reiserfs_release_claimed_blocks(
- struct super_block *sb, /* super block of
- filesystem where
- blocks should be
- reserved */
- int blocks /* How much to unreserve */
- )
+void reiserfs_release_claimed_blocks(struct super_block *sb, /* super block of
+ filesystem where
+ blocks should be
+ reserved */
+ int blocks /* How much to unreserve */
+ )
{
- /* Fast case, if unreservation is zero - exit immediately. */
- if ( !blocks )
- return;
+ /* Fast case, if unreservation is zero - exit immediately. */
+ if (!blocks)
+ return;
- spin_lock(&REISERFS_SB(sb)->bitmap_lock);
- REISERFS_SB(sb)->reserved_blocks -= blocks;
- spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
- RFALSE( REISERFS_SB(sb)->reserved_blocks < 0, "amount of blocks reserved became zero?");
+ spin_lock(&REISERFS_SB(sb)->bitmap_lock);
+ REISERFS_SB(sb)->reserved_blocks -= blocks;
+ spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
+ RFALSE(REISERFS_SB(sb)->reserved_blocks < 0,
+ "amount of blocks reserved became zero?");
}
/* This function estimates how much pages we will be able to write to FS
used for reiserfs_file_write() purposes for now. */
-int reiserfs_can_fit_pages ( struct super_block *sb /* superblock of filesystem
- to estimate space */ )
+int reiserfs_can_fit_pages(struct super_block *sb /* superblock of filesystem
+ to estimate space */ )
{
int space;
spin_lock(&REISERFS_SB(sb)->bitmap_lock);
- space = (SB_FREE_BLOCKS(sb) - REISERFS_SB(sb)->reserved_blocks) >> ( PAGE_CACHE_SHIFT - sb->s_blocksize_bits);
+ space =
+ (SB_FREE_BLOCKS(sb) -
+ REISERFS_SB(sb)->reserved_blocks) >> (PAGE_CACHE_SHIFT -
+ sb->s_blocksize_bits);
spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
- return space>0?space:0;
+ return space > 0 ? space : 0;
}
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index fbde4b01a32..9dd71e80703 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -12,264 +12,286 @@
#include <linux/buffer_head.h>
#include <asm/uaccess.h>
-extern struct reiserfs_key MIN_KEY;
+extern struct reiserfs_key MIN_KEY;
-static int reiserfs_readdir (struct file *, void *, filldir_t);
-static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) ;
+static int reiserfs_readdir(struct file *, void *, filldir_t);
+static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
+ int datasync);
struct file_operations reiserfs_dir_operations = {
- .read = generic_read_dir,
- .readdir = reiserfs_readdir,
- .fsync = reiserfs_dir_fsync,
- .ioctl = reiserfs_ioctl,
+ .read = generic_read_dir,
+ .readdir = reiserfs_readdir,
+ .fsync = reiserfs_dir_fsync,
+ .ioctl = reiserfs_ioctl,
};
-static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, int datasync) {
- struct inode *inode = dentry->d_inode;
- int err;
- reiserfs_write_lock(inode->i_sb);
- err = reiserfs_commit_for_inode(inode) ;
- reiserfs_write_unlock(inode->i_sb) ;
- if (err < 0)
- return err;
- return 0;
+static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry,
+ int datasync)
+{
+ struct inode *inode = dentry->d_inode;
+ int err;
+ reiserfs_write_lock(inode->i_sb);
+ err = reiserfs_commit_for_inode(inode);
+ reiserfs_write_unlock(inode->i_sb);
+ if (err < 0)
+ return err;
+ return 0;
}
-
#define store_ih(where,what) copy_item_head (where, what)
//
-static int reiserfs_readdir (struct file * filp, void * dirent, filldir_t filldir)
+static int reiserfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
- struct inode *inode = filp->f_dentry->d_inode;
- struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
- INITIALIZE_PATH (path_to_entry);
- struct buffer_head * bh;
- int item_num, entry_num;
- const struct reiserfs_key * rkey;
- struct item_head * ih, tmp_ih;
- int search_res;
- char * local_buf;
- loff_t next_pos;
- char small_buf[32] ; /* avoid kmalloc if we can */
- struct reiserfs_dir_entry de;
- int ret = 0;
-
- reiserfs_write_lock(inode->i_sb);
-
- reiserfs_check_lock_depth(inode->i_sb, "readdir") ;
-
- /* form key for search the next directory entry using f_pos field of
- file structure */
- make_cpu_key (&pos_key, inode, (filp->f_pos) ? (filp->f_pos) : DOT_OFFSET,
- TYPE_DIRENTRY, 3);
- next_pos = cpu_key_k_offset (&pos_key);
-
- /* reiserfs_warning (inode->i_sb, "reiserfs_readdir 1: f_pos = %Ld", filp->f_pos);*/
-
- path_to_entry.reada = PATH_READA;
- while (1) {
- research:
- /* search the directory item, containing entry with specified key */
- search_res = search_by_entry_key (inode->i_sb, &pos_key, &path_to_entry, &de);
- if (search_res == IO_ERROR) {
- // FIXME: we could just skip part of directory which could
- // not be read
- ret = -EIO;
- goto out;
- }
- entry_num = de.de_entry_num;
- bh = de.de_bh;
- item_num = de.de_item_num;
- ih = de.de_ih;
- store_ih (&tmp_ih, ih);
-
- /* we must have found item, that is item of this directory, */
- RFALSE( COMP_SHORT_KEYS (&(ih->ih_key), &pos_key),
- "vs-9000: found item %h does not match to dir we readdir %K",
- ih, &pos_key);
- RFALSE( item_num > B_NR_ITEMS (bh) - 1,
- "vs-9005 item_num == %d, item amount == %d",
- item_num, B_NR_ITEMS (bh));
-
- /* and entry must be not more than number of entries in the item */
- RFALSE( I_ENTRY_COUNT (ih) < entry_num,
- "vs-9010: entry number is too big %d (%d)",
- entry_num, I_ENTRY_COUNT (ih));
-
- if (search_res == POSITION_FOUND || entry_num < I_ENTRY_COUNT (ih)) {
- /* go through all entries in the directory item beginning from the entry, that has been found */
- struct reiserfs_de_head * deh = B_I_DEH (bh, ih) + entry_num;
-
- for (; entry_num < I_ENTRY_COUNT (ih); entry_num ++, deh ++) {
- int d_reclen;
- char * d_name;
- off_t d_off;
- ino_t d_ino;
-
- if (!de_visible (deh))
- /* it is hidden entry */
- continue;
- d_reclen = entry_length (bh, ih, entry_num);
- d_name = B_I_DEH_ENTRY_FILE_NAME (bh, ih, deh);
- if (!d_name[d_reclen - 1])
- d_reclen = strlen (d_name);
-
- if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)){
- /* too big to send back to VFS */
- continue ;
- }
-
- /* Ignore the .reiserfs_priv entry */
- if (reiserfs_xattrs (inode->i_sb) &&
- !old_format_only(inode->i_sb) &&
- filp->f_dentry == inode->i_sb->s_root &&
- REISERFS_SB(inode->i_sb)->priv_root &&
- REISERFS_SB(inode->i_sb)->priv_root->d_inode &&
- deh_objectid(deh) == le32_to_cpu (INODE_PKEY(REISERFS_SB(inode->i_sb)->priv_root->d_inode)->k_objectid)) {
- continue;
- }
-
- d_off = deh_offset (deh);
- filp->f_pos = d_off ;
- d_ino = deh_objectid (deh);
- if (d_reclen <= 32) {
- local_buf = small_buf ;
- } else {
- local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
- if (!local_buf) {
- pathrelse (&path_to_entry);
- ret = -ENOMEM ;
+ struct inode *inode = filp->f_dentry->d_inode;
+ struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
+ INITIALIZE_PATH(path_to_entry);
+ struct buffer_head *bh;
+ int item_num, entry_num;
+ const struct reiserfs_key *rkey;
+ struct item_head *ih, tmp_ih;
+ int search_res;
+ char *local_buf;
+ loff_t next_pos;
+ char small_buf[32]; /* avoid kmalloc if we can */
+ struct reiserfs_dir_entry de;
+ int ret = 0;
+
+ reiserfs_write_lock(inode->i_sb);
+
+ reiserfs_check_lock_depth(inode->i_sb, "readdir");
+
+ /* form key for search the next directory entry using f_pos field of
+ file structure */
+ make_cpu_key(&pos_key, inode,
+ (filp->f_pos) ? (filp->f_pos) : DOT_OFFSET, TYPE_DIRENTRY,
+ 3);
+ next_pos = cpu_key_k_offset(&pos_key);
+
+ /* reiserfs_warning (inode->i_sb, "reiserfs_readdir 1: f_pos = %Ld", filp->f_pos); */
+
+ path_to_entry.reada = PATH_READA;
+ while (1) {
+ research:
+ /* search the directory item, containing entry with specified key */
+ search_res =
+ search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
+ &de);
+ if (search_res == IO_ERROR) {
+ // FIXME: we could just skip part of directory which could
+ // not be read
+ ret = -EIO;
goto out;
- }
- if (item_moved (&tmp_ih, &path_to_entry)) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
- goto research;
- }
- }
- // Note, that we copy name to user space via temporary
- // buffer (local_buf) because filldir will block if
- // user space buffer is swapped out. At that time
- // entry can move to somewhere else
- memcpy (local_buf, d_name, d_reclen);
- if (filldir (dirent, local_buf, d_reclen, d_off, d_ino,
- DT_UNKNOWN) < 0) {
- if (local_buf != small_buf) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
- }
- goto end;
}
- if (local_buf != small_buf) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
+ entry_num = de.de_entry_num;
+ bh = de.de_bh;
+ item_num = de.de_item_num;
+ ih = de.de_ih;
+ store_ih(&tmp_ih, ih);
+
+ /* we must have found item, that is item of this directory, */
+ RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
+ "vs-9000: found item %h does not match to dir we readdir %K",
+ ih, &pos_key);
+ RFALSE(item_num > B_NR_ITEMS(bh) - 1,
+ "vs-9005 item_num == %d, item amount == %d",
+ item_num, B_NR_ITEMS(bh));
+
+ /* and entry must be not more than number of entries in the item */
+ RFALSE(I_ENTRY_COUNT(ih) < entry_num,
+ "vs-9010: entry number is too big %d (%d)",
+ entry_num, I_ENTRY_COUNT(ih));
+
+ if (search_res == POSITION_FOUND
+ || entry_num < I_ENTRY_COUNT(ih)) {
+ /* go through all entries in the directory item beginning from the entry, that has been found */
+ struct reiserfs_de_head *deh =
+ B_I_DEH(bh, ih) + entry_num;
+
+ for (; entry_num < I_ENTRY_COUNT(ih);
+ entry_num++, deh++) {
+ int d_reclen;
+ char *d_name;
+ off_t d_off;
+ ino_t d_ino;
+
+ if (!de_visible(deh))
+ /* it is hidden entry */
+ continue;
+ d_reclen = entry_length(bh, ih, entry_num);
+ d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
+ if (!d_name[d_reclen - 1])
+ d_reclen = strlen(d_name);
+
+ if (d_reclen >
+ REISERFS_MAX_NAME(inode->i_sb->
+ s_blocksize)) {
+ /* too big to send back to VFS */
+ continue;
+ }
+
+ /* Ignore the .reiserfs_priv entry */
+ if (reiserfs_xattrs(inode->i_sb) &&
+ !old_format_only(inode->i_sb) &&
+ filp->f_dentry == inode->i_sb->s_root &&
+ REISERFS_SB(inode->i_sb)->priv_root &&
+ REISERFS_SB(inode->i_sb)->priv_root->d_inode
+ && deh_objectid(deh) ==
+ le32_to_cpu(INODE_PKEY
+ (REISERFS_SB(inode->i_sb)->
+ priv_root->d_inode)->
+ k_objectid)) {
+ continue;
+ }
+
+ d_off = deh_offset(deh);
+ filp->f_pos = d_off;
+ d_ino = deh_objectid(deh);
+ if (d_reclen <= 32) {
+ local_buf = small_buf;
+ } else {
+ local_buf =
+ reiserfs_kmalloc(d_reclen, GFP_NOFS,
+ inode->i_sb);
+ if (!local_buf) {
+ pathrelse(&path_to_entry);
+ ret = -ENOMEM;
+ goto out;
+ }
+ if (item_moved(&tmp_ih, &path_to_entry)) {
+ reiserfs_kfree(local_buf,
+ d_reclen,
+ inode->i_sb);
+ goto research;
+ }
+ }
+ // Note, that we copy name to user space via temporary
+ // buffer (local_buf) because filldir will block if
+ // user space buffer is swapped out. At that time
+ // entry can move to somewhere else
+ memcpy(local_buf, d_name, d_reclen);
+ if (filldir
+ (dirent, local_buf, d_reclen, d_off, d_ino,
+ DT_UNKNOWN) < 0) {
+ if (local_buf != small_buf) {
+ reiserfs_kfree(local_buf,
+ d_reclen,
+ inode->i_sb);
+ }
+ goto end;
+ }
+ if (local_buf != small_buf) {
+ reiserfs_kfree(local_buf, d_reclen,
+ inode->i_sb);
+ }
+ // next entry should be looked for with such offset
+ next_pos = deh_offset(deh) + 1;
+
+ if (item_moved(&tmp_ih, &path_to_entry)) {
+ goto research;
+ }
+ } /* for */
}
- // next entry should be looked for with such offset
- next_pos = deh_offset (deh) + 1;
+ if (item_num != B_NR_ITEMS(bh) - 1)
+ // end of directory has been reached
+ goto end;
+
+ /* item we went through is last item of node. Using right
+ delimiting key check is it directory end */
+ rkey = get_rkey(&path_to_entry, inode->i_sb);
+ if (!comp_le_keys(rkey, &MIN_KEY)) {
+ /* set pos_key to key, that is the smallest and greater
+ that key of the last entry in the item */
+ set_cpu_key_k_offset(&pos_key, next_pos);
+ continue;
+ }
- if (item_moved (&tmp_ih, &path_to_entry)) {
- goto research;
+ if (COMP_SHORT_KEYS(rkey, &pos_key)) {
+ // end of directory has been reached
+ goto end;
}
- } /* for */
- }
-
- if (item_num != B_NR_ITEMS (bh) - 1)
- // end of directory has been reached
- goto end;
-
- /* item we went through is last item of node. Using right
- delimiting key check is it directory end */
- rkey = get_rkey (&path_to_entry, inode->i_sb);
- if (! comp_le_keys (rkey, &MIN_KEY)) {
- /* set pos_key to key, that is the smallest and greater
- that key of the last entry in the item */
- set_cpu_key_k_offset (&pos_key, next_pos);
- continue;
- }
-
- if ( COMP_SHORT_KEYS (rkey, &pos_key)) {
- // end of directory has been reached
- goto end;
- }
-
- /* directory continues in the right neighboring block */
- set_cpu_key_k_offset (&pos_key, le_key_k_offset (KEY_FORMAT_3_5, rkey));
-
- } /* while */
-
-
- end:
- filp->f_pos = next_pos;
- pathrelse (&path_to_entry);
- reiserfs_check_path(&path_to_entry) ;
- out:
- reiserfs_write_unlock(inode->i_sb);
- return ret;
+
+ /* directory continues in the right neighboring block */
+ set_cpu_key_k_offset(&pos_key,
+ le_key_k_offset(KEY_FORMAT_3_5, rkey));
+
+ } /* while */
+
+ end:
+ filp->f_pos = next_pos;
+ pathrelse(&path_to_entry);
+ reiserfs_check_path(&path_to_entry);
+ out:
+ reiserfs_write_unlock(inode->i_sb);
+ return ret;
}
/* compose directory item containing "." and ".." entries (entries are
not aligned to 4 byte boundary) */
/* the last four params are LE */
-void make_empty_dir_item_v1 (char * body, __le32 dirid, __le32 objid,
- __le32 par_dirid, __le32 par_objid)
+void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid,
+ __le32 par_dirid, __le32 par_objid)
{
- struct reiserfs_de_head * deh;
-
- memset (body, 0, EMPTY_DIR_SIZE_V1);
- deh = (struct reiserfs_de_head *)body;
-
- /* direntry header of "." */
- put_deh_offset( &(deh[0]), DOT_OFFSET );
- /* these two are from make_le_item_head, and are are LE */
- deh[0].deh_dir_id = dirid;
- deh[0].deh_objectid = objid;
- deh[0].deh_state = 0; /* Endian safe if 0 */
- put_deh_location( &(deh[0]), EMPTY_DIR_SIZE_V1 - strlen( "." ));
- mark_de_visible(&(deh[0]));
-
- /* direntry header of ".." */
- put_deh_offset( &(deh[1]), DOT_DOT_OFFSET);
- /* key of ".." for the root directory */
- /* these two are from the inode, and are are LE */
- deh[1].deh_dir_id = par_dirid;
- deh[1].deh_objectid = par_objid;
- deh[1].deh_state = 0; /* Endian safe if 0 */
- put_deh_location( &(deh[1]), deh_location( &(deh[0]) ) - strlen( ".." ) );
- mark_de_visible(&(deh[1]));
-
- /* copy ".." and "." */
- memcpy (body + deh_location( &(deh[0]) ), ".", 1);
- memcpy (body + deh_location( &(deh[1]) ), "..", 2);
+ struct reiserfs_de_head *deh;
+
+ memset(body, 0, EMPTY_DIR_SIZE_V1);
+ deh = (struct reiserfs_de_head *)body;
+
+ /* direntry header of "." */
+ put_deh_offset(&(deh[0]), DOT_OFFSET);
+ /* these two are from make_le_item_head, and are are LE */
+ deh[0].deh_dir_id = dirid;
+ deh[0].deh_objectid = objid;
+ deh[0].deh_state = 0; /* Endian safe if 0 */
+ put_deh_location(&(deh[0]), EMPTY_DIR_SIZE_V1 - strlen("."));
+ mark_de_visible(&(deh[0]));
+
+ /* direntry header of ".." */
+ put_deh_offset(&(deh[1]), DOT_DOT_OFFSET);
+ /* key of ".." for the root directory */
+ /* these two are from the inode, and are are LE */
+ deh[1].deh_dir_id = par_dirid;
+ deh[1].deh_objectid = par_objid;
+ deh[1].deh_state = 0; /* Endian safe if 0 */
+ put_deh_location(&(deh[1]), deh_location(&(deh[0])) - strlen(".."));
+ mark_de_visible(&(deh[1]));
+
+ /* copy ".." and "." */
+ memcpy(body + deh_location(&(deh[0])), ".", 1);
+ memcpy(body + deh_location(&(deh[1])), "..", 2);
}
/* compose directory item containing "." and ".." entries */
-void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
- __le32 par_dirid, __le32 par_objid)
+void make_empty_dir_item(char *body, __le32 dirid, __le32 objid,
+ __le32 par_dirid, __le32 par_objid)
{
- struct reiserfs_de_head * deh;
-
- memset (body, 0, EMPTY_DIR_SIZE);
- deh = (struct reiserfs_de_head *)body;
-
- /* direntry header of "." */
- put_deh_offset( &(deh[0]), DOT_OFFSET );
- /* these two are from make_le_item_head, and are are LE */
- deh[0].deh_dir_id = dirid;
- deh[0].deh_objectid = objid;
- deh[0].deh_state = 0; /* Endian safe if 0 */
- put_deh_location( &(deh[0]), EMPTY_DIR_SIZE - ROUND_UP( strlen( "." ) ) );
- mark_de_visible(&(deh[0]));
-
- /* direntry header of ".." */
- put_deh_offset( &(deh[1]), DOT_DOT_OFFSET );
- /* key of ".." for the root directory */
- /* these two are from the inode, and are are LE */
- deh[1].deh_dir_id = par_dirid;
- deh[1].deh_objectid = par_objid;
- deh[1].deh_state = 0; /* Endian safe if 0 */
- put_deh_location( &(deh[1]), deh_location( &(deh[0])) - ROUND_UP( strlen( ".." ) ) );
- mark_de_visible(&(deh[1]));
-
- /* copy ".." and "." */
- memcpy (body + deh_location( &(deh[0]) ), ".", 1);
- memcpy (body + deh_location( &(deh[1]) ), "..", 2);
+ struct reiserfs_de_head *deh;
+
+ memset(body, 0, EMPTY_DIR_SIZE);
+ deh = (struct reiserfs_de_head *)body;
+
+ /* direntry header of "." */
+ put_deh_offset(&(deh[0]), DOT_OFFSET);
+ /* these two are from make_le_item_head, and are are LE */
+ deh[0].deh_dir_id = dirid;
+ deh[0].deh_objectid = objid;
+ deh[0].deh_state = 0; /* Endian safe if 0 */
+ put_deh_location(&(deh[0]), EMPTY_DIR_SIZE - ROUND_UP(strlen(".")));
+ mark_de_visible(&(deh[0]));
+
+ /* direntry header of ".." */
+ put_deh_offset(&(deh[1]), DOT_DOT_OFFSET);
+ /* key of ".." for the root directory */
+ /* these two are from the inode, and are are LE */
+ deh[1].deh_dir_id = par_dirid;
+ deh[1].deh_objectid = par_objid;
+ deh[1].deh_state = 0; /* Endian safe if 0 */
+ put_deh_location(&(deh[1]),
+ deh_location(&(deh[0])) - ROUND_UP(strlen("..")));
+ mark_de_visible(&(deh[1]));
+
+ /* copy ".." and "." */
+ memcpy(body + deh_location(&(deh[0])), ".", 1);
+ memcpy(body + deh_location(&(deh[1])), "..", 2);
}
diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
index 2118db2896c..b2264ba3cc5 100644
--- a/fs/reiserfs/do_balan.c
+++ b/fs/reiserfs/do_balan.c
@@ -8,7 +8,6 @@
/* balance the tree according to the analysis made before, */
/* and using buffers obtained after all above. */
-
/**
** balance_leaf_when_delete
** balance_leaf
@@ -24,23 +23,22 @@
#ifdef CONFIG_REISERFS_CHECK
-struct tree_balance * cur_tb = NULL; /* detects whether more than one
- copy of tb exists as a means
- of checking whether schedule
- is interrupting do_balance */
+struct tree_balance *cur_tb = NULL; /* detects whether more than one
+ copy of tb exists as a means
+ of checking whether schedule
+ is interrupting do_balance */
#endif
-inline void do_balance_mark_leaf_dirty (struct tree_balance * tb,
- struct buffer_head * bh, int flag)
+inline void do_balance_mark_leaf_dirty(struct tree_balance *tb,
+ struct buffer_head *bh, int flag)
{
- journal_mark_dirty(tb->transaction_handle,
- tb->transaction_handle->t_super, bh) ;
+ journal_mark_dirty(tb->transaction_handle,
+ tb->transaction_handle->t_super, bh);
}
#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
-
/* summary:
if deleting something ( tb->insert_size[0] < 0 )
return(balance_leaf_when_delete()); (flag d handled here)
@@ -64,8 +62,6 @@ be performed by do_balance.
-Hans */
-
-
/* Balance leaf node in case of delete or cut: insert_size[0] < 0
*
* lnum, rnum can have values >= -1
@@ -73,1384 +69,1933 @@ be performed by do_balance.
* 0 means that nothing should be done with the neighbor
* >0 means to shift entirely or partly the specified number of items to the neighbor
*/
-static int balance_leaf_when_delete (struct tree_balance * tb, int flag)
+static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
{
- struct buffer_head * tbS0 = PATH_PLAST_BUFFER (tb->tb_path);
- int item_pos = PATH_LAST_POSITION (tb->tb_path);
- int pos_in_item = tb->tb_path->pos_in_item;
- struct buffer_info bi;
- int n;
- struct item_head * ih;
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+ int pos_in_item = tb->tb_path->pos_in_item;
+ struct buffer_info bi;
+ int n;
+ struct item_head *ih;
- RFALSE( tb->FR[0] && B_LEVEL (tb->FR[0]) != DISK_LEAF_NODE_LEVEL + 1,
- "vs- 12000: level: wrong FR %z", tb->FR[0]);
- RFALSE( tb->blknum[0] > 1,
- "PAP-12005: tb->blknum == %d, can not be > 1", tb->blknum[0]);
- RFALSE( ! tb->blknum[0] && ! PATH_H_PPARENT(tb->tb_path, 0),
- "PAP-12010: tree can not be empty");
+ RFALSE(tb->FR[0] && B_LEVEL(tb->FR[0]) != DISK_LEAF_NODE_LEVEL + 1,
+ "vs- 12000: level: wrong FR %z", tb->FR[0]);
+ RFALSE(tb->blknum[0] > 1,
+ "PAP-12005: tb->blknum == %d, can not be > 1", tb->blknum[0]);
+ RFALSE(!tb->blknum[0] && !PATH_H_PPARENT(tb->tb_path, 0),
+ "PAP-12010: tree can not be empty");
- ih = B_N_PITEM_HEAD (tbS0, item_pos);
+ ih = B_N_PITEM_HEAD(tbS0, item_pos);
- /* Delete or truncate the item */
+ /* Delete or truncate the item */
- switch (flag) {
- case M_DELETE: /* delete item in S[0] */
+ switch (flag) {
+ case M_DELETE: /* delete item in S[0] */
+
+ RFALSE(ih_item_len(ih) + IH_SIZE != -tb->insert_size[0],
+ "vs-12013: mode Delete, insert size %d, ih to be deleted %h",
+ -tb->insert_size[0], ih);
+
+ bi.tb = tb;
+ bi.bi_bh = tbS0;
+ bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
+ leaf_delete_items(&bi, 0, item_pos, 1, -1);
+
+ if (!item_pos && tb->CFL[0]) {
+ if (B_NR_ITEMS(tbS0)) {
+ replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0,
+ 0);
+ } else {
+ if (!PATH_H_POSITION(tb->tb_path, 1))
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ PATH_H_PPARENT(tb->tb_path,
+ 0), 0);
+ }
+ }
- RFALSE( ih_item_len(ih) + IH_SIZE != -tb->insert_size[0],
- "vs-12013: mode Delete, insert size %d, ih to be deleted %h",
- -tb->insert_size [0], ih);
+ RFALSE(!item_pos && !tb->CFL[0],
+ "PAP-12020: tb->CFL[0]==%p, tb->L[0]==%p", tb->CFL[0],
+ tb->L[0]);
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, 1);
- leaf_delete_items (&bi, 0, item_pos, 1, -1);
-
- if ( ! item_pos && tb->CFL[0] ) {
- if ( B_NR_ITEMS(tbS0) ) {
- replace_key(tb, tb->CFL[0],tb->lkey[0],tbS0,0);
- }
- else {
- if ( ! PATH_H_POSITION (tb->tb_path, 1) )
- replace_key(tb, tb->CFL[0],tb->lkey[0],PATH_H_PPARENT(tb->tb_path, 0),0);
- }
- }
-
- RFALSE( ! item_pos && !tb->CFL[0],
- "PAP-12020: tb->CFL[0]==%p, tb->L[0]==%p", tb->CFL[0], tb->L[0]);
-
- break;
-
- case M_CUT: { /* cut item in S[0] */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, 1);
- if (is_direntry_le_ih (ih)) {
-
- /* UFS unlink semantics are such that you can only delete one directory entry at a time. */
- /* when we cut a directory tb->insert_size[0] means number of entries to be cut (always 1) */
- tb->insert_size[0] = -1;
- leaf_cut_from_buffer (&bi, item_pos, pos_in_item, -tb->insert_size[0]);
-
- RFALSE( ! item_pos && ! pos_in_item && ! tb->CFL[0],
- "PAP-12030: can not change delimiting key. CFL[0]=%p",
- tb->CFL[0]);
-
- if ( ! item_pos && ! pos_in_item && tb->CFL[0] ) {
- replace_key(tb, tb->CFL[0],tb->lkey[0],tbS0,0);
- }
- } else {
- leaf_cut_from_buffer (&bi, item_pos, pos_in_item, -tb->insert_size[0]);
-
- RFALSE( ! ih_item_len(ih),
- "PAP-12035: cut must leave non-zero dynamic length of item");
- }
- break;
- }
-
- default:
- print_cur_tb ("12040");
- reiserfs_panic (tb->tb_sb, "PAP-12040: balance_leaf_when_delete: unexpectable mode: %s(%d)",
- (flag == M_PASTE) ? "PASTE" : ((flag == M_INSERT) ? "INSERT" : "UNKNOWN"), flag);
- }
-
- /* the rule is that no shifting occurs unless by shifting a node can be freed */
- n = B_NR_ITEMS(tbS0);
- if ( tb->lnum[0] ) /* L[0] takes part in balancing */
- {
- if ( tb->lnum[0] == -1 ) /* L[0] must be joined with S[0] */
- {
- if ( tb->rnum[0] == -1 ) /* R[0] must be also joined with S[0] */
- {
- if ( tb->FR[0] == PATH_H_PPARENT(tb->tb_path, 0) )
- {
- /* all contents of all the 3 buffers will be in L[0] */
- if ( PATH_H_POSITION (tb->tb_path, 1) == 0 && 1 < B_NR_ITEMS(tb->FR[0]) )
- replace_key(tb, tb->CFL[0],tb->lkey[0],tb->FR[0],1);
-
- leaf_move_items (LEAF_FROM_S_TO_L, tb, n, -1, NULL);
- leaf_move_items (LEAF_FROM_R_TO_L, tb, B_NR_ITEMS(tb->R[0]), -1, NULL);
-
- reiserfs_invalidate_buffer (tb, tbS0);
- reiserfs_invalidate_buffer (tb, tb->R[0]);
-
- return 0;
+ break;
+
+ case M_CUT:{ /* cut item in S[0] */
+ bi.tb = tb;
+ bi.bi_bh = tbS0;
+ bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
+ if (is_direntry_le_ih(ih)) {
+
+ /* UFS unlink semantics are such that you can only delete one directory entry at a time. */
+ /* when we cut a directory tb->insert_size[0] means number of entries to be cut (always 1) */
+ tb->insert_size[0] = -1;
+ leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
+ -tb->insert_size[0]);
+
+ RFALSE(!item_pos && !pos_in_item && !tb->CFL[0],
+ "PAP-12030: can not change delimiting key. CFL[0]=%p",
+ tb->CFL[0]);
+
+ if (!item_pos && !pos_in_item && tb->CFL[0]) {
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ tbS0, 0);
+ }
+ } else {
+ leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
+ -tb->insert_size[0]);
+
+ RFALSE(!ih_item_len(ih),
+ "PAP-12035: cut must leave non-zero dynamic length of item");
+ }
+ break;
}
- /* all contents of all the 3 buffers will be in R[0] */
- leaf_move_items (LEAF_FROM_S_TO_R, tb, n, -1, NULL);
- leaf_move_items (LEAF_FROM_L_TO_R, tb, B_NR_ITEMS(tb->L[0]), -1, NULL);
- /* right_delimiting_key is correct in R[0] */
- replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
+ default:
+ print_cur_tb("12040");
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12040: balance_leaf_when_delete: unexpectable mode: %s(%d)",
+ (flag ==
+ M_PASTE) ? "PASTE" : ((flag ==
+ M_INSERT) ? "INSERT" :
+ "UNKNOWN"), flag);
+ }
- reiserfs_invalidate_buffer (tb, tbS0);
- reiserfs_invalidate_buffer (tb, tb->L[0]);
+ /* the rule is that no shifting occurs unless by shifting a node can be freed */
+ n = B_NR_ITEMS(tbS0);
+ if (tb->lnum[0]) { /* L[0] takes part in balancing */
+ if (tb->lnum[0] == -1) { /* L[0] must be joined with S[0] */
+ if (tb->rnum[0] == -1) { /* R[0] must be also joined with S[0] */
+ if (tb->FR[0] == PATH_H_PPARENT(tb->tb_path, 0)) {
+ /* all contents of all the 3 buffers will be in L[0] */
+ if (PATH_H_POSITION(tb->tb_path, 1) == 0
+ && 1 < B_NR_ITEMS(tb->FR[0]))
+ replace_key(tb, tb->CFL[0],
+ tb->lkey[0],
+ tb->FR[0], 1);
+
+ leaf_move_items(LEAF_FROM_S_TO_L, tb, n,
+ -1, NULL);
+ leaf_move_items(LEAF_FROM_R_TO_L, tb,
+ B_NR_ITEMS(tb->R[0]),
+ -1, NULL);
+
+ reiserfs_invalidate_buffer(tb, tbS0);
+ reiserfs_invalidate_buffer(tb,
+ tb->R[0]);
+
+ return 0;
+ }
+ /* all contents of all the 3 buffers will be in R[0] */
+ leaf_move_items(LEAF_FROM_S_TO_R, tb, n, -1,
+ NULL);
+ leaf_move_items(LEAF_FROM_L_TO_R, tb,
+ B_NR_ITEMS(tb->L[0]), -1, NULL);
+
+ /* right_delimiting_key is correct in R[0] */
+ replace_key(tb, tb->CFR[0], tb->rkey[0],
+ tb->R[0], 0);
- return -1;
- }
+ reiserfs_invalidate_buffer(tb, tbS0);
+ reiserfs_invalidate_buffer(tb, tb->L[0]);
- RFALSE( tb->rnum[0] != 0,
- "PAP-12045: rnum must be 0 (%d)", tb->rnum[0]);
- /* all contents of L[0] and S[0] will be in L[0] */
- leaf_shift_left(tb, n, -1);
+ return -1;
+ }
- reiserfs_invalidate_buffer (tb, tbS0);
+ RFALSE(tb->rnum[0] != 0,
+ "PAP-12045: rnum must be 0 (%d)", tb->rnum[0]);
+ /* all contents of L[0] and S[0] will be in L[0] */
+ leaf_shift_left(tb, n, -1);
- return 0;
+ reiserfs_invalidate_buffer(tb, tbS0);
+
+ return 0;
+ }
+ /* a part of contents of S[0] will be in L[0] and the rest part of S[0] will be in R[0] */
+
+ RFALSE((tb->lnum[0] + tb->rnum[0] < n) ||
+ (tb->lnum[0] + tb->rnum[0] > n + 1),
+ "PAP-12050: rnum(%d) and lnum(%d) and item number(%d) in S[0] are not consistent",
+ tb->rnum[0], tb->lnum[0], n);
+ RFALSE((tb->lnum[0] + tb->rnum[0] == n) &&
+ (tb->lbytes != -1 || tb->rbytes != -1),
+ "PAP-12055: bad rbytes (%d)/lbytes (%d) parameters when items are not split",
+ tb->rbytes, tb->lbytes);
+ RFALSE((tb->lnum[0] + tb->rnum[0] == n + 1) &&
+ (tb->lbytes < 1 || tb->rbytes != -1),
+ "PAP-12060: bad rbytes (%d)/lbytes (%d) parameters when items are split",
+ tb->rbytes, tb->lbytes);
+
+ leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
+
+ reiserfs_invalidate_buffer(tb, tbS0);
+
+ return 0;
}
- /* a part of contents of S[0] will be in L[0] and the rest part of S[0] will be in R[0] */
-
- RFALSE( ( tb->lnum[0] + tb->rnum[0] < n ) ||
- ( tb->lnum[0] + tb->rnum[0] > n+1 ),
- "PAP-12050: rnum(%d) and lnum(%d) and item number(%d) in S[0] are not consistent",
- tb->rnum[0], tb->lnum[0], n);
- RFALSE( ( tb->lnum[0] + tb->rnum[0] == n ) &&
- (tb->lbytes != -1 || tb->rbytes != -1),
- "PAP-12055: bad rbytes (%d)/lbytes (%d) parameters when items are not split",
- tb->rbytes, tb->lbytes);
- RFALSE( ( tb->lnum[0] + tb->rnum[0] == n + 1 ) &&
- (tb->lbytes < 1 || tb->rbytes != -1),
- "PAP-12060: bad rbytes (%d)/lbytes (%d) parameters when items are split",
- tb->rbytes, tb->lbytes);
-
- leaf_shift_left (tb, tb->lnum[0], tb->lbytes);
- leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
-
- reiserfs_invalidate_buffer (tb, tbS0);
- return 0;
- }
+ if (tb->rnum[0] == -1) {
+ /* all contents of R[0] and S[0] will be in R[0] */
+ leaf_shift_right(tb, n, -1);
+ reiserfs_invalidate_buffer(tb, tbS0);
+ return 0;
+ }
- if ( tb->rnum[0] == -1 ) {
- /* all contents of R[0] and S[0] will be in R[0] */
- leaf_shift_right(tb, n, -1);
- reiserfs_invalidate_buffer (tb, tbS0);
+ RFALSE(tb->rnum[0],
+ "PAP-12065: bad rnum parameter must be 0 (%d)", tb->rnum[0]);
return 0;
- }
-
- RFALSE( tb->rnum[0],
- "PAP-12065: bad rnum parameter must be 0 (%d)", tb->rnum[0]);
- return 0;
}
-
-static int balance_leaf (struct tree_balance * tb,
- struct item_head * ih, /* item header of inserted item (this is on little endian) */
- const char * body, /* body of inserted item or bytes to paste */
- int flag, /* i - insert, d - delete, c - cut, p - paste
- (see comment to do_balance) */
- struct item_head * insert_key, /* in our processing of one level we sometimes determine what
- must be inserted into the next higher level. This insertion
- consists of a key or two keys and their corresponding
- pointers */
- struct buffer_head ** insert_ptr /* inserted node-ptrs for the next level */
+static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
+ const char *body, /* body of inserted item or bytes to paste */
+ int flag, /* i - insert, d - delete, c - cut, p - paste
+ (see comment to do_balance) */
+ struct item_head *insert_key, /* in our processing of one level we sometimes determine what
+ must be inserted into the next higher level. This insertion
+ consists of a key or two keys and their corresponding
+ pointers */
+ struct buffer_head **insert_ptr /* inserted node-ptrs for the next level */
)
{
- struct buffer_head * tbS0 = PATH_PLAST_BUFFER (tb->tb_path);
- int item_pos = PATH_LAST_POSITION (tb->tb_path); /* index into the array of item headers in S[0]
- of the affected item */
- struct buffer_info bi;
- struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
- int snum[2]; /* number of items that will be placed
- into S_new (includes partially shifted
- items) */
- int sbytes[2]; /* if an item is partially shifted into S_new then
- if it is a directory item
- it is the number of entries from the item that are shifted into S_new
- else
- it is the number of bytes from the item that are shifted into S_new
- */
- int n, i;
- int ret_val;
- int pos_in_item;
- int zeros_num;
-
- PROC_INFO_INC( tb -> tb_sb, balance_at[ 0 ] );
-
- /* Make balance in case insert_size[0] < 0 */
- if ( tb->insert_size[0] < 0 )
- return balance_leaf_when_delete (tb, flag);
-
- zeros_num = 0;
- if (flag == M_INSERT && body == 0)
- zeros_num = ih_item_len( ih );
-
- pos_in_item = tb->tb_path->pos_in_item;
- /* for indirect item pos_in_item is measured in unformatted node
- pointers. Recalculate to bytes */
- if (flag != M_INSERT && is_indirect_le_ih (B_N_PITEM_HEAD (tbS0, item_pos)))
- pos_in_item *= UNFM_P_SIZE;
-
- if ( tb->lnum[0] > 0 ) {
- /* Shift lnum[0] items from S[0] to the left neighbor L[0] */
- if ( item_pos < tb->lnum[0] ) {
- /* new item or it part falls to L[0], shift it too */
- n = B_NR_ITEMS(tb->L[0]);
-
- switch (flag) {
- case M_INSERT: /* insert item into L[0] */
-
- if ( item_pos == tb->lnum[0] - 1 && tb->lbytes != -1 ) {
- /* part of new item falls into L[0] */
- int new_item_len;
- int version;
-
- ret_val = leaf_shift_left (tb, tb->lnum[0]-1, -1);
-
- /* Calculate item length to insert to S[0] */
- new_item_len = ih_item_len(ih) - tb->lbytes;
- /* Calculate and check item length to insert to L[0] */
- put_ih_item_len(ih, ih_item_len(ih) - new_item_len );
-
- RFALSE( ih_item_len(ih) <= 0,
- "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d",
- ih_item_len(ih));
-
- /* Insert new item into L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position = get_left_neighbor_position (tb, 0);
- leaf_insert_into_buf (&bi, n + item_pos - ret_val, ih, body,
- zeros_num > ih_item_len(ih) ? ih_item_len(ih) : zeros_num);
-
- version = ih_version (ih);
-
- /* Calculate key component, item length and body to insert into S[0] */
- set_le_ih_k_offset( ih, le_ih_k_offset( ih ) + (tb->lbytes << (is_indirect_le_ih(ih)?tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT:0)) );
-
- put_ih_item_len( ih, new_item_len );
- if ( tb->lbytes > zeros_num ) {
- body += (tb->lbytes - zeros_num);
- zeros_num = 0;
- }
- else
- zeros_num -= tb->lbytes;
-
- RFALSE( ih_item_len(ih) <= 0,
- "PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d",
- ih_item_len(ih));
- } else {
- /* new item in whole falls into L[0] */
- /* Shift lnum[0]-1 items to L[0] */
- ret_val = leaf_shift_left(tb, tb->lnum[0]-1, tb->lbytes);
- /* Insert new item into L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position = get_left_neighbor_position (tb, 0);
- leaf_insert_into_buf (&bi, n + item_pos - ret_val, ih, body, zeros_num);
- tb->insert_size[0] = 0;
- zeros_num = 0;
- }
- break;
-
- case M_PASTE: /* append item in L[0] */
-
- if ( item_pos == tb->lnum[0] - 1 && tb->lbytes != -1 ) {
- /* we must shift the part of the appended item */
- if ( is_direntry_le_ih (B_N_PITEM_HEAD (tbS0, item_pos))) {
-
- RFALSE( zeros_num,
- "PAP-12090: invalid parameter in case of a directory");
- /* directory item */
- if ( tb->lbytes > pos_in_item ) {
- /* new directory entry falls into L[0] */
- struct item_head * pasted;
- int l_pos_in_item = pos_in_item;
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */
- ret_val = leaf_shift_left(tb, tb->lnum[0], tb->lbytes - 1);
- if ( ret_val && ! item_pos ) {
- pasted = B_N_PITEM_HEAD(tb->L[0],B_NR_ITEMS(tb->L[0])-1);
- l_pos_in_item += I_ENTRY_COUNT(pasted) - (tb->lbytes-1);
- }
-
- /* Append given directory entry to directory item */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position = get_left_neighbor_position (tb, 0);
- leaf_paste_in_buffer (&bi, n + item_pos - ret_val, l_pos_in_item,
- tb->insert_size[0], body, zeros_num);
-
- /* previous string prepared space for pasting new entry, following string pastes this entry */
-
- /* when we have merge directory item, pos_in_item has been changed too */
-
- /* paste new directory entry. 1 is entry number */
- leaf_paste_entries (bi.bi_bh, n + item_pos - ret_val, l_pos_in_item, 1,
- (struct reiserfs_de_head *)body,
- body + DEH_SIZE, tb->insert_size[0]
- );
- tb->insert_size[0] = 0;
- } else {
- /* new directory item doesn't fall into L[0] */
- /* Shift lnum[0]-1 items in whole. Shift lbytes directory entries from directory item number lnum[0] */
- leaf_shift_left (tb, tb->lnum[0], tb->lbytes);
- }
- /* Calculate new position to append in item body */
- pos_in_item -= tb->lbytes;
- }
- else {
- /* regular object */
- RFALSE( tb->lbytes <= 0,
- "PAP-12095: there is nothing to shift to L[0]. lbytes=%d",
- tb->lbytes);
- RFALSE( pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)),
- "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d",
- ih_item_len(B_N_PITEM_HEAD(tbS0,item_pos)), pos_in_item);
-
- if ( tb->lbytes >= pos_in_item ) {
- /* appended item will be in L[0] in whole */
- int l_n;
-
- /* this bytes number must be appended to the last item of L[h] */
- l_n = tb->lbytes - pos_in_item;
-
- /* Calculate new insert_size[0] */
- tb->insert_size[0] -= l_n;
-
- RFALSE( tb->insert_size[0] <= 0,
- "PAP-12105: there is nothing to paste into L[0]. insert_size=%d",
- tb->insert_size[0]);
- ret_val = leaf_shift_left(tb,tb->lnum[0],
- ih_item_len(B_N_PITEM_HEAD(tbS0,item_pos)));
- /* Append to body of item in L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position = get_left_neighbor_position (tb, 0);
- leaf_paste_in_buffer(
- &bi,n + item_pos - ret_val,
- ih_item_len( B_N_PITEM_HEAD(tb->L[0],n+item_pos-ret_val)),
- l_n,body, zeros_num > l_n ? l_n : zeros_num
- );
- /* 0-th item in S0 can be only of DIRECT type when l_n != 0*/
- {
- int version;
- int temp_l = l_n;
-
- RFALSE (ih_item_len (B_N_PITEM_HEAD (tbS0, 0)),
- "PAP-12106: item length must be 0");
- RFALSE (comp_short_le_keys (B_N_PKEY (tbS0, 0),
- B_N_PKEY (tb->L[0],
- n + item_pos - ret_val)),
- "PAP-12107: items must be of the same file");
- if (is_indirect_le_ih(B_N_PITEM_HEAD (tb->L[0],
- n + item_pos - ret_val))) {
- temp_l = l_n << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT);
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
+ of the affected item */
+ struct buffer_info bi;
+ struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
+ int snum[2]; /* number of items that will be placed
+ into S_new (includes partially shifted
+ items) */
+ int sbytes[2]; /* if an item is partially shifted into S_new then
+ if it is a directory item
+ it is the number of entries from the item that are shifted into S_new
+ else
+ it is the number of bytes from the item that are shifted into S_new
+ */
+ int n, i;
+ int ret_val;
+ int pos_in_item;
+ int zeros_num;
+
+ PROC_INFO_INC(tb->tb_sb, balance_at[0]);
+
+ /* Make balance in case insert_size[0] < 0 */
+ if (tb->insert_size[0] < 0)
+ return balance_leaf_when_delete(tb, flag);
+
+ zeros_num = 0;
+ if (flag == M_INSERT && body == 0)
+ zeros_num = ih_item_len(ih);
+
+ pos_in_item = tb->tb_path->pos_in_item;
+ /* for indirect item pos_in_item is measured in unformatted node
+ pointers. Recalculate to bytes */
+ if (flag != M_INSERT
+ && is_indirect_le_ih(B_N_PITEM_HEAD(tbS0, item_pos)))
+ pos_in_item *= UNFM_P_SIZE;
+
+ if (tb->lnum[0] > 0) {
+ /* Shift lnum[0] items from S[0] to the left neighbor L[0] */
+ if (item_pos < tb->lnum[0]) {
+ /* new item or it part falls to L[0], shift it too */
+ n = B_NR_ITEMS(tb->L[0]);
+
+ switch (flag) {
+ case M_INSERT: /* insert item into L[0] */
+
+ if (item_pos == tb->lnum[0] - 1
+ && tb->lbytes != -1) {
+ /* part of new item falls into L[0] */
+ int new_item_len;
+ int version;
+
+ ret_val =
+ leaf_shift_left(tb, tb->lnum[0] - 1,
+ -1);
+
+ /* Calculate item length to insert to S[0] */
+ new_item_len =
+ ih_item_len(ih) - tb->lbytes;
+ /* Calculate and check item length to insert to L[0] */
+ put_ih_item_len(ih,
+ ih_item_len(ih) -
+ new_item_len);
+
+ RFALSE(ih_item_len(ih) <= 0,
+ "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d",
+ ih_item_len(ih));
+
+ /* Insert new item into L[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[0];
+ bi.bi_parent = tb->FL[0];
+ bi.bi_position =
+ get_left_neighbor_position(tb, 0);
+ leaf_insert_into_buf(&bi,
+ n + item_pos -
+ ret_val, ih, body,
+ zeros_num >
+ ih_item_len(ih) ?
+ ih_item_len(ih) :
+ zeros_num);
+
+ version = ih_version(ih);
+
+ /* Calculate key component, item length and body to insert into S[0] */
+ set_le_ih_k_offset(ih,
+ le_ih_k_offset(ih) +
+ (tb->
+ lbytes <<
+ (is_indirect_le_ih
+ (ih) ? tb->tb_sb->
+ s_blocksize_bits -
+ UNFM_P_SHIFT :
+ 0)));
+
+ put_ih_item_len(ih, new_item_len);
+ if (tb->lbytes > zeros_num) {
+ body +=
+ (tb->lbytes - zeros_num);
+ zeros_num = 0;
+ } else
+ zeros_num -= tb->lbytes;
+
+ RFALSE(ih_item_len(ih) <= 0,
+ "PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d",
+ ih_item_len(ih));
+ } else {
+ /* new item in whole falls into L[0] */
+ /* Shift lnum[0]-1 items to L[0] */
+ ret_val =
+ leaf_shift_left(tb, tb->lnum[0] - 1,
+ tb->lbytes);
+ /* Insert new item into L[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[0];
+ bi.bi_parent = tb->FL[0];
+ bi.bi_position =
+ get_left_neighbor_position(tb, 0);
+ leaf_insert_into_buf(&bi,
+ n + item_pos -
+ ret_val, ih, body,
+ zeros_num);
+ tb->insert_size[0] = 0;
+ zeros_num = 0;
}
- /* update key of first item in S0 */
- version = ih_version (B_N_PITEM_HEAD (tbS0, 0));
- set_le_key_k_offset (version, B_N_PKEY (tbS0, 0),
- le_key_k_offset (version, B_N_PKEY (tbS0, 0)) + temp_l);
- /* update left delimiting key */
- set_le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0]),
- le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0])) + temp_l);
- }
-
- /* Calculate new body, position in item and insert_size[0] */
- if ( l_n > zeros_num ) {
- body += (l_n - zeros_num);
- zeros_num = 0;
- }
- else
- zeros_num -= l_n;
- pos_in_item = 0;
-
- RFALSE( comp_short_le_keys
- (B_N_PKEY(tbS0,0),
- B_N_PKEY(tb->L[0],B_NR_ITEMS(tb->L[0])-1)) ||
-
- !op_is_left_mergeable
- (B_N_PKEY (tbS0, 0), tbS0->b_size) ||
- !op_is_left_mergeable
- (B_N_PDELIM_KEY(tb->CFL[0],tb->lkey[0]),
- tbS0->b_size),
- "PAP-12120: item must be merge-able with left neighboring item");
- }
- else /* only part of the appended item will be in L[0] */
- {
- /* Calculate position in item for append in S[0] */
- pos_in_item -= tb->lbytes;
-
- RFALSE( pos_in_item <= 0,
- "PAP-12125: no place for paste. pos_in_item=%d", pos_in_item);
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
- leaf_shift_left(tb,tb->lnum[0],tb->lbytes);
- }
- }
- }
- else /* appended item will be in L[0] in whole */
- {
- struct item_head * pasted;
-
- if ( ! item_pos && op_is_left_mergeable (B_N_PKEY (tbS0, 0), tbS0->b_size) )
- { /* if we paste into first item of S[0] and it is left mergable */
- /* then increment pos_in_item by the size of the last item in L[0] */
- pasted = B_N_PITEM_HEAD(tb->L[0],n-1);
- if ( is_direntry_le_ih (pasted) )
- pos_in_item += ih_entry_count(pasted);
- else
- pos_in_item += ih_item_len(pasted);
+ break;
+
+ case M_PASTE: /* append item in L[0] */
+
+ if (item_pos == tb->lnum[0] - 1
+ && tb->lbytes != -1) {
+ /* we must shift the part of the appended item */
+ if (is_direntry_le_ih
+ (B_N_PITEM_HEAD(tbS0, item_pos))) {
+
+ RFALSE(zeros_num,
+ "PAP-12090: invalid parameter in case of a directory");
+ /* directory item */
+ if (tb->lbytes > pos_in_item) {
+ /* new directory entry falls into L[0] */
+ struct item_head
+ *pasted;
+ int l_pos_in_item =
+ pos_in_item;
+
+ /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */
+ ret_val =
+ leaf_shift_left(tb,
+ tb->
+ lnum
+ [0],
+ tb->
+ lbytes
+ -
+ 1);
+ if (ret_val
+ && !item_pos) {
+ pasted =
+ B_N_PITEM_HEAD
+ (tb->L[0],
+ B_NR_ITEMS
+ (tb->
+ L[0]) -
+ 1);
+ l_pos_in_item +=
+ I_ENTRY_COUNT
+ (pasted) -
+ (tb->
+ lbytes -
+ 1);
+ }
+
+ /* Append given directory entry to directory item */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[0];
+ bi.bi_parent =
+ tb->FL[0];
+ bi.bi_position =
+ get_left_neighbor_position
+ (tb, 0);
+ leaf_paste_in_buffer
+ (&bi,
+ n + item_pos -
+ ret_val,
+ l_pos_in_item,
+ tb->insert_size[0],
+ body, zeros_num);
+
+ /* previous string prepared space for pasting new entry, following string pastes this entry */
+
+ /* when we have merge directory item, pos_in_item has been changed too */
+
+ /* paste new directory entry. 1 is entry number */
+ leaf_paste_entries(bi.
+ bi_bh,
+ n +
+ item_pos
+ -
+ ret_val,
+ l_pos_in_item,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)
+ body,
+ body
+ +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ tb->insert_size[0] = 0;
+ } else {
+ /* new directory item doesn't fall into L[0] */
+ /* Shift lnum[0]-1 items in whole. Shift lbytes directory entries from directory item number lnum[0] */
+ leaf_shift_left(tb,
+ tb->
+ lnum[0],
+ tb->
+ lbytes);
+ }
+ /* Calculate new position to append in item body */
+ pos_in_item -= tb->lbytes;
+ } else {
+ /* regular object */
+ RFALSE(tb->lbytes <= 0,
+ "PAP-12095: there is nothing to shift to L[0]. lbytes=%d",
+ tb->lbytes);
+ RFALSE(pos_in_item !=
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0, item_pos)),
+ "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d",
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0, item_pos)),
+ pos_in_item);
+
+ if (tb->lbytes >= pos_in_item) {
+ /* appended item will be in L[0] in whole */
+ int l_n;
+
+ /* this bytes number must be appended to the last item of L[h] */
+ l_n =
+ tb->lbytes -
+ pos_in_item;
+
+ /* Calculate new insert_size[0] */
+ tb->insert_size[0] -=
+ l_n;
+
+ RFALSE(tb->
+ insert_size[0] <=
+ 0,
+ "PAP-12105: there is nothing to paste into L[0]. insert_size=%d",
+ tb->
+ insert_size[0]);
+ ret_val =
+ leaf_shift_left(tb,
+ tb->
+ lnum
+ [0],
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0,
+ item_pos)));
+ /* Append to body of item in L[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[0];
+ bi.bi_parent =
+ tb->FL[0];
+ bi.bi_position =
+ get_left_neighbor_position
+ (tb, 0);
+ leaf_paste_in_buffer
+ (&bi,
+ n + item_pos -
+ ret_val,
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tb->L[0],
+ n + item_pos -
+ ret_val)), l_n,
+ body,
+ zeros_num >
+ l_n ? l_n :
+ zeros_num);
+ /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
+ {
+ int version;
+ int temp_l =
+ l_n;
+
+ RFALSE
+ (ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0,
+ 0)),
+ "PAP-12106: item length must be 0");
+ RFALSE
+ (comp_short_le_keys
+ (B_N_PKEY
+ (tbS0, 0),
+ B_N_PKEY
+ (tb->L[0],
+ n +
+ item_pos
+ -
+ ret_val)),
+ "PAP-12107: items must be of the same file");
+ if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val))) {
+ temp_l =
+ l_n
+ <<
+ (tb->
+ tb_sb->
+ s_blocksize_bits
+ -
+ UNFM_P_SHIFT);
+ }
+ /* update key of first item in S0 */
+ version =
+ ih_version
+ (B_N_PITEM_HEAD
+ (tbS0, 0));
+ set_le_key_k_offset
+ (version,
+ B_N_PKEY
+ (tbS0, 0),
+ le_key_k_offset
+ (version,
+ B_N_PKEY
+ (tbS0,
+ 0)) +
+ temp_l);
+ /* update left delimiting key */
+ set_le_key_k_offset
+ (version,
+ B_N_PDELIM_KEY
+ (tb->
+ CFL[0],
+ tb->
+ lkey[0]),
+ le_key_k_offset
+ (version,
+ B_N_PDELIM_KEY
+ (tb->
+ CFL[0],
+ tb->
+ lkey[0]))
+ + temp_l);
+ }
+
+ /* Calculate new body, position in item and insert_size[0] */
+ if (l_n > zeros_num) {
+ body +=
+ (l_n -
+ zeros_num);
+ zeros_num = 0;
+ } else
+ zeros_num -=
+ l_n;
+ pos_in_item = 0;
+
+ RFALSE
+ (comp_short_le_keys
+ (B_N_PKEY(tbS0, 0),
+ B_N_PKEY(tb->L[0],
+ B_NR_ITEMS
+ (tb->
+ L[0]) -
+ 1))
+ ||
+ !op_is_left_mergeable
+ (B_N_PKEY(tbS0, 0),
+ tbS0->b_size)
+ ||
+ !op_is_left_mergeable
+ (B_N_PDELIM_KEY
+ (tb->CFL[0],
+ tb->lkey[0]),
+ tbS0->b_size),
+ "PAP-12120: item must be merge-able with left neighboring item");
+ } else { /* only part of the appended item will be in L[0] */
+
+ /* Calculate position in item for append in S[0] */
+ pos_in_item -=
+ tb->lbytes;
+
+ RFALSE(pos_in_item <= 0,
+ "PAP-12125: no place for paste. pos_in_item=%d",
+ pos_in_item);
+
+ /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
+ leaf_shift_left(tb,
+ tb->
+ lnum[0],
+ tb->
+ lbytes);
+ }
+ }
+ } else { /* appended item will be in L[0] in whole */
+
+ struct item_head *pasted;
+
+ if (!item_pos && op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)) { /* if we paste into first item of S[0] and it is left mergable */
+ /* then increment pos_in_item by the size of the last item in L[0] */
+ pasted =
+ B_N_PITEM_HEAD(tb->L[0],
+ n - 1);
+ if (is_direntry_le_ih(pasted))
+ pos_in_item +=
+ ih_entry_count
+ (pasted);
+ else
+ pos_in_item +=
+ ih_item_len(pasted);
+ }
+
+ /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
+ ret_val =
+ leaf_shift_left(tb, tb->lnum[0],
+ tb->lbytes);
+ /* Append to body of item in L[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[0];
+ bi.bi_parent = tb->FL[0];
+ bi.bi_position =
+ get_left_neighbor_position(tb, 0);
+ leaf_paste_in_buffer(&bi,
+ n + item_pos -
+ ret_val,
+ pos_in_item,
+ tb->insert_size[0],
+ body, zeros_num);
+
+ /* if appended item is directory, paste entry */
+ pasted =
+ B_N_PITEM_HEAD(tb->L[0],
+ n + item_pos -
+ ret_val);
+ if (is_direntry_le_ih(pasted))
+ leaf_paste_entries(bi.bi_bh,
+ n +
+ item_pos -
+ ret_val,
+ pos_in_item,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)body,
+ body +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ /* if appended item is indirect item, put unformatted node into un list */
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ tb->insert_size[0] = 0;
+ zeros_num = 0;
+ }
+ break;
+ default: /* cases d and t */
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12130: balance_leaf: lnum > 0: unexpectable mode: %s(%d)",
+ (flag ==
+ M_DELETE) ? "DELETE" : ((flag ==
+ M_CUT)
+ ? "CUT"
+ :
+ "UNKNOWN"),
+ flag);
}
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
- ret_val = leaf_shift_left(tb,tb->lnum[0],tb->lbytes);
- /* Append to body of item in L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position = get_left_neighbor_position (tb, 0);
- leaf_paste_in_buffer (&bi, n + item_pos - ret_val, pos_in_item, tb->insert_size[0],
- body, zeros_num);
-
- /* if appended item is directory, paste entry */
- pasted = B_N_PITEM_HEAD (tb->L[0], n + item_pos - ret_val);
- if (is_direntry_le_ih (pasted))
- leaf_paste_entries (
- bi.bi_bh, n + item_pos - ret_val, pos_in_item, 1,
- (struct reiserfs_de_head *)body, body + DEH_SIZE, tb->insert_size[0]
- );
- /* if appended item is indirect item, put unformatted node into un list */
- if (is_indirect_le_ih (pasted))
- set_ih_free_space (pasted, 0);
- tb->insert_size[0] = 0;
- zeros_num = 0;
+ } else {
+ /* new item doesn't fall into L[0] */
+ leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
}
- break;
- default: /* cases d and t */
- reiserfs_panic (tb->tb_sb, "PAP-12130: balance_leaf: lnum > 0: unexpectable mode: %s(%d)",
- (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
- }
- } else {
- /* new item doesn't fall into L[0] */
- leaf_shift_left(tb,tb->lnum[0],tb->lbytes);
}
- } /* tb->lnum[0] > 0 */
- /* Calculate new item position */
- item_pos -= ( tb->lnum[0] - (( tb->lbytes != -1 ) ? 1 : 0));
-
- if ( tb->rnum[0] > 0 ) {
- /* shift rnum[0] items from S[0] to the right neighbor R[0] */
- n = B_NR_ITEMS(tbS0);
- switch ( flag ) {
-
- case M_INSERT: /* insert item */
- if ( n - tb->rnum[0] < item_pos )
- { /* new item or its part falls to R[0] */
- if ( item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1 )
- { /* part of new item falls into R[0] */
- loff_t old_key_comp, old_len, r_zeros_number;
- const char * r_body;
- int version;
- loff_t offset;
-
- leaf_shift_right(tb,tb->rnum[0]-1,-1);
-
- version = ih_version(ih);
- /* Remember key component and item length */
- old_key_comp = le_ih_k_offset( ih );
- old_len = ih_item_len(ih);
-
- /* Calculate key component and item length to insert into R[0] */
- offset = le_ih_k_offset( ih ) + ((old_len - tb->rbytes )<<(is_indirect_le_ih(ih)?tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT:0));
- set_le_ih_k_offset( ih, offset );
- put_ih_item_len( ih, tb->rbytes);
- /* Insert part of the item into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position = get_right_neighbor_position (tb, 0);
- if ( (old_len - tb->rbytes) > zeros_num ) {
- r_zeros_number = 0;
- r_body = body + (old_len - tb->rbytes) - zeros_num;
- }
- else {
- r_body = body;
- r_zeros_number = zeros_num - (old_len - tb->rbytes);
- zeros_num -= r_zeros_number;
- }
-
- leaf_insert_into_buf (&bi, 0, ih, r_body, r_zeros_number);
-
- /* Replace right delimiting key by first key in R[0] */
- replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
-
- /* Calculate key component and item length to insert into S[0] */
- set_le_ih_k_offset( ih, old_key_comp );
- put_ih_item_len( ih, old_len - tb->rbytes );
-
- tb->insert_size[0] -= tb->rbytes;
+ /* tb->lnum[0] > 0 */
+ /* Calculate new item position */
+ item_pos -= (tb->lnum[0] - ((tb->lbytes != -1) ? 1 : 0));
+
+ if (tb->rnum[0] > 0) {
+ /* shift rnum[0] items from S[0] to the right neighbor R[0] */
+ n = B_NR_ITEMS(tbS0);
+ switch (flag) {
+
+ case M_INSERT: /* insert item */
+ if (n - tb->rnum[0] < item_pos) { /* new item or its part falls to R[0] */
+ if (item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { /* part of new item falls into R[0] */
+ loff_t old_key_comp, old_len,
+ r_zeros_number;
+ const char *r_body;
+ int version;
+ loff_t offset;
+
+ leaf_shift_right(tb, tb->rnum[0] - 1,
+ -1);
+
+ version = ih_version(ih);
+ /* Remember key component and item length */
+ old_key_comp = le_ih_k_offset(ih);
+ old_len = ih_item_len(ih);
+
+ /* Calculate key component and item length to insert into R[0] */
+ offset =
+ le_ih_k_offset(ih) +
+ ((old_len -
+ tb->
+ rbytes) << (is_indirect_le_ih(ih)
+ ? tb->tb_sb->
+ s_blocksize_bits -
+ UNFM_P_SHIFT : 0));
+ set_le_ih_k_offset(ih, offset);
+ put_ih_item_len(ih, tb->rbytes);
+ /* Insert part of the item into R[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->R[0];
+ bi.bi_parent = tb->FR[0];
+ bi.bi_position =
+ get_right_neighbor_position(tb, 0);
+ if ((old_len - tb->rbytes) > zeros_num) {
+ r_zeros_number = 0;
+ r_body =
+ body + (old_len -
+ tb->rbytes) -
+ zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number =
+ zeros_num - (old_len -
+ tb->rbytes);
+ zeros_num -= r_zeros_number;
+ }
+
+ leaf_insert_into_buf(&bi, 0, ih, r_body,
+ r_zeros_number);
+
+ /* Replace right delimiting key by first key in R[0] */
+ replace_key(tb, tb->CFR[0], tb->rkey[0],
+ tb->R[0], 0);
+
+ /* Calculate key component and item length to insert into S[0] */
+ set_le_ih_k_offset(ih, old_key_comp);
+ put_ih_item_len(ih,
+ old_len - tb->rbytes);
+
+ tb->insert_size[0] -= tb->rbytes;
+
+ } else { /* whole new item falls into R[0] */
+
+ /* Shift rnum[0]-1 items to R[0] */
+ ret_val =
+ leaf_shift_right(tb,
+ tb->rnum[0] - 1,
+ tb->rbytes);
+ /* Insert new item into R[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->R[0];
+ bi.bi_parent = tb->FR[0];
+ bi.bi_position =
+ get_right_neighbor_position(tb, 0);
+ leaf_insert_into_buf(&bi,
+ item_pos - n +
+ tb->rnum[0] - 1,
+ ih, body,
+ zeros_num);
+
+ if (item_pos - n + tb->rnum[0] - 1 == 0) {
+ replace_key(tb, tb->CFR[0],
+ tb->rkey[0],
+ tb->R[0], 0);
+
+ }
+ zeros_num = tb->insert_size[0] = 0;
+ }
+ } else { /* new item or part of it doesn't fall into R[0] */
- }
- else /* whole new item falls into R[0] */
- {
- /* Shift rnum[0]-1 items to R[0] */
- ret_val = leaf_shift_right(tb,tb->rnum[0]-1,tb->rbytes);
- /* Insert new item into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position = get_right_neighbor_position (tb, 0);
- leaf_insert_into_buf (&bi, item_pos - n + tb->rnum[0] - 1, ih, body, zeros_num);
-
- if ( item_pos - n + tb->rnum[0] - 1 == 0 ) {
- replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
-
- }
- zeros_num = tb->insert_size[0] = 0;
- }
- }
- else /* new item or part of it doesn't fall into R[0] */
- {
- leaf_shift_right(tb,tb->rnum[0],tb->rbytes);
- }
- break;
-
- case M_PASTE: /* append item */
-
- if ( n - tb->rnum[0] <= item_pos ) /* pasted item or part of it falls to R[0] */
- {
- if ( item_pos == n - tb->rnum[0] && tb->rbytes != -1 )
- { /* we must shift the part of the appended item */
- if ( is_direntry_le_ih (B_N_PITEM_HEAD(tbS0, item_pos)))
- { /* we append to directory item */
- int entry_count;
-
- RFALSE( zeros_num,
- "PAP-12145: invalid parameter in case of a directory");
- entry_count = I_ENTRY_COUNT(B_N_PITEM_HEAD(tbS0, item_pos));
- if ( entry_count - tb->rbytes < pos_in_item )
- /* new directory entry falls into R[0] */
- {
- int paste_entry_position;
-
- RFALSE( tb->rbytes - 1 >= entry_count ||
- ! tb->insert_size[0],
- "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
- tb->rbytes, entry_count);
- /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */
- leaf_shift_right(tb,tb->rnum[0],tb->rbytes - 1);
- /* Paste given directory entry to directory item */
- paste_entry_position = pos_in_item - entry_count + tb->rbytes - 1;
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position = get_right_neighbor_position (tb, 0);
- leaf_paste_in_buffer (&bi, 0, paste_entry_position,
- tb->insert_size[0],body,zeros_num);
- /* paste entry */
- leaf_paste_entries (
- bi.bi_bh, 0, paste_entry_position, 1, (struct reiserfs_de_head *)body,
- body + DEH_SIZE, tb->insert_size[0]
- );
-
- if ( paste_entry_position == 0 ) {
- /* change delimiting keys */
- replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
- }
-
- tb->insert_size[0] = 0;
- pos_in_item++;
- }
- else /* new directory entry doesn't fall into R[0] */
- {
- leaf_shift_right(tb,tb->rnum[0],tb->rbytes);
- }
- }
- else /* regular object */
- {
- int n_shift, n_rem, r_zeros_number;
- const char * r_body;
-
- /* Calculate number of bytes which must be shifted from appended item */
- if ( (n_shift = tb->rbytes - tb->insert_size[0]) < 0 )
- n_shift = 0;
-
- RFALSE(pos_in_item != ih_item_len(B_N_PITEM_HEAD (tbS0, item_pos)),
- "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
- pos_in_item, ih_item_len( B_N_PITEM_HEAD(tbS0,item_pos)));
-
- leaf_shift_right(tb,tb->rnum[0],n_shift);
- /* Calculate number of bytes which must remain in body after appending to R[0] */
- if ( (n_rem = tb->insert_size[0] - tb->rbytes) < 0 )
- n_rem = 0;
-
- {
- int version;
- unsigned long temp_rem = n_rem;
-
- version = ih_version (B_N_PITEM_HEAD (tb->R[0],0));
- if (is_indirect_le_key(version,B_N_PKEY(tb->R[0],0))){
- temp_rem = n_rem << (tb->tb_sb->s_blocksize_bits -
- UNFM_P_SHIFT);
- }
- set_le_key_k_offset (version, B_N_PKEY(tb->R[0],0),
- le_key_k_offset (version, B_N_PKEY(tb->R[0],0)) + temp_rem);
- set_le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0]),
- le_key_k_offset (version, B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) + temp_rem);
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
}
+ break;
+
+ case M_PASTE: /* append item */
+
+ if (n - tb->rnum[0] <= item_pos) { /* pasted item or part of it falls to R[0] */
+ if (item_pos == n - tb->rnum[0] && tb->rbytes != -1) { /* we must shift the part of the appended item */
+ if (is_direntry_le_ih(B_N_PITEM_HEAD(tbS0, item_pos))) { /* we append to directory item */
+ int entry_count;
+
+ RFALSE(zeros_num,
+ "PAP-12145: invalid parameter in case of a directory");
+ entry_count =
+ I_ENTRY_COUNT(B_N_PITEM_HEAD
+ (tbS0,
+ item_pos));
+ if (entry_count - tb->rbytes <
+ pos_in_item)
+ /* new directory entry falls into R[0] */
+ {
+ int paste_entry_position;
+
+ RFALSE(tb->rbytes - 1 >=
+ entry_count
+ || !tb->
+ insert_size[0],
+ "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
+ tb->rbytes,
+ entry_count);
+ /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */
+ leaf_shift_right(tb,
+ tb->
+ rnum
+ [0],
+ tb->
+ rbytes
+ - 1);
+ /* Paste given directory entry to directory item */
+ paste_entry_position =
+ pos_in_item -
+ entry_count +
+ tb->rbytes - 1;
+ bi.tb = tb;
+ bi.bi_bh = tb->R[0];
+ bi.bi_parent =
+ tb->FR[0];
+ bi.bi_position =
+ get_right_neighbor_position
+ (tb, 0);
+ leaf_paste_in_buffer
+ (&bi, 0,
+ paste_entry_position,
+ tb->insert_size[0],
+ body, zeros_num);
+ /* paste entry */
+ leaf_paste_entries(bi.
+ bi_bh,
+ 0,
+ paste_entry_position,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)
+ body,
+ body
+ +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+
+ if (paste_entry_position
+ == 0) {
+ /* change delimiting keys */
+ replace_key(tb,
+ tb->
+ CFR
+ [0],
+ tb->
+ rkey
+ [0],
+ tb->
+ R
+ [0],
+ 0);
+ }
+
+ tb->insert_size[0] = 0;
+ pos_in_item++;
+ } else { /* new directory entry doesn't fall into R[0] */
+
+ leaf_shift_right(tb,
+ tb->
+ rnum
+ [0],
+ tb->
+ rbytes);
+ }
+ } else { /* regular object */
+
+ int n_shift, n_rem,
+ r_zeros_number;
+ const char *r_body;
+
+ /* Calculate number of bytes which must be shifted from appended item */
+ if ((n_shift =
+ tb->rbytes -
+ tb->insert_size[0]) < 0)
+ n_shift = 0;
+
+ RFALSE(pos_in_item !=
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0, item_pos)),
+ "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
+ pos_in_item,
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0, item_pos)));
+
+ leaf_shift_right(tb,
+ tb->rnum[0],
+ n_shift);
+ /* Calculate number of bytes which must remain in body after appending to R[0] */
+ if ((n_rem =
+ tb->insert_size[0] -
+ tb->rbytes) < 0)
+ n_rem = 0;
+
+ {
+ int version;
+ unsigned long temp_rem =
+ n_rem;
+
+ version =
+ ih_version
+ (B_N_PITEM_HEAD
+ (tb->R[0], 0));
+ if (is_indirect_le_key
+ (version,
+ B_N_PKEY(tb->R[0],
+ 0))) {
+ temp_rem =
+ n_rem <<
+ (tb->tb_sb->
+ s_blocksize_bits
+ -
+ UNFM_P_SHIFT);
+ }
+ set_le_key_k_offset
+ (version,
+ B_N_PKEY(tb->R[0],
+ 0),
+ le_key_k_offset
+ (version,
+ B_N_PKEY(tb->R[0],
+ 0)) +
+ temp_rem);
+ set_le_key_k_offset
+ (version,
+ B_N_PDELIM_KEY(tb->
+ CFR
+ [0],
+ tb->
+ rkey
+ [0]),
+ le_key_k_offset
+ (version,
+ B_N_PDELIM_KEY
+ (tb->CFR[0],
+ tb->rkey[0])) +
+ temp_rem);
+ }
/* k_offset (B_N_PKEY(tb->R[0],0)) += n_rem;
k_offset (B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) += n_rem;*/
- do_balance_mark_internal_dirty (tb, tb->CFR[0], 0);
-
- /* Append part of body into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position = get_right_neighbor_position (tb, 0);
- if ( n_rem > zeros_num ) {
- r_zeros_number = 0;
- r_body = body + n_rem - zeros_num;
- }
- else {
- r_body = body;
- r_zeros_number = zeros_num - n_rem;
- zeros_num -= r_zeros_number;
- }
-
- leaf_paste_in_buffer(&bi, 0, n_shift, tb->insert_size[0] - n_rem, r_body, r_zeros_number);
-
- if (is_indirect_le_ih (B_N_PITEM_HEAD(tb->R[0],0))) {
+ do_balance_mark_internal_dirty
+ (tb, tb->CFR[0], 0);
+
+ /* Append part of body into R[0] */
+ bi.tb = tb;
+ bi.bi_bh = tb->R[0];
+ bi.bi_parent = tb->FR[0];
+ bi.bi_position =
+ get_right_neighbor_position
+ (tb, 0);
+ if (n_rem > zeros_num) {
+ r_zeros_number = 0;
+ r_body =
+ body + n_rem -
+ zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number =
+ zeros_num - n_rem;
+ zeros_num -=
+ r_zeros_number;
+ }
+
+ leaf_paste_in_buffer(&bi, 0,
+ n_shift,
+ tb->
+ insert_size
+ [0] -
+ n_rem,
+ r_body,
+ r_zeros_number);
+
+ if (is_indirect_le_ih
+ (B_N_PITEM_HEAD
+ (tb->R[0], 0))) {
#if 0
- RFALSE( n_rem,
- "PAP-12160: paste more than one unformatted node pointer");
+ RFALSE(n_rem,
+ "PAP-12160: paste more than one unformatted node pointer");
#endif
- set_ih_free_space (B_N_PITEM_HEAD(tb->R[0],0), 0);
- }
- tb->insert_size[0] = n_rem;
- if ( ! n_rem )
- pos_in_item ++;
- }
- }
- else /* pasted item in whole falls into R[0] */
- {
- struct item_head * pasted;
+ set_ih_free_space
+ (B_N_PITEM_HEAD
+ (tb->R[0], 0), 0);
+ }
+ tb->insert_size[0] = n_rem;
+ if (!n_rem)
+ pos_in_item++;
+ }
+ } else { /* pasted item in whole falls into R[0] */
+
+ struct item_head *pasted;
+
+ ret_val =
+ leaf_shift_right(tb, tb->rnum[0],
+ tb->rbytes);
+ /* append item in R[0] */
+ if (pos_in_item >= 0) {
+ bi.tb = tb;
+ bi.bi_bh = tb->R[0];
+ bi.bi_parent = tb->FR[0];
+ bi.bi_position =
+ get_right_neighbor_position
+ (tb, 0);
+ leaf_paste_in_buffer(&bi,
+ item_pos -
+ n +
+ tb->
+ rnum[0],
+ pos_in_item,
+ tb->
+ insert_size
+ [0], body,
+ zeros_num);
+ }
+
+ /* paste new entry, if item is directory item */
+ pasted =
+ B_N_PITEM_HEAD(tb->R[0],
+ item_pos - n +
+ tb->rnum[0]);
+ if (is_direntry_le_ih(pasted)
+ && pos_in_item >= 0) {
+ leaf_paste_entries(bi.bi_bh,
+ item_pos -
+ n +
+ tb->rnum[0],
+ pos_in_item,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)body,
+ body +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ if (!pos_in_item) {
+
+ RFALSE(item_pos - n +
+ tb->rnum[0],
+ "PAP-12165: directory item must be first item of node when pasting is in 0th position");
+
+ /* update delimiting keys */
+ replace_key(tb,
+ tb->CFR[0],
+ tb->rkey[0],
+ tb->R[0],
+ 0);
+ }
+ }
+
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ zeros_num = tb->insert_size[0] = 0;
+ }
+ } else { /* new item doesn't fall into R[0] */
- ret_val = leaf_shift_right(tb,tb->rnum[0],tb->rbytes);
- /* append item in R[0] */
- if ( pos_in_item >= 0 ) {
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position = get_right_neighbor_position (tb, 0);
- leaf_paste_in_buffer(&bi,item_pos - n + tb->rnum[0], pos_in_item,
- tb->insert_size[0],body, zeros_num);
- }
-
- /* paste new entry, if item is directory item */
- pasted = B_N_PITEM_HEAD(tb->R[0], item_pos - n + tb->rnum[0]);
- if (is_direntry_le_ih (pasted) && pos_in_item >= 0 ) {
- leaf_paste_entries (
- bi.bi_bh, item_pos - n + tb->rnum[0], pos_in_item, 1,
- (struct reiserfs_de_head *)body, body + DEH_SIZE, tb->insert_size[0]
- );
- if ( ! pos_in_item ) {
-
- RFALSE( item_pos - n + tb->rnum[0],
- "PAP-12165: directory item must be first item of node when pasting is in 0th position");
-
- /* update delimiting keys */
- replace_key(tb, tb->CFR[0],tb->rkey[0],tb->R[0],0);
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
}
- }
-
- if (is_indirect_le_ih (pasted))
- set_ih_free_space (pasted, 0);
- zeros_num = tb->insert_size[0] = 0;
+ break;
+ default: /* cases d and t */
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12175: balance_leaf: rnum > 0: unexpectable mode: %s(%d)",
+ (flag ==
+ M_DELETE) ? "DELETE" : ((flag ==
+ M_CUT) ? "CUT"
+ : "UNKNOWN"),
+ flag);
}
- }
- else /* new item doesn't fall into R[0] */
- {
- leaf_shift_right(tb,tb->rnum[0],tb->rbytes);
- }
- break;
- default: /* cases d and t */
- reiserfs_panic (tb->tb_sb, "PAP-12175: balance_leaf: rnum > 0: unexpectable mode: %s(%d)",
- (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
- }
-
- } /* tb->rnum[0] > 0 */
-
-
- RFALSE( tb->blknum[0] > 3,
- "PAP-12180: blknum can not be %d. It must be <= 3", tb->blknum[0]);
- RFALSE( tb->blknum[0] < 0,
- "PAP-12185: blknum can not be %d. It must be >= 0", tb->blknum[0]);
-
- /* if while adding to a node we discover that it is possible to split
- it in two, and merge the left part into the left neighbor and the
- right part into the right neighbor, eliminating the node */
- if ( tb->blknum[0] == 0 ) { /* node S[0] is empty now */
-
- RFALSE( ! tb->lnum[0] || ! tb->rnum[0],
- "PAP-12190: lnum and rnum must not be zero");
- /* if insertion was done before 0-th position in R[0], right
- delimiting key of the tb->L[0]'s and left delimiting key are
- not set correctly */
- if (tb->CFL[0]) {
- if (!tb->CFR[0])
- reiserfs_panic (tb->tb_sb, "vs-12195: balance_leaf: CFR not initialized");
- copy_key (B_N_PDELIM_KEY (tb->CFL[0], tb->lkey[0]), B_N_PDELIM_KEY (tb->CFR[0], tb->rkey[0]));
- do_balance_mark_internal_dirty (tb, tb->CFL[0], 0);
- }
-
- reiserfs_invalidate_buffer(tb,tbS0);
- return 0;
- }
-
-
- /* Fill new nodes that appear in place of S[0] */
- /* I am told that this copying is because we need an array to enable
- the looping code. -Hans */
- snum[0] = tb->s1num,
- snum[1] = tb->s2num;
- sbytes[0] = tb->s1bytes;
- sbytes[1] = tb->s2bytes;
- for( i = tb->blknum[0] - 2; i >= 0; i-- ) {
-
- RFALSE( !snum[i], "PAP-12200: snum[%d] == %d. Must be > 0", i, snum[i]);
+ }
- /* here we shift from S to S_new nodes */
+ /* tb->rnum[0] > 0 */
+ RFALSE(tb->blknum[0] > 3,
+ "PAP-12180: blknum can not be %d. It must be <= 3",
+ tb->blknum[0]);
+ RFALSE(tb->blknum[0] < 0,
+ "PAP-12185: blknum can not be %d. It must be >= 0",
+ tb->blknum[0]);
+
+ /* if while adding to a node we discover that it is possible to split
+ it in two, and merge the left part into the left neighbor and the
+ right part into the right neighbor, eliminating the node */
+ if (tb->blknum[0] == 0) { /* node S[0] is empty now */
+
+ RFALSE(!tb->lnum[0] || !tb->rnum[0],
+ "PAP-12190: lnum and rnum must not be zero");
+ /* if insertion was done before 0-th position in R[0], right
+ delimiting key of the tb->L[0]'s and left delimiting key are
+ not set correctly */
+ if (tb->CFL[0]) {
+ if (!tb->CFR[0])
+ reiserfs_panic(tb->tb_sb,
+ "vs-12195: balance_leaf: CFR not initialized");
+ copy_key(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
+ B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]));
+ do_balance_mark_internal_dirty(tb, tb->CFL[0], 0);
+ }
- S_new[i] = get_FEB(tb);
+ reiserfs_invalidate_buffer(tb, tbS0);
+ return 0;
+ }
- /* initialized block type and tree level */
- set_blkh_level( B_BLK_HEAD(S_new[i]), DISK_LEAF_NODE_LEVEL );
+ /* Fill new nodes that appear in place of S[0] */
+
+ /* I am told that this copying is because we need an array to enable
+ the looping code. -Hans */
+ snum[0] = tb->s1num, snum[1] = tb->s2num;
+ sbytes[0] = tb->s1bytes;
+ sbytes[1] = tb->s2bytes;
+ for (i = tb->blknum[0] - 2; i >= 0; i--) {
+
+ RFALSE(!snum[i], "PAP-12200: snum[%d] == %d. Must be > 0", i,
+ snum[i]);
+
+ /* here we shift from S to S_new nodes */
+
+ S_new[i] = get_FEB(tb);
+
+ /* initialized block type and tree level */
+ set_blkh_level(B_BLK_HEAD(S_new[i]), DISK_LEAF_NODE_LEVEL);
+
+ n = B_NR_ITEMS(tbS0);
+
+ switch (flag) {
+ case M_INSERT: /* insert item */
+
+ if (n - snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */
+ if (item_pos == n - snum[i] + 1 && sbytes[i] != -1) { /* part of new item falls into S_new[i] */
+ int old_key_comp, old_len,
+ r_zeros_number;
+ const char *r_body;
+ int version;
+
+ /* Move snum[i]-1 items from S[0] to S_new[i] */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum[i] - 1, -1,
+ S_new[i]);
+ /* Remember key component and item length */
+ version = ih_version(ih);
+ old_key_comp = le_ih_k_offset(ih);
+ old_len = ih_item_len(ih);
+
+ /* Calculate key component and item length to insert into S_new[i] */
+ set_le_ih_k_offset(ih,
+ le_ih_k_offset(ih) +
+ ((old_len -
+ sbytes[i]) <<
+ (is_indirect_le_ih
+ (ih) ? tb->tb_sb->
+ s_blocksize_bits -
+ UNFM_P_SHIFT :
+ 0)));
+
+ put_ih_item_len(ih, sbytes[i]);
+
+ /* Insert part of the item into S_new[i] before 0-th item */
+ bi.tb = tb;
+ bi.bi_bh = S_new[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+
+ if ((old_len - sbytes[i]) > zeros_num) {
+ r_zeros_number = 0;
+ r_body =
+ body + (old_len -
+ sbytes[i]) -
+ zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number =
+ zeros_num - (old_len -
+ sbytes[i]);
+ zeros_num -= r_zeros_number;
+ }
+
+ leaf_insert_into_buf(&bi, 0, ih, r_body,
+ r_zeros_number);
+
+ /* Calculate key component and item length to insert into S[i] */
+ set_le_ih_k_offset(ih, old_key_comp);
+ put_ih_item_len(ih,
+ old_len - sbytes[i]);
+ tb->insert_size[0] -= sbytes[i];
+ } else { /* whole new item falls into S_new[i] */
+
+ /* Shift snum[0] - 1 items to S_new[i] (sbytes[i] of split item) */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum[i] - 1, sbytes[i],
+ S_new[i]);
+
+ /* Insert new item into S_new[i] */
+ bi.tb = tb;
+ bi.bi_bh = S_new[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+ leaf_insert_into_buf(&bi,
+ item_pos - n +
+ snum[i] - 1, ih,
+ body, zeros_num);
+
+ zeros_num = tb->insert_size[0] = 0;
+ }
+ }
+ else { /* new item or it part don't falls into S_new[i] */
- n = B_NR_ITEMS(tbS0);
-
- switch (flag) {
- case M_INSERT: /* insert item */
-
- if ( n - snum[i] < item_pos )
- { /* new item or it's part falls to first new node S_new[i]*/
- if ( item_pos == n - snum[i] + 1 && sbytes[i] != -1 )
- { /* part of new item falls into S_new[i] */
- int old_key_comp, old_len, r_zeros_number;
- const char * r_body;
- int version;
-
- /* Move snum[i]-1 items from S[0] to S_new[i] */
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i] - 1, -1, S_new[i]);
- /* Remember key component and item length */
- version = ih_version (ih);
- old_key_comp = le_ih_k_offset( ih );
- old_len = ih_item_len(ih);
-
- /* Calculate key component and item length to insert into S_new[i] */
- set_le_ih_k_offset( ih,
- le_ih_k_offset(ih) + ((old_len - sbytes[i] )<<(is_indirect_le_ih(ih)?tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT:0)) );
-
- put_ih_item_len( ih, sbytes[i] );
-
- /* Insert part of the item into S_new[i] before 0-th item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
-
- if ( (old_len - sbytes[i]) > zeros_num ) {
- r_zeros_number = 0;
- r_body = body + (old_len - sbytes[i]) - zeros_num;
- }
- else {
- r_body = body;
- r_zeros_number = zeros_num - (old_len - sbytes[i]);
- zeros_num -= r_zeros_number;
- }
-
- leaf_insert_into_buf (&bi, 0, ih, r_body, r_zeros_number);
-
- /* Calculate key component and item length to insert into S[i] */
- set_le_ih_k_offset( ih, old_key_comp );
- put_ih_item_len( ih, old_len - sbytes[i] );
- tb->insert_size[0] -= sbytes[i];
- }
- else /* whole new item falls into S_new[i] */
- {
- /* Shift snum[0] - 1 items to S_new[i] (sbytes[i] of split item) */
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i] - 1, sbytes[i], S_new[i]);
-
- /* Insert new item into S_new[i] */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
- leaf_insert_into_buf (&bi, item_pos - n + snum[i] - 1, ih, body, zeros_num);
-
- zeros_num = tb->insert_size[0] = 0;
- }
- }
-
- else /* new item or it part don't falls into S_new[i] */
- {
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
- }
- break;
-
- case M_PASTE: /* append item */
-
- if ( n - snum[i] <= item_pos ) /* pasted item or part if it falls to S_new[i] */
- {
- if ( item_pos == n - snum[i] && sbytes[i] != -1 )
- { /* we must shift part of the appended item */
- struct item_head * aux_ih;
-
- RFALSE( ih, "PAP-12210: ih must be 0");
-
- if ( is_direntry_le_ih (aux_ih = B_N_PITEM_HEAD(tbS0,item_pos))) {
- /* we append to directory item */
-
- int entry_count;
-
- entry_count = ih_entry_count(aux_ih);
-
- if ( entry_count - sbytes[i] < pos_in_item && pos_in_item <= entry_count ) {
- /* new directory entry falls into S_new[i] */
-
- RFALSE( ! tb->insert_size[0],
- "PAP-12215: insert_size is already 0");
- RFALSE( sbytes[i] - 1 >= entry_count,
- "PAP-12220: there are no so much entries (%d), only %d",
- sbytes[i] - 1, entry_count);
-
- /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i]-1, S_new[i]);
- /* Paste given directory entry to directory item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
- leaf_paste_in_buffer (&bi, 0, pos_in_item - entry_count + sbytes[i] - 1,
- tb->insert_size[0], body,zeros_num);
- /* paste new directory entry */
- leaf_paste_entries (
- bi.bi_bh, 0, pos_in_item - entry_count + sbytes[i] - 1,
- 1, (struct reiserfs_de_head *)body, body + DEH_SIZE,
- tb->insert_size[0]
- );
- tb->insert_size[0] = 0;
- pos_in_item++;
- } else { /* new directory entry doesn't fall into S_new[i] */
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum[i], sbytes[i], S_new[i]);
}
- }
- else /* regular object */
- {
- int n_shift, n_rem, r_zeros_number;
- const char * r_body;
-
- RFALSE( pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0,item_pos)) ||
- tb->insert_size[0] <= 0,
- "PAP-12225: item too short or insert_size <= 0");
-
- /* Calculate number of bytes which must be shifted from appended item */
- n_shift = sbytes[i] - tb->insert_size[0];
- if ( n_shift < 0 )
- n_shift = 0;
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], n_shift, S_new[i]);
-
- /* Calculate number of bytes which must remain in body after append to S_new[i] */
- n_rem = tb->insert_size[0] - sbytes[i];
- if ( n_rem < 0 )
- n_rem = 0;
- /* Append part of body into S_new[0] */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ break;
+
+ case M_PASTE: /* append item */
+
+ if (n - snum[i] <= item_pos) { /* pasted item or part if it falls to S_new[i] */
+ if (item_pos == n - snum[i] && sbytes[i] != -1) { /* we must shift part of the appended item */
+ struct item_head *aux_ih;
+
+ RFALSE(ih, "PAP-12210: ih must be 0");
+
+ if (is_direntry_le_ih
+ (aux_ih =
+ B_N_PITEM_HEAD(tbS0, item_pos))) {
+ /* we append to directory item */
+
+ int entry_count;
+
+ entry_count =
+ ih_entry_count(aux_ih);
+
+ if (entry_count - sbytes[i] <
+ pos_in_item
+ && pos_in_item <=
+ entry_count) {
+ /* new directory entry falls into S_new[i] */
+
+ RFALSE(!tb->
+ insert_size[0],
+ "PAP-12215: insert_size is already 0");
+ RFALSE(sbytes[i] - 1 >=
+ entry_count,
+ "PAP-12220: there are no so much entries (%d), only %d",
+ sbytes[i] - 1,
+ entry_count);
+
+ /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */
+ leaf_move_items
+ (LEAF_FROM_S_TO_SNEW,
+ tb, snum[i],
+ sbytes[i] - 1,
+ S_new[i]);
+ /* Paste given directory entry to directory item */
+ bi.tb = tb;
+ bi.bi_bh = S_new[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+ leaf_paste_in_buffer
+ (&bi, 0,
+ pos_in_item -
+ entry_count +
+ sbytes[i] - 1,
+ tb->insert_size[0],
+ body, zeros_num);
+ /* paste new directory entry */
+ leaf_paste_entries(bi.
+ bi_bh,
+ 0,
+ pos_in_item
+ -
+ entry_count
+ +
+ sbytes
+ [i] -
+ 1, 1,
+ (struct
+ reiserfs_de_head
+ *)
+ body,
+ body
+ +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ tb->insert_size[0] = 0;
+ pos_in_item++;
+ } else { /* new directory entry doesn't fall into S_new[i] */
+ leaf_move_items
+ (LEAF_FROM_S_TO_SNEW,
+ tb, snum[i],
+ sbytes[i],
+ S_new[i]);
+ }
+ } else { /* regular object */
+
+ int n_shift, n_rem,
+ r_zeros_number;
+ const char *r_body;
+
+ RFALSE(pos_in_item !=
+ ih_item_len
+ (B_N_PITEM_HEAD
+ (tbS0, item_pos))
+ || tb->insert_size[0] <=
+ 0,
+ "PAP-12225: item too short or insert_size <= 0");
+
+ /* Calculate number of bytes which must be shifted from appended item */
+ n_shift =
+ sbytes[i] -
+ tb->insert_size[0];
+ if (n_shift < 0)
+ n_shift = 0;
+ leaf_move_items
+ (LEAF_FROM_S_TO_SNEW, tb,
+ snum[i], n_shift,
+ S_new[i]);
+
+ /* Calculate number of bytes which must remain in body after append to S_new[i] */
+ n_rem =
+ tb->insert_size[0] -
+ sbytes[i];
+ if (n_rem < 0)
+ n_rem = 0;
+ /* Append part of body into S_new[0] */
+ bi.tb = tb;
+ bi.bi_bh = S_new[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+
+ if (n_rem > zeros_num) {
+ r_zeros_number = 0;
+ r_body =
+ body + n_rem -
+ zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number =
+ zeros_num - n_rem;
+ zeros_num -=
+ r_zeros_number;
+ }
+
+ leaf_paste_in_buffer(&bi, 0,
+ n_shift,
+ tb->
+ insert_size
+ [0] -
+ n_rem,
+ r_body,
+ r_zeros_number);
+ {
+ struct item_head *tmp;
+
+ tmp =
+ B_N_PITEM_HEAD(S_new
+ [i],
+ 0);
+ if (is_indirect_le_ih
+ (tmp)) {
+ set_ih_free_space
+ (tmp, 0);
+ set_le_ih_k_offset
+ (tmp,
+ le_ih_k_offset
+ (tmp) +
+ (n_rem <<
+ (tb->
+ tb_sb->
+ s_blocksize_bits
+ -
+ UNFM_P_SHIFT)));
+ } else {
+ set_le_ih_k_offset
+ (tmp,
+ le_ih_k_offset
+ (tmp) +
+ n_rem);
+ }
+ }
+
+ tb->insert_size[0] = n_rem;
+ if (!n_rem)
+ pos_in_item++;
+ }
+ } else
+ /* item falls wholly into S_new[i] */
+ {
+ int ret_val;
+ struct item_head *pasted;
- if ( n_rem > zeros_num ) {
- r_zeros_number = 0;
- r_body = body + n_rem - zeros_num;
- }
- else {
- r_body = body;
- r_zeros_number = zeros_num - n_rem;
- zeros_num -= r_zeros_number;
+#ifdef CONFIG_REISERFS_CHECK
+ struct item_head *ih =
+ B_N_PITEM_HEAD(tbS0, item_pos);
+
+ if (!is_direntry_le_ih(ih)
+ && (pos_in_item != ih_item_len(ih)
+ || tb->insert_size[0] <= 0))
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12235: balance_leaf: pos_in_item must be equal to ih_item_len");
+#endif /* CONFIG_REISERFS_CHECK */
+
+ ret_val =
+ leaf_move_items(LEAF_FROM_S_TO_SNEW,
+ tb, snum[i],
+ sbytes[i],
+ S_new[i]);
+
+ RFALSE(ret_val,
+ "PAP-12240: unexpected value returned by leaf_move_items (%d)",
+ ret_val);
+
+ /* paste into item */
+ bi.tb = tb;
+ bi.bi_bh = S_new[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+ leaf_paste_in_buffer(&bi,
+ item_pos - n +
+ snum[i],
+ pos_in_item,
+ tb->insert_size[0],
+ body, zeros_num);
+
+ pasted =
+ B_N_PITEM_HEAD(S_new[i],
+ item_pos - n +
+ snum[i]);
+ if (is_direntry_le_ih(pasted)) {
+ leaf_paste_entries(bi.bi_bh,
+ item_pos -
+ n + snum[i],
+ pos_in_item,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)body,
+ body +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ }
+
+ /* if we paste to indirect item update ih_free_space */
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ zeros_num = tb->insert_size[0] = 0;
+ }
}
- leaf_paste_in_buffer(&bi, 0, n_shift, tb->insert_size[0]-n_rem, r_body,r_zeros_number);
- {
- struct item_head * tmp;
-
- tmp = B_N_PITEM_HEAD(S_new[i],0);
- if (is_indirect_le_ih (tmp)) {
- set_ih_free_space (tmp, 0);
- set_le_ih_k_offset( tmp, le_ih_k_offset(tmp) +
- (n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT)));
- } else {
- set_le_ih_k_offset( tmp, le_ih_k_offset(tmp) +
- n_rem );
- }
- }
+ else { /* pasted item doesn't fall into S_new[i] */
- tb->insert_size[0] = n_rem;
- if ( ! n_rem )
- pos_in_item++;
- }
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum[i], sbytes[i], S_new[i]);
+ }
+ break;
+ default: /* cases d and t */
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12245: balance_leaf: blknum > 2: unexpectable mode: %s(%d)",
+ (flag ==
+ M_DELETE) ? "DELETE" : ((flag ==
+ M_CUT) ? "CUT"
+ : "UNKNOWN"),
+ flag);
}
- else
- /* item falls wholly into S_new[i] */
- {
- int ret_val;
- struct item_head * pasted;
-#ifdef CONFIG_REISERFS_CHECK
- struct item_head * ih = B_N_PITEM_HEAD(tbS0,item_pos);
-
- if ( ! is_direntry_le_ih(ih) && (pos_in_item != ih_item_len(ih) ||
- tb->insert_size[0] <= 0) )
- reiserfs_panic (tb->tb_sb, "PAP-12235: balance_leaf: pos_in_item must be equal to ih_item_len");
-#endif /* CONFIG_REISERFS_CHECK */
-
- ret_val = leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
-
- RFALSE( ret_val,
- "PAP-12240: unexpected value returned by leaf_move_items (%d)",
- ret_val);
-
- /* paste into item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
- leaf_paste_in_buffer(&bi, item_pos - n + snum[i], pos_in_item, tb->insert_size[0], body, zeros_num);
-
- pasted = B_N_PITEM_HEAD(S_new[i], item_pos - n + snum[i]);
- if (is_direntry_le_ih (pasted))
- {
- leaf_paste_entries (
- bi.bi_bh, item_pos - n + snum[i], pos_in_item, 1,
- (struct reiserfs_de_head *)body, body + DEH_SIZE, tb->insert_size[0]
- );
- }
-
- /* if we paste to indirect item update ih_free_space */
- if (is_indirect_le_ih (pasted))
- set_ih_free_space (pasted, 0);
- zeros_num = tb->insert_size[0] = 0;
- }
- }
-
- else /* pasted item doesn't fall into S_new[i] */
- {
- leaf_move_items (LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i], S_new[i]);
- }
- break;
- default: /* cases d and t */
- reiserfs_panic (tb->tb_sb, "PAP-12245: balance_leaf: blknum > 2: unexpectable mode: %s(%d)",
- (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
+ memcpy(insert_key + i, B_N_PKEY(S_new[i], 0), KEY_SIZE);
+ insert_ptr[i] = S_new[i];
+
+ RFALSE(!buffer_journaled(S_new[i])
+ || buffer_journal_dirty(S_new[i])
+ || buffer_dirty(S_new[i]), "PAP-12247: S_new[%d] : (%b)",
+ i, S_new[i]);
}
- memcpy (insert_key + i,B_N_PKEY(S_new[i],0),KEY_SIZE);
- insert_ptr[i] = S_new[i];
-
- RFALSE (!buffer_journaled (S_new [i]) || buffer_journal_dirty (S_new [i]) ||
- buffer_dirty (S_new [i]),
- "PAP-12247: S_new[%d] : (%b)", i, S_new[i]);
- }
-
- /* if the affected item was not wholly shifted then we perform all necessary operations on that part or whole of the
- affected item which remains in S */
- if ( 0 <= item_pos && item_pos < tb->s0num )
- { /* if we must insert or append into buffer S[0] */
-
- switch (flag)
- {
- case M_INSERT: /* insert item into S[0] */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, 1);
- leaf_insert_into_buf (&bi, item_pos, ih, body, zeros_num);
-
- /* If we insert the first key change the delimiting key */
- if( item_pos == 0 ) {
- if (tb->CFL[0]) /* can be 0 in reiserfsck */
- replace_key(tb, tb->CFL[0], tb->lkey[0],tbS0,0);
-
- }
- break;
-
- case M_PASTE: { /* append item in S[0] */
- struct item_head * pasted;
-
- pasted = B_N_PITEM_HEAD (tbS0, item_pos);
- /* when directory, may be new entry already pasted */
- if (is_direntry_le_ih (pasted)) {
- if ( pos_in_item >= 0 &&
- pos_in_item <= ih_entry_count(pasted) ) {
-
- RFALSE( ! tb->insert_size[0],
- "PAP-12260: insert_size is 0 already");
-
- /* prepare space */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, 1);
- leaf_paste_in_buffer(&bi, item_pos, pos_in_item, tb->insert_size[0], body, zeros_num);
-
- /* paste entry */
- leaf_paste_entries (
- bi.bi_bh, item_pos, pos_in_item, 1, (struct reiserfs_de_head *)body,
- body + DEH_SIZE, tb->insert_size[0]
- );
- if ( ! item_pos && ! pos_in_item ) {
- RFALSE( !tb->CFL[0] || !tb->L[0],
- "PAP-12270: CFL[0]/L[0] must be specified");
- if (tb->CFL[0]) {
- replace_key(tb, tb->CFL[0], tb->lkey[0],tbS0,0);
+ /* if the affected item was not wholly shifted then we perform all necessary operations on that part or whole of the
+ affected item which remains in S */
+ if (0 <= item_pos && item_pos < tb->s0num) { /* if we must insert or append into buffer S[0] */
+
+ switch (flag) {
+ case M_INSERT: /* insert item into S[0] */
+ bi.tb = tb;
+ bi.bi_bh = tbS0;
+ bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
+ leaf_insert_into_buf(&bi, item_pos, ih, body,
+ zeros_num);
+
+ /* If we insert the first key change the delimiting key */
+ if (item_pos == 0) {
+ if (tb->CFL[0]) /* can be 0 in reiserfsck */
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ tbS0, 0);
}
- }
- tb->insert_size[0] = 0;
- }
- } else { /* regular object */
- if ( pos_in_item == ih_item_len(pasted) ) {
-
- RFALSE( tb->insert_size[0] <= 0,
- "PAP-12275: insert size must not be %d",
- tb->insert_size[0]);
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, 1);
- leaf_paste_in_buffer (&bi, item_pos, pos_in_item, tb->insert_size[0], body, zeros_num);
-
- if (is_indirect_le_ih (pasted)) {
+ break;
+
+ case M_PASTE:{ /* append item in S[0] */
+ struct item_head *pasted;
+
+ pasted = B_N_PITEM_HEAD(tbS0, item_pos);
+ /* when directory, may be new entry already pasted */
+ if (is_direntry_le_ih(pasted)) {
+ if (pos_in_item >= 0 &&
+ pos_in_item <=
+ ih_entry_count(pasted)) {
+
+ RFALSE(!tb->insert_size[0],
+ "PAP-12260: insert_size is 0 already");
+
+ /* prepare space */
+ bi.tb = tb;
+ bi.bi_bh = tbS0;
+ bi.bi_parent =
+ PATH_H_PPARENT(tb->tb_path,
+ 0);
+ bi.bi_position =
+ PATH_H_POSITION(tb->tb_path,
+ 1);
+ leaf_paste_in_buffer(&bi,
+ item_pos,
+ pos_in_item,
+ tb->
+ insert_size
+ [0], body,
+ zeros_num);
+
+ /* paste entry */
+ leaf_paste_entries(bi.bi_bh,
+ item_pos,
+ pos_in_item,
+ 1,
+ (struct
+ reiserfs_de_head
+ *)body,
+ body +
+ DEH_SIZE,
+ tb->
+ insert_size
+ [0]
+ );
+ if (!item_pos && !pos_in_item) {
+ RFALSE(!tb->CFL[0]
+ || !tb->L[0],
+ "PAP-12270: CFL[0]/L[0] must be specified");
+ if (tb->CFL[0]) {
+ replace_key(tb,
+ tb->
+ CFL
+ [0],
+ tb->
+ lkey
+ [0],
+ tbS0,
+ 0);
+
+ }
+ }
+ tb->insert_size[0] = 0;
+ }
+ } else { /* regular object */
+ if (pos_in_item == ih_item_len(pasted)) {
+
+ RFALSE(tb->insert_size[0] <= 0,
+ "PAP-12275: insert size must not be %d",
+ tb->insert_size[0]);
+ bi.tb = tb;
+ bi.bi_bh = tbS0;
+ bi.bi_parent =
+ PATH_H_PPARENT(tb->tb_path,
+ 0);
+ bi.bi_position =
+ PATH_H_POSITION(tb->tb_path,
+ 1);
+ leaf_paste_in_buffer(&bi,
+ item_pos,
+ pos_in_item,
+ tb->
+ insert_size
+ [0], body,
+ zeros_num);
+
+ if (is_indirect_le_ih(pasted)) {
#if 0
- RFALSE( tb->insert_size[0] != UNFM_P_SIZE,
- "PAP-12280: insert_size for indirect item must be %d, not %d",
- UNFM_P_SIZE, tb->insert_size[0]);
+ RFALSE(tb->
+ insert_size[0] !=
+ UNFM_P_SIZE,
+ "PAP-12280: insert_size for indirect item must be %d, not %d",
+ UNFM_P_SIZE,
+ tb->
+ insert_size[0]);
#endif
- set_ih_free_space (pasted, 0);
- }
- tb->insert_size[0] = 0;
- }
-
+ set_ih_free_space
+ (pasted, 0);
+ }
+ tb->insert_size[0] = 0;
+ }
#ifdef CONFIG_REISERFS_CHECK
- else {
- if ( tb->insert_size[0] ) {
- print_cur_tb ("12285");
- reiserfs_panic (tb->tb_sb, "PAP-12285: balance_leaf: insert_size must be 0 (%d)", tb->insert_size[0]);
- }
+ else {
+ if (tb->insert_size[0]) {
+ print_cur_tb("12285");
+ reiserfs_panic(tb->
+ tb_sb,
+ "PAP-12285: balance_leaf: insert_size must be 0 (%d)",
+ tb->
+ insert_size
+ [0]);
+ }
+ }
+#endif /* CONFIG_REISERFS_CHECK */
+
+ }
+ } /* case M_PASTE: */
}
-#endif /* CONFIG_REISERFS_CHECK */
-
- }
- } /* case M_PASTE: */
}
- }
-
#ifdef CONFIG_REISERFS_CHECK
- if ( flag == M_PASTE && tb->insert_size[0] ) {
- print_cur_tb ("12290");
- reiserfs_panic (tb->tb_sb, "PAP-12290: balance_leaf: insert_size is still not 0 (%d)", tb->insert_size[0]);
- }
-#endif /* CONFIG_REISERFS_CHECK */
-
- return 0;
-} /* Leaf level of the tree is balanced (end of balance_leaf) */
-
+ if (flag == M_PASTE && tb->insert_size[0]) {
+ print_cur_tb("12290");
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12290: balance_leaf: insert_size is still not 0 (%d)",
+ tb->insert_size[0]);
+ }
+#endif /* CONFIG_REISERFS_CHECK */
+ return 0;
+} /* Leaf level of the tree is balanced (end of balance_leaf) */
/* Make empty node */
-void make_empty_node (struct buffer_info * bi)
+void make_empty_node(struct buffer_info *bi)
{
- struct block_head * blkh;
+ struct block_head *blkh;
- RFALSE( bi->bi_bh == NULL, "PAP-12295: pointer to the buffer is NULL");
+ RFALSE(bi->bi_bh == NULL, "PAP-12295: pointer to the buffer is NULL");
- blkh = B_BLK_HEAD(bi->bi_bh);
- set_blkh_nr_item( blkh, 0 );
- set_blkh_free_space( blkh, MAX_CHILD_SIZE(bi->bi_bh) );
+ blkh = B_BLK_HEAD(bi->bi_bh);
+ set_blkh_nr_item(blkh, 0);
+ set_blkh_free_space(blkh, MAX_CHILD_SIZE(bi->bi_bh));
- if (bi->bi_parent)
- B_N_CHILD (bi->bi_parent, bi->bi_position)->dc_size = 0; /* Endian safe if 0 */
+ if (bi->bi_parent)
+ B_N_CHILD(bi->bi_parent, bi->bi_position)->dc_size = 0; /* Endian safe if 0 */
}
-
/* Get first empty buffer */
-struct buffer_head * get_FEB (struct tree_balance * tb)
+struct buffer_head *get_FEB(struct tree_balance *tb)
{
- int i;
- struct buffer_head * first_b;
- struct buffer_info bi;
-
- for (i = 0; i < MAX_FEB_SIZE; i ++)
- if (tb->FEB[i] != 0)
- break;
-
- if (i == MAX_FEB_SIZE)
- reiserfs_panic(tb->tb_sb, "vs-12300: get_FEB: FEB list is empty");
-
- bi.tb = tb;
- bi.bi_bh = first_b = tb->FEB[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
- make_empty_node (&bi);
- set_buffer_uptodate(first_b);
- tb->FEB[i] = NULL;
- tb->used[i] = first_b;
-
- return(first_b);
-}
+ int i;
+ struct buffer_head *first_b;
+ struct buffer_info bi;
+ for (i = 0; i < MAX_FEB_SIZE; i++)
+ if (tb->FEB[i] != 0)
+ break;
+
+ if (i == MAX_FEB_SIZE)
+ reiserfs_panic(tb->tb_sb,
+ "vs-12300: get_FEB: FEB list is empty");
+
+ bi.tb = tb;
+ bi.bi_bh = first_b = tb->FEB[i];
+ bi.bi_parent = NULL;
+ bi.bi_position = 0;
+ make_empty_node(&bi);
+ set_buffer_uptodate(first_b);
+ tb->FEB[i] = NULL;
+ tb->used[i] = first_b;
+
+ return (first_b);
+}
/* This is now used because reiserfs_free_block has to be able to
** schedule.
*/
-static void store_thrown (struct tree_balance * tb, struct buffer_head * bh)
+static void store_thrown(struct tree_balance *tb, struct buffer_head *bh)
{
- int i;
-
- if (buffer_dirty (bh))
- reiserfs_warning (tb->tb_sb, "store_thrown deals with dirty buffer");
- for (i = 0; i < sizeof (tb->thrown)/sizeof (tb->thrown[0]); i ++)
- if (!tb->thrown[i]) {
- tb->thrown[i] = bh;
- get_bh(bh) ; /* free_thrown puts this */
- return;
- }
- reiserfs_warning (tb->tb_sb, "store_thrown: too many thrown buffers");
+ int i;
+
+ if (buffer_dirty(bh))
+ reiserfs_warning(tb->tb_sb,
+ "store_thrown deals with dirty buffer");
+ for (i = 0; i < sizeof(tb->thrown) / sizeof(tb->thrown[0]); i++)
+ if (!tb->thrown[i]) {
+ tb->thrown[i] = bh;
+ get_bh(bh); /* free_thrown puts this */
+ return;
+ }
+ reiserfs_warning(tb->tb_sb, "store_thrown: too many thrown buffers");
}
-static void free_thrown(struct tree_balance *tb) {
- int i ;
- b_blocknr_t blocknr ;
- for (i = 0; i < sizeof (tb->thrown)/sizeof (tb->thrown[0]); i++) {
- if (tb->thrown[i]) {
- blocknr = tb->thrown[i]->b_blocknr ;
- if (buffer_dirty (tb->thrown[i]))
- reiserfs_warning (tb->tb_sb,
- "free_thrown deals with dirty buffer %d",
- blocknr);
- brelse(tb->thrown[i]) ; /* incremented in store_thrown */
- reiserfs_free_block (tb->transaction_handle, NULL, blocknr, 0);
+static void free_thrown(struct tree_balance *tb)
+{
+ int i;
+ b_blocknr_t blocknr;
+ for (i = 0; i < sizeof(tb->thrown) / sizeof(tb->thrown[0]); i++) {
+ if (tb->thrown[i]) {
+ blocknr = tb->thrown[i]->b_blocknr;
+ if (buffer_dirty(tb->thrown[i]))
+ reiserfs_warning(tb->tb_sb,
+ "free_thrown deals with dirty buffer %d",
+ blocknr);
+ brelse(tb->thrown[i]); /* incremented in store_thrown */
+ reiserfs_free_block(tb->transaction_handle, NULL,
+ blocknr, 0);
+ }
}
- }
}
-void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh)
+void reiserfs_invalidate_buffer(struct tree_balance *tb, struct buffer_head *bh)
{
- struct block_head *blkh;
- blkh = B_BLK_HEAD(bh);
- set_blkh_level( blkh, FREE_LEVEL );
- set_blkh_nr_item( blkh, 0 );
-
- clear_buffer_dirty(bh);
- store_thrown (tb, bh);
+ struct block_head *blkh;
+ blkh = B_BLK_HEAD(bh);
+ set_blkh_level(blkh, FREE_LEVEL);
+ set_blkh_nr_item(blkh, 0);
+
+ clear_buffer_dirty(bh);
+ store_thrown(tb, bh);
}
/* Replace n_dest'th key in buffer dest by n_src'th key of buffer src.*/
-void replace_key (struct tree_balance * tb, struct buffer_head * dest, int n_dest,
- struct buffer_head * src, int n_src)
+void replace_key(struct tree_balance *tb, struct buffer_head *dest, int n_dest,
+ struct buffer_head *src, int n_src)
{
- RFALSE( dest == NULL || src == NULL,
- "vs-12305: source or destination buffer is 0 (src=%p, dest=%p)",
- src, dest);
- RFALSE( ! B_IS_KEYS_LEVEL (dest),
- "vs-12310: invalid level (%z) for destination buffer. dest must be leaf",
- dest);
- RFALSE( n_dest < 0 || n_src < 0,
- "vs-12315: src(%d) or dest(%d) key number < 0", n_src, n_dest);
- RFALSE( n_dest >= B_NR_ITEMS(dest) || n_src >= B_NR_ITEMS(src),
- "vs-12320: src(%d(%d)) or dest(%d(%d)) key number is too big",
- n_src, B_NR_ITEMS(src), n_dest, B_NR_ITEMS(dest));
-
- if (B_IS_ITEMS_LEVEL (src))
- /* source buffer contains leaf node */
- memcpy (B_N_PDELIM_KEY(dest,n_dest), B_N_PITEM_HEAD(src,n_src), KEY_SIZE);
- else
- memcpy (B_N_PDELIM_KEY(dest,n_dest), B_N_PDELIM_KEY(src,n_src), KEY_SIZE);
-
- do_balance_mark_internal_dirty (tb, dest, 0);
+ RFALSE(dest == NULL || src == NULL,
+ "vs-12305: source or destination buffer is 0 (src=%p, dest=%p)",
+ src, dest);
+ RFALSE(!B_IS_KEYS_LEVEL(dest),
+ "vs-12310: invalid level (%z) for destination buffer. dest must be leaf",
+ dest);
+ RFALSE(n_dest < 0 || n_src < 0,
+ "vs-12315: src(%d) or dest(%d) key number < 0", n_src, n_dest);
+ RFALSE(n_dest >= B_NR_ITEMS(dest) || n_src >= B_NR_ITEMS(src),
+ "vs-12320: src(%d(%d)) or dest(%d(%d)) key number is too big",
+ n_src, B_NR_ITEMS(src), n_dest, B_NR_ITEMS(dest));
+
+ if (B_IS_ITEMS_LEVEL(src))
+ /* source buffer contains leaf node */
+ memcpy(B_N_PDELIM_KEY(dest, n_dest), B_N_PITEM_HEAD(src, n_src),
+ KEY_SIZE);
+ else
+ memcpy(B_N_PDELIM_KEY(dest, n_dest), B_N_PDELIM_KEY(src, n_src),
+ KEY_SIZE);
+
+ do_balance_mark_internal_dirty(tb, dest, 0);
}
-
-int get_left_neighbor_position (
- struct tree_balance * tb,
- int h
- )
+int get_left_neighbor_position(struct tree_balance *tb, int h)
{
- int Sh_position = PATH_H_POSITION (tb->tb_path, h + 1);
+ int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
- RFALSE( PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FL[h] == 0,
- "vs-12325: FL[%d](%p) or F[%d](%p) does not exist",
- h, tb->FL[h], h, PATH_H_PPARENT (tb->tb_path, h));
+ RFALSE(PATH_H_PPARENT(tb->tb_path, h) == 0 || tb->FL[h] == 0,
+ "vs-12325: FL[%d](%p) or F[%d](%p) does not exist",
+ h, tb->FL[h], h, PATH_H_PPARENT(tb->tb_path, h));
- if (Sh_position == 0)
- return B_NR_ITEMS (tb->FL[h]);
- else
- return Sh_position - 1;
+ if (Sh_position == 0)
+ return B_NR_ITEMS(tb->FL[h]);
+ else
+ return Sh_position - 1;
}
-
-int get_right_neighbor_position (struct tree_balance * tb, int h)
+int get_right_neighbor_position(struct tree_balance *tb, int h)
{
- int Sh_position = PATH_H_POSITION (tb->tb_path, h + 1);
+ int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
- RFALSE( PATH_H_PPARENT (tb->tb_path, h) == 0 || tb->FR[h] == 0,
- "vs-12330: F[%d](%p) or FR[%d](%p) does not exist",
- h, PATH_H_PPARENT (tb->tb_path, h), h, tb->FR[h]);
+ RFALSE(PATH_H_PPARENT(tb->tb_path, h) == 0 || tb->FR[h] == 0,
+ "vs-12330: F[%d](%p) or FR[%d](%p) does not exist",
+ h, PATH_H_PPARENT(tb->tb_path, h), h, tb->FR[h]);
- if (Sh_position == B_NR_ITEMS (PATH_H_PPARENT (tb->tb_path, h)))
- return 0;
- else
- return Sh_position + 1;
+ if (Sh_position == B_NR_ITEMS(PATH_H_PPARENT(tb->tb_path, h)))
+ return 0;
+ else
+ return Sh_position + 1;
}
-
#ifdef CONFIG_REISERFS_CHECK
-int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value);
-static void check_internal_node (struct super_block * s, struct buffer_head * bh, char * mes)
+int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value);
+static void check_internal_node(struct super_block *s, struct buffer_head *bh,
+ char *mes)
{
- struct disk_child * dc;
- int i;
-
- RFALSE( !bh, "PAP-12336: bh == 0");
-
- if (!bh || !B_IS_IN_TREE (bh))
- return;
-
- RFALSE( !buffer_dirty (bh) &&
- !(buffer_journaled(bh) || buffer_journal_dirty(bh)),
- "PAP-12337: buffer (%b) must be dirty", bh);
- dc = B_N_CHILD (bh, 0);
-
- for (i = 0; i <= B_NR_ITEMS (bh); i ++, dc ++) {
- if (!is_reusable (s, dc_block_number(dc), 1) ) {
- print_cur_tb (mes);
- reiserfs_panic (s, "PAP-12338: check_internal_node: invalid child pointer %y in %b", dc, bh);
- }
- }
-}
+ struct disk_child *dc;
+ int i;
+ RFALSE(!bh, "PAP-12336: bh == 0");
-static int locked_or_not_in_tree (struct buffer_head * bh, char * which)
-{
- if ( (!buffer_journal_prepared (bh) && buffer_locked (bh)) ||
- !B_IS_IN_TREE (bh) ) {
- reiserfs_warning (NULL, "vs-12339: locked_or_not_in_tree: %s (%b)",
- which, bh);
- return 1;
- }
- return 0;
-}
+ if (!bh || !B_IS_IN_TREE(bh))
+ return;
+ RFALSE(!buffer_dirty(bh) &&
+ !(buffer_journaled(bh) || buffer_journal_dirty(bh)),
+ "PAP-12337: buffer (%b) must be dirty", bh);
+ dc = B_N_CHILD(bh, 0);
-static int check_before_balancing (struct tree_balance * tb)
-{
- int retval = 0;
-
- if ( cur_tb ) {
- reiserfs_panic (tb->tb_sb, "vs-12335: check_before_balancing: "
- "suspect that schedule occurred based on cur_tb not being null at this point in code. "
- "do_balance cannot properly handle schedule occurring while it runs.");
- }
-
- /* double check that buffers that we will modify are unlocked. (fix_nodes should already have
- prepped all of these for us). */
- if ( tb->lnum[0] ) {
- retval |= locked_or_not_in_tree (tb->L[0], "L[0]");
- retval |= locked_or_not_in_tree (tb->FL[0], "FL[0]");
- retval |= locked_or_not_in_tree (tb->CFL[0], "CFL[0]");
- check_leaf (tb->L[0]);
- }
- if ( tb->rnum[0] ) {
- retval |= locked_or_not_in_tree (tb->R[0], "R[0]");
- retval |= locked_or_not_in_tree (tb->FR[0], "FR[0]");
- retval |= locked_or_not_in_tree (tb->CFR[0], "CFR[0]");
- check_leaf (tb->R[0]);
- }
- retval |= locked_or_not_in_tree (PATH_PLAST_BUFFER (tb->tb_path), "S[0]");
- check_leaf (PATH_PLAST_BUFFER (tb->tb_path));
-
- return retval;
+ for (i = 0; i <= B_NR_ITEMS(bh); i++, dc++) {
+ if (!is_reusable(s, dc_block_number(dc), 1)) {
+ print_cur_tb(mes);
+ reiserfs_panic(s,
+ "PAP-12338: check_internal_node: invalid child pointer %y in %b",
+ dc, bh);
+ }
+ }
}
+static int locked_or_not_in_tree(struct buffer_head *bh, char *which)
+{
+ if ((!buffer_journal_prepared(bh) && buffer_locked(bh)) ||
+ !B_IS_IN_TREE(bh)) {
+ reiserfs_warning(NULL,
+ "vs-12339: locked_or_not_in_tree: %s (%b)",
+ which, bh);
+ return 1;
+ }
+ return 0;
+}
-static void check_after_balance_leaf (struct tree_balance * tb)
+static int check_before_balancing(struct tree_balance *tb)
{
- if (tb->lnum[0]) {
- if (B_FREE_SPACE (tb->L[0]) !=
- MAX_CHILD_SIZE (tb->L[0]) - dc_size(B_N_CHILD (tb->FL[0], get_left_neighbor_position (tb, 0)))) {
- print_cur_tb ("12221");
- reiserfs_panic (tb->tb_sb, "PAP-12355: check_after_balance_leaf: shift to left was incorrect");
+ int retval = 0;
+
+ if (cur_tb) {
+ reiserfs_panic(tb->tb_sb, "vs-12335: check_before_balancing: "
+ "suspect that schedule occurred based on cur_tb not being null at this point in code. "
+ "do_balance cannot properly handle schedule occurring while it runs.");
}
- }
- if (tb->rnum[0]) {
- if (B_FREE_SPACE (tb->R[0]) !=
- MAX_CHILD_SIZE (tb->R[0]) - dc_size(B_N_CHILD (tb->FR[0], get_right_neighbor_position (tb, 0)))) {
- print_cur_tb ("12222");
- reiserfs_panic (tb->tb_sb, "PAP-12360: check_after_balance_leaf: shift to right was incorrect");
+
+ /* double check that buffers that we will modify are unlocked. (fix_nodes should already have
+ prepped all of these for us). */
+ if (tb->lnum[0]) {
+ retval |= locked_or_not_in_tree(tb->L[0], "L[0]");
+ retval |= locked_or_not_in_tree(tb->FL[0], "FL[0]");
+ retval |= locked_or_not_in_tree(tb->CFL[0], "CFL[0]");
+ check_leaf(tb->L[0]);
}
- }
- if (PATH_H_PBUFFER(tb->tb_path,1) &&
- (B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0)) !=
- (MAX_CHILD_SIZE (PATH_H_PBUFFER(tb->tb_path,0)) -
- dc_size(B_N_CHILD (PATH_H_PBUFFER(tb->tb_path,1),
- PATH_H_POSITION (tb->tb_path, 1)))) )) {
- int left = B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0));
- int right = (MAX_CHILD_SIZE (PATH_H_PBUFFER(tb->tb_path,0)) -
- dc_size(B_N_CHILD (PATH_H_PBUFFER(tb->tb_path,1),
- PATH_H_POSITION (tb->tb_path, 1))));
- print_cur_tb ("12223");
- reiserfs_warning (tb->tb_sb,
- "B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0)) = %d; "
- "MAX_CHILD_SIZE (%d) - dc_size( %y, %d ) [%d] = %d",
- left,
- MAX_CHILD_SIZE (PATH_H_PBUFFER(tb->tb_path,0)),
- PATH_H_PBUFFER(tb->tb_path,1),
- PATH_H_POSITION (tb->tb_path, 1),
- dc_size(B_N_CHILD (PATH_H_PBUFFER(tb->tb_path,1), PATH_H_POSITION (tb->tb_path, 1 )) ),
- right );
- reiserfs_panic (tb->tb_sb, "PAP-12365: check_after_balance_leaf: S is incorrect");
- }
-}
+ if (tb->rnum[0]) {
+ retval |= locked_or_not_in_tree(tb->R[0], "R[0]");
+ retval |= locked_or_not_in_tree(tb->FR[0], "FR[0]");
+ retval |= locked_or_not_in_tree(tb->CFR[0], "CFR[0]");
+ check_leaf(tb->R[0]);
+ }
+ retval |= locked_or_not_in_tree(PATH_PLAST_BUFFER(tb->tb_path), "S[0]");
+ check_leaf(PATH_PLAST_BUFFER(tb->tb_path));
+ return retval;
+}
-static void check_leaf_level (struct tree_balance * tb)
+static void check_after_balance_leaf(struct tree_balance *tb)
{
- check_leaf (tb->L[0]);
- check_leaf (tb->R[0]);
- check_leaf (PATH_PLAST_BUFFER (tb->tb_path));
+ if (tb->lnum[0]) {
+ if (B_FREE_SPACE(tb->L[0]) !=
+ MAX_CHILD_SIZE(tb->L[0]) -
+ dc_size(B_N_CHILD
+ (tb->FL[0], get_left_neighbor_position(tb, 0)))) {
+ print_cur_tb("12221");
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12355: check_after_balance_leaf: shift to left was incorrect");
+ }
+ }
+ if (tb->rnum[0]) {
+ if (B_FREE_SPACE(tb->R[0]) !=
+ MAX_CHILD_SIZE(tb->R[0]) -
+ dc_size(B_N_CHILD
+ (tb->FR[0], get_right_neighbor_position(tb, 0)))) {
+ print_cur_tb("12222");
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12360: check_after_balance_leaf: shift to right was incorrect");
+ }
+ }
+ if (PATH_H_PBUFFER(tb->tb_path, 1) &&
+ (B_FREE_SPACE(PATH_H_PBUFFER(tb->tb_path, 0)) !=
+ (MAX_CHILD_SIZE(PATH_H_PBUFFER(tb->tb_path, 0)) -
+ dc_size(B_N_CHILD(PATH_H_PBUFFER(tb->tb_path, 1),
+ PATH_H_POSITION(tb->tb_path, 1)))))) {
+ int left = B_FREE_SPACE(PATH_H_PBUFFER(tb->tb_path, 0));
+ int right = (MAX_CHILD_SIZE(PATH_H_PBUFFER(tb->tb_path, 0)) -
+ dc_size(B_N_CHILD(PATH_H_PBUFFER(tb->tb_path, 1),
+ PATH_H_POSITION(tb->tb_path,
+ 1))));
+ print_cur_tb("12223");
+ reiserfs_warning(tb->tb_sb,
+ "B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0)) = %d; "
+ "MAX_CHILD_SIZE (%d) - dc_size( %y, %d ) [%d] = %d",
+ left,
+ MAX_CHILD_SIZE(PATH_H_PBUFFER(tb->tb_path, 0)),
+ PATH_H_PBUFFER(tb->tb_path, 1),
+ PATH_H_POSITION(tb->tb_path, 1),
+ dc_size(B_N_CHILD
+ (PATH_H_PBUFFER(tb->tb_path, 1),
+ PATH_H_POSITION(tb->tb_path, 1))),
+ right);
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12365: check_after_balance_leaf: S is incorrect");
+ }
}
-static void check_internal_levels (struct tree_balance * tb)
+static void check_leaf_level(struct tree_balance *tb)
{
- int h;
+ check_leaf(tb->L[0]);
+ check_leaf(tb->R[0]);
+ check_leaf(PATH_PLAST_BUFFER(tb->tb_path));
+}
- /* check all internal nodes */
- for (h = 1; tb->insert_size[h]; h ++) {
- check_internal_node (tb->tb_sb, PATH_H_PBUFFER (tb->tb_path, h), "BAD BUFFER ON PATH");
- if (tb->lnum[h])
- check_internal_node (tb->tb_sb, tb->L[h], "BAD L");
- if (tb->rnum[h])
- check_internal_node (tb->tb_sb, tb->R[h], "BAD R");
- }
+static void check_internal_levels(struct tree_balance *tb)
+{
+ int h;
+
+ /* check all internal nodes */
+ for (h = 1; tb->insert_size[h]; h++) {
+ check_internal_node(tb->tb_sb, PATH_H_PBUFFER(tb->tb_path, h),
+ "BAD BUFFER ON PATH");
+ if (tb->lnum[h])
+ check_internal_node(tb->tb_sb, tb->L[h], "BAD L");
+ if (tb->rnum[h])
+ check_internal_node(tb->tb_sb, tb->R[h], "BAD R");
+ }
}
#endif
-
-
-
-
-
/* Now we have all of the buffers that must be used in balancing of
the tree. We rely on the assumption that schedule() will not occur
while do_balance works. ( Only interrupt handlers are acceptable.)
@@ -1484,114 +2029,109 @@ static void check_internal_levels (struct tree_balance * tb)
*/
-static inline void do_balance_starts (struct tree_balance *tb)
+static inline void do_balance_starts(struct tree_balance *tb)
{
- /* use print_cur_tb() to see initial state of struct
- tree_balance */
+ /* use print_cur_tb() to see initial state of struct
+ tree_balance */
- /* store_print_tb (tb); */
+ /* store_print_tb (tb); */
- /* do not delete, just comment it out */
+ /* do not delete, just comment it out */
/* print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb,
"check");*/
- RFALSE( check_before_balancing (tb), "PAP-12340: locked buffers in TB");
+ RFALSE(check_before_balancing(tb), "PAP-12340: locked buffers in TB");
#ifdef CONFIG_REISERFS_CHECK
- cur_tb = tb;
+ cur_tb = tb;
#endif
}
-
-static inline void do_balance_completed (struct tree_balance * tb)
+static inline void do_balance_completed(struct tree_balance *tb)
{
-
+
#ifdef CONFIG_REISERFS_CHECK
- check_leaf_level (tb);
- check_internal_levels (tb);
- cur_tb = NULL;
+ check_leaf_level(tb);
+ check_internal_levels(tb);
+ cur_tb = NULL;
#endif
- /* reiserfs_free_block is no longer schedule safe. So, we need to
- ** put the buffers we want freed on the thrown list during do_balance,
- ** and then free them now
- */
-
- REISERFS_SB(tb->tb_sb)->s_do_balance ++;
+ /* reiserfs_free_block is no longer schedule safe. So, we need to
+ ** put the buffers we want freed on the thrown list during do_balance,
+ ** and then free them now
+ */
+ REISERFS_SB(tb->tb_sb)->s_do_balance++;
- /* release all nodes hold to perform the balancing */
- unfix_nodes(tb);
+ /* release all nodes hold to perform the balancing */
+ unfix_nodes(tb);
- free_thrown(tb) ;
+ free_thrown(tb);
}
+void do_balance(struct tree_balance *tb, /* tree_balance structure */
+ struct item_head *ih, /* item header of inserted item */
+ const char *body, /* body of inserted item or bytes to paste */
+ int flag)
+{ /* i - insert, d - delete
+ c - cut, p - paste
+
+ Cut means delete part of an item
+ (includes removing an entry from a
+ directory).
+
+ Delete means delete whole item.
+
+ Insert means add a new item into the
+ tree.
+
+ Paste means to append to the end of an
+ existing file or to insert a directory
+ entry. */
+ int child_pos, /* position of a child node in its parent */
+ h; /* level of the tree being processed */
+ struct item_head insert_key[2]; /* in our processing of one level
+ we sometimes determine what
+ must be inserted into the next
+ higher level. This insertion
+ consists of a key or two keys
+ and their corresponding
+ pointers */
+ struct buffer_head *insert_ptr[2]; /* inserted node-ptrs for the next
+ level */
+
+ tb->tb_mode = flag;
+ tb->need_balance_dirty = 0;
+
+ if (FILESYSTEM_CHANGED_TB(tb)) {
+ reiserfs_panic(tb->tb_sb,
+ "clm-6000: do_balance, fs generation has changed\n");
+ }
+ /* if we have no real work to do */
+ if (!tb->insert_size[0]) {
+ reiserfs_warning(tb->tb_sb,
+ "PAP-12350: do_balance: insert_size == 0, mode == %c",
+ flag);
+ unfix_nodes(tb);
+ return;
+ }
+ atomic_inc(&(fs_generation(tb->tb_sb)));
+ do_balance_starts(tb);
-
-
-void do_balance (struct tree_balance * tb, /* tree_balance structure */
- struct item_head * ih, /* item header of inserted item */
- const char * body, /* body of inserted item or bytes to paste */
- int flag) /* i - insert, d - delete
- c - cut, p - paste
-
- Cut means delete part of an item
- (includes removing an entry from a
- directory).
-
- Delete means delete whole item.
-
- Insert means add a new item into the
- tree.
-
- Paste means to append to the end of an
- existing file or to insert a directory
- entry. */
-{
- int child_pos, /* position of a child node in its parent */
- h; /* level of the tree being processed */
- struct item_head insert_key[2]; /* in our processing of one level
- we sometimes determine what
- must be inserted into the next
- higher level. This insertion
- consists of a key or two keys
- and their corresponding
- pointers */
- struct buffer_head *insert_ptr[2]; /* inserted node-ptrs for the next
- level */
-
- tb->tb_mode = flag;
- tb->need_balance_dirty = 0;
-
- if (FILESYSTEM_CHANGED_TB(tb)) {
- reiserfs_panic(tb->tb_sb, "clm-6000: do_balance, fs generation has changed\n") ;
- }
- /* if we have no real work to do */
- if ( ! tb->insert_size[0] ) {
- reiserfs_warning (tb->tb_sb,
- "PAP-12350: do_balance: insert_size == 0, mode == %c",
- flag);
- unfix_nodes(tb);
- return;
- }
-
- atomic_inc (&(fs_generation (tb->tb_sb)));
- do_balance_starts (tb);
-
/* balance leaf returns 0 except if combining L R and S into
one node. see balance_internal() for explanation of this
- line of code.*/
- child_pos = PATH_H_B_ITEM_ORDER (tb->tb_path, 0) +
- balance_leaf (tb, ih, body, flag, insert_key, insert_ptr);
+ line of code. */
+ child_pos = PATH_H_B_ITEM_ORDER(tb->tb_path, 0) +
+ balance_leaf(tb, ih, body, flag, insert_key, insert_ptr);
#ifdef CONFIG_REISERFS_CHECK
- check_after_balance_leaf (tb);
+ check_after_balance_leaf(tb);
#endif
- /* Balance internal level of the tree. */
- for ( h = 1; h < MAX_HEIGHT && tb->insert_size[h]; h++ )
- child_pos = balance_internal (tb, h, child_pos, insert_key, insert_ptr);
-
+ /* Balance internal level of the tree. */
+ for (h = 1; h < MAX_HEIGHT && tb->insert_size[h]; h++)
+ child_pos =
+ balance_internal(tb, h, child_pos, insert_key, insert_ptr);
- do_balance_completed (tb);
+ do_balance_completed(tb);
}
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 12e91209544..c9f178fb494 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -2,7 +2,6 @@
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*/
-
#include <linux/time.h>
#include <linux/reiserfs_fs.h>
#include <linux/reiserfs_acl.h>
@@ -31,82 +30,84 @@
** We use reiserfs_truncate_file to pack the tail, since it already has
** all the conditions coded.
*/
-static int reiserfs_file_release (struct inode * inode, struct file * filp)
+static int reiserfs_file_release(struct inode *inode, struct file *filp)
{
- struct reiserfs_transaction_handle th ;
- int err;
- int jbegin_failure = 0;
+ struct reiserfs_transaction_handle th;
+ int err;
+ int jbegin_failure = 0;
- if (!S_ISREG (inode->i_mode))
- BUG ();
+ if (!S_ISREG(inode->i_mode))
+ BUG();
- /* fast out for when nothing needs to be done */
- if ((atomic_read(&inode->i_count) > 1 ||
- !(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) ||
- !tail_has_to_be_packed(inode)) &&
- REISERFS_I(inode)->i_prealloc_count <= 0) {
- return 0;
- }
-
- reiserfs_write_lock(inode->i_sb);
- down (&inode->i_sem);
- /* freeing preallocation only involves relogging blocks that
- * are already in the current transaction. preallocation gets
- * freed at the end of each transaction, so it is impossible for
- * us to log any additional blocks (including quota blocks)
- */
- err = journal_begin(&th, inode->i_sb, 1);
- if (err) {
- /* uh oh, we can't allow the inode to go away while there
- * is still preallocation blocks pending. Try to join the
- * aborted transaction
- */
- jbegin_failure = err;
- err = journal_join_abort(&th, inode->i_sb, 1);
+ /* fast out for when nothing needs to be done */
+ if ((atomic_read(&inode->i_count) > 1 ||
+ !(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) ||
+ !tail_has_to_be_packed(inode)) &&
+ REISERFS_I(inode)->i_prealloc_count <= 0) {
+ return 0;
+ }
+ reiserfs_write_lock(inode->i_sb);
+ down(&inode->i_sem);
+ /* freeing preallocation only involves relogging blocks that
+ * are already in the current transaction. preallocation gets
+ * freed at the end of each transaction, so it is impossible for
+ * us to log any additional blocks (including quota blocks)
+ */
+ err = journal_begin(&th, inode->i_sb, 1);
if (err) {
- /* hmpf, our choices here aren't good. We can pin the inode
- * which will disallow unmount from every happening, we can
- * do nothing, which will corrupt random memory on unmount,
- * or we can forcibly remove the file from the preallocation
- * list, which will leak blocks on disk. Lets pin the inode
- * and let the admin know what is going on.
- */
- igrab(inode);
- reiserfs_warning(inode->i_sb, "pinning inode %lu because the "
- "preallocation can't be freed");
- goto out;
+ /* uh oh, we can't allow the inode to go away while there
+ * is still preallocation blocks pending. Try to join the
+ * aborted transaction
+ */
+ jbegin_failure = err;
+ err = journal_join_abort(&th, inode->i_sb, 1);
+
+ if (err) {
+ /* hmpf, our choices here aren't good. We can pin the inode
+ * which will disallow unmount from every happening, we can
+ * do nothing, which will corrupt random memory on unmount,
+ * or we can forcibly remove the file from the preallocation
+ * list, which will leak blocks on disk. Lets pin the inode
+ * and let the admin know what is going on.
+ */
+ igrab(inode);
+ reiserfs_warning(inode->i_sb,
+ "pinning inode %lu because the "
+ "preallocation can't be freed");
+ goto out;
+ }
}
- }
- reiserfs_update_inode_transaction(inode) ;
+ reiserfs_update_inode_transaction(inode);
#ifdef REISERFS_PREALLOCATE
- reiserfs_discard_prealloc (&th, inode);
+ reiserfs_discard_prealloc(&th, inode);
#endif
- err = journal_end(&th, inode->i_sb, 1);
-
- /* copy back the error code from journal_begin */
- if (!err)
- err = jbegin_failure;
-
- if (!err && atomic_read(&inode->i_count) <= 1 &&
- (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) &&
- tail_has_to_be_packed (inode)) {
- /* if regular file is released by last holder and it has been
- appended (we append by unformatted node only) or its direct
- item(s) had to be converted, then it may have to be
- indirect2direct converted */
- err = reiserfs_truncate_file(inode, 0) ;
- }
-out:
- up (&inode->i_sem);
- reiserfs_write_unlock(inode->i_sb);
- return err;
+ err = journal_end(&th, inode->i_sb, 1);
+
+ /* copy back the error code from journal_begin */
+ if (!err)
+ err = jbegin_failure;
+
+ if (!err && atomic_read(&inode->i_count) <= 1 &&
+ (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) &&
+ tail_has_to_be_packed(inode)) {
+ /* if regular file is released by last holder and it has been
+ appended (we append by unformatted node only) or its direct
+ item(s) had to be converted, then it may have to be
+ indirect2direct converted */
+ err = reiserfs_truncate_file(inode, 0);
+ }
+ out:
+ up(&inode->i_sem);
+ reiserfs_write_unlock(inode->i_sb);
+ return err;
}
-static void reiserfs_vfs_truncate_file(struct inode *inode) {
- reiserfs_truncate_file(inode, 1) ;
+static void reiserfs_vfs_truncate_file(struct inode *inode)
+{
+ reiserfs_truncate_file(inode, 1);
}
/* Sync a reiserfs file. */
@@ -116,26 +117,24 @@ static void reiserfs_vfs_truncate_file(struct inode *inode) {
* be removed...
*/
-static int reiserfs_sync_file(
- struct file * p_s_filp,
- struct dentry * p_s_dentry,
- int datasync
- ) {
- struct inode * p_s_inode = p_s_dentry->d_inode;
- int n_err;
- int barrier_done;
-
- if (!S_ISREG(p_s_inode->i_mode))
- BUG ();
- n_err = sync_mapping_buffers(p_s_inode->i_mapping) ;
- reiserfs_write_lock(p_s_inode->i_sb);
- barrier_done = reiserfs_commit_for_inode(p_s_inode);
- reiserfs_write_unlock(p_s_inode->i_sb);
- if (barrier_done != 1)
- blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL);
- if (barrier_done < 0)
- return barrier_done;
- return ( n_err < 0 ) ? -EIO : 0;
+static int reiserfs_sync_file(struct file *p_s_filp,
+ struct dentry *p_s_dentry, int datasync)
+{
+ struct inode *p_s_inode = p_s_dentry->d_inode;
+ int n_err;
+ int barrier_done;
+
+ if (!S_ISREG(p_s_inode->i_mode))
+ BUG();
+ n_err = sync_mapping_buffers(p_s_inode->i_mapping);
+ reiserfs_write_lock(p_s_inode->i_sb);
+ barrier_done = reiserfs_commit_for_inode(p_s_inode);
+ reiserfs_write_unlock(p_s_inode->i_sb);
+ if (barrier_done != 1)
+ blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL);
+ if (barrier_done < 0)
+ return barrier_done;
+ return (n_err < 0) ? -EIO : 0;
}
/* I really do not want to play with memory shortage right now, so
@@ -147,700 +146,797 @@ static int reiserfs_sync_file(
/* Allocates blocks for a file to fulfil write request.
Maps all unmapped but prepared pages from the list.
Updates metadata with newly allocated blocknumbers as needed */
-static int reiserfs_allocate_blocks_for_region(
- struct reiserfs_transaction_handle *th,
- struct inode *inode, /* Inode we work with */
- loff_t pos, /* Writing position */
- int num_pages, /* number of pages write going
- to touch */
- int write_bytes, /* amount of bytes to write */
- struct page **prepared_pages, /* array of
- prepared pages
- */
- int blocks_to_allocate /* Amount of blocks we
- need to allocate to
- fit the data into file
- */
- )
+static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handle *th, struct inode *inode, /* Inode we work with */
+ loff_t pos, /* Writing position */
+ int num_pages, /* number of pages write going
+ to touch */
+ int write_bytes, /* amount of bytes to write */
+ struct page **prepared_pages, /* array of
+ prepared pages
+ */
+ int blocks_to_allocate /* Amount of blocks we
+ need to allocate to
+ fit the data into file
+ */
+ )
{
- struct cpu_key key; // cpu key of item that we are going to deal with
- struct item_head *ih; // pointer to item head that we are going to deal with
- struct buffer_head *bh; // Buffer head that contains items that we are going to deal with
- __le32 * item; // pointer to item we are going to deal with
- INITIALIZE_PATH(path); // path to item, that we are going to deal with.
- b_blocknr_t *allocated_blocks; // Pointer to a place where allocated blocknumbers would be stored.
- reiserfs_blocknr_hint_t hint; // hint structure for block allocator.
- size_t res; // return value of various functions that we call.
- int curr_block; // current block used to keep track of unmapped blocks.
- int i; // loop counter
- int itempos; // position in item
- unsigned int from = (pos & (PAGE_CACHE_SIZE - 1)); // writing position in
- // first page
- unsigned int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1; /* last modified byte offset in last page */
- __u64 hole_size ; // amount of blocks for a file hole, if it needed to be created.
- int modifying_this_item = 0; // Flag for items traversal code to keep track
- // of the fact that we already prepared
- // current block for journal
- int will_prealloc = 0;
- RFALSE(!blocks_to_allocate, "green-9004: tried to allocate zero blocks?");
-
- /* only preallocate if this is a small write */
- if (REISERFS_I(inode)->i_prealloc_count ||
- (!(write_bytes & (inode->i_sb->s_blocksize -1)) &&
- blocks_to_allocate <
- REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize))
- will_prealloc = REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize;
-
- allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
- sizeof(b_blocknr_t), GFP_NOFS);
-
- /* First we compose a key to point at the writing position, we want to do
- that outside of any locking region. */
- make_cpu_key (&key, inode, pos+1, TYPE_ANY, 3/*key length*/);
-
- /* If we came here, it means we absolutely need to open a transaction,
- since we need to allocate some blocks */
- reiserfs_write_lock(inode->i_sb); // Journaling stuff and we need that.
- res = journal_begin(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb)); // Wish I know if this number enough
- if (res)
- goto error_exit;
- reiserfs_update_inode_transaction(inode) ;
-
- /* Look for the in-tree position of our write, need path for block allocator */
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR ) {
- res = -EIO;
- goto error_exit;
- }
-
- /* Allocate blocks */
- /* First fill in "hint" structure for block allocator */
- hint.th = th; // transaction handle.
- hint.path = &path; // Path, so that block allocator can determine packing locality or whatever it needs to determine.
- hint.inode = inode; // Inode is needed by block allocator too.
- hint.search_start = 0; // We have no hint on where to search free blocks for block allocator.
- hint.key = key.on_disk_key; // on disk key of file.
- hint.block = inode->i_blocks>>(inode->i_sb->s_blocksize_bits-9); // Number of disk blocks this file occupies already.
- hint.formatted_node = 0; // We are allocating blocks for unformatted node.
- hint.preallocate = will_prealloc;
-
- /* Call block allocator to allocate blocks */
- res = reiserfs_allocate_blocknrs(&hint, allocated_blocks, blocks_to_allocate, blocks_to_allocate);
- if ( res != CARRY_ON ) {
- if ( res == NO_DISK_SPACE ) {
- /* We flush the transaction in case of no space. This way some
- blocks might become free */
- SB_JOURNAL(inode->i_sb)->j_must_wait = 1;
- res = restart_transaction(th, inode, &path);
- if (res)
- goto error_exit;
-
- /* We might have scheduled, so search again */
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR ) {
- res = -EIO;
+ struct cpu_key key; // cpu key of item that we are going to deal with
+ struct item_head *ih; // pointer to item head that we are going to deal with
+ struct buffer_head *bh; // Buffer head that contains items that we are going to deal with
+ __le32 *item; // pointer to item we are going to deal with
+ INITIALIZE_PATH(path); // path to item, that we are going to deal with.
+ b_blocknr_t *allocated_blocks; // Pointer to a place where allocated blocknumbers would be stored.
+ reiserfs_blocknr_hint_t hint; // hint structure for block allocator.
+ size_t res; // return value of various functions that we call.
+ int curr_block; // current block used to keep track of unmapped blocks.
+ int i; // loop counter
+ int itempos; // position in item
+ unsigned int from = (pos & (PAGE_CACHE_SIZE - 1)); // writing position in
+ // first page
+ unsigned int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1; /* last modified byte offset in last page */
+ __u64 hole_size; // amount of blocks for a file hole, if it needed to be created.
+ int modifying_this_item = 0; // Flag for items traversal code to keep track
+ // of the fact that we already prepared
+ // current block for journal
+ int will_prealloc = 0;
+ RFALSE(!blocks_to_allocate,
+ "green-9004: tried to allocate zero blocks?");
+
+ /* only preallocate if this is a small write */
+ if (REISERFS_I(inode)->i_prealloc_count ||
+ (!(write_bytes & (inode->i_sb->s_blocksize - 1)) &&
+ blocks_to_allocate <
+ REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize))
+ will_prealloc =
+ REISERFS_SB(inode->i_sb)->s_alloc_options.preallocsize;
+
+ allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
+ sizeof(b_blocknr_t), GFP_NOFS);
+
+ /* First we compose a key to point at the writing position, we want to do
+ that outside of any locking region. */
+ make_cpu_key(&key, inode, pos + 1, TYPE_ANY, 3 /*key length */ );
+
+ /* If we came here, it means we absolutely need to open a transaction,
+ since we need to allocate some blocks */
+ reiserfs_write_lock(inode->i_sb); // Journaling stuff and we need that.
+ res = journal_begin(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb)); // Wish I know if this number enough
+ if (res)
goto error_exit;
- }
+ reiserfs_update_inode_transaction(inode);
- /* update changed info for hint structure. */
- res = reiserfs_allocate_blocknrs(&hint, allocated_blocks, blocks_to_allocate, blocks_to_allocate);
- if ( res != CARRY_ON ) {
- res = -ENOSPC;
- pathrelse(&path);
+ /* Look for the in-tree position of our write, need path for block allocator */
+ res = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
goto error_exit;
- }
- } else {
- res = -ENOSPC;
- pathrelse(&path);
- goto error_exit;
}
- }
-#ifdef __BIG_ENDIAN
- // Too bad, I have not found any way to convert a given region from
- // cpu format to little endian format
- {
- int i;
- for ( i = 0; i < blocks_to_allocate ; i++)
- allocated_blocks[i]=cpu_to_le32(allocated_blocks[i]);
- }
-#endif
-
- /* Blocks allocating well might have scheduled and tree might have changed,
- let's search the tree again */
- /* find where in the tree our write should go */
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR ) {
- res = -EIO;
- goto error_exit_free_blocks;
- }
-
- bh = get_last_bh( &path ); // Get a bufferhead for last element in path.
- ih = get_ih( &path ); // Get a pointer to last item head in path.
- item = get_item( &path ); // Get a pointer to last item in path
-
- /* Let's see what we have found */
- if ( res != POSITION_FOUND ) { /* position not found, this means that we
- might need to append file with holes
- first */
- // Since we are writing past the file's end, we need to find out if
- // there is a hole that needs to be inserted before our writing
- // position, and how many blocks it is going to cover (we need to
- // populate pointers to file blocks representing the hole with zeros)
+ /* Allocate blocks */
+ /* First fill in "hint" structure for block allocator */
+ hint.th = th; // transaction handle.
+ hint.path = &path; // Path, so that block allocator can determine packing locality or whatever it needs to determine.
+ hint.inode = inode; // Inode is needed by block allocator too.
+ hint.search_start = 0; // We have no hint on where to search free blocks for block allocator.
+ hint.key = key.on_disk_key; // on disk key of file.
+ hint.block = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9); // Number of disk blocks this file occupies already.
+ hint.formatted_node = 0; // We are allocating blocks for unformatted node.
+ hint.preallocate = will_prealloc;
+
+ /* Call block allocator to allocate blocks */
+ res =
+ reiserfs_allocate_blocknrs(&hint, allocated_blocks,
+ blocks_to_allocate, blocks_to_allocate);
+ if (res != CARRY_ON) {
+ if (res == NO_DISK_SPACE) {
+ /* We flush the transaction in case of no space. This way some
+ blocks might become free */
+ SB_JOURNAL(inode->i_sb)->j_must_wait = 1;
+ res = restart_transaction(th, inode, &path);
+ if (res)
+ goto error_exit;
+
+ /* We might have scheduled, so search again */
+ res =
+ search_for_position_by_key(inode->i_sb, &key,
+ &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
+ goto error_exit;
+ }
+ /* update changed info for hint structure. */
+ res =
+ reiserfs_allocate_blocknrs(&hint, allocated_blocks,
+ blocks_to_allocate,
+ blocks_to_allocate);
+ if (res != CARRY_ON) {
+ res = -ENOSPC;
+ pathrelse(&path);
+ goto error_exit;
+ }
+ } else {
+ res = -ENOSPC;
+ pathrelse(&path);
+ goto error_exit;
+ }
+ }
+#ifdef __BIG_ENDIAN
+ // Too bad, I have not found any way to convert a given region from
+ // cpu format to little endian format
{
- int item_offset = 1;
- /*
- * if ih is stat data, its offset is 0 and we don't want to
- * add 1 to pos in the hole_size calculation
- */
- if (is_statdata_le_ih(ih))
- item_offset = 0;
- hole_size = (pos + item_offset -
- (le_key_k_offset( get_inode_item_key_version(inode),
- &(ih->ih_key)) +
- op_bytes_number(ih, inode->i_sb->s_blocksize))) >>
- inode->i_sb->s_blocksize_bits;
+ int i;
+ for (i = 0; i < blocks_to_allocate; i++)
+ allocated_blocks[i] = cpu_to_le32(allocated_blocks[i]);
}
+#endif
- if ( hole_size > 0 ) {
- int to_paste = min_t(__u64, hole_size, MAX_ITEM_LEN(inode->i_sb->s_blocksize)/UNFM_P_SIZE ); // How much data to insert first time.
- /* area filled with zeroes, to supply as list of zero blocknumbers
- We allocate it outside of loop just in case loop would spin for
- several iterations. */
- char *zeros = kmalloc(to_paste*UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway.
- if ( !zeros ) {
- res = -ENOMEM;
+ /* Blocks allocating well might have scheduled and tree might have changed,
+ let's search the tree again */
+ /* find where in the tree our write should go */
+ res = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
goto error_exit_free_blocks;
- }
- memset ( zeros, 0, to_paste*UNFM_P_SIZE);
- do {
- to_paste = min_t(__u64, hole_size, MAX_ITEM_LEN(inode->i_sb->s_blocksize)/UNFM_P_SIZE );
- if ( is_indirect_le_ih(ih) ) {
- /* Ok, there is existing indirect item already. Need to append it */
- /* Calculate position past inserted item */
- make_cpu_key( &key, inode, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize), TYPE_INDIRECT, 3);
- res = reiserfs_paste_into_item( th, &path, &key, inode, (char *)zeros, UNFM_P_SIZE*to_paste);
- if ( res ) {
- kfree(zeros);
- goto error_exit_free_blocks;
- }
- } else if ( is_statdata_le_ih(ih) ) {
- /* No existing item, create it */
- /* item head for new item */
- struct item_head ins_ih;
-
- /* create a key for our new item */
- make_cpu_key( &key, inode, 1, TYPE_INDIRECT, 3);
-
- /* Create new item head for our new item */
- make_le_item_head (&ins_ih, &key, key.version, 1,
- TYPE_INDIRECT, to_paste*UNFM_P_SIZE,
- 0 /* free space */);
-
- /* Find where such item should live in the tree */
- res = search_item (inode->i_sb, &key, &path);
- if ( res != ITEM_NOT_FOUND ) {
- /* item should not exist, otherwise we have error */
- if ( res != -ENOSPC ) {
- reiserfs_warning (inode->i_sb,
- "green-9008: search_by_key (%K) returned %d",
- &key, res);
+ }
+
+ bh = get_last_bh(&path); // Get a bufferhead for last element in path.
+ ih = get_ih(&path); // Get a pointer to last item head in path.
+ item = get_item(&path); // Get a pointer to last item in path
+
+ /* Let's see what we have found */
+ if (res != POSITION_FOUND) { /* position not found, this means that we
+ might need to append file with holes
+ first */
+ // Since we are writing past the file's end, we need to find out if
+ // there is a hole that needs to be inserted before our writing
+ // position, and how many blocks it is going to cover (we need to
+ // populate pointers to file blocks representing the hole with zeros)
+
+ {
+ int item_offset = 1;
+ /*
+ * if ih is stat data, its offset is 0 and we don't want to
+ * add 1 to pos in the hole_size calculation
+ */
+ if (is_statdata_le_ih(ih))
+ item_offset = 0;
+ hole_size = (pos + item_offset -
+ (le_key_k_offset
+ (get_inode_item_key_version(inode),
+ &(ih->ih_key)) + op_bytes_number(ih,
+ inode->
+ i_sb->
+ s_blocksize)))
+ >> inode->i_sb->s_blocksize_bits;
+ }
+
+ if (hole_size > 0) {
+ int to_paste = min_t(__u64, hole_size, MAX_ITEM_LEN(inode->i_sb->s_blocksize) / UNFM_P_SIZE); // How much data to insert first time.
+ /* area filled with zeroes, to supply as list of zero blocknumbers
+ We allocate it outside of loop just in case loop would spin for
+ several iterations. */
+ char *zeros = kmalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway.
+ if (!zeros) {
+ res = -ENOMEM;
+ goto error_exit_free_blocks;
}
- res = -EIO;
- kfree(zeros);
- goto error_exit_free_blocks;
- }
- res = reiserfs_insert_item( th, &path, &key, &ins_ih, inode, (char *)zeros);
- } else {
- reiserfs_panic(inode->i_sb, "green-9011: Unexpected key type %K\n", &key);
+ memset(zeros, 0, to_paste * UNFM_P_SIZE);
+ do {
+ to_paste =
+ min_t(__u64, hole_size,
+ MAX_ITEM_LEN(inode->i_sb->
+ s_blocksize) /
+ UNFM_P_SIZE);
+ if (is_indirect_le_ih(ih)) {
+ /* Ok, there is existing indirect item already. Need to append it */
+ /* Calculate position past inserted item */
+ make_cpu_key(&key, inode,
+ le_key_k_offset
+ (get_inode_item_key_version
+ (inode),
+ &(ih->ih_key)) +
+ op_bytes_number(ih,
+ inode->
+ i_sb->
+ s_blocksize),
+ TYPE_INDIRECT, 3);
+ res =
+ reiserfs_paste_into_item(th, &path,
+ &key,
+ inode,
+ (char *)
+ zeros,
+ UNFM_P_SIZE
+ *
+ to_paste);
+ if (res) {
+ kfree(zeros);
+ goto error_exit_free_blocks;
+ }
+ } else if (is_statdata_le_ih(ih)) {
+ /* No existing item, create it */
+ /* item head for new item */
+ struct item_head ins_ih;
+
+ /* create a key for our new item */
+ make_cpu_key(&key, inode, 1,
+ TYPE_INDIRECT, 3);
+
+ /* Create new item head for our new item */
+ make_le_item_head(&ins_ih, &key,
+ key.version, 1,
+ TYPE_INDIRECT,
+ to_paste *
+ UNFM_P_SIZE,
+ 0 /* free space */ );
+
+ /* Find where such item should live in the tree */
+ res =
+ search_item(inode->i_sb, &key,
+ &path);
+ if (res != ITEM_NOT_FOUND) {
+ /* item should not exist, otherwise we have error */
+ if (res != -ENOSPC) {
+ reiserfs_warning(inode->
+ i_sb,
+ "green-9008: search_by_key (%K) returned %d",
+ &key,
+ res);
+ }
+ res = -EIO;
+ kfree(zeros);
+ goto error_exit_free_blocks;
+ }
+ res =
+ reiserfs_insert_item(th, &path,
+ &key, &ins_ih,
+ inode,
+ (char *)zeros);
+ } else {
+ reiserfs_panic(inode->i_sb,
+ "green-9011: Unexpected key type %K\n",
+ &key);
+ }
+ if (res) {
+ kfree(zeros);
+ goto error_exit_free_blocks;
+ }
+ /* Now we want to check if transaction is too full, and if it is
+ we restart it. This will also free the path. */
+ if (journal_transaction_should_end
+ (th, th->t_blocks_allocated)) {
+ res =
+ restart_transaction(th, inode,
+ &path);
+ if (res) {
+ pathrelse(&path);
+ kfree(zeros);
+ goto error_exit;
+ }
+ }
+
+ /* Well, need to recalculate path and stuff */
+ set_cpu_key_k_offset(&key,
+ cpu_key_k_offset(&key) +
+ (to_paste << inode->
+ i_blkbits));
+ res =
+ search_for_position_by_key(inode->i_sb,
+ &key, &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
+ kfree(zeros);
+ goto error_exit_free_blocks;
+ }
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ hole_size -= to_paste;
+ } while (hole_size);
+ kfree(zeros);
}
- if ( res ) {
- kfree(zeros);
- goto error_exit_free_blocks;
+ }
+ // Go through existing indirect items first
+ // replace all zeroes with blocknumbers from list
+ // Note that if no corresponding item was found, by previous search,
+ // it means there are no existing in-tree representation for file area
+ // we are going to overwrite, so there is nothing to scan through for holes.
+ for (curr_block = 0, itempos = path.pos_in_item;
+ curr_block < blocks_to_allocate && res == POSITION_FOUND;) {
+ retry:
+
+ if (itempos >= ih_item_len(ih) / UNFM_P_SIZE) {
+ /* We run out of data in this indirect item, let's look for another
+ one. */
+ /* First if we are already modifying current item, log it */
+ if (modifying_this_item) {
+ journal_mark_dirty(th, inode->i_sb, bh);
+ modifying_this_item = 0;
+ }
+ /* Then set the key to look for a new indirect item (offset of old
+ item is added to old item length */
+ set_cpu_key_k_offset(&key,
+ le_key_k_offset
+ (get_inode_item_key_version(inode),
+ &(ih->ih_key)) +
+ op_bytes_number(ih,
+ inode->i_sb->
+ s_blocksize));
+ /* Search ofor position of new key in the tree. */
+ res =
+ search_for_position_by_key(inode->i_sb, &key,
+ &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
+ goto error_exit_free_blocks;
+ }
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ itempos = path.pos_in_item;
+ continue; // loop to check all kinds of conditions and so on.
}
- /* Now we want to check if transaction is too full, and if it is
- we restart it. This will also free the path. */
- if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
- res = restart_transaction(th, inode, &path);
- if (res) {
- pathrelse (&path);
- kfree(zeros);
- goto error_exit;
- }
- }
-
- /* Well, need to recalculate path and stuff */
- set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + (to_paste << inode->i_blkbits));
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR ) {
- res = -EIO;
- kfree(zeros);
- goto error_exit_free_blocks;
+ /* Ok, we have correct position in item now, so let's see if it is
+ representing file hole (blocknumber is zero) and fill it if needed */
+ if (!item[itempos]) {
+ /* Ok, a hole. Now we need to check if we already prepared this
+ block to be journaled */
+ while (!modifying_this_item) { // loop until succeed
+ /* Well, this item is not journaled yet, so we must prepare
+ it for journal first, before we can change it */
+ struct item_head tmp_ih; // We copy item head of found item,
+ // here to detect if fs changed under
+ // us while we were preparing for
+ // journal.
+ int fs_gen; // We store fs generation here to find if someone
+ // changes fs under our feet
+
+ copy_item_head(&tmp_ih, ih); // Remember itemhead
+ fs_gen = get_generation(inode->i_sb); // remember fs generation
+ reiserfs_prepare_for_journal(inode->i_sb, bh, 1); // Prepare a buffer within which indirect item is stored for changing.
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ // Sigh, fs was changed under us, we need to look for new
+ // location of item we are working with
+
+ /* unmark prepaerd area as journaled and search for it's
+ new position */
+ reiserfs_restore_prepared_buffer(inode->
+ i_sb,
+ bh);
+ res =
+ search_for_position_by_key(inode->
+ i_sb,
+ &key,
+ &path);
+ if (res == IO_ERROR) {
+ res = -EIO;
+ goto error_exit_free_blocks;
+ }
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ itempos = path.pos_in_item;
+ goto retry;
+ }
+ modifying_this_item = 1;
+ }
+ item[itempos] = allocated_blocks[curr_block]; // Assign new block
+ curr_block++;
}
- bh=get_last_bh(&path);
- ih=get_ih(&path);
- item = get_item(&path);
- hole_size -= to_paste;
- } while ( hole_size );
- kfree(zeros);
+ itempos++;
}
- }
-
- // Go through existing indirect items first
- // replace all zeroes with blocknumbers from list
- // Note that if no corresponding item was found, by previous search,
- // it means there are no existing in-tree representation for file area
- // we are going to overwrite, so there is nothing to scan through for holes.
- for ( curr_block = 0, itempos = path.pos_in_item ; curr_block < blocks_to_allocate && res == POSITION_FOUND ; ) {
-retry:
-
- if ( itempos >= ih_item_len(ih)/UNFM_P_SIZE ) {
- /* We run out of data in this indirect item, let's look for another
- one. */
- /* First if we are already modifying current item, log it */
- if ( modifying_this_item ) {
- journal_mark_dirty (th, inode->i_sb, bh);
- modifying_this_item = 0;
- }
- /* Then set the key to look for a new indirect item (offset of old
- item is added to old item length */
- set_cpu_key_k_offset( &key, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize));
- /* Search ofor position of new key in the tree. */
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR) {
- res = -EIO;
- goto error_exit_free_blocks;
- }
- bh=get_last_bh(&path);
- ih=get_ih(&path);
- item = get_item(&path);
- itempos = path.pos_in_item;
- continue; // loop to check all kinds of conditions and so on.
+
+ if (modifying_this_item) { // We need to log last-accessed block, if it
+ // was modified, but not logged yet.
+ journal_mark_dirty(th, inode->i_sb, bh);
}
- /* Ok, we have correct position in item now, so let's see if it is
- representing file hole (blocknumber is zero) and fill it if needed */
- if ( !item[itempos] ) {
- /* Ok, a hole. Now we need to check if we already prepared this
- block to be journaled */
- while ( !modifying_this_item ) { // loop until succeed
- /* Well, this item is not journaled yet, so we must prepare
- it for journal first, before we can change it */
- struct item_head tmp_ih; // We copy item head of found item,
- // here to detect if fs changed under
- // us while we were preparing for
- // journal.
- int fs_gen; // We store fs generation here to find if someone
- // changes fs under our feet
-
- copy_item_head (&tmp_ih, ih); // Remember itemhead
- fs_gen = get_generation (inode->i_sb); // remember fs generation
- reiserfs_prepare_for_journal(inode->i_sb, bh, 1); // Prepare a buffer within which indirect item is stored for changing.
- if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
- // Sigh, fs was changed under us, we need to look for new
- // location of item we are working with
-
- /* unmark prepaerd area as journaled and search for it's
- new position */
- reiserfs_restore_prepared_buffer(inode->i_sb, bh);
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR) {
- res = -EIO;
- goto error_exit_free_blocks;
- }
- bh=get_last_bh(&path);
- ih=get_ih(&path);
- item = get_item(&path);
- itempos = path.pos_in_item;
- goto retry;
+
+ if (curr_block < blocks_to_allocate) {
+ // Oh, well need to append to indirect item, or to create indirect item
+ // if there weren't any
+ if (is_indirect_le_ih(ih)) {
+ // Existing indirect item - append. First calculate key for append
+ // position. We do not need to recalculate path as it should
+ // already point to correct place.
+ make_cpu_key(&key, inode,
+ le_key_k_offset(get_inode_item_key_version
+ (inode),
+ &(ih->ih_key)) +
+ op_bytes_number(ih,
+ inode->i_sb->s_blocksize),
+ TYPE_INDIRECT, 3);
+ res =
+ reiserfs_paste_into_item(th, &path, &key, inode,
+ (char *)(allocated_blocks +
+ curr_block),
+ UNFM_P_SIZE *
+ (blocks_to_allocate -
+ curr_block));
+ if (res) {
+ goto error_exit_free_blocks;
+ }
+ } else if (is_statdata_le_ih(ih)) {
+ // Last found item was statdata. That means we need to create indirect item.
+ struct item_head ins_ih; /* itemhead for new item */
+
+ /* create a key for our new item */
+ make_cpu_key(&key, inode, 1, TYPE_INDIRECT, 3); // Position one,
+ // because that's
+ // where first
+ // indirect item
+ // begins
+ /* Create new item head for our new item */
+ make_le_item_head(&ins_ih, &key, key.version, 1,
+ TYPE_INDIRECT,
+ (blocks_to_allocate -
+ curr_block) * UNFM_P_SIZE,
+ 0 /* free space */ );
+ /* Find where such item should live in the tree */
+ res = search_item(inode->i_sb, &key, &path);
+ if (res != ITEM_NOT_FOUND) {
+ /* Well, if we have found such item already, or some error
+ occured, we need to warn user and return error */
+ if (res != -ENOSPC) {
+ reiserfs_warning(inode->i_sb,
+ "green-9009: search_by_key (%K) "
+ "returned %d", &key,
+ res);
+ }
+ res = -EIO;
+ goto error_exit_free_blocks;
+ }
+ /* Insert item into the tree with the data as its body */
+ res =
+ reiserfs_insert_item(th, &path, &key, &ins_ih,
+ inode,
+ (char *)(allocated_blocks +
+ curr_block));
+ } else {
+ reiserfs_panic(inode->i_sb,
+ "green-9010: unexpected item type for key %K\n",
+ &key);
}
- modifying_this_item = 1;
- }
- item[itempos] = allocated_blocks[curr_block]; // Assign new block
- curr_block++;
}
- itempos++;
- }
-
- if ( modifying_this_item ) { // We need to log last-accessed block, if it
- // was modified, but not logged yet.
- journal_mark_dirty (th, inode->i_sb, bh);
- }
-
- if ( curr_block < blocks_to_allocate ) {
- // Oh, well need to append to indirect item, or to create indirect item
- // if there weren't any
- if ( is_indirect_le_ih(ih) ) {
- // Existing indirect item - append. First calculate key for append
- // position. We do not need to recalculate path as it should
- // already point to correct place.
- make_cpu_key( &key, inode, le_key_k_offset( get_inode_item_key_version(inode), &(ih->ih_key)) + op_bytes_number(ih, inode->i_sb->s_blocksize), TYPE_INDIRECT, 3);
- res = reiserfs_paste_into_item( th, &path, &key, inode, (char *)(allocated_blocks+curr_block), UNFM_P_SIZE*(blocks_to_allocate-curr_block));
- if ( res ) {
- goto error_exit_free_blocks;
- }
- } else if (is_statdata_le_ih(ih) ) {
- // Last found item was statdata. That means we need to create indirect item.
- struct item_head ins_ih; /* itemhead for new item */
-
- /* create a key for our new item */
- make_cpu_key( &key, inode, 1, TYPE_INDIRECT, 3); // Position one,
- // because that's
- // where first
- // indirect item
- // begins
- /* Create new item head for our new item */
- make_le_item_head (&ins_ih, &key, key.version, 1, TYPE_INDIRECT,
- (blocks_to_allocate-curr_block)*UNFM_P_SIZE,
- 0 /* free space */);
- /* Find where such item should live in the tree */
- res = search_item (inode->i_sb, &key, &path);
- if ( res != ITEM_NOT_FOUND ) {
- /* Well, if we have found such item already, or some error
- occured, we need to warn user and return error */
- if ( res != -ENOSPC ) {
- reiserfs_warning (inode->i_sb,
- "green-9009: search_by_key (%K) "
- "returned %d", &key, res);
+ // the caller is responsible for closing the transaction
+ // unless we return an error, they are also responsible for logging
+ // the inode.
+ //
+ pathrelse(&path);
+ /*
+ * cleanup prellocation from previous writes
+ * if this is a partial block write
+ */
+ if (write_bytes & (inode->i_sb->s_blocksize - 1))
+ reiserfs_discard_prealloc(th, inode);
+ reiserfs_write_unlock(inode->i_sb);
+
+ // go through all the pages/buffers and map the buffers to newly allocated
+ // blocks (so that system knows where to write these pages later).
+ curr_block = 0;
+ for (i = 0; i < num_pages; i++) {
+ struct page *page = prepared_pages[i]; //current page
+ struct buffer_head *head = page_buffers(page); // first buffer for a page
+ int block_start, block_end; // in-page offsets for buffers.
+
+ if (!page_buffers(page))
+ reiserfs_panic(inode->i_sb,
+ "green-9005: No buffers for prepared page???");
+
+ /* For each buffer in page */
+ for (bh = head, block_start = 0; bh != head || !block_start;
+ block_start = block_end, bh = bh->b_this_page) {
+ if (!bh)
+ reiserfs_panic(inode->i_sb,
+ "green-9006: Allocated but absent buffer for a page?");
+ block_end = block_start + inode->i_sb->s_blocksize;
+ if (i == 0 && block_end <= from)
+ /* if this buffer is before requested data to map, skip it */
+ continue;
+ if (i == num_pages - 1 && block_start >= to)
+ /* If this buffer is after requested data to map, abort
+ processing of current page */
+ break;
+
+ if (!buffer_mapped(bh)) { // Ok, unmapped buffer, need to map it
+ map_bh(bh, inode->i_sb,
+ le32_to_cpu(allocated_blocks
+ [curr_block]));
+ curr_block++;
+ set_buffer_new(bh);
+ }
}
- res = -EIO;
- goto error_exit_free_blocks;
- }
- /* Insert item into the tree with the data as its body */
- res = reiserfs_insert_item( th, &path, &key, &ins_ih, inode, (char *)(allocated_blocks+curr_block));
- } else {
- reiserfs_panic(inode->i_sb, "green-9010: unexpected item type for key %K\n",&key);
- }
- }
-
- // the caller is responsible for closing the transaction
- // unless we return an error, they are also responsible for logging
- // the inode.
- //
- pathrelse(&path);
- /*
- * cleanup prellocation from previous writes
- * if this is a partial block write
- */
- if (write_bytes & (inode->i_sb->s_blocksize -1))
- reiserfs_discard_prealloc(th, inode);
- reiserfs_write_unlock(inode->i_sb);
-
- // go through all the pages/buffers and map the buffers to newly allocated
- // blocks (so that system knows where to write these pages later).
- curr_block = 0;
- for ( i = 0; i < num_pages ; i++ ) {
- struct page *page=prepared_pages[i]; //current page
- struct buffer_head *head = page_buffers(page);// first buffer for a page
- int block_start, block_end; // in-page offsets for buffers.
-
- if (!page_buffers(page))
- reiserfs_panic(inode->i_sb, "green-9005: No buffers for prepared page???");
-
- /* For each buffer in page */
- for(bh = head, block_start = 0; bh != head || !block_start;
- block_start=block_end, bh = bh->b_this_page) {
- if (!bh)
- reiserfs_panic(inode->i_sb, "green-9006: Allocated but absent buffer for a page?");
- block_end = block_start+inode->i_sb->s_blocksize;
- if (i == 0 && block_end <= from )
- /* if this buffer is before requested data to map, skip it */
- continue;
- if (i == num_pages - 1 && block_start >= to)
- /* If this buffer is after requested data to map, abort
- processing of current page */
- break;
-
- if ( !buffer_mapped(bh) ) { // Ok, unmapped buffer, need to map it
- map_bh( bh, inode->i_sb, le32_to_cpu(allocated_blocks[curr_block]));
- curr_block++;
- set_buffer_new(bh);
- }
}
- }
- RFALSE( curr_block > blocks_to_allocate, "green-9007: Used too many blocks? weird");
+ RFALSE(curr_block > blocks_to_allocate,
+ "green-9007: Used too many blocks? weird");
- kfree(allocated_blocks);
- return 0;
+ kfree(allocated_blocks);
+ return 0;
// Need to deal with transaction here.
-error_exit_free_blocks:
- pathrelse(&path);
- // free blocks
- for( i = 0; i < blocks_to_allocate; i++ )
- reiserfs_free_block(th, inode, le32_to_cpu(allocated_blocks[i]), 1);
-
-error_exit:
- if (th->t_trans_id) {
- int err;
- // update any changes we made to blk count
- reiserfs_update_sd(th, inode);
- err = journal_end(th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 3 + 1 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb));
- if (err)
- res = err;
- }
- reiserfs_write_unlock(inode->i_sb);
- kfree(allocated_blocks);
-
- return res;
+ error_exit_free_blocks:
+ pathrelse(&path);
+ // free blocks
+ for (i = 0; i < blocks_to_allocate; i++)
+ reiserfs_free_block(th, inode, le32_to_cpu(allocated_blocks[i]),
+ 1);
+
+ error_exit:
+ if (th->t_trans_id) {
+ int err;
+ // update any changes we made to blk count
+ reiserfs_update_sd(th, inode);
+ err =
+ journal_end(th, inode->i_sb,
+ JOURNAL_PER_BALANCE_CNT * 3 + 1 +
+ 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb));
+ if (err)
+ res = err;
+ }
+ reiserfs_write_unlock(inode->i_sb);
+ kfree(allocated_blocks);
+
+ return res;
}
/* Unlock pages prepared by reiserfs_prepare_file_region_for_write */
-static void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of locked pages */
- size_t num_pages /* amount of pages */) {
- int i; // loop counter
+static void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of locked pages */
+ size_t num_pages /* amount of pages */ )
+{
+ int i; // loop counter
- for (i=0; i < num_pages ; i++) {
- struct page *page = prepared_pages[i];
+ for (i = 0; i < num_pages; i++) {
+ struct page *page = prepared_pages[i];
- try_to_free_buffers(page);
- unlock_page(page);
- page_cache_release(page);
- }
+ try_to_free_buffers(page);
+ unlock_page(page);
+ page_cache_release(page);
+ }
}
/* This function will copy data from userspace to specified pages within
supplied byte range */
-static int reiserfs_copy_from_user_to_file_region(
- loff_t pos, /* In-file position */
- int num_pages, /* Number of pages affected */
- int write_bytes, /* Amount of bytes to write */
- struct page **prepared_pages, /* pointer to
- array to
- prepared pages
- */
- const char __user *buf /* Pointer to user-supplied
- data*/
- )
+static int reiserfs_copy_from_user_to_file_region(loff_t pos, /* In-file position */
+ int num_pages, /* Number of pages affected */
+ int write_bytes, /* Amount of bytes to write */
+ struct page **prepared_pages, /* pointer to
+ array to
+ prepared pages
+ */
+ const char __user * buf /* Pointer to user-supplied
+ data */
+ )
{
- long page_fault=0; // status of copy_from_user.
- int i; // loop counter.
- int offset; // offset in page
-
- for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) {
- size_t count = min_t(size_t,PAGE_CACHE_SIZE-offset,write_bytes); // How much of bytes to write to this page
- struct page *page=prepared_pages[i]; // Current page we process.
-
- fault_in_pages_readable( buf, count);
-
- /* Copy data from userspace to the current page */
- kmap(page);
- page_fault = __copy_from_user(page_address(page)+offset, buf, count); // Copy the data.
- /* Flush processor's dcache for this page */
- flush_dcache_page(page);
- kunmap(page);
- buf+=count;
- write_bytes-=count;
-
- if (page_fault)
- break; // Was there a fault? abort.
- }
-
- return page_fault?-EFAULT:0;
+ long page_fault = 0; // status of copy_from_user.
+ int i; // loop counter.
+ int offset; // offset in page
+
+ for (i = 0, offset = (pos & (PAGE_CACHE_SIZE - 1)); i < num_pages;
+ i++, offset = 0) {
+ size_t count = min_t(size_t, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
+ struct page *page = prepared_pages[i]; // Current page we process.
+
+ fault_in_pages_readable(buf, count);
+
+ /* Copy data from userspace to the current page */
+ kmap(page);
+ page_fault = __copy_from_user(page_address(page) + offset, buf, count); // Copy the data.
+ /* Flush processor's dcache for this page */
+ flush_dcache_page(page);
+ kunmap(page);
+ buf += count;
+ write_bytes -= count;
+
+ if (page_fault)
+ break; // Was there a fault? abort.
+ }
+
+ return page_fault ? -EFAULT : 0;
}
/* taken fs/buffer.c:__block_commit_write */
int reiserfs_commit_page(struct inode *inode, struct page *page,
- unsigned from, unsigned to)
+ unsigned from, unsigned to)
{
- unsigned block_start, block_end;
- int partial = 0;
- unsigned blocksize;
- struct buffer_head *bh, *head;
- unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT;
- int new;
- int logit = reiserfs_file_data_log(inode);
- struct super_block *s = inode->i_sb;
- int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
- struct reiserfs_transaction_handle th;
- int ret = 0;
-
- th.t_trans_id = 0;
- blocksize = 1 << inode->i_blkbits;
-
- if (logit) {
- reiserfs_write_lock(s);
- ret = journal_begin(&th, s, bh_per_page + 1);
- if (ret)
- goto drop_write_lock;
- reiserfs_update_inode_transaction(inode);
- }
- for(bh = head = page_buffers(page), block_start = 0;
- bh != head || !block_start;
- block_start=block_end, bh = bh->b_this_page)
- {
-
- new = buffer_new(bh);
- clear_buffer_new(bh);
- block_end = block_start + blocksize;
- if (block_end <= from || block_start >= to) {
- if (!buffer_uptodate(bh))
- partial = 1;
- } else {
- set_buffer_uptodate(bh);
- if (logit) {
- reiserfs_prepare_for_journal(s, bh, 1);
- journal_mark_dirty(&th, s, bh);
- } else if (!buffer_dirty(bh)) {
- mark_buffer_dirty(bh);
- /* do data=ordered on any page past the end
- * of file and any buffer marked BH_New.
- */
- if (reiserfs_data_ordered(inode->i_sb) &&
- (new || page->index >= i_size_index)) {
- reiserfs_add_ordered_list(inode, bh);
- }
- }
+ unsigned block_start, block_end;
+ int partial = 0;
+ unsigned blocksize;
+ struct buffer_head *bh, *head;
+ unsigned long i_size_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ int new;
+ int logit = reiserfs_file_data_log(inode);
+ struct super_block *s = inode->i_sb;
+ int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
+ struct reiserfs_transaction_handle th;
+ int ret = 0;
+
+ th.t_trans_id = 0;
+ blocksize = 1 << inode->i_blkbits;
+
+ if (logit) {
+ reiserfs_write_lock(s);
+ ret = journal_begin(&th, s, bh_per_page + 1);
+ if (ret)
+ goto drop_write_lock;
+ reiserfs_update_inode_transaction(inode);
+ }
+ for (bh = head = page_buffers(page), block_start = 0;
+ bh != head || !block_start;
+ block_start = block_end, bh = bh->b_this_page) {
+
+ new = buffer_new(bh);
+ clear_buffer_new(bh);
+ block_end = block_start + blocksize;
+ if (block_end <= from || block_start >= to) {
+ if (!buffer_uptodate(bh))
+ partial = 1;
+ } else {
+ set_buffer_uptodate(bh);
+ if (logit) {
+ reiserfs_prepare_for_journal(s, bh, 1);
+ journal_mark_dirty(&th, s, bh);
+ } else if (!buffer_dirty(bh)) {
+ mark_buffer_dirty(bh);
+ /* do data=ordered on any page past the end
+ * of file and any buffer marked BH_New.
+ */
+ if (reiserfs_data_ordered(inode->i_sb) &&
+ (new || page->index >= i_size_index)) {
+ reiserfs_add_ordered_list(inode, bh);
+ }
+ }
+ }
}
- }
- if (logit) {
- ret = journal_end(&th, s, bh_per_page + 1);
-drop_write_lock:
- reiserfs_write_unlock(s);
- }
- /*
- * If this is a partial write which happened to make all buffers
- * uptodate then we can optimize away a bogus readpage() for
- * the next read(). Here we 'discover' whether the page went
- * uptodate as a result of this (potentially partial) write.
- */
- if (!partial)
- SetPageUptodate(page);
- return ret;
+ if (logit) {
+ ret = journal_end(&th, s, bh_per_page + 1);
+ drop_write_lock:
+ reiserfs_write_unlock(s);
+ }
+ /*
+ * If this is a partial write which happened to make all buffers
+ * uptodate then we can optimize away a bogus readpage() for
+ * the next read(). Here we 'discover' whether the page went
+ * uptodate as a result of this (potentially partial) write.
+ */
+ if (!partial)
+ SetPageUptodate(page);
+ return ret;
}
-
/* Submit pages for write. This was separated from actual file copying
because we might want to allocate block numbers in-between.
This function assumes that caller will adjust file size to correct value. */
-static int reiserfs_submit_file_region_for_write(
- struct reiserfs_transaction_handle *th,
- struct inode *inode,
- loff_t pos, /* Writing position offset */
- size_t num_pages, /* Number of pages to write */
- size_t write_bytes, /* number of bytes to write */
- struct page **prepared_pages /* list of pages */
- )
+static int reiserfs_submit_file_region_for_write(struct reiserfs_transaction_handle *th, struct inode *inode, loff_t pos, /* Writing position offset */
+ size_t num_pages, /* Number of pages to write */
+ size_t write_bytes, /* number of bytes to write */
+ struct page **prepared_pages /* list of pages */
+ )
{
- int status; // return status of block_commit_write.
- int retval = 0; // Return value we are going to return.
- int i; // loop counter
- int offset; // Writing offset in page.
- int orig_write_bytes = write_bytes;
- int sd_update = 0;
-
- for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) {
- int count = min_t(int,PAGE_CACHE_SIZE-offset,write_bytes); // How much of bytes to write to this page
- struct page *page=prepared_pages[i]; // Current page we process.
-
- status = reiserfs_commit_page(inode, page, offset, offset+count);
- if ( status )
- retval = status; // To not overcomplicate matters We are going to
- // submit all the pages even if there was error.
- // we only remember error status to report it on
- // exit.
- write_bytes-=count;
- }
- /* now that we've gotten all the ordered buffers marked dirty,
- * we can safely update i_size and close any running transaction
- */
- if ( pos + orig_write_bytes > inode->i_size) {
- inode->i_size = pos + orig_write_bytes; // Set new size
- /* If the file have grown so much that tail packing is no
- * longer possible, reset "need to pack" flag */
- if ( (have_large_tails (inode->i_sb) &&
- inode->i_size > i_block_size (inode)*4) ||
- (have_small_tails (inode->i_sb) &&
- inode->i_size > i_block_size(inode)) )
- REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask ;
- else if ( (have_large_tails (inode->i_sb) &&
- inode->i_size < i_block_size (inode)*4) ||
- (have_small_tails (inode->i_sb) &&
- inode->i_size < i_block_size(inode)) )
- REISERFS_I(inode)->i_flags |= i_pack_on_close_mask ;
-
+ int status; // return status of block_commit_write.
+ int retval = 0; // Return value we are going to return.
+ int i; // loop counter
+ int offset; // Writing offset in page.
+ int orig_write_bytes = write_bytes;
+ int sd_update = 0;
+
+ for (i = 0, offset = (pos & (PAGE_CACHE_SIZE - 1)); i < num_pages;
+ i++, offset = 0) {
+ int count = min_t(int, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
+ struct page *page = prepared_pages[i]; // Current page we process.
+
+ status =
+ reiserfs_commit_page(inode, page, offset, offset + count);
+ if (status)
+ retval = status; // To not overcomplicate matters We are going to
+ // submit all the pages even if there was error.
+ // we only remember error status to report it on
+ // exit.
+ write_bytes -= count;
+ }
+ /* now that we've gotten all the ordered buffers marked dirty,
+ * we can safely update i_size and close any running transaction
+ */
+ if (pos + orig_write_bytes > inode->i_size) {
+ inode->i_size = pos + orig_write_bytes; // Set new size
+ /* If the file have grown so much that tail packing is no
+ * longer possible, reset "need to pack" flag */
+ if ((have_large_tails(inode->i_sb) &&
+ inode->i_size > i_block_size(inode) * 4) ||
+ (have_small_tails(inode->i_sb) &&
+ inode->i_size > i_block_size(inode)))
+ REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
+ else if ((have_large_tails(inode->i_sb) &&
+ inode->i_size < i_block_size(inode) * 4) ||
+ (have_small_tails(inode->i_sb) &&
+ inode->i_size < i_block_size(inode)))
+ REISERFS_I(inode)->i_flags |= i_pack_on_close_mask;
+
+ if (th->t_trans_id) {
+ reiserfs_write_lock(inode->i_sb);
+ reiserfs_update_sd(th, inode); // And update on-disk metadata
+ reiserfs_write_unlock(inode->i_sb);
+ } else
+ inode->i_sb->s_op->dirty_inode(inode);
+
+ sd_update = 1;
+ }
if (th->t_trans_id) {
- reiserfs_write_lock(inode->i_sb);
- reiserfs_update_sd(th, inode); // And update on-disk metadata
- reiserfs_write_unlock(inode->i_sb);
- } else
- inode->i_sb->s_op->dirty_inode(inode);
+ reiserfs_write_lock(inode->i_sb);
+ if (!sd_update)
+ reiserfs_update_sd(th, inode);
+ status = journal_end(th, th->t_super, th->t_blocks_allocated);
+ if (status)
+ retval = status;
+ reiserfs_write_unlock(inode->i_sb);
+ }
+ th->t_trans_id = 0;
- sd_update = 1;
- }
- if (th->t_trans_id) {
- reiserfs_write_lock(inode->i_sb);
- if (!sd_update)
- reiserfs_update_sd(th, inode);
- status = journal_end(th, th->t_super, th->t_blocks_allocated);
- if (status)
- retval = status;
- reiserfs_write_unlock(inode->i_sb);
- }
- th->t_trans_id = 0;
-
- /*
- * we have to unlock the pages after updating i_size, otherwise
- * we race with writepage
- */
- for ( i = 0; i < num_pages ; i++) {
- struct page *page=prepared_pages[i];
- unlock_page(page);
- mark_page_accessed(page);
- page_cache_release(page);
- }
- return retval;
+ /*
+ * we have to unlock the pages after updating i_size, otherwise
+ * we race with writepage
+ */
+ for (i = 0; i < num_pages; i++) {
+ struct page *page = prepared_pages[i];
+ unlock_page(page);
+ mark_page_accessed(page);
+ page_cache_release(page);
+ }
+ return retval;
}
/* Look if passed writing region is going to touch file's tail
(if it is present). And if it is, convert the tail to unformatted node */
-static int reiserfs_check_for_tail_and_convert( struct inode *inode, /* inode to deal with */
- loff_t pos, /* Writing position */
- int write_bytes /* amount of bytes to write */
- )
+static int reiserfs_check_for_tail_and_convert(struct inode *inode, /* inode to deal with */
+ loff_t pos, /* Writing position */
+ int write_bytes /* amount of bytes to write */
+ )
{
- INITIALIZE_PATH(path); // needed for search_for_position
- struct cpu_key key; // Key that would represent last touched writing byte.
- struct item_head *ih; // item header of found block;
- int res; // Return value of various functions we call.
- int cont_expand_offset; // We will put offset for generic_cont_expand here
- // This can be int just because tails are created
- // only for small files.
-
+ INITIALIZE_PATH(path); // needed for search_for_position
+ struct cpu_key key; // Key that would represent last touched writing byte.
+ struct item_head *ih; // item header of found block;
+ int res; // Return value of various functions we call.
+ int cont_expand_offset; // We will put offset for generic_cont_expand here
+ // This can be int just because tails are created
+ // only for small files.
+
/* this embodies a dependency on a particular tail policy */
- if ( inode->i_size >= inode->i_sb->s_blocksize*4 ) {
- /* such a big files do not have tails, so we won't bother ourselves
- to look for tails, simply return */
- return 0;
- }
-
- reiserfs_write_lock(inode->i_sb);
- /* find the item containing the last byte to be written, or if
- * writing past the end of the file then the last item of the
- * file (and then we check its type). */
- make_cpu_key (&key, inode, pos+write_bytes+1, TYPE_ANY, 3/*key length*/);
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- if ( res == IO_ERROR ) {
- reiserfs_write_unlock(inode->i_sb);
- return -EIO;
- }
- ih = get_ih(&path);
- res = 0;
- if ( is_direct_le_ih(ih) ) {
- /* Ok, closest item is file tail (tails are stored in "direct"
- * items), so we need to unpack it. */
- /* To not overcomplicate matters, we just call generic_cont_expand
- which will in turn call other stuff and finally will boil down to
- reiserfs_get_block() that would do necessary conversion. */
- cont_expand_offset = le_key_k_offset(get_inode_item_key_version(inode), &(ih->ih_key));
- pathrelse(&path);
- res = generic_cont_expand( inode, cont_expand_offset);
- } else
- pathrelse(&path);
+ if (inode->i_size >= inode->i_sb->s_blocksize * 4) {
+ /* such a big files do not have tails, so we won't bother ourselves
+ to look for tails, simply return */
+ return 0;
+ }
- reiserfs_write_unlock(inode->i_sb);
- return res;
+ reiserfs_write_lock(inode->i_sb);
+ /* find the item containing the last byte to be written, or if
+ * writing past the end of the file then the last item of the
+ * file (and then we check its type). */
+ make_cpu_key(&key, inode, pos + write_bytes + 1, TYPE_ANY,
+ 3 /*key length */ );
+ res = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (res == IO_ERROR) {
+ reiserfs_write_unlock(inode->i_sb);
+ return -EIO;
+ }
+ ih = get_ih(&path);
+ res = 0;
+ if (is_direct_le_ih(ih)) {
+ /* Ok, closest item is file tail (tails are stored in "direct"
+ * items), so we need to unpack it. */
+ /* To not overcomplicate matters, we just call generic_cont_expand
+ which will in turn call other stuff and finally will boil down to
+ reiserfs_get_block() that would do necessary conversion. */
+ cont_expand_offset =
+ le_key_k_offset(get_inode_item_key_version(inode),
+ &(ih->ih_key));
+ pathrelse(&path);
+ res = generic_cont_expand(inode, cont_expand_offset);
+ } else
+ pathrelse(&path);
+
+ reiserfs_write_unlock(inode->i_sb);
+ return res;
}
/* This function locks pages starting from @pos for @inode.
@@ -851,275 +947,296 @@ static int reiserfs_check_for_tail_and_convert( struct inode *inode, /* inode to
append), it is zeroed, then.
Returns number of unallocated blocks that should be allocated to cover
new file data.*/
-static int reiserfs_prepare_file_region_for_write(
- struct inode *inode /* Inode of the file */,
- loff_t pos, /* position in the file */
- size_t num_pages, /* number of pages to
- prepare */
- size_t write_bytes, /* Amount of bytes to be
- overwritten from
- @pos */
- struct page **prepared_pages /* pointer to array
- where to store
- prepared pages */
- )
+static int reiserfs_prepare_file_region_for_write(struct inode *inode
+ /* Inode of the file */ ,
+ loff_t pos, /* position in the file */
+ size_t num_pages, /* number of pages to
+ prepare */
+ size_t write_bytes, /* Amount of bytes to be
+ overwritten from
+ @pos */
+ struct page **prepared_pages /* pointer to array
+ where to store
+ prepared pages */
+ )
{
- int res=0; // Return values of different functions we call.
- unsigned long index = pos >> PAGE_CACHE_SHIFT; // Offset in file in pages.
- int from = (pos & (PAGE_CACHE_SIZE - 1)); // Writing offset in first page
- int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1;
- /* offset of last modified byte in last
- page */
- struct address_space *mapping = inode->i_mapping; // Pages are mapped here.
- int i; // Simple counter
- int blocks = 0; /* Return value (blocks that should be allocated) */
- struct buffer_head *bh, *head; // Current bufferhead and first bufferhead
- // of a page.
- unsigned block_start, block_end; // Starting and ending offsets of current
- // buffer in the page.
- struct buffer_head *wait[2], **wait_bh=wait; // Buffers for page, if
- // Page appeared to be not up
- // to date. Note how we have
- // at most 2 buffers, this is
- // because we at most may
- // partially overwrite two
- // buffers for one page. One at // the beginning of write area
- // and one at the end.
- // Everything inthe middle gets // overwritten totally.
-
- struct cpu_key key; // cpu key of item that we are going to deal with
- struct item_head *ih = NULL; // pointer to item head that we are going to deal with
- struct buffer_head *itembuf=NULL; // Buffer head that contains items that we are going to deal with
- INITIALIZE_PATH(path); // path to item, that we are going to deal with.
- __le32 * item=NULL; // pointer to item we are going to deal with
- int item_pos=-1; /* Position in indirect item */
-
-
- if ( num_pages < 1 ) {
- reiserfs_warning (inode->i_sb,
- "green-9001: reiserfs_prepare_file_region_for_write "
- "called with zero number of pages to process");
- return -EFAULT;
- }
-
- /* We have 2 loops for pages. In first loop we grab and lock the pages, so
- that nobody would touch these until we release the pages. Then
- we'd start to deal with mapping buffers to blocks. */
- for ( i = 0; i < num_pages; i++) {
- prepared_pages[i] = grab_cache_page(mapping, index + i); // locks the page
- if ( !prepared_pages[i]) {
- res = -ENOMEM;
- goto failed_page_grabbing;
- }
- if (!page_has_buffers(prepared_pages[i]))
- create_empty_buffers(prepared_pages[i], inode->i_sb->s_blocksize, 0);
- }
-
- /* Let's count amount of blocks for a case where all the blocks
- overwritten are new (we will substract already allocated blocks later)*/
- if ( num_pages > 2 )
- /* These are full-overwritten pages so we count all the blocks in
- these pages are counted as needed to be allocated */
- blocks = (num_pages - 2) << (PAGE_CACHE_SHIFT - inode->i_blkbits);
-
- /* count blocks needed for first page (possibly partially written) */
- blocks += ((PAGE_CACHE_SIZE - from) >> inode->i_blkbits) +
- !!(from & (inode->i_sb->s_blocksize-1)); /* roundup */
-
- /* Now we account for last page. If last page == first page (we
- overwrite only one page), we substract all the blocks past the
- last writing position in a page out of already calculated number
- of blocks */
- blocks += ((num_pages > 1) << (PAGE_CACHE_SHIFT-inode->i_blkbits)) -
- ((PAGE_CACHE_SIZE - to) >> inode->i_blkbits);
- /* Note how we do not roundup here since partial blocks still
- should be allocated */
-
- /* Now if all the write area lies past the file end, no point in
- maping blocks, since there is none, so we just zero out remaining
- parts of first and last pages in write area (if needed) */
- if ( (pos & ~((loff_t)PAGE_CACHE_SIZE - 1)) > inode->i_size ) {
- if ( from != 0 ) {/* First page needs to be partially zeroed */
- char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
- memset(kaddr, 0, from);
- kunmap_atomic( kaddr, KM_USER0);
- }
- if ( to != PAGE_CACHE_SIZE ) { /* Last page needs to be partially zeroed */
- char *kaddr = kmap_atomic(prepared_pages[num_pages-1], KM_USER0);
- memset(kaddr+to, 0, PAGE_CACHE_SIZE - to);
- kunmap_atomic( kaddr, KM_USER0);
+ int res = 0; // Return values of different functions we call.
+ unsigned long index = pos >> PAGE_CACHE_SHIFT; // Offset in file in pages.
+ int from = (pos & (PAGE_CACHE_SIZE - 1)); // Writing offset in first page
+ int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1;
+ /* offset of last modified byte in last
+ page */
+ struct address_space *mapping = inode->i_mapping; // Pages are mapped here.
+ int i; // Simple counter
+ int blocks = 0; /* Return value (blocks that should be allocated) */
+ struct buffer_head *bh, *head; // Current bufferhead and first bufferhead
+ // of a page.
+ unsigned block_start, block_end; // Starting and ending offsets of current
+ // buffer in the page.
+ struct buffer_head *wait[2], **wait_bh = wait; // Buffers for page, if
+ // Page appeared to be not up
+ // to date. Note how we have
+ // at most 2 buffers, this is
+ // because we at most may
+ // partially overwrite two
+ // buffers for one page. One at // the beginning of write area
+ // and one at the end.
+ // Everything inthe middle gets // overwritten totally.
+
+ struct cpu_key key; // cpu key of item that we are going to deal with
+ struct item_head *ih = NULL; // pointer to item head that we are going to deal with
+ struct buffer_head *itembuf = NULL; // Buffer head that contains items that we are going to deal with
+ INITIALIZE_PATH(path); // path to item, that we are going to deal with.
+ __le32 *item = NULL; // pointer to item we are going to deal with
+ int item_pos = -1; /* Position in indirect item */
+
+ if (num_pages < 1) {
+ reiserfs_warning(inode->i_sb,
+ "green-9001: reiserfs_prepare_file_region_for_write "
+ "called with zero number of pages to process");
+ return -EFAULT;
}
- /* Since all blocks are new - use already calculated value */
- return blocks;
- }
-
- /* Well, since we write somewhere into the middle of a file, there is
- possibility we are writing over some already allocated blocks, so
- let's map these blocks and substract number of such blocks out of blocks
- we need to allocate (calculated above) */
- /* Mask write position to start on blocksize, we do it out of the
- loop for performance reasons */
- pos &= ~((loff_t) inode->i_sb->s_blocksize - 1);
- /* Set cpu key to the starting position in a file (on left block boundary)*/
- make_cpu_key (&key, inode, 1 + ((pos) & ~((loff_t) inode->i_sb->s_blocksize - 1)), TYPE_ANY, 3/*key length*/);
-
- reiserfs_write_lock(inode->i_sb); // We need that for at least search_by_key()
- for ( i = 0; i < num_pages ; i++ ) {
-
- head = page_buffers(prepared_pages[i]);
- /* For each buffer in the page */
- for(bh = head, block_start = 0; bh != head || !block_start;
- block_start=block_end, bh = bh->b_this_page) {
- if (!bh)
- reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
- /* Find where this buffer ends */
- block_end = block_start+inode->i_sb->s_blocksize;
- if (i == 0 && block_end <= from )
- /* if this buffer is before requested data to map, skip it*/
- continue;
-
- if (i == num_pages - 1 && block_start >= to) {
- /* If this buffer is after requested data to map, abort
- processing of current page */
- break;
+ /* We have 2 loops for pages. In first loop we grab and lock the pages, so
+ that nobody would touch these until we release the pages. Then
+ we'd start to deal with mapping buffers to blocks. */
+ for (i = 0; i < num_pages; i++) {
+ prepared_pages[i] = grab_cache_page(mapping, index + i); // locks the page
+ if (!prepared_pages[i]) {
+ res = -ENOMEM;
+ goto failed_page_grabbing;
}
+ if (!page_has_buffers(prepared_pages[i]))
+ create_empty_buffers(prepared_pages[i],
+ inode->i_sb->s_blocksize, 0);
+ }
- if ( buffer_mapped(bh) && bh->b_blocknr !=0 ) {
- /* This is optimisation for a case where buffer is mapped
- and have blocknumber assigned. In case significant amount
- of such buffers are present, we may avoid some amount
- of search_by_key calls.
- Probably it would be possible to move parts of this code
- out of BKL, but I afraid that would overcomplicate code
- without any noticeable benefit.
- */
- item_pos++;
- /* Update the key */
- set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + inode->i_sb->s_blocksize);
- blocks--; // Decrease the amount of blocks that need to be
- // allocated
- continue; // Go to the next buffer
+ /* Let's count amount of blocks for a case where all the blocks
+ overwritten are new (we will substract already allocated blocks later) */
+ if (num_pages > 2)
+ /* These are full-overwritten pages so we count all the blocks in
+ these pages are counted as needed to be allocated */
+ blocks =
+ (num_pages - 2) << (PAGE_CACHE_SHIFT - inode->i_blkbits);
+
+ /* count blocks needed for first page (possibly partially written) */
+ blocks += ((PAGE_CACHE_SIZE - from) >> inode->i_blkbits) + !!(from & (inode->i_sb->s_blocksize - 1)); /* roundup */
+
+ /* Now we account for last page. If last page == first page (we
+ overwrite only one page), we substract all the blocks past the
+ last writing position in a page out of already calculated number
+ of blocks */
+ blocks += ((num_pages > 1) << (PAGE_CACHE_SHIFT - inode->i_blkbits)) -
+ ((PAGE_CACHE_SIZE - to) >> inode->i_blkbits);
+ /* Note how we do not roundup here since partial blocks still
+ should be allocated */
+
+ /* Now if all the write area lies past the file end, no point in
+ maping blocks, since there is none, so we just zero out remaining
+ parts of first and last pages in write area (if needed) */
+ if ((pos & ~((loff_t) PAGE_CACHE_SIZE - 1)) > inode->i_size) {
+ if (from != 0) { /* First page needs to be partially zeroed */
+ char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
+ memset(kaddr, 0, from);
+ kunmap_atomic(kaddr, KM_USER0);
+ }
+ if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */
+ char *kaddr =
+ kmap_atomic(prepared_pages[num_pages - 1],
+ KM_USER0);
+ memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
+ kunmap_atomic(kaddr, KM_USER0);
}
- if ( !itembuf || /* if first iteration */
- item_pos >= ih_item_len(ih)/UNFM_P_SIZE)
- { /* or if we progressed past the
- current unformatted_item */
- /* Try to find next item */
- res = search_for_position_by_key(inode->i_sb, &key, &path);
- /* Abort if no more items */
- if ( res != POSITION_FOUND ) {
- /* make sure later loops don't use this item */
- itembuf = NULL;
- item = NULL;
- break;
+ /* Since all blocks are new - use already calculated value */
+ return blocks;
+ }
+
+ /* Well, since we write somewhere into the middle of a file, there is
+ possibility we are writing over some already allocated blocks, so
+ let's map these blocks and substract number of such blocks out of blocks
+ we need to allocate (calculated above) */
+ /* Mask write position to start on blocksize, we do it out of the
+ loop for performance reasons */
+ pos &= ~((loff_t) inode->i_sb->s_blocksize - 1);
+ /* Set cpu key to the starting position in a file (on left block boundary) */
+ make_cpu_key(&key, inode,
+ 1 + ((pos) & ~((loff_t) inode->i_sb->s_blocksize - 1)),
+ TYPE_ANY, 3 /*key length */ );
+
+ reiserfs_write_lock(inode->i_sb); // We need that for at least search_by_key()
+ for (i = 0; i < num_pages; i++) {
+
+ head = page_buffers(prepared_pages[i]);
+ /* For each buffer in the page */
+ for (bh = head, block_start = 0; bh != head || !block_start;
+ block_start = block_end, bh = bh->b_this_page) {
+ if (!bh)
+ reiserfs_panic(inode->i_sb,
+ "green-9002: Allocated but absent buffer for a page?");
+ /* Find where this buffer ends */
+ block_end = block_start + inode->i_sb->s_blocksize;
+ if (i == 0 && block_end <= from)
+ /* if this buffer is before requested data to map, skip it */
+ continue;
+
+ if (i == num_pages - 1 && block_start >= to) {
+ /* If this buffer is after requested data to map, abort
+ processing of current page */
+ break;
}
- /* Update information about current indirect item */
- itembuf = get_last_bh( &path );
- ih = get_ih( &path );
- item = get_item( &path );
- item_pos = path.pos_in_item;
+ if (buffer_mapped(bh) && bh->b_blocknr != 0) {
+ /* This is optimisation for a case where buffer is mapped
+ and have blocknumber assigned. In case significant amount
+ of such buffers are present, we may avoid some amount
+ of search_by_key calls.
+ Probably it would be possible to move parts of this code
+ out of BKL, but I afraid that would overcomplicate code
+ without any noticeable benefit.
+ */
+ item_pos++;
+ /* Update the key */
+ set_cpu_key_k_offset(&key,
+ cpu_key_k_offset(&key) +
+ inode->i_sb->s_blocksize);
+ blocks--; // Decrease the amount of blocks that need to be
+ // allocated
+ continue; // Go to the next buffer
+ }
- RFALSE( !is_indirect_le_ih (ih), "green-9003: indirect item expected");
- }
+ if (!itembuf || /* if first iteration */
+ item_pos >= ih_item_len(ih) / UNFM_P_SIZE) { /* or if we progressed past the
+ current unformatted_item */
+ /* Try to find next item */
+ res =
+ search_for_position_by_key(inode->i_sb,
+ &key, &path);
+ /* Abort if no more items */
+ if (res != POSITION_FOUND) {
+ /* make sure later loops don't use this item */
+ itembuf = NULL;
+ item = NULL;
+ break;
+ }
+
+ /* Update information about current indirect item */
+ itembuf = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ item_pos = path.pos_in_item;
+
+ RFALSE(!is_indirect_le_ih(ih),
+ "green-9003: indirect item expected");
+ }
- /* See if there is some block associated with the file
- at that position, map the buffer to this block */
- if ( get_block_num(item,item_pos) ) {
- map_bh(bh, inode->i_sb, get_block_num(item,item_pos));
- blocks--; // Decrease the amount of blocks that need to be
- // allocated
+ /* See if there is some block associated with the file
+ at that position, map the buffer to this block */
+ if (get_block_num(item, item_pos)) {
+ map_bh(bh, inode->i_sb,
+ get_block_num(item, item_pos));
+ blocks--; // Decrease the amount of blocks that need to be
+ // allocated
+ }
+ item_pos++;
+ /* Update the key */
+ set_cpu_key_k_offset(&key,
+ cpu_key_k_offset(&key) +
+ inode->i_sb->s_blocksize);
}
- item_pos++;
- /* Update the key */
- set_cpu_key_k_offset( &key, cpu_key_k_offset(&key) + inode->i_sb->s_blocksize);
}
- }
- pathrelse(&path); // Free the path
- reiserfs_write_unlock(inode->i_sb);
+ pathrelse(&path); // Free the path
+ reiserfs_write_unlock(inode->i_sb);
/* Now zero out unmappend buffers for the first and last pages of
write area or issue read requests if page is mapped. */
/* First page, see if it is not uptodate */
- if ( !PageUptodate(prepared_pages[0]) ) {
- head = page_buffers(prepared_pages[0]);
-
- /* For each buffer in page */
- for(bh = head, block_start = 0; bh != head || !block_start;
- block_start=block_end, bh = bh->b_this_page) {
-
- if (!bh)
- reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
- /* Find where this buffer ends */
- block_end = block_start+inode->i_sb->s_blocksize;
- if ( block_end <= from )
- /* if this buffer is before requested data to map, skip it*/
- continue;
- if ( block_start < from ) { /* Aha, our partial buffer */
- if ( buffer_mapped(bh) ) { /* If it is mapped, we need to
- issue READ request for it to
- not loose data */
- ll_rw_block(READ, 1, &bh);
- *wait_bh++=bh;
- } else { /* Not mapped, zero it */
- char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
- memset(kaddr+block_start, 0, from-block_start);
- kunmap_atomic( kaddr, KM_USER0);
- set_buffer_uptodate(bh);
- }
+ if (!PageUptodate(prepared_pages[0])) {
+ head = page_buffers(prepared_pages[0]);
+
+ /* For each buffer in page */
+ for (bh = head, block_start = 0; bh != head || !block_start;
+ block_start = block_end, bh = bh->b_this_page) {
+
+ if (!bh)
+ reiserfs_panic(inode->i_sb,
+ "green-9002: Allocated but absent buffer for a page?");
+ /* Find where this buffer ends */
+ block_end = block_start + inode->i_sb->s_blocksize;
+ if (block_end <= from)
+ /* if this buffer is before requested data to map, skip it */
+ continue;
+ if (block_start < from) { /* Aha, our partial buffer */
+ if (buffer_mapped(bh)) { /* If it is mapped, we need to
+ issue READ request for it to
+ not loose data */
+ ll_rw_block(READ, 1, &bh);
+ *wait_bh++ = bh;
+ } else { /* Not mapped, zero it */
+ char *kaddr =
+ kmap_atomic(prepared_pages[0],
+ KM_USER0);
+ memset(kaddr + block_start, 0,
+ from - block_start);
+ kunmap_atomic(kaddr, KM_USER0);
+ set_buffer_uptodate(bh);
+ }
+ }
}
- }
}
/* Last page, see if it is not uptodate, or if the last page is past the end of the file. */
- if ( !PageUptodate(prepared_pages[num_pages-1]) ||
- ((pos+write_bytes)>>PAGE_CACHE_SHIFT) > (inode->i_size>>PAGE_CACHE_SHIFT) ) {
- head = page_buffers(prepared_pages[num_pages-1]);
-
- /* for each buffer in page */
- for(bh = head, block_start = 0; bh != head || !block_start;
- block_start=block_end, bh = bh->b_this_page) {
-
- if (!bh)
- reiserfs_panic(inode->i_sb, "green-9002: Allocated but absent buffer for a page?");
- /* Find where this buffer ends */
- block_end = block_start+inode->i_sb->s_blocksize;
- if ( block_start >= to )
- /* if this buffer is after requested data to map, skip it*/
- break;
- if ( block_end > to ) { /* Aha, our partial buffer */
- if ( buffer_mapped(bh) ) { /* If it is mapped, we need to
- issue READ request for it to
- not loose data */
- ll_rw_block(READ, 1, &bh);
- *wait_bh++=bh;
- } else { /* Not mapped, zero it */
- char *kaddr = kmap_atomic(prepared_pages[num_pages-1], KM_USER0);
- memset(kaddr+to, 0, block_end-to);
- kunmap_atomic( kaddr, KM_USER0);
- set_buffer_uptodate(bh);
- }
+ if (!PageUptodate(prepared_pages[num_pages - 1]) ||
+ ((pos + write_bytes) >> PAGE_CACHE_SHIFT) >
+ (inode->i_size >> PAGE_CACHE_SHIFT)) {
+ head = page_buffers(prepared_pages[num_pages - 1]);
+
+ /* for each buffer in page */
+ for (bh = head, block_start = 0; bh != head || !block_start;
+ block_start = block_end, bh = bh->b_this_page) {
+
+ if (!bh)
+ reiserfs_panic(inode->i_sb,
+ "green-9002: Allocated but absent buffer for a page?");
+ /* Find where this buffer ends */
+ block_end = block_start + inode->i_sb->s_blocksize;
+ if (block_start >= to)
+ /* if this buffer is after requested data to map, skip it */
+ break;
+ if (block_end > to) { /* Aha, our partial buffer */
+ if (buffer_mapped(bh)) { /* If it is mapped, we need to
+ issue READ request for it to
+ not loose data */
+ ll_rw_block(READ, 1, &bh);
+ *wait_bh++ = bh;
+ } else { /* Not mapped, zero it */
+ char *kaddr =
+ kmap_atomic(prepared_pages
+ [num_pages - 1],
+ KM_USER0);
+ memset(kaddr + to, 0, block_end - to);
+ kunmap_atomic(kaddr, KM_USER0);
+ set_buffer_uptodate(bh);
+ }
+ }
}
- }
}
- /* Wait for read requests we made to happen, if necessary */
- while(wait_bh > wait) {
- wait_on_buffer(*--wait_bh);
- if (!buffer_uptodate(*wait_bh)) {
- res = -EIO;
- goto failed_read;
+ /* Wait for read requests we made to happen, if necessary */
+ while (wait_bh > wait) {
+ wait_on_buffer(*--wait_bh);
+ if (!buffer_uptodate(*wait_bh)) {
+ res = -EIO;
+ goto failed_read;
+ }
}
- }
-
- return blocks;
-failed_page_grabbing:
- num_pages = i;
-failed_read:
- reiserfs_unprepare_pages(prepared_pages, num_pages);
- return res;
+
+ return blocks;
+ failed_page_grabbing:
+ num_pages = i;
+ failed_read:
+ reiserfs_unprepare_pages(prepared_pages, num_pages);
+ return res;
}
/* Write @count bytes at position @ppos in a file indicated by @file
@@ -1148,262 +1265,305 @@ failed_read:
Future Features: providing search_by_key with hints.
*/
-static ssize_t reiserfs_file_write( struct file *file, /* the file we are going to write into */
- const char __user *buf, /* pointer to user supplied data
-(in userspace) */
- size_t count, /* amount of bytes to write */
- loff_t *ppos /* pointer to position in file that we start writing at. Should be updated to
- * new current position before returning. */ )
+static ssize_t reiserfs_file_write(struct file *file, /* the file we are going to write into */
+ const char __user * buf, /* pointer to user supplied data
+ (in userspace) */
+ size_t count, /* amount of bytes to write */
+ loff_t * ppos /* pointer to position in file that we start writing at. Should be updated to
+ * new current position before returning. */
+ )
{
- size_t already_written = 0; // Number of bytes already written to the file.
- loff_t pos; // Current position in the file.
- ssize_t res; // return value of various functions that we call.
- int err = 0;
- struct inode *inode = file->f_dentry->d_inode; // Inode of the file that we are writing to.
- /* To simplify coding at this time, we store
- locked pages in array for now */
- struct page * prepared_pages[REISERFS_WRITE_PAGES_AT_A_TIME];
- struct reiserfs_transaction_handle th;
- th.t_trans_id = 0;
-
- if ( file->f_flags & O_DIRECT) { // Direct IO needs treatment
- ssize_t result, after_file_end = 0;
- if ( (*ppos + count >= inode->i_size) || (file->f_flags & O_APPEND) ) {
- /* If we are appending a file, we need to put this savelink in here.
- If we will crash while doing direct io, finish_unfinished will
- cut the garbage from the file end. */
- reiserfs_write_lock(inode->i_sb);
- err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
- if (err) {
- reiserfs_write_unlock (inode->i_sb);
- return err;
- }
- reiserfs_update_inode_transaction(inode);
- add_save_link (&th, inode, 1 /* Truncate */);
- after_file_end = 1;
- err = journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT );
- reiserfs_write_unlock(inode->i_sb);
- if (err)
- return err;
- }
- result = generic_file_write(file, buf, count, ppos);
-
- if ( after_file_end ) { /* Now update i_size and remove the savelink */
- struct reiserfs_transaction_handle th;
- reiserfs_write_lock(inode->i_sb);
- err = journal_begin(&th, inode->i_sb, 1);
- if (err) {
- reiserfs_write_unlock (inode->i_sb);
- return err;
- }
- reiserfs_update_inode_transaction(inode);
- reiserfs_update_sd(&th, inode);
- err = journal_end(&th, inode->i_sb, 1);
- if (err) {
- reiserfs_write_unlock (inode->i_sb);
- return err;
- }
- err = remove_save_link (inode, 1/* truncate */);
- reiserfs_write_unlock(inode->i_sb);
- if (err)
- return err;
- }
-
- return result;
- }
-
- if ( unlikely((ssize_t) count < 0 ))
- return -EINVAL;
-
- if (unlikely(!access_ok(VERIFY_READ, buf, count)))
- return -EFAULT;
-
- down(&inode->i_sem); // locks the entire file for just us
-
- pos = *ppos;
-
- /* Check if we can write to specified region of file, file
- is not overly big and this kind of stuff. Adjust pos and
- count, if needed */
- res = generic_write_checks(file, &pos, &count, 0);
- if (res)
- goto out;
-
- if ( count == 0 )
- goto out;
-
- res = remove_suid(file->f_dentry);
- if (res)
- goto out;
-
- inode_update_time(inode, 1); /* Both mtime and ctime */
-
- // Ok, we are done with all the checks.
+ size_t already_written = 0; // Number of bytes already written to the file.
+ loff_t pos; // Current position in the file.
+ ssize_t res; // return value of various functions that we call.
+ int err = 0;
+ struct inode *inode = file->f_dentry->d_inode; // Inode of the file that we are writing to.
+ /* To simplify coding at this time, we store
+ locked pages in array for now */
+ struct page *prepared_pages[REISERFS_WRITE_PAGES_AT_A_TIME];
+ struct reiserfs_transaction_handle th;
+ th.t_trans_id = 0;
+
+ if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
+ ssize_t result, after_file_end = 0;
+ if ((*ppos + count >= inode->i_size)
+ || (file->f_flags & O_APPEND)) {
+ /* If we are appending a file, we need to put this savelink in here.
+ If we will crash while doing direct io, finish_unfinished will
+ cut the garbage from the file end. */
+ reiserfs_write_lock(inode->i_sb);
+ err =
+ journal_begin(&th, inode->i_sb,
+ JOURNAL_PER_BALANCE_CNT);
+ if (err) {
+ reiserfs_write_unlock(inode->i_sb);
+ return err;
+ }
+ reiserfs_update_inode_transaction(inode);
+ add_save_link(&th, inode, 1 /* Truncate */ );
+ after_file_end = 1;
+ err =
+ journal_end(&th, inode->i_sb,
+ JOURNAL_PER_BALANCE_CNT);
+ reiserfs_write_unlock(inode->i_sb);
+ if (err)
+ return err;
+ }
+ result = generic_file_write(file, buf, count, ppos);
+
+ if (after_file_end) { /* Now update i_size and remove the savelink */
+ struct reiserfs_transaction_handle th;
+ reiserfs_write_lock(inode->i_sb);
+ err = journal_begin(&th, inode->i_sb, 1);
+ if (err) {
+ reiserfs_write_unlock(inode->i_sb);
+ return err;
+ }
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_sd(&th, inode);
+ err = journal_end(&th, inode->i_sb, 1);
+ if (err) {
+ reiserfs_write_unlock(inode->i_sb);
+ return err;
+ }
+ err = remove_save_link(inode, 1 /* truncate */ );
+ reiserfs_write_unlock(inode->i_sb);
+ if (err)
+ return err;
+ }
- // Now we should start real work
+ return result;
+ }
- /* If we are going to write past the file's packed tail or if we are going
- to overwrite part of the tail, we need that tail to be converted into
- unformatted node */
- res = reiserfs_check_for_tail_and_convert( inode, pos, count);
- if (res)
- goto out;
+ if (unlikely((ssize_t) count < 0))
+ return -EINVAL;
+
+ if (unlikely(!access_ok(VERIFY_READ, buf, count)))
+ return -EFAULT;
+
+ down(&inode->i_sem); // locks the entire file for just us
+
+ pos = *ppos;
+
+ /* Check if we can write to specified region of file, file
+ is not overly big and this kind of stuff. Adjust pos and
+ count, if needed */
+ res = generic_write_checks(file, &pos, &count, 0);
+ if (res)
+ goto out;
+
+ if (count == 0)
+ goto out;
+
+ res = remove_suid(file->f_dentry);
+ if (res)
+ goto out;
+
+ inode_update_time(inode, 1); /* Both mtime and ctime */
+
+ // Ok, we are done with all the checks.
+
+ // Now we should start real work
+
+ /* If we are going to write past the file's packed tail or if we are going
+ to overwrite part of the tail, we need that tail to be converted into
+ unformatted node */
+ res = reiserfs_check_for_tail_and_convert(inode, pos, count);
+ if (res)
+ goto out;
+
+ while (count > 0) {
+ /* This is the main loop in which we running until some error occures
+ or until we write all of the data. */
+ size_t num_pages; /* amount of pages we are going to write this iteration */
+ size_t write_bytes; /* amount of bytes to write during this iteration */
+ size_t blocks_to_allocate; /* how much blocks we need to allocate for this iteration */
+
+ /* (pos & (PAGE_CACHE_SIZE-1)) is an idiom for offset into a page of pos */
+ num_pages = !!((pos + count) & (PAGE_CACHE_SIZE - 1)) + /* round up partial
+ pages */
+ ((count +
+ (pos & (PAGE_CACHE_SIZE - 1))) >> PAGE_CACHE_SHIFT);
+ /* convert size to amount of
+ pages */
+ reiserfs_write_lock(inode->i_sb);
+ if (num_pages > REISERFS_WRITE_PAGES_AT_A_TIME
+ || num_pages > reiserfs_can_fit_pages(inode->i_sb)) {
+ /* If we were asked to write more data than we want to or if there
+ is not that much space, then we shorten amount of data to write
+ for this iteration. */
+ num_pages =
+ min_t(size_t, REISERFS_WRITE_PAGES_AT_A_TIME,
+ reiserfs_can_fit_pages(inode->i_sb));
+ /* Also we should not forget to set size in bytes accordingly */
+ write_bytes = (num_pages << PAGE_CACHE_SHIFT) -
+ (pos & (PAGE_CACHE_SIZE - 1));
+ /* If position is not on the
+ start of the page, we need
+ to substract the offset
+ within page */
+ } else
+ write_bytes = count;
+
+ /* reserve the blocks to be allocated later, so that later on
+ we still have the space to write the blocks to */
+ reiserfs_claim_blocks_to_be_allocated(inode->i_sb,
+ num_pages <<
+ (PAGE_CACHE_SHIFT -
+ inode->i_blkbits));
+ reiserfs_write_unlock(inode->i_sb);
+
+ if (!num_pages) { /* If we do not have enough space even for a single page... */
+ if (pos >
+ inode->i_size + inode->i_sb->s_blocksize -
+ (pos & (inode->i_sb->s_blocksize - 1))) {
+ res = -ENOSPC;
+ break; // In case we are writing past the end of the last file block, break.
+ }
+ // Otherwise we are possibly overwriting the file, so
+ // let's set write size to be equal or less than blocksize.
+ // This way we get it correctly for file holes.
+ // But overwriting files on absolutelly full volumes would not
+ // be very efficient. Well, people are not supposed to fill
+ // 100% of disk space anyway.
+ write_bytes =
+ min_t(size_t, count,
+ inode->i_sb->s_blocksize -
+ (pos & (inode->i_sb->s_blocksize - 1)));
+ num_pages = 1;
+ // No blocks were claimed before, so do it now.
+ reiserfs_claim_blocks_to_be_allocated(inode->i_sb,
+ 1 <<
+ (PAGE_CACHE_SHIFT
+ -
+ inode->
+ i_blkbits));
+ }
- while ( count > 0) {
- /* This is the main loop in which we running until some error occures
- or until we write all of the data. */
- size_t num_pages;/* amount of pages we are going to write this iteration */
- size_t write_bytes; /* amount of bytes to write during this iteration */
- size_t blocks_to_allocate; /* how much blocks we need to allocate for this iteration */
-
- /* (pos & (PAGE_CACHE_SIZE-1)) is an idiom for offset into a page of pos*/
- num_pages = !!((pos+count) & (PAGE_CACHE_SIZE - 1)) + /* round up partial
- pages */
- ((count + (pos & (PAGE_CACHE_SIZE-1))) >> PAGE_CACHE_SHIFT);
- /* convert size to amount of
- pages */
- reiserfs_write_lock(inode->i_sb);
- if ( num_pages > REISERFS_WRITE_PAGES_AT_A_TIME
- || num_pages > reiserfs_can_fit_pages(inode->i_sb) ) {
- /* If we were asked to write more data than we want to or if there
- is not that much space, then we shorten amount of data to write
- for this iteration. */
- num_pages = min_t(size_t, REISERFS_WRITE_PAGES_AT_A_TIME, reiserfs_can_fit_pages(inode->i_sb));
- /* Also we should not forget to set size in bytes accordingly */
- write_bytes = (num_pages << PAGE_CACHE_SHIFT) -
- (pos & (PAGE_CACHE_SIZE-1));
- /* If position is not on the
- start of the page, we need
- to substract the offset
- within page */
- } else
- write_bytes = count;
+ /* Prepare for writing into the region, read in all the
+ partially overwritten pages, if needed. And lock the pages,
+ so that nobody else can access these until we are done.
+ We get number of actual blocks needed as a result. */
+ blocks_to_allocate =
+ reiserfs_prepare_file_region_for_write(inode, pos,
+ num_pages,
+ write_bytes,
+ prepared_pages);
+ if (blocks_to_allocate < 0) {
+ res = blocks_to_allocate;
+ reiserfs_release_claimed_blocks(inode->i_sb,
+ num_pages <<
+ (PAGE_CACHE_SHIFT -
+ inode->i_blkbits));
+ break;
+ }
- /* reserve the blocks to be allocated later, so that later on
- we still have the space to write the blocks to */
- reiserfs_claim_blocks_to_be_allocated(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
- reiserfs_write_unlock(inode->i_sb);
+ /* First we correct our estimate of how many blocks we need */
+ reiserfs_release_claimed_blocks(inode->i_sb,
+ (num_pages <<
+ (PAGE_CACHE_SHIFT -
+ inode->i_sb->
+ s_blocksize_bits)) -
+ blocks_to_allocate);
+
+ if (blocks_to_allocate > 0) { /*We only allocate blocks if we need to */
+ /* Fill in all the possible holes and append the file if needed */
+ res =
+ reiserfs_allocate_blocks_for_region(&th, inode, pos,
+ num_pages,
+ write_bytes,
+ prepared_pages,
+ blocks_to_allocate);
+ }
- if ( !num_pages ) { /* If we do not have enough space even for a single page... */
- if ( pos > inode->i_size+inode->i_sb->s_blocksize-(pos & (inode->i_sb->s_blocksize-1))) {
- res = -ENOSPC;
- break; // In case we are writing past the end of the last file block, break.
- }
- // Otherwise we are possibly overwriting the file, so
- // let's set write size to be equal or less than blocksize.
- // This way we get it correctly for file holes.
- // But overwriting files on absolutelly full volumes would not
- // be very efficient. Well, people are not supposed to fill
- // 100% of disk space anyway.
- write_bytes = min_t(size_t, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1)));
- num_pages = 1;
- // No blocks were claimed before, so do it now.
- reiserfs_claim_blocks_to_be_allocated(inode->i_sb, 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits));
- }
+ /* well, we have allocated the blocks, so it is time to free
+ the reservation we made earlier. */
+ reiserfs_release_claimed_blocks(inode->i_sb,
+ blocks_to_allocate);
+ if (res) {
+ reiserfs_unprepare_pages(prepared_pages, num_pages);
+ break;
+ }
- /* Prepare for writing into the region, read in all the
- partially overwritten pages, if needed. And lock the pages,
- so that nobody else can access these until we are done.
- We get number of actual blocks needed as a result.*/
- blocks_to_allocate = reiserfs_prepare_file_region_for_write(inode, pos, num_pages, write_bytes, prepared_pages);
- if ( blocks_to_allocate < 0 ) {
- res = blocks_to_allocate;
- reiserfs_release_claimed_blocks(inode->i_sb, num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
- break;
- }
+/* NOTE that allocating blocks and filling blocks can be done in reverse order
+ and probably we would do that just to get rid of garbage in files after a
+ crash */
- /* First we correct our estimate of how many blocks we need */
- reiserfs_release_claimed_blocks(inode->i_sb, (num_pages << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits)) - blocks_to_allocate );
+ /* Copy data from user-supplied buffer to file's pages */
+ res =
+ reiserfs_copy_from_user_to_file_region(pos, num_pages,
+ write_bytes,
+ prepared_pages, buf);
+ if (res) {
+ reiserfs_unprepare_pages(prepared_pages, num_pages);
+ break;
+ }
- if ( blocks_to_allocate > 0) {/*We only allocate blocks if we need to*/
- /* Fill in all the possible holes and append the file if needed */
- res = reiserfs_allocate_blocks_for_region(&th, inode, pos, num_pages, write_bytes, prepared_pages, blocks_to_allocate);
+ /* Send the pages to disk and unlock them. */
+ res =
+ reiserfs_submit_file_region_for_write(&th, inode, pos,
+ num_pages,
+ write_bytes,
+ prepared_pages);
+ if (res)
+ break;
+
+ already_written += write_bytes;
+ buf += write_bytes;
+ *ppos = pos += write_bytes;
+ count -= write_bytes;
+ balance_dirty_pages_ratelimited(inode->i_mapping);
}
- /* well, we have allocated the blocks, so it is time to free
- the reservation we made earlier. */
- reiserfs_release_claimed_blocks(inode->i_sb, blocks_to_allocate);
- if ( res ) {
- reiserfs_unprepare_pages(prepared_pages, num_pages);
- break;
+ /* this is only true on error */
+ if (th.t_trans_id) {
+ reiserfs_write_lock(inode->i_sb);
+ err = journal_end(&th, th.t_super, th.t_blocks_allocated);
+ reiserfs_write_unlock(inode->i_sb);
+ if (err) {
+ res = err;
+ goto out;
+ }
}
-/* NOTE that allocating blocks and filling blocks can be done in reverse order
- and probably we would do that just to get rid of garbage in files after a
- crash */
+ if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
+ res =
+ generic_osync_inode(inode, file->f_mapping,
+ OSYNC_METADATA | OSYNC_DATA);
- /* Copy data from user-supplied buffer to file's pages */
- res = reiserfs_copy_from_user_to_file_region(pos, num_pages, write_bytes, prepared_pages, buf);
- if ( res ) {
- reiserfs_unprepare_pages(prepared_pages, num_pages);
- break;
- }
+ up(&inode->i_sem);
+ reiserfs_async_progress_wait(inode->i_sb);
+ return (already_written != 0) ? already_written : res;
- /* Send the pages to disk and unlock them. */
- res = reiserfs_submit_file_region_for_write(&th, inode, pos, num_pages,
- write_bytes,prepared_pages);
- if ( res )
- break;
-
- already_written += write_bytes;
- buf += write_bytes;
- *ppos = pos += write_bytes;
- count -= write_bytes;
- balance_dirty_pages_ratelimited(inode->i_mapping);
- }
-
- /* this is only true on error */
- if (th.t_trans_id) {
- reiserfs_write_lock(inode->i_sb);
- err = journal_end(&th, th.t_super, th.t_blocks_allocated);
- reiserfs_write_unlock(inode->i_sb);
- if (err) {
- res = err;
- goto out;
- }
- }
-
- if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
- res = generic_osync_inode(inode, file->f_mapping, OSYNC_METADATA|OSYNC_DATA);
-
- up(&inode->i_sem);
- reiserfs_async_progress_wait(inode->i_sb);
- return (already_written != 0)?already_written:res;
-
-out:
- up(&inode->i_sem); // unlock the file on exit.
- return res;
+ out:
+ up(&inode->i_sem); // unlock the file on exit.
+ return res;
}
-static ssize_t reiserfs_aio_write(struct kiocb *iocb, const char __user *buf,
- size_t count, loff_t pos)
+static ssize_t reiserfs_aio_write(struct kiocb *iocb, const char __user * buf,
+ size_t count, loff_t pos)
{
- return generic_file_aio_write(iocb, buf, count, pos);
+ return generic_file_aio_write(iocb, buf, count, pos);
}
-
-
struct file_operations reiserfs_file_operations = {
- .read = generic_file_read,
- .write = reiserfs_file_write,
- .ioctl = reiserfs_ioctl,
- .mmap = generic_file_mmap,
- .release = reiserfs_file_release,
- .fsync = reiserfs_sync_file,
- .sendfile = generic_file_sendfile,
- .aio_read = generic_file_aio_read,
- .aio_write = reiserfs_aio_write,
+ .read = generic_file_read,
+ .write = reiserfs_file_write,
+ .ioctl = reiserfs_ioctl,
+ .mmap = generic_file_mmap,
+ .release = reiserfs_file_release,
+ .fsync = reiserfs_sync_file,
+ .sendfile = generic_file_sendfile,
+ .aio_read = generic_file_aio_read,
+ .aio_write = reiserfs_aio_write,
};
-
-struct inode_operations reiserfs_file_inode_operations = {
- .truncate = reiserfs_vfs_truncate_file,
- .setattr = reiserfs_setattr,
- .setxattr = reiserfs_setxattr,
- .getxattr = reiserfs_getxattr,
- .listxattr = reiserfs_listxattr,
- .removexattr = reiserfs_removexattr,
- .permission = reiserfs_permission,
+struct inode_operations reiserfs_file_inode_operations = {
+ .truncate = reiserfs_vfs_truncate_file,
+ .setattr = reiserfs_setattr,
+ .setxattr = reiserfs_setxattr,
+ .getxattr = reiserfs_getxattr,
+ .listxattr = reiserfs_listxattr,
+ .removexattr = reiserfs_removexattr,
+ .permission = reiserfs_permission,
};
-
-
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index e4f64be9e15..2706e2adffa 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
@@ -34,14 +34,12 @@
**
**/
-
#include <linux/config.h>
#include <linux/time.h>
#include <linux/string.h>
#include <linux/reiserfs_fs.h>
#include <linux/buffer_head.h>
-
/* To make any changes in the tree we find a node, that contains item
to be changed/deleted or position in the node we insert a new item
to. We call this node S. To do balancing we need to decide what we
@@ -56,490 +54,522 @@
have to have if we do not any shiftings, if we shift to left/right
neighbor or to both. */
-
/* taking item number in virtual node, returns number of item, that it has in source buffer */
-static inline int old_item_num (int new_num, int affected_item_num, int mode)
+static inline int old_item_num(int new_num, int affected_item_num, int mode)
{
- if (mode == M_PASTE || mode == M_CUT || new_num < affected_item_num)
- return new_num;
+ if (mode == M_PASTE || mode == M_CUT || new_num < affected_item_num)
+ return new_num;
- if (mode == M_INSERT) {
+ if (mode == M_INSERT) {
- RFALSE( new_num == 0,
- "vs-8005: for INSERT mode and item number of inserted item");
+ RFALSE(new_num == 0,
+ "vs-8005: for INSERT mode and item number of inserted item");
- return new_num - 1;
- }
+ return new_num - 1;
+ }
- RFALSE( mode != M_DELETE,
- "vs-8010: old_item_num: mode must be M_DELETE (mode = \'%c\'", mode);
- /* delete mode */
- return new_num + 1;
+ RFALSE(mode != M_DELETE,
+ "vs-8010: old_item_num: mode must be M_DELETE (mode = \'%c\'",
+ mode);
+ /* delete mode */
+ return new_num + 1;
}
-static void create_virtual_node (struct tree_balance * tb, int h)
+static void create_virtual_node(struct tree_balance *tb, int h)
{
- struct item_head * ih;
- struct virtual_node * vn = tb->tb_vn;
- int new_num;
- struct buffer_head * Sh; /* this comes from tb->S[h] */
+ struct item_head *ih;
+ struct virtual_node *vn = tb->tb_vn;
+ int new_num;
+ struct buffer_head *Sh; /* this comes from tb->S[h] */
- Sh = PATH_H_PBUFFER (tb->tb_path, h);
+ Sh = PATH_H_PBUFFER(tb->tb_path, h);
- /* size of changed node */
- vn->vn_size = MAX_CHILD_SIZE (Sh) - B_FREE_SPACE (Sh) + tb->insert_size[h];
+ /* size of changed node */
+ vn->vn_size =
+ MAX_CHILD_SIZE(Sh) - B_FREE_SPACE(Sh) + tb->insert_size[h];
- /* for internal nodes array if virtual items is not created */
- if (h) {
- vn->vn_nr_item = (vn->vn_size - DC_SIZE) / (DC_SIZE + KEY_SIZE);
- return;
- }
-
- /* number of items in virtual node */
- vn->vn_nr_item = B_NR_ITEMS (Sh) + ((vn->vn_mode == M_INSERT)? 1 : 0) - ((vn->vn_mode == M_DELETE)? 1 : 0);
-
- /* first virtual item */
- vn->vn_vi = (struct virtual_item *)(tb->tb_vn + 1);
- memset (vn->vn_vi, 0, vn->vn_nr_item * sizeof (struct virtual_item));
- vn->vn_free_ptr += vn->vn_nr_item * sizeof (struct virtual_item);
-
-
- /* first item in the node */
- ih = B_N_PITEM_HEAD (Sh, 0);
-
- /* define the mergeability for 0-th item (if it is not being deleted) */
- if (op_is_left_mergeable (&(ih->ih_key), Sh->b_size) && (vn->vn_mode != M_DELETE || vn->vn_affected_item_num))
- vn->vn_vi[0].vi_type |= VI_TYPE_LEFT_MERGEABLE;
-
- /* go through all items those remain in the virtual node (except for the new (inserted) one) */
- for (new_num = 0; new_num < vn->vn_nr_item; new_num ++) {
- int j;
- struct virtual_item * vi = vn->vn_vi + new_num;
- int is_affected = ((new_num != vn->vn_affected_item_num) ? 0 : 1);
-
-
- if (is_affected && vn->vn_mode == M_INSERT)
- continue;
-
- /* get item number in source node */
- j = old_item_num (new_num, vn->vn_affected_item_num, vn->vn_mode);
-
- vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE;
- vi->vi_ih = ih + j;
- vi->vi_item = B_I_PITEM (Sh, ih + j);
- vi->vi_uarea = vn->vn_free_ptr;
-
- // FIXME: there is no check, that item operation did not
- // consume too much memory
- vn->vn_free_ptr += op_create_vi (vn, vi, is_affected, tb->insert_size [0]);
- if (tb->vn_buf + tb->vn_buf_size < vn->vn_free_ptr)
- reiserfs_panic (tb->tb_sb, "vs-8030: create_virtual_node: "
- "virtual node space consumed");
-
- if (!is_affected)
- /* this is not being changed */
- continue;
-
- if (vn->vn_mode == M_PASTE || vn->vn_mode == M_CUT) {
- vn->vn_vi[new_num].vi_item_len += tb->insert_size[0];
- vi->vi_new_data = vn->vn_data; // pointer to data which is going to be pasted
+ /* for internal nodes array if virtual items is not created */
+ if (h) {
+ vn->vn_nr_item = (vn->vn_size - DC_SIZE) / (DC_SIZE + KEY_SIZE);
+ return;
}
- }
-
-
- /* virtual inserted item is not defined yet */
- if (vn->vn_mode == M_INSERT) {
- struct virtual_item * vi = vn->vn_vi + vn->vn_affected_item_num;
-
- RFALSE( vn->vn_ins_ih == 0,
- "vs-8040: item header of inserted item is not specified");
- vi->vi_item_len = tb->insert_size[0];
- vi->vi_ih = vn->vn_ins_ih;
- vi->vi_item = vn->vn_data;
- vi->vi_uarea = vn->vn_free_ptr;
-
- op_create_vi (vn, vi, 0/*not pasted or cut*/, tb->insert_size [0]);
- }
-
- /* set right merge flag we take right delimiting key and check whether it is a mergeable item */
- if (tb->CFR[0]) {
- struct reiserfs_key * key;
-
- key = B_N_PDELIM_KEY (tb->CFR[0], tb->rkey[0]);
- if (op_is_left_mergeable (key, Sh->b_size) && (vn->vn_mode != M_DELETE ||
- vn->vn_affected_item_num != B_NR_ITEMS (Sh) - 1))
- vn->vn_vi[vn->vn_nr_item-1].vi_type |= VI_TYPE_RIGHT_MERGEABLE;
-#ifdef CONFIG_REISERFS_CHECK
- if (op_is_left_mergeable (key, Sh->b_size) &&
- !(vn->vn_mode != M_DELETE || vn->vn_affected_item_num != B_NR_ITEMS (Sh) - 1) ) {
- /* we delete last item and it could be merged with right neighbor's first item */
- if (!(B_NR_ITEMS (Sh) == 1 && is_direntry_le_ih (B_N_PITEM_HEAD (Sh, 0)) &&
- I_ENTRY_COUNT (B_N_PITEM_HEAD (Sh, 0)) == 1)) {
- /* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */
- print_block (Sh, 0, -1, -1);
- reiserfs_panic (tb->tb_sb, "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
- key, vn->vn_affected_item_num, vn->vn_mode, M_DELETE);
- } else
- /* we can delete directory item, that has only one directory entry in it */
- ;
+ /* number of items in virtual node */
+ vn->vn_nr_item =
+ B_NR_ITEMS(Sh) + ((vn->vn_mode == M_INSERT) ? 1 : 0) -
+ ((vn->vn_mode == M_DELETE) ? 1 : 0);
+
+ /* first virtual item */
+ vn->vn_vi = (struct virtual_item *)(tb->tb_vn + 1);
+ memset(vn->vn_vi, 0, vn->vn_nr_item * sizeof(struct virtual_item));
+ vn->vn_free_ptr += vn->vn_nr_item * sizeof(struct virtual_item);
+
+ /* first item in the node */
+ ih = B_N_PITEM_HEAD(Sh, 0);
+
+ /* define the mergeability for 0-th item (if it is not being deleted) */
+ if (op_is_left_mergeable(&(ih->ih_key), Sh->b_size)
+ && (vn->vn_mode != M_DELETE || vn->vn_affected_item_num))
+ vn->vn_vi[0].vi_type |= VI_TYPE_LEFT_MERGEABLE;
+
+ /* go through all items those remain in the virtual node (except for the new (inserted) one) */
+ for (new_num = 0; new_num < vn->vn_nr_item; new_num++) {
+ int j;
+ struct virtual_item *vi = vn->vn_vi + new_num;
+ int is_affected =
+ ((new_num != vn->vn_affected_item_num) ? 0 : 1);
+
+ if (is_affected && vn->vn_mode == M_INSERT)
+ continue;
+
+ /* get item number in source node */
+ j = old_item_num(new_num, vn->vn_affected_item_num,
+ vn->vn_mode);
+
+ vi->vi_item_len += ih_item_len(ih + j) + IH_SIZE;
+ vi->vi_ih = ih + j;
+ vi->vi_item = B_I_PITEM(Sh, ih + j);
+ vi->vi_uarea = vn->vn_free_ptr;
+
+ // FIXME: there is no check, that item operation did not
+ // consume too much memory
+ vn->vn_free_ptr +=
+ op_create_vi(vn, vi, is_affected, tb->insert_size[0]);
+ if (tb->vn_buf + tb->vn_buf_size < vn->vn_free_ptr)
+ reiserfs_panic(tb->tb_sb,
+ "vs-8030: create_virtual_node: "
+ "virtual node space consumed");
+
+ if (!is_affected)
+ /* this is not being changed */
+ continue;
+
+ if (vn->vn_mode == M_PASTE || vn->vn_mode == M_CUT) {
+ vn->vn_vi[new_num].vi_item_len += tb->insert_size[0];
+ vi->vi_new_data = vn->vn_data; // pointer to data which is going to be pasted
+ }
}
+
+ /* virtual inserted item is not defined yet */
+ if (vn->vn_mode == M_INSERT) {
+ struct virtual_item *vi = vn->vn_vi + vn->vn_affected_item_num;
+
+ RFALSE(vn->vn_ins_ih == 0,
+ "vs-8040: item header of inserted item is not specified");
+ vi->vi_item_len = tb->insert_size[0];
+ vi->vi_ih = vn->vn_ins_ih;
+ vi->vi_item = vn->vn_data;
+ vi->vi_uarea = vn->vn_free_ptr;
+
+ op_create_vi(vn, vi, 0 /*not pasted or cut */ ,
+ tb->insert_size[0]);
+ }
+
+ /* set right merge flag we take right delimiting key and check whether it is a mergeable item */
+ if (tb->CFR[0]) {
+ struct reiserfs_key *key;
+
+ key = B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]);
+ if (op_is_left_mergeable(key, Sh->b_size)
+ && (vn->vn_mode != M_DELETE
+ || vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1))
+ vn->vn_vi[vn->vn_nr_item - 1].vi_type |=
+ VI_TYPE_RIGHT_MERGEABLE;
+
+#ifdef CONFIG_REISERFS_CHECK
+ if (op_is_left_mergeable(key, Sh->b_size) &&
+ !(vn->vn_mode != M_DELETE
+ || vn->vn_affected_item_num != B_NR_ITEMS(Sh) - 1)) {
+ /* we delete last item and it could be merged with right neighbor's first item */
+ if (!
+ (B_NR_ITEMS(Sh) == 1
+ && is_direntry_le_ih(B_N_PITEM_HEAD(Sh, 0))
+ && I_ENTRY_COUNT(B_N_PITEM_HEAD(Sh, 0)) == 1)) {
+ /* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */
+ print_block(Sh, 0, -1, -1);
+ reiserfs_panic(tb->tb_sb,
+ "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
+ key, vn->vn_affected_item_num,
+ vn->vn_mode, M_DELETE);
+ } else
+ /* we can delete directory item, that has only one directory entry in it */
+ ;
+ }
#endif
-
- }
-}
+ }
+}
/* using virtual node check, how many items can be shifted to left
neighbor */
-static void check_left (struct tree_balance * tb, int h, int cur_free)
+static void check_left(struct tree_balance *tb, int h, int cur_free)
{
- int i;
- struct virtual_node * vn = tb->tb_vn;
- struct virtual_item * vi;
- int d_size, ih_size;
+ int i;
+ struct virtual_node *vn = tb->tb_vn;
+ struct virtual_item *vi;
+ int d_size, ih_size;
- RFALSE( cur_free < 0, "vs-8050: cur_free (%d) < 0", cur_free);
+ RFALSE(cur_free < 0, "vs-8050: cur_free (%d) < 0", cur_free);
- /* internal level */
- if (h > 0) {
- tb->lnum[h] = cur_free / (DC_SIZE + KEY_SIZE);
- return;
- }
+ /* internal level */
+ if (h > 0) {
+ tb->lnum[h] = cur_free / (DC_SIZE + KEY_SIZE);
+ return;
+ }
- /* leaf level */
+ /* leaf level */
- if (!cur_free || !vn->vn_nr_item) {
- /* no free space or nothing to move */
- tb->lnum[h] = 0;
- tb->lbytes = -1;
- return;
- }
+ if (!cur_free || !vn->vn_nr_item) {
+ /* no free space or nothing to move */
+ tb->lnum[h] = 0;
+ tb->lbytes = -1;
+ return;
+ }
- RFALSE( !PATH_H_PPARENT (tb->tb_path, 0),
- "vs-8055: parent does not exist or invalid");
+ RFALSE(!PATH_H_PPARENT(tb->tb_path, 0),
+ "vs-8055: parent does not exist or invalid");
- vi = vn->vn_vi;
- if ((unsigned int)cur_free >= (vn->vn_size - ((vi->vi_type & VI_TYPE_LEFT_MERGEABLE) ? IH_SIZE : 0))) {
- /* all contents of S[0] fits into L[0] */
+ vi = vn->vn_vi;
+ if ((unsigned int)cur_free >=
+ (vn->vn_size -
+ ((vi->vi_type & VI_TYPE_LEFT_MERGEABLE) ? IH_SIZE : 0))) {
+ /* all contents of S[0] fits into L[0] */
- RFALSE( vn->vn_mode == M_INSERT || vn->vn_mode == M_PASTE,
- "vs-8055: invalid mode or balance condition failed");
+ RFALSE(vn->vn_mode == M_INSERT || vn->vn_mode == M_PASTE,
+ "vs-8055: invalid mode or balance condition failed");
- tb->lnum[0] = vn->vn_nr_item;
- tb->lbytes = -1;
- return;
- }
-
-
- d_size = 0, ih_size = IH_SIZE;
-
- /* first item may be merge with last item in left neighbor */
- if (vi->vi_type & VI_TYPE_LEFT_MERGEABLE)
- d_size = -((int)IH_SIZE), ih_size = 0;
-
- tb->lnum[0] = 0;
- for (i = 0; i < vn->vn_nr_item; i ++, ih_size = IH_SIZE, d_size = 0, vi ++) {
- d_size += vi->vi_item_len;
- if (cur_free >= d_size) {
- /* the item can be shifted entirely */
- cur_free -= d_size;
- tb->lnum[0] ++;
- continue;
+ tb->lnum[0] = vn->vn_nr_item;
+ tb->lbytes = -1;
+ return;
}
-
- /* the item cannot be shifted entirely, try to split it */
- /* check whether L[0] can hold ih and at least one byte of the item body */
- if (cur_free <= ih_size) {
- /* cannot shift even a part of the current item */
- tb->lbytes = -1;
- return;
+
+ d_size = 0, ih_size = IH_SIZE;
+
+ /* first item may be merge with last item in left neighbor */
+ if (vi->vi_type & VI_TYPE_LEFT_MERGEABLE)
+ d_size = -((int)IH_SIZE), ih_size = 0;
+
+ tb->lnum[0] = 0;
+ for (i = 0; i < vn->vn_nr_item;
+ i++, ih_size = IH_SIZE, d_size = 0, vi++) {
+ d_size += vi->vi_item_len;
+ if (cur_free >= d_size) {
+ /* the item can be shifted entirely */
+ cur_free -= d_size;
+ tb->lnum[0]++;
+ continue;
+ }
+
+ /* the item cannot be shifted entirely, try to split it */
+ /* check whether L[0] can hold ih and at least one byte of the item body */
+ if (cur_free <= ih_size) {
+ /* cannot shift even a part of the current item */
+ tb->lbytes = -1;
+ return;
+ }
+ cur_free -= ih_size;
+
+ tb->lbytes = op_check_left(vi, cur_free, 0, 0);
+ if (tb->lbytes != -1)
+ /* count partially shifted item */
+ tb->lnum[0]++;
+
+ break;
}
- cur_free -= ih_size;
-
- tb->lbytes = op_check_left (vi, cur_free, 0, 0);
- if (tb->lbytes != -1)
- /* count partially shifted item */
- tb->lnum[0] ++;
-
- break;
- }
-
- return;
-}
+ return;
+}
/* using virtual node check, how many items can be shifted to right
neighbor */
-static void check_right (struct tree_balance * tb, int h, int cur_free)
+static void check_right(struct tree_balance *tb, int h, int cur_free)
{
- int i;
- struct virtual_node * vn = tb->tb_vn;
- struct virtual_item * vi;
- int d_size, ih_size;
-
- RFALSE( cur_free < 0, "vs-8070: cur_free < 0");
-
- /* internal level */
- if (h > 0) {
- tb->rnum[h] = cur_free / (DC_SIZE + KEY_SIZE);
- return;
- }
-
- /* leaf level */
-
- if (!cur_free || !vn->vn_nr_item) {
- /* no free space */
- tb->rnum[h] = 0;
- tb->rbytes = -1;
- return;
- }
-
- RFALSE( !PATH_H_PPARENT (tb->tb_path, 0),
- "vs-8075: parent does not exist or invalid");
-
- vi = vn->vn_vi + vn->vn_nr_item - 1;
- if ((unsigned int)cur_free >= (vn->vn_size - ((vi->vi_type & VI_TYPE_RIGHT_MERGEABLE) ? IH_SIZE : 0))) {
- /* all contents of S[0] fits into R[0] */
-
- RFALSE( vn->vn_mode == M_INSERT || vn->vn_mode == M_PASTE,
- "vs-8080: invalid mode or balance condition failed");
-
- tb->rnum[h] = vn->vn_nr_item;
- tb->rbytes = -1;
- return;
- }
-
- d_size = 0, ih_size = IH_SIZE;
-
- /* last item may be merge with first item in right neighbor */
- if (vi->vi_type & VI_TYPE_RIGHT_MERGEABLE)
- d_size = -(int)IH_SIZE, ih_size = 0;
-
- tb->rnum[0] = 0;
- for (i = vn->vn_nr_item - 1; i >= 0; i --, d_size = 0, ih_size = IH_SIZE, vi --) {
- d_size += vi->vi_item_len;
- if (cur_free >= d_size) {
- /* the item can be shifted entirely */
- cur_free -= d_size;
- tb->rnum[0] ++;
- continue;
+ int i;
+ struct virtual_node *vn = tb->tb_vn;
+ struct virtual_item *vi;
+ int d_size, ih_size;
+
+ RFALSE(cur_free < 0, "vs-8070: cur_free < 0");
+
+ /* internal level */
+ if (h > 0) {
+ tb->rnum[h] = cur_free / (DC_SIZE + KEY_SIZE);
+ return;
}
-
- /* check whether R[0] can hold ih and at least one byte of the item body */
- if ( cur_free <= ih_size ) { /* cannot shift even a part of the current item */
- tb->rbytes = -1;
- return;
+
+ /* leaf level */
+
+ if (!cur_free || !vn->vn_nr_item) {
+ /* no free space */
+ tb->rnum[h] = 0;
+ tb->rbytes = -1;
+ return;
}
-
- /* R[0] can hold the header of the item and at least one byte of its body */
- cur_free -= ih_size; /* cur_free is still > 0 */
-
- tb->rbytes = op_check_right (vi, cur_free);
- if (tb->rbytes != -1)
- /* count partially shifted item */
- tb->rnum[0] ++;
-
- break;
- }
-
- return;
-}
+ RFALSE(!PATH_H_PPARENT(tb->tb_path, 0),
+ "vs-8075: parent does not exist or invalid");
+
+ vi = vn->vn_vi + vn->vn_nr_item - 1;
+ if ((unsigned int)cur_free >=
+ (vn->vn_size -
+ ((vi->vi_type & VI_TYPE_RIGHT_MERGEABLE) ? IH_SIZE : 0))) {
+ /* all contents of S[0] fits into R[0] */
+
+ RFALSE(vn->vn_mode == M_INSERT || vn->vn_mode == M_PASTE,
+ "vs-8080: invalid mode or balance condition failed");
+
+ tb->rnum[h] = vn->vn_nr_item;
+ tb->rbytes = -1;
+ return;
+ }
+
+ d_size = 0, ih_size = IH_SIZE;
+
+ /* last item may be merge with first item in right neighbor */
+ if (vi->vi_type & VI_TYPE_RIGHT_MERGEABLE)
+ d_size = -(int)IH_SIZE, ih_size = 0;
+
+ tb->rnum[0] = 0;
+ for (i = vn->vn_nr_item - 1; i >= 0;
+ i--, d_size = 0, ih_size = IH_SIZE, vi--) {
+ d_size += vi->vi_item_len;
+ if (cur_free >= d_size) {
+ /* the item can be shifted entirely */
+ cur_free -= d_size;
+ tb->rnum[0]++;
+ continue;
+ }
+
+ /* check whether R[0] can hold ih and at least one byte of the item body */
+ if (cur_free <= ih_size) { /* cannot shift even a part of the current item */
+ tb->rbytes = -1;
+ return;
+ }
+
+ /* R[0] can hold the header of the item and at least one byte of its body */
+ cur_free -= ih_size; /* cur_free is still > 0 */
+
+ tb->rbytes = op_check_right(vi, cur_free);
+ if (tb->rbytes != -1)
+ /* count partially shifted item */
+ tb->rnum[0]++;
+
+ break;
+ }
+
+ return;
+}
/*
* from - number of items, which are shifted to left neighbor entirely
* to - number of item, which are shifted to right neighbor entirely
* from_bytes - number of bytes of boundary item (or directory entries) which are shifted to left neighbor
* to_bytes - number of bytes of boundary item (or directory entries) which are shifted to right neighbor */
-static int get_num_ver (int mode, struct tree_balance * tb, int h,
- int from, int from_bytes,
- int to, int to_bytes,
- short * snum012, int flow
- )
+static int get_num_ver(int mode, struct tree_balance *tb, int h,
+ int from, int from_bytes,
+ int to, int to_bytes, short *snum012, int flow)
{
- int i;
- int cur_free;
- // int bytes;
- int units;
- struct virtual_node * vn = tb->tb_vn;
- // struct virtual_item * vi;
-
- int total_node_size, max_node_size, current_item_size;
- int needed_nodes;
- int start_item, /* position of item we start filling node from */
- end_item, /* position of item we finish filling node by */
- start_bytes,/* number of first bytes (entries for directory) of start_item-th item
- we do not include into node that is being filled */
- end_bytes; /* number of last bytes (entries for directory) of end_item-th item
- we do node include into node that is being filled */
- int split_item_positions[2]; /* these are positions in virtual item of
- items, that are split between S[0] and
- S1new and S1new and S2new */
-
- split_item_positions[0] = -1;
- split_item_positions[1] = -1;
-
- /* We only create additional nodes if we are in insert or paste mode
- or we are in replace mode at the internal level. If h is 0 and
- the mode is M_REPLACE then in fix_nodes we change the mode to
- paste or insert before we get here in the code. */
- RFALSE( tb->insert_size[h] < 0 || (mode != M_INSERT && mode != M_PASTE),
- "vs-8100: insert_size < 0 in overflow");
-
- max_node_size = MAX_CHILD_SIZE (PATH_H_PBUFFER (tb->tb_path, h));
-
- /* snum012 [0-2] - number of items, that lay
- to S[0], first new node and second new node */
- snum012[3] = -1; /* s1bytes */
- snum012[4] = -1; /* s2bytes */
-
- /* internal level */
- if (h > 0) {
- i = ((to - from) * (KEY_SIZE + DC_SIZE) + DC_SIZE);
- if (i == max_node_size)
- return 1;
- return (i / max_node_size + 1);
- }
-
- /* leaf level */
- needed_nodes = 1;
- total_node_size = 0;
- cur_free = max_node_size;
-
- // start from 'from'-th item
- start_item = from;
- // skip its first 'start_bytes' units
- start_bytes = ((from_bytes != -1) ? from_bytes : 0);
-
- // last included item is the 'end_item'-th one
- end_item = vn->vn_nr_item - to - 1;
- // do not count last 'end_bytes' units of 'end_item'-th item
- end_bytes = (to_bytes != -1) ? to_bytes : 0;
-
- /* go through all item beginning from the start_item-th item and ending by
- the end_item-th item. Do not count first 'start_bytes' units of
- 'start_item'-th item and last 'end_bytes' of 'end_item'-th item */
-
- for (i = start_item; i <= end_item; i ++) {
- struct virtual_item * vi = vn->vn_vi + i;
- int skip_from_end = ((i == end_item) ? end_bytes : 0);
-
- RFALSE( needed_nodes > 3, "vs-8105: too many nodes are needed");
-
- /* get size of current item */
- current_item_size = vi->vi_item_len;
-
- /* do not take in calculation head part (from_bytes) of from-th item */
- current_item_size -= op_part_size (vi, 0/*from start*/, start_bytes);
-
- /* do not take in calculation tail part of last item */
- current_item_size -= op_part_size (vi, 1/*from end*/, skip_from_end);
-
- /* if item fits into current node entierly */
- if (total_node_size + current_item_size <= max_node_size) {
- snum012[needed_nodes - 1] ++;
- total_node_size += current_item_size;
- start_bytes = 0;
- continue;
+ int i;
+ int cur_free;
+ // int bytes;
+ int units;
+ struct virtual_node *vn = tb->tb_vn;
+ // struct virtual_item * vi;
+
+ int total_node_size, max_node_size, current_item_size;
+ int needed_nodes;
+ int start_item, /* position of item we start filling node from */
+ end_item, /* position of item we finish filling node by */
+ start_bytes, /* number of first bytes (entries for directory) of start_item-th item
+ we do not include into node that is being filled */
+ end_bytes; /* number of last bytes (entries for directory) of end_item-th item
+ we do node include into node that is being filled */
+ int split_item_positions[2]; /* these are positions in virtual item of
+ items, that are split between S[0] and
+ S1new and S1new and S2new */
+
+ split_item_positions[0] = -1;
+ split_item_positions[1] = -1;
+
+ /* We only create additional nodes if we are in insert or paste mode
+ or we are in replace mode at the internal level. If h is 0 and
+ the mode is M_REPLACE then in fix_nodes we change the mode to
+ paste or insert before we get here in the code. */
+ RFALSE(tb->insert_size[h] < 0 || (mode != M_INSERT && mode != M_PASTE),
+ "vs-8100: insert_size < 0 in overflow");
+
+ max_node_size = MAX_CHILD_SIZE(PATH_H_PBUFFER(tb->tb_path, h));
+
+ /* snum012 [0-2] - number of items, that lay
+ to S[0], first new node and second new node */
+ snum012[3] = -1; /* s1bytes */
+ snum012[4] = -1; /* s2bytes */
+
+ /* internal level */
+ if (h > 0) {
+ i = ((to - from) * (KEY_SIZE + DC_SIZE) + DC_SIZE);
+ if (i == max_node_size)
+ return 1;
+ return (i / max_node_size + 1);
}
- if (current_item_size > max_node_size) {
- /* virtual item length is longer, than max size of item in
- a node. It is impossible for direct item */
- RFALSE( is_direct_le_ih (vi->vi_ih),
- "vs-8110: "
- "direct item length is %d. It can not be longer than %d",
- current_item_size, max_node_size);
- /* we will try to split it */
- flow = 1;
+ /* leaf level */
+ needed_nodes = 1;
+ total_node_size = 0;
+ cur_free = max_node_size;
+
+ // start from 'from'-th item
+ start_item = from;
+ // skip its first 'start_bytes' units
+ start_bytes = ((from_bytes != -1) ? from_bytes : 0);
+
+ // last included item is the 'end_item'-th one
+ end_item = vn->vn_nr_item - to - 1;
+ // do not count last 'end_bytes' units of 'end_item'-th item
+ end_bytes = (to_bytes != -1) ? to_bytes : 0;
+
+ /* go through all item beginning from the start_item-th item and ending by
+ the end_item-th item. Do not count first 'start_bytes' units of
+ 'start_item'-th item and last 'end_bytes' of 'end_item'-th item */
+
+ for (i = start_item; i <= end_item; i++) {
+ struct virtual_item *vi = vn->vn_vi + i;
+ int skip_from_end = ((i == end_item) ? end_bytes : 0);
+
+ RFALSE(needed_nodes > 3, "vs-8105: too many nodes are needed");
+
+ /* get size of current item */
+ current_item_size = vi->vi_item_len;
+
+ /* do not take in calculation head part (from_bytes) of from-th item */
+ current_item_size -=
+ op_part_size(vi, 0 /*from start */ , start_bytes);
+
+ /* do not take in calculation tail part of last item */
+ current_item_size -=
+ op_part_size(vi, 1 /*from end */ , skip_from_end);
+
+ /* if item fits into current node entierly */
+ if (total_node_size + current_item_size <= max_node_size) {
+ snum012[needed_nodes - 1]++;
+ total_node_size += current_item_size;
+ start_bytes = 0;
+ continue;
+ }
+
+ if (current_item_size > max_node_size) {
+ /* virtual item length is longer, than max size of item in
+ a node. It is impossible for direct item */
+ RFALSE(is_direct_le_ih(vi->vi_ih),
+ "vs-8110: "
+ "direct item length is %d. It can not be longer than %d",
+ current_item_size, max_node_size);
+ /* we will try to split it */
+ flow = 1;
+ }
+
+ if (!flow) {
+ /* as we do not split items, take new node and continue */
+ needed_nodes++;
+ i--;
+ total_node_size = 0;
+ continue;
+ }
+ // calculate number of item units which fit into node being
+ // filled
+ {
+ int free_space;
+
+ free_space = max_node_size - total_node_size - IH_SIZE;
+ units =
+ op_check_left(vi, free_space, start_bytes,
+ skip_from_end);
+ if (units == -1) {
+ /* nothing fits into current node, take new node and continue */
+ needed_nodes++, i--, total_node_size = 0;
+ continue;
+ }
+ }
+
+ /* something fits into the current node */
+ //if (snum012[3] != -1 || needed_nodes != 1)
+ // reiserfs_panic (tb->tb_sb, "vs-8115: get_num_ver: too many nodes required");
+ //snum012[needed_nodes - 1 + 3] = op_unit_num (vi) - start_bytes - units;
+ start_bytes += units;
+ snum012[needed_nodes - 1 + 3] = units;
+
+ if (needed_nodes > 2)
+ reiserfs_warning(tb->tb_sb, "vs-8111: get_num_ver: "
+ "split_item_position is out of boundary");
+ snum012[needed_nodes - 1]++;
+ split_item_positions[needed_nodes - 1] = i;
+ needed_nodes++;
+ /* continue from the same item with start_bytes != -1 */
+ start_item = i;
+ i--;
+ total_node_size = 0;
}
- if (!flow) {
- /* as we do not split items, take new node and continue */
- needed_nodes ++; i --; total_node_size = 0;
- continue;
+ // sum012[4] (if it is not -1) contains number of units of which
+ // are to be in S1new, snum012[3] - to be in S0. They are supposed
+ // to be S1bytes and S2bytes correspondingly, so recalculate
+ if (snum012[4] > 0) {
+ int split_item_num;
+ int bytes_to_r, bytes_to_l;
+ int bytes_to_S1new;
+
+ split_item_num = split_item_positions[1];
+ bytes_to_l =
+ ((from == split_item_num
+ && from_bytes != -1) ? from_bytes : 0);
+ bytes_to_r =
+ ((end_item == split_item_num
+ && end_bytes != -1) ? end_bytes : 0);
+ bytes_to_S1new =
+ ((split_item_positions[0] ==
+ split_item_positions[1]) ? snum012[3] : 0);
+
+ // s2bytes
+ snum012[4] =
+ op_unit_num(&vn->vn_vi[split_item_num]) - snum012[4] -
+ bytes_to_r - bytes_to_l - bytes_to_S1new;
+
+ if (vn->vn_vi[split_item_num].vi_index != TYPE_DIRENTRY &&
+ vn->vn_vi[split_item_num].vi_index != TYPE_INDIRECT)
+ reiserfs_warning(tb->tb_sb, "vs-8115: get_num_ver: not "
+ "directory or indirect item");
}
- // calculate number of item units which fit into node being
- // filled
- {
- int free_space;
-
- free_space = max_node_size - total_node_size - IH_SIZE;
- units = op_check_left (vi, free_space, start_bytes, skip_from_end);
- if (units == -1) {
- /* nothing fits into current node, take new node and continue */
- needed_nodes ++, i--, total_node_size = 0;
- continue;
- }
+ /* now we know S2bytes, calculate S1bytes */
+ if (snum012[3] > 0) {
+ int split_item_num;
+ int bytes_to_r, bytes_to_l;
+ int bytes_to_S2new;
+
+ split_item_num = split_item_positions[0];
+ bytes_to_l =
+ ((from == split_item_num
+ && from_bytes != -1) ? from_bytes : 0);
+ bytes_to_r =
+ ((end_item == split_item_num
+ && end_bytes != -1) ? end_bytes : 0);
+ bytes_to_S2new =
+ ((split_item_positions[0] == split_item_positions[1]
+ && snum012[4] != -1) ? snum012[4] : 0);
+
+ // s1bytes
+ snum012[3] =
+ op_unit_num(&vn->vn_vi[split_item_num]) - snum012[3] -
+ bytes_to_r - bytes_to_l - bytes_to_S2new;
}
- /* something fits into the current node */
- //if (snum012[3] != -1 || needed_nodes != 1)
- // reiserfs_panic (tb->tb_sb, "vs-8115: get_num_ver: too many nodes required");
- //snum012[needed_nodes - 1 + 3] = op_unit_num (vi) - start_bytes - units;
- start_bytes += units;
- snum012[needed_nodes - 1 + 3] = units;
-
- if (needed_nodes > 2)
- reiserfs_warning (tb->tb_sb, "vs-8111: get_num_ver: "
- "split_item_position is out of boundary");
- snum012[needed_nodes - 1] ++;
- split_item_positions[needed_nodes - 1] = i;
- needed_nodes ++;
- /* continue from the same item with start_bytes != -1 */
- start_item = i;
- i --;
- total_node_size = 0;
- }
-
- // sum012[4] (if it is not -1) contains number of units of which
- // are to be in S1new, snum012[3] - to be in S0. They are supposed
- // to be S1bytes and S2bytes correspondingly, so recalculate
- if (snum012[4] > 0) {
- int split_item_num;
- int bytes_to_r, bytes_to_l;
- int bytes_to_S1new;
-
- split_item_num = split_item_positions[1];
- bytes_to_l = ((from == split_item_num && from_bytes != -1) ? from_bytes : 0);
- bytes_to_r = ((end_item == split_item_num && end_bytes != -1) ? end_bytes : 0);
- bytes_to_S1new = ((split_item_positions[0] == split_item_positions[1]) ? snum012[3] : 0);
-
- // s2bytes
- snum012[4] = op_unit_num (&vn->vn_vi[split_item_num]) - snum012[4] - bytes_to_r - bytes_to_l - bytes_to_S1new;
-
- if (vn->vn_vi[split_item_num].vi_index != TYPE_DIRENTRY &&
- vn->vn_vi[split_item_num].vi_index != TYPE_INDIRECT)
- reiserfs_warning (tb->tb_sb, "vs-8115: get_num_ver: not "
- "directory or indirect item");
- }
-
- /* now we know S2bytes, calculate S1bytes */
- if (snum012[3] > 0) {
- int split_item_num;
- int bytes_to_r, bytes_to_l;
- int bytes_to_S2new;
-
- split_item_num = split_item_positions[0];
- bytes_to_l = ((from == split_item_num && from_bytes != -1) ? from_bytes : 0);
- bytes_to_r = ((end_item == split_item_num && end_bytes != -1) ? end_bytes : 0);
- bytes_to_S2new = ((split_item_positions[0] == split_item_positions[1] && snum012[4] != -1) ? snum012[4] : 0);
-
- // s1bytes
- snum012[3] = op_unit_num (&vn->vn_vi[split_item_num]) - snum012[3] - bytes_to_r - bytes_to_l - bytes_to_S2new;
- }
-
- return needed_nodes;
+ return needed_nodes;
}
-
#ifdef CONFIG_REISERFS_CHECK
-extern struct tree_balance * cur_tb;
+extern struct tree_balance *cur_tb;
#endif
-
/* Set parameters for balancing.
* Performs write of results of analysis of balancing into structure tb,
* where it will later be used by the functions that actually do the balancing.
@@ -557,131 +587,130 @@ extern struct tree_balance * cur_tb;
* s1bytes number of bytes which flow to the first new node when S[0] splits (this number is contained in s012 array)
*/
-static void set_parameters (struct tree_balance * tb, int h, int lnum,
- int rnum, int blk_num, short * s012, int lb, int rb)
+static void set_parameters(struct tree_balance *tb, int h, int lnum,
+ int rnum, int blk_num, short *s012, int lb, int rb)
{
- tb->lnum[h] = lnum;
- tb->rnum[h] = rnum;
- tb->blknum[h] = blk_num;
+ tb->lnum[h] = lnum;
+ tb->rnum[h] = rnum;
+ tb->blknum[h] = blk_num;
- if (h == 0)
- { /* only for leaf level */
- if (s012 != NULL)
- {
- tb->s0num = * s012 ++,
- tb->s1num = * s012 ++,
- tb->s2num = * s012 ++;
- tb->s1bytes = * s012 ++;
- tb->s2bytes = * s012;
+ if (h == 0) { /* only for leaf level */
+ if (s012 != NULL) {
+ tb->s0num = *s012++,
+ tb->s1num = *s012++, tb->s2num = *s012++;
+ tb->s1bytes = *s012++;
+ tb->s2bytes = *s012;
+ }
+ tb->lbytes = lb;
+ tb->rbytes = rb;
}
- tb->lbytes = lb;
- tb->rbytes = rb;
- }
- PROC_INFO_ADD( tb -> tb_sb, lnum[ h ], lnum );
- PROC_INFO_ADD( tb -> tb_sb, rnum[ h ], rnum );
-
- PROC_INFO_ADD( tb -> tb_sb, lbytes[ h ], lb );
- PROC_INFO_ADD( tb -> tb_sb, rbytes[ h ], rb );
-}
-
+ PROC_INFO_ADD(tb->tb_sb, lnum[h], lnum);
+ PROC_INFO_ADD(tb->tb_sb, rnum[h], rnum);
+ PROC_INFO_ADD(tb->tb_sb, lbytes[h], lb);
+ PROC_INFO_ADD(tb->tb_sb, rbytes[h], rb);
+}
/* check, does node disappear if we shift tb->lnum[0] items to left
neighbor and tb->rnum[0] to the right one. */
-static int is_leaf_removable (struct tree_balance * tb)
+static int is_leaf_removable(struct tree_balance *tb)
{
- struct virtual_node * vn = tb->tb_vn;
- int to_left, to_right;
- int size;
- int remain_items;
-
- /* number of items, that will be shifted to left (right) neighbor
- entirely */
- to_left = tb->lnum[0] - ((tb->lbytes != -1) ? 1 : 0);
- to_right = tb->rnum[0] - ((tb->rbytes != -1) ? 1 : 0);
- remain_items = vn->vn_nr_item;
-
- /* how many items remain in S[0] after shiftings to neighbors */
- remain_items -= (to_left + to_right);
-
- if (remain_items < 1) {
- /* all content of node can be shifted to neighbors */
- set_parameters (tb, 0, to_left, vn->vn_nr_item - to_left, 0, NULL, -1, -1);
- return 1;
- }
-
- if (remain_items > 1 || tb->lbytes == -1 || tb->rbytes == -1)
- /* S[0] is not removable */
- return 0;
-
- /* check, whether we can divide 1 remaining item between neighbors */
-
- /* get size of remaining item (in item units) */
- size = op_unit_num (&(vn->vn_vi[to_left]));
-
- if (tb->lbytes + tb->rbytes >= size) {
- set_parameters (tb, 0, to_left + 1, to_right + 1, 0, NULL, tb->lbytes, -1);
- return 1;
- }
-
- return 0;
-}
+ struct virtual_node *vn = tb->tb_vn;
+ int to_left, to_right;
+ int size;
+ int remain_items;
+
+ /* number of items, that will be shifted to left (right) neighbor
+ entirely */
+ to_left = tb->lnum[0] - ((tb->lbytes != -1) ? 1 : 0);
+ to_right = tb->rnum[0] - ((tb->rbytes != -1) ? 1 : 0);
+ remain_items = vn->vn_nr_item;
+
+ /* how many items remain in S[0] after shiftings to neighbors */
+ remain_items -= (to_left + to_right);
+
+ if (remain_items < 1) {
+ /* all content of node can be shifted to neighbors */
+ set_parameters(tb, 0, to_left, vn->vn_nr_item - to_left, 0,
+ NULL, -1, -1);
+ return 1;
+ }
+ if (remain_items > 1 || tb->lbytes == -1 || tb->rbytes == -1)
+ /* S[0] is not removable */
+ return 0;
+
+ /* check, whether we can divide 1 remaining item between neighbors */
+
+ /* get size of remaining item (in item units) */
+ size = op_unit_num(&(vn->vn_vi[to_left]));
+
+ if (tb->lbytes + tb->rbytes >= size) {
+ set_parameters(tb, 0, to_left + 1, to_right + 1, 0, NULL,
+ tb->lbytes, -1);
+ return 1;
+ }
+
+ return 0;
+}
/* check whether L, S, R can be joined in one node */
-static int are_leaves_removable (struct tree_balance * tb, int lfree, int rfree)
+static int are_leaves_removable(struct tree_balance *tb, int lfree, int rfree)
{
- struct virtual_node * vn = tb->tb_vn;
- int ih_size;
- struct buffer_head *S0;
-
- S0 = PATH_H_PBUFFER (tb->tb_path, 0);
-
- ih_size = 0;
- if (vn->vn_nr_item) {
- if (vn->vn_vi[0].vi_type & VI_TYPE_LEFT_MERGEABLE)
- ih_size += IH_SIZE;
-
- if (vn->vn_vi[vn->vn_nr_item-1].vi_type & VI_TYPE_RIGHT_MERGEABLE)
- ih_size += IH_SIZE;
- } else {
- /* there was only one item and it will be deleted */
- struct item_head * ih;
-
- RFALSE( B_NR_ITEMS (S0) != 1,
- "vs-8125: item number must be 1: it is %d", B_NR_ITEMS(S0));
-
- ih = B_N_PITEM_HEAD (S0, 0);
- if (tb->CFR[0] && !comp_short_le_keys (&(ih->ih_key), B_N_PDELIM_KEY (tb->CFR[0], tb->rkey[0])))
- if (is_direntry_le_ih (ih)) {
- /* Directory must be in correct state here: that is
- somewhere at the left side should exist first directory
- item. But the item being deleted can not be that first
- one because its right neighbor is item of the same
- directory. (But first item always gets deleted in last
- turn). So, neighbors of deleted item can be merged, so
- we can save ih_size */
- ih_size = IH_SIZE;
-
- /* we might check that left neighbor exists and is of the
- same directory */
- RFALSE(le_ih_k_offset (ih) == DOT_OFFSET,
- "vs-8130: first directory item can not be removed until directory is not empty");
- }
-
- }
-
- if (MAX_CHILD_SIZE (S0) + vn->vn_size <= rfree + lfree + ih_size) {
- set_parameters (tb, 0, -1, -1, -1, NULL, -1, -1);
- PROC_INFO_INC( tb -> tb_sb, leaves_removable );
- return 1;
- }
- return 0;
-
-}
+ struct virtual_node *vn = tb->tb_vn;
+ int ih_size;
+ struct buffer_head *S0;
+
+ S0 = PATH_H_PBUFFER(tb->tb_path, 0);
+
+ ih_size = 0;
+ if (vn->vn_nr_item) {
+ if (vn->vn_vi[0].vi_type & VI_TYPE_LEFT_MERGEABLE)
+ ih_size += IH_SIZE;
+
+ if (vn->vn_vi[vn->vn_nr_item - 1].
+ vi_type & VI_TYPE_RIGHT_MERGEABLE)
+ ih_size += IH_SIZE;
+ } else {
+ /* there was only one item and it will be deleted */
+ struct item_head *ih;
+
+ RFALSE(B_NR_ITEMS(S0) != 1,
+ "vs-8125: item number must be 1: it is %d",
+ B_NR_ITEMS(S0));
+
+ ih = B_N_PITEM_HEAD(S0, 0);
+ if (tb->CFR[0]
+ && !comp_short_le_keys(&(ih->ih_key),
+ B_N_PDELIM_KEY(tb->CFR[0],
+ tb->rkey[0])))
+ if (is_direntry_le_ih(ih)) {
+ /* Directory must be in correct state here: that is
+ somewhere at the left side should exist first directory
+ item. But the item being deleted can not be that first
+ one because its right neighbor is item of the same
+ directory. (But first item always gets deleted in last
+ turn). So, neighbors of deleted item can be merged, so
+ we can save ih_size */
+ ih_size = IH_SIZE;
+
+ /* we might check that left neighbor exists and is of the
+ same directory */
+ RFALSE(le_ih_k_offset(ih) == DOT_OFFSET,
+ "vs-8130: first directory item can not be removed until directory is not empty");
+ }
+ }
+
+ if (MAX_CHILD_SIZE(S0) + vn->vn_size <= rfree + lfree + ih_size) {
+ set_parameters(tb, 0, -1, -1, -1, NULL, -1, -1);
+ PROC_INFO_INC(tb->tb_sb, leaves_removable);
+ return 1;
+ }
+ return 0;
+}
/* when we do not split item, lnum and rnum are numbers of entire items */
#define SET_PAR_SHIFT_LEFT \
@@ -704,7 +733,6 @@ else \
-1, -1);\
}
-
#define SET_PAR_SHIFT_RIGHT \
if (h)\
{\
@@ -724,214 +752,199 @@ else \
-1, -1);\
}
-
-static void free_buffers_in_tb (
- struct tree_balance * p_s_tb
- ) {
- int n_counter;
-
- decrement_counters_in_path(p_s_tb->tb_path);
-
- for ( n_counter = 0; n_counter < MAX_HEIGHT; n_counter++ ) {
- decrement_bcount(p_s_tb->L[n_counter]);
- p_s_tb->L[n_counter] = NULL;
- decrement_bcount(p_s_tb->R[n_counter]);
- p_s_tb->R[n_counter] = NULL;
- decrement_bcount(p_s_tb->FL[n_counter]);
- p_s_tb->FL[n_counter] = NULL;
- decrement_bcount(p_s_tb->FR[n_counter]);
- p_s_tb->FR[n_counter] = NULL;
- decrement_bcount(p_s_tb->CFL[n_counter]);
- p_s_tb->CFL[n_counter] = NULL;
- decrement_bcount(p_s_tb->CFR[n_counter]);
- p_s_tb->CFR[n_counter] = NULL;
- }
+static void free_buffers_in_tb(struct tree_balance *p_s_tb)
+{
+ int n_counter;
+
+ decrement_counters_in_path(p_s_tb->tb_path);
+
+ for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) {
+ decrement_bcount(p_s_tb->L[n_counter]);
+ p_s_tb->L[n_counter] = NULL;
+ decrement_bcount(p_s_tb->R[n_counter]);
+ p_s_tb->R[n_counter] = NULL;
+ decrement_bcount(p_s_tb->FL[n_counter]);
+ p_s_tb->FL[n_counter] = NULL;
+ decrement_bcount(p_s_tb->FR[n_counter]);
+ p_s_tb->FR[n_counter] = NULL;
+ decrement_bcount(p_s_tb->CFL[n_counter]);
+ p_s_tb->CFL[n_counter] = NULL;
+ decrement_bcount(p_s_tb->CFR[n_counter]);
+ p_s_tb->CFR[n_counter] = NULL;
+ }
}
-
/* Get new buffers for storing new nodes that are created while balancing.
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
* NO_DISK_SPACE - no disk space.
*/
/* The function is NOT SCHEDULE-SAFE! */
-static int get_empty_nodes(
- struct tree_balance * p_s_tb,
- int n_h
- ) {
- struct buffer_head * p_s_new_bh,
- * p_s_Sh = PATH_H_PBUFFER (p_s_tb->tb_path, n_h);
- b_blocknr_t * p_n_blocknr,
- a_n_blocknrs[MAX_AMOUNT_NEEDED] = {0, };
- int n_counter,
- n_number_of_freeblk,
- n_amount_needed,/* number of needed empty blocks */
- n_retval = CARRY_ON;
- struct super_block * p_s_sb = p_s_tb->tb_sb;
-
-
- /* number_of_freeblk is the number of empty blocks which have been
- acquired for use by the balancing algorithm minus the number of
- empty blocks used in the previous levels of the analysis,
- number_of_freeblk = tb->cur_blknum can be non-zero if a schedule occurs
- after empty blocks are acquired, and the balancing analysis is
- then restarted, amount_needed is the number needed by this level
- (n_h) of the balancing analysis.
-
- Note that for systems with many processes writing, it would be
- more layout optimal to calculate the total number needed by all
- levels and then to run reiserfs_new_blocks to get all of them at once. */
-
- /* Initiate number_of_freeblk to the amount acquired prior to the restart of
- the analysis or 0 if not restarted, then subtract the amount needed
- by all of the levels of the tree below n_h. */
- /* blknum includes S[n_h], so we subtract 1 in this calculation */
- for ( n_counter = 0, n_number_of_freeblk = p_s_tb->cur_blknum; n_counter < n_h; n_counter++ )
- n_number_of_freeblk -= ( p_s_tb->blknum[n_counter] ) ? (p_s_tb->blknum[n_counter] - 1) : 0;
-
- /* Allocate missing empty blocks. */
- /* if p_s_Sh == 0 then we are getting a new root */
- n_amount_needed = ( p_s_Sh ) ? (p_s_tb->blknum[n_h] - 1) : 1;
- /* Amount_needed = the amount that we need more than the amount that we have. */
- if ( n_amount_needed > n_number_of_freeblk )
- n_amount_needed -= n_number_of_freeblk;
- else /* If we have enough already then there is nothing to do. */
- return CARRY_ON;
-
- /* No need to check quota - is not allocated for blocks used for formatted nodes */
- if (reiserfs_new_form_blocknrs (p_s_tb, a_n_blocknrs,
- n_amount_needed) == NO_DISK_SPACE)
- return NO_DISK_SPACE;
-
- /* for each blocknumber we just got, get a buffer and stick it on FEB */
- for ( p_n_blocknr = a_n_blocknrs, n_counter = 0; n_counter < n_amount_needed;
- p_n_blocknr++, n_counter++ ) {
-
- RFALSE( ! *p_n_blocknr,
- "PAP-8135: reiserfs_new_blocknrs failed when got new blocks");
-
- p_s_new_bh = sb_getblk(p_s_sb, *p_n_blocknr);
- RFALSE (buffer_dirty (p_s_new_bh) ||
- buffer_journaled (p_s_new_bh) ||
- buffer_journal_dirty (p_s_new_bh),
- "PAP-8140: journlaled or dirty buffer %b for the new block",
- p_s_new_bh);
-
- /* Put empty buffers into the array. */
- RFALSE (p_s_tb->FEB[p_s_tb->cur_blknum],
- "PAP-8141: busy slot for new buffer");
-
- set_buffer_journal_new (p_s_new_bh);
- p_s_tb->FEB[p_s_tb->cur_blknum++] = p_s_new_bh;
- }
-
- if ( n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB (p_s_tb) )
- n_retval = REPEAT_SEARCH ;
-
- return n_retval;
-}
+static int get_empty_nodes(struct tree_balance *p_s_tb, int n_h)
+{
+ struct buffer_head *p_s_new_bh,
+ *p_s_Sh = PATH_H_PBUFFER(p_s_tb->tb_path, n_h);
+ b_blocknr_t *p_n_blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
+ int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */
+ n_retval = CARRY_ON;
+ struct super_block *p_s_sb = p_s_tb->tb_sb;
+
+ /* number_of_freeblk is the number of empty blocks which have been
+ acquired for use by the balancing algorithm minus the number of
+ empty blocks used in the previous levels of the analysis,
+ number_of_freeblk = tb->cur_blknum can be non-zero if a schedule occurs
+ after empty blocks are acquired, and the balancing analysis is
+ then restarted, amount_needed is the number needed by this level
+ (n_h) of the balancing analysis.
+
+ Note that for systems with many processes writing, it would be
+ more layout optimal to calculate the total number needed by all
+ levels and then to run reiserfs_new_blocks to get all of them at once. */
+
+ /* Initiate number_of_freeblk to the amount acquired prior to the restart of
+ the analysis or 0 if not restarted, then subtract the amount needed
+ by all of the levels of the tree below n_h. */
+ /* blknum includes S[n_h], so we subtract 1 in this calculation */
+ for (n_counter = 0, n_number_of_freeblk = p_s_tb->cur_blknum;
+ n_counter < n_h; n_counter++)
+ n_number_of_freeblk -=
+ (p_s_tb->blknum[n_counter]) ? (p_s_tb->blknum[n_counter] -
+ 1) : 0;
+
+ /* Allocate missing empty blocks. */
+ /* if p_s_Sh == 0 then we are getting a new root */
+ n_amount_needed = (p_s_Sh) ? (p_s_tb->blknum[n_h] - 1) : 1;
+ /* Amount_needed = the amount that we need more than the amount that we have. */
+ if (n_amount_needed > n_number_of_freeblk)
+ n_amount_needed -= n_number_of_freeblk;
+ else /* If we have enough already then there is nothing to do. */
+ return CARRY_ON;
+
+ /* No need to check quota - is not allocated for blocks used for formatted nodes */
+ if (reiserfs_new_form_blocknrs(p_s_tb, a_n_blocknrs,
+ n_amount_needed) == NO_DISK_SPACE)
+ return NO_DISK_SPACE;
+
+ /* for each blocknumber we just got, get a buffer and stick it on FEB */
+ for (p_n_blocknr = a_n_blocknrs, n_counter = 0;
+ n_counter < n_amount_needed; p_n_blocknr++, n_counter++) {
+
+ RFALSE(!*p_n_blocknr,
+ "PAP-8135: reiserfs_new_blocknrs failed when got new blocks");
+
+ p_s_new_bh = sb_getblk(p_s_sb, *p_n_blocknr);
+ RFALSE(buffer_dirty(p_s_new_bh) ||
+ buffer_journaled(p_s_new_bh) ||
+ buffer_journal_dirty(p_s_new_bh),
+ "PAP-8140: journlaled or dirty buffer %b for the new block",
+ p_s_new_bh);
+
+ /* Put empty buffers into the array. */
+ RFALSE(p_s_tb->FEB[p_s_tb->cur_blknum],
+ "PAP-8141: busy slot for new buffer");
+
+ set_buffer_journal_new(p_s_new_bh);
+ p_s_tb->FEB[p_s_tb->cur_blknum++] = p_s_new_bh;
+ }
+
+ if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(p_s_tb))
+ n_retval = REPEAT_SEARCH;
+ return n_retval;
+}
/* Get free space of the left neighbor, which is stored in the parent
* node of the left neighbor. */
-static int get_lfree (struct tree_balance * tb, int h)
+static int get_lfree(struct tree_balance *tb, int h)
{
- struct buffer_head * l, * f;
- int order;
+ struct buffer_head *l, *f;
+ int order;
- if ((f = PATH_H_PPARENT (tb->tb_path, h)) == 0 || (l = tb->FL[h]) == 0)
- return 0;
+ if ((f = PATH_H_PPARENT(tb->tb_path, h)) == 0 || (l = tb->FL[h]) == 0)
+ return 0;
- if (f == l)
- order = PATH_H_B_ITEM_ORDER (tb->tb_path, h) - 1;
- else {
- order = B_NR_ITEMS (l);
- f = l;
- }
+ if (f == l)
+ order = PATH_H_B_ITEM_ORDER(tb->tb_path, h) - 1;
+ else {
+ order = B_NR_ITEMS(l);
+ f = l;
+ }
- return (MAX_CHILD_SIZE(f) - dc_size(B_N_CHILD(f,order)));
+ return (MAX_CHILD_SIZE(f) - dc_size(B_N_CHILD(f, order)));
}
-
/* Get free space of the right neighbor,
* which is stored in the parent node of the right neighbor.
*/
-static int get_rfree (struct tree_balance * tb, int h)
+static int get_rfree(struct tree_balance *tb, int h)
{
- struct buffer_head * r, * f;
- int order;
+ struct buffer_head *r, *f;
+ int order;
- if ((f = PATH_H_PPARENT (tb->tb_path, h)) == 0 || (r = tb->FR[h]) == 0)
- return 0;
+ if ((f = PATH_H_PPARENT(tb->tb_path, h)) == 0 || (r = tb->FR[h]) == 0)
+ return 0;
- if (f == r)
- order = PATH_H_B_ITEM_ORDER (tb->tb_path, h) + 1;
- else {
- order = 0;
- f = r;
- }
+ if (f == r)
+ order = PATH_H_B_ITEM_ORDER(tb->tb_path, h) + 1;
+ else {
+ order = 0;
+ f = r;
+ }
- return (MAX_CHILD_SIZE(f) - dc_size( B_N_CHILD(f,order)));
+ return (MAX_CHILD_SIZE(f) - dc_size(B_N_CHILD(f, order)));
}
-
/* Check whether left neighbor is in memory. */
-static int is_left_neighbor_in_cache(
- struct tree_balance * p_s_tb,
- int n_h
- ) {
- struct buffer_head * p_s_father, * left;
- struct super_block * p_s_sb = p_s_tb->tb_sb;
- b_blocknr_t n_left_neighbor_blocknr;
- int n_left_neighbor_position;
-
- if ( ! p_s_tb->FL[n_h] ) /* Father of the left neighbor does not exist. */
- return 0;
-
- /* Calculate father of the node to be balanced. */
- p_s_father = PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1);
-
- RFALSE( ! p_s_father ||
- ! B_IS_IN_TREE (p_s_father) ||
- ! B_IS_IN_TREE (p_s_tb->FL[n_h]) ||
- ! buffer_uptodate (p_s_father) ||
- ! buffer_uptodate (p_s_tb->FL[n_h]),
- "vs-8165: F[h] (%b) or FL[h] (%b) is invalid",
- p_s_father, p_s_tb->FL[n_h]);
-
-
- /* Get position of the pointer to the left neighbor into the left father. */
- n_left_neighbor_position = ( p_s_father == p_s_tb->FL[n_h] ) ?
- p_s_tb->lkey[n_h] : B_NR_ITEMS (p_s_tb->FL[n_h]);
- /* Get left neighbor block number. */
- n_left_neighbor_blocknr = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_left_neighbor_position);
- /* Look for the left neighbor in the cache. */
- if ( (left = sb_find_get_block(p_s_sb, n_left_neighbor_blocknr)) ) {
-
- RFALSE( buffer_uptodate (left) && ! B_IS_IN_TREE(left),
- "vs-8170: left neighbor (%b %z) is not in the tree", left, left);
- put_bh(left) ;
- return 1;
- }
-
- return 0;
-}
+static int is_left_neighbor_in_cache(struct tree_balance *p_s_tb, int n_h)
+{
+ struct buffer_head *p_s_father, *left;
+ struct super_block *p_s_sb = p_s_tb->tb_sb;
+ b_blocknr_t n_left_neighbor_blocknr;
+ int n_left_neighbor_position;
+
+ if (!p_s_tb->FL[n_h]) /* Father of the left neighbor does not exist. */
+ return 0;
+
+ /* Calculate father of the node to be balanced. */
+ p_s_father = PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1);
+
+ RFALSE(!p_s_father ||
+ !B_IS_IN_TREE(p_s_father) ||
+ !B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
+ !buffer_uptodate(p_s_father) ||
+ !buffer_uptodate(p_s_tb->FL[n_h]),
+ "vs-8165: F[h] (%b) or FL[h] (%b) is invalid",
+ p_s_father, p_s_tb->FL[n_h]);
+
+ /* Get position of the pointer to the left neighbor into the left father. */
+ n_left_neighbor_position = (p_s_father == p_s_tb->FL[n_h]) ?
+ p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->FL[n_h]);
+ /* Get left neighbor block number. */
+ n_left_neighbor_blocknr =
+ B_N_CHILD_NUM(p_s_tb->FL[n_h], n_left_neighbor_position);
+ /* Look for the left neighbor in the cache. */
+ if ((left = sb_find_get_block(p_s_sb, n_left_neighbor_blocknr))) {
+
+ RFALSE(buffer_uptodate(left) && !B_IS_IN_TREE(left),
+ "vs-8170: left neighbor (%b %z) is not in the tree",
+ left, left);
+ put_bh(left);
+ return 1;
+ }
+ return 0;
+}
#define LEFT_PARENTS 'l'
#define RIGHT_PARENTS 'r'
-
-static void decrement_key (struct cpu_key * p_s_key)
+static void decrement_key(struct cpu_key *p_s_key)
{
- // call item specific function for this key
- item_ops[cpu_key_k_type (p_s_key)]->decrement_key (p_s_key);
+ // call item specific function for this key
+ item_ops[cpu_key_k_type(p_s_key)]->decrement_key(p_s_key);
}
-
-
-
/* Calculate far left/right parent of the left/right neighbor of the current node, that
* is calculate the left/right (FL[h]/FR[h]) neighbor of the parent F[h].
* Calculate left/right common parent of the current node and L[h]/R[h].
@@ -940,111 +953,121 @@ static void decrement_key (struct cpu_key * p_s_key)
SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_far_parent (struct tree_balance * p_s_tb,
- int n_h,
- struct buffer_head ** pp_s_father,
- struct buffer_head ** pp_s_com_father,
- char c_lr_par)
+static int get_far_parent(struct tree_balance *p_s_tb,
+ int n_h,
+ struct buffer_head **pp_s_father,
+ struct buffer_head **pp_s_com_father, char c_lr_par)
{
- struct buffer_head * p_s_parent;
- INITIALIZE_PATH (s_path_to_neighbor_father);
- struct path * p_s_path = p_s_tb->tb_path;
- struct cpu_key s_lr_father_key;
- int n_counter,
- n_position = INT_MAX,
- n_first_last_position = 0,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_path, n_h);
-
- /* Starting from F[n_h] go upwards in the tree, and look for the common
- ancestor of F[n_h], and its neighbor l/r, that should be obtained. */
-
- n_counter = n_path_offset;
-
- RFALSE( n_counter < FIRST_PATH_ELEMENT_OFFSET,
- "PAP-8180: invalid path length");
-
-
- for ( ; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter-- ) {
- /* Check whether parent of the current buffer in the path is really parent in the tree. */
- if ( ! B_IS_IN_TREE(p_s_parent = PATH_OFFSET_PBUFFER(p_s_path, n_counter - 1)) )
- return REPEAT_SEARCH;
- /* Check whether position in the parent is correct. */
- if ( (n_position = PATH_OFFSET_POSITION(p_s_path, n_counter - 1)) > B_NR_ITEMS(p_s_parent) )
- return REPEAT_SEARCH;
- /* Check whether parent at the path really points to the child. */
- if ( B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_path, n_counter)->b_blocknr )
- return REPEAT_SEARCH;
- /* Return delimiting key if position in the parent is not equal to first/last one. */
- if ( c_lr_par == RIGHT_PARENTS )
- n_first_last_position = B_NR_ITEMS (p_s_parent);
- if ( n_position != n_first_last_position ) {
- *pp_s_com_father = p_s_parent;
- get_bh(*pp_s_com_father) ;
- /*(*pp_s_com_father = p_s_parent)->b_count++;*/
- break;
+ struct buffer_head *p_s_parent;
+ INITIALIZE_PATH(s_path_to_neighbor_father);
+ struct path *p_s_path = p_s_tb->tb_path;
+ struct cpu_key s_lr_father_key;
+ int n_counter,
+ n_position = INT_MAX,
+ n_first_last_position = 0,
+ n_path_offset = PATH_H_PATH_OFFSET(p_s_path, n_h);
+
+ /* Starting from F[n_h] go upwards in the tree, and look for the common
+ ancestor of F[n_h], and its neighbor l/r, that should be obtained. */
+
+ n_counter = n_path_offset;
+
+ RFALSE(n_counter < FIRST_PATH_ELEMENT_OFFSET,
+ "PAP-8180: invalid path length");
+
+ for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) {
+ /* Check whether parent of the current buffer in the path is really parent in the tree. */
+ if (!B_IS_IN_TREE
+ (p_s_parent = PATH_OFFSET_PBUFFER(p_s_path, n_counter - 1)))
+ return REPEAT_SEARCH;
+ /* Check whether position in the parent is correct. */
+ if ((n_position =
+ PATH_OFFSET_POSITION(p_s_path,
+ n_counter - 1)) >
+ B_NR_ITEMS(p_s_parent))
+ return REPEAT_SEARCH;
+ /* Check whether parent at the path really points to the child. */
+ if (B_N_CHILD_NUM(p_s_parent, n_position) !=
+ PATH_OFFSET_PBUFFER(p_s_path, n_counter)->b_blocknr)
+ return REPEAT_SEARCH;
+ /* Return delimiting key if position in the parent is not equal to first/last one. */
+ if (c_lr_par == RIGHT_PARENTS)
+ n_first_last_position = B_NR_ITEMS(p_s_parent);
+ if (n_position != n_first_last_position) {
+ *pp_s_com_father = p_s_parent;
+ get_bh(*pp_s_com_father);
+ /*(*pp_s_com_father = p_s_parent)->b_count++; */
+ break;
+ }
}
- }
-
- /* if we are in the root of the tree, then there is no common father */
- if ( n_counter == FIRST_PATH_ELEMENT_OFFSET ) {
- /* Check whether first buffer in the path is the root of the tree. */
- if ( PATH_OFFSET_PBUFFER(p_s_tb->tb_path, FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
- SB_ROOT_BLOCK (p_s_tb->tb_sb) ) {
- *pp_s_father = *pp_s_com_father = NULL;
- return CARRY_ON;
+
+ /* if we are in the root of the tree, then there is no common father */
+ if (n_counter == FIRST_PATH_ELEMENT_OFFSET) {
+ /* Check whether first buffer in the path is the root of the tree. */
+ if (PATH_OFFSET_PBUFFER
+ (p_s_tb->tb_path,
+ FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
+ SB_ROOT_BLOCK(p_s_tb->tb_sb)) {
+ *pp_s_father = *pp_s_com_father = NULL;
+ return CARRY_ON;
+ }
+ return REPEAT_SEARCH;
}
- return REPEAT_SEARCH;
- }
- RFALSE( B_LEVEL (*pp_s_com_father) <= DISK_LEAF_NODE_LEVEL,
- "PAP-8185: (%b %z) level too small",
- *pp_s_com_father, *pp_s_com_father);
+ RFALSE(B_LEVEL(*pp_s_com_father) <= DISK_LEAF_NODE_LEVEL,
+ "PAP-8185: (%b %z) level too small",
+ *pp_s_com_father, *pp_s_com_father);
- /* Check whether the common parent is locked. */
+ /* Check whether the common parent is locked. */
- if ( buffer_locked (*pp_s_com_father) ) {
- __wait_on_buffer(*pp_s_com_father);
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) {
- decrement_bcount(*pp_s_com_father);
- return REPEAT_SEARCH;
+ if (buffer_locked(*pp_s_com_father)) {
+ __wait_on_buffer(*pp_s_com_father);
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ decrement_bcount(*pp_s_com_father);
+ return REPEAT_SEARCH;
+ }
}
- }
-
- /* So, we got common parent of the current node and its left/right neighbor.
- Now we are geting the parent of the left/right neighbor. */
- /* Form key to get parent of the left/right neighbor. */
- le_key2cpu_key (&s_lr_father_key, B_N_PDELIM_KEY(*pp_s_com_father, ( c_lr_par == LEFT_PARENTS ) ?
- (p_s_tb->lkey[n_h - 1] = n_position - 1) : (p_s_tb->rkey[n_h - 1] = n_position)));
+ /* So, we got common parent of the current node and its left/right neighbor.
+ Now we are geting the parent of the left/right neighbor. */
+ /* Form key to get parent of the left/right neighbor. */
+ le_key2cpu_key(&s_lr_father_key,
+ B_N_PDELIM_KEY(*pp_s_com_father,
+ (c_lr_par ==
+ LEFT_PARENTS) ? (p_s_tb->lkey[n_h - 1] =
+ n_position -
+ 1) : (p_s_tb->rkey[n_h -
+ 1] =
+ n_position)));
- if ( c_lr_par == LEFT_PARENTS )
- decrement_key(&s_lr_father_key);
+ if (c_lr_par == LEFT_PARENTS)
+ decrement_key(&s_lr_father_key);
- if (search_by_key(p_s_tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father, n_h + 1) == IO_ERROR)
- // path is released
- return IO_ERROR;
+ if (search_by_key
+ (p_s_tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father,
+ n_h + 1) == IO_ERROR)
+ // path is released
+ return IO_ERROR;
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) {
- decrement_counters_in_path(&s_path_to_neighbor_father);
- decrement_bcount(*pp_s_com_father);
- return REPEAT_SEARCH;
- }
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ decrement_counters_in_path(&s_path_to_neighbor_father);
+ decrement_bcount(*pp_s_com_father);
+ return REPEAT_SEARCH;
+ }
- *pp_s_father = PATH_PLAST_BUFFER(&s_path_to_neighbor_father);
+ *pp_s_father = PATH_PLAST_BUFFER(&s_path_to_neighbor_father);
- RFALSE( B_LEVEL (*pp_s_father) != n_h + 1,
- "PAP-8190: (%b %z) level too small", *pp_s_father, *pp_s_father);
- RFALSE( s_path_to_neighbor_father.path_length < FIRST_PATH_ELEMENT_OFFSET,
- "PAP-8192: path length is too small");
+ RFALSE(B_LEVEL(*pp_s_father) != n_h + 1,
+ "PAP-8190: (%b %z) level too small", *pp_s_father, *pp_s_father);
+ RFALSE(s_path_to_neighbor_father.path_length <
+ FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small");
- s_path_to_neighbor_father.path_length--;
- decrement_counters_in_path(&s_path_to_neighbor_father);
- return CARRY_ON;
+ s_path_to_neighbor_father.path_length--;
+ decrement_counters_in_path(&s_path_to_neighbor_father);
+ return CARRY_ON;
}
-
/* Get parents of neighbors of node in the path(S[n_path_offset]) and common parents of
* S[n_path_offset] and L[n_path_offset]/R[n_path_offset]: F[n_path_offset], FL[n_path_offset],
* FR[n_path_offset], CFL[n_path_offset], CFR[n_path_offset].
@@ -1052,122 +1075,127 @@ static int get_far_parent (struct tree_balance * p_s_tb,
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_parents (struct tree_balance * p_s_tb, int n_h)
+static int get_parents(struct tree_balance *p_s_tb, int n_h)
{
- struct path * p_s_path = p_s_tb->tb_path;
- int n_position,
- n_ret_value,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
- struct buffer_head * p_s_curf,
- * p_s_curcf;
-
- /* Current node is the root of the tree or will be root of the tree */
- if ( n_path_offset <= FIRST_PATH_ELEMENT_OFFSET ) {
- /* The root can not have parents.
- Release nodes which previously were obtained as parents of the current node neighbors. */
+ struct path *p_s_path = p_s_tb->tb_path;
+ int n_position,
+ n_ret_value,
+ n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
+ struct buffer_head *p_s_curf, *p_s_curcf;
+
+ /* Current node is the root of the tree or will be root of the tree */
+ if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
+ /* The root can not have parents.
+ Release nodes which previously were obtained as parents of the current node neighbors. */
+ decrement_bcount(p_s_tb->FL[n_h]);
+ decrement_bcount(p_s_tb->CFL[n_h]);
+ decrement_bcount(p_s_tb->FR[n_h]);
+ decrement_bcount(p_s_tb->CFR[n_h]);
+ p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] =
+ p_s_tb->CFR[n_h] = NULL;
+ return CARRY_ON;
+ }
+
+ /* Get parent FL[n_path_offset] of L[n_path_offset]. */
+ if ((n_position = PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1))) {
+ /* Current node is not the first child of its parent. */
+ /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */
+ p_s_curf = p_s_curcf =
+ PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
+ get_bh(p_s_curf);
+ get_bh(p_s_curf);
+ p_s_tb->lkey[n_h] = n_position - 1;
+ } else {
+ /* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node.
+ Calculate current common parent of L[n_path_offset] and the current node. Note that
+ CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset].
+ Calculate lkey[n_path_offset]. */
+ if ((n_ret_value = get_far_parent(p_s_tb, n_h + 1, &p_s_curf,
+ &p_s_curcf,
+ LEFT_PARENTS)) != CARRY_ON)
+ return n_ret_value;
+ }
+
decrement_bcount(p_s_tb->FL[n_h]);
+ p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
decrement_bcount(p_s_tb->CFL[n_h]);
- decrement_bcount(p_s_tb->FR[n_h]);
- decrement_bcount(p_s_tb->CFR[n_h]);
- p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] = p_s_tb->CFR[n_h] = NULL;
- return CARRY_ON;
- }
-
- /* Get parent FL[n_path_offset] of L[n_path_offset]. */
- if ( (n_position = PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1)) ) {
- /* Current node is not the first child of its parent. */
- /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2;*/
- p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
- get_bh(p_s_curf) ;
- get_bh(p_s_curf) ;
- p_s_tb->lkey[n_h] = n_position - 1;
- }
- else {
- /* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node.
- Calculate current common parent of L[n_path_offset] and the current node. Note that
- CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset].
- Calculate lkey[n_path_offset]. */
- if ( (n_ret_value = get_far_parent(p_s_tb, n_h + 1, &p_s_curf,
- &p_s_curcf, LEFT_PARENTS)) != CARRY_ON )
- return n_ret_value;
- }
-
- decrement_bcount(p_s_tb->FL[n_h]);
- p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
- decrement_bcount(p_s_tb->CFL[n_h]);
- p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
-
- RFALSE( (p_s_curf && !B_IS_IN_TREE (p_s_curf)) ||
- (p_s_curcf && !B_IS_IN_TREE (p_s_curcf)),
- "PAP-8195: FL (%b) or CFL (%b) is invalid", p_s_curf, p_s_curcf);
+ p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
+
+ RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
+ (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
+ "PAP-8195: FL (%b) or CFL (%b) is invalid", p_s_curf, p_s_curcf);
/* Get parent FR[n_h] of R[n_h]. */
/* Current node is the last child of F[n_h]. FR[n_h] != F[n_h]. */
- if ( n_position == B_NR_ITEMS (PATH_H_PBUFFER(p_s_path, n_h + 1)) ) {
+ if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(p_s_path, n_h + 1))) {
/* Calculate current parent of R[n_h], which is the right neighbor of F[n_h].
Calculate current common parent of R[n_h] and current node. Note that CFR[n_h]
not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */
- if ( (n_ret_value = get_far_parent(p_s_tb, n_h + 1, &p_s_curf, &p_s_curcf, RIGHT_PARENTS)) != CARRY_ON )
- return n_ret_value;
- }
- else {
+ if ((n_ret_value =
+ get_far_parent(p_s_tb, n_h + 1, &p_s_curf, &p_s_curcf,
+ RIGHT_PARENTS)) != CARRY_ON)
+ return n_ret_value;
+ } else {
/* Current node is not the last child of its parent F[n_h]. */
- /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2;*/
- p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
- get_bh(p_s_curf) ;
- get_bh(p_s_curf) ;
- p_s_tb->rkey[n_h] = n_position;
- }
-
- decrement_bcount(p_s_tb->FR[n_h]);
- p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
-
- decrement_bcount(p_s_tb->CFR[n_h]);
- p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
-
- RFALSE( (p_s_curf && !B_IS_IN_TREE (p_s_curf)) ||
- (p_s_curcf && !B_IS_IN_TREE (p_s_curcf)),
- "PAP-8205: FR (%b) or CFR (%b) is invalid", p_s_curf, p_s_curcf);
-
- return CARRY_ON;
-}
+ /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */
+ p_s_curf = p_s_curcf =
+ PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
+ get_bh(p_s_curf);
+ get_bh(p_s_curf);
+ p_s_tb->rkey[n_h] = n_position;
+ }
+ decrement_bcount(p_s_tb->FR[n_h]);
+ p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
+
+ decrement_bcount(p_s_tb->CFR[n_h]);
+ p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
+
+ RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
+ (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
+ "PAP-8205: FR (%b) or CFR (%b) is invalid", p_s_curf, p_s_curcf);
+
+ return CARRY_ON;
+}
/* it is possible to remove node as result of shiftings to
neighbors even when we insert or paste item. */
-static inline int can_node_be_removed (int mode, int lfree, int sfree, int rfree, struct tree_balance * tb, int h)
+static inline int can_node_be_removed(int mode, int lfree, int sfree, int rfree,
+ struct tree_balance *tb, int h)
{
- struct buffer_head * Sh = PATH_H_PBUFFER (tb->tb_path, h);
- int levbytes = tb->insert_size[h];
- struct item_head * ih;
- struct reiserfs_key * r_key = NULL;
-
- ih = B_N_PITEM_HEAD (Sh, 0);
- if ( tb->CFR[h] )
- r_key = B_N_PDELIM_KEY(tb->CFR[h],tb->rkey[h]);
-
- if (
- lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes
- /* shifting may merge items which might save space */
- - (( ! h && op_is_left_mergeable (&(ih->ih_key), Sh->b_size) ) ? IH_SIZE : 0)
- - (( ! h && r_key && op_is_left_mergeable (r_key, Sh->b_size) ) ? IH_SIZE : 0)
- + (( h ) ? KEY_SIZE : 0))
- {
- /* node can not be removed */
- if (sfree >= levbytes ) { /* new item fits into node S[h] without any shifting */
- if ( ! h )
- tb->s0num = B_NR_ITEMS(Sh) + ((mode == M_INSERT ) ? 1 : 0);
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED;
+ struct buffer_head *Sh = PATH_H_PBUFFER(tb->tb_path, h);
+ int levbytes = tb->insert_size[h];
+ struct item_head *ih;
+ struct reiserfs_key *r_key = NULL;
+
+ ih = B_N_PITEM_HEAD(Sh, 0);
+ if (tb->CFR[h])
+ r_key = B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]);
+
+ if (lfree + rfree + sfree < MAX_CHILD_SIZE(Sh) + levbytes
+ /* shifting may merge items which might save space */
+ -
+ ((!h
+ && op_is_left_mergeable(&(ih->ih_key), Sh->b_size)) ? IH_SIZE : 0)
+ -
+ ((!h && r_key
+ && op_is_left_mergeable(r_key, Sh->b_size)) ? IH_SIZE : 0)
+ + ((h) ? KEY_SIZE : 0)) {
+ /* node can not be removed */
+ if (sfree >= levbytes) { /* new item fits into node S[h] without any shifting */
+ if (!h)
+ tb->s0num =
+ B_NR_ITEMS(Sh) +
+ ((mode == M_INSERT) ? 1 : 0);
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED;
+ }
}
- }
- PROC_INFO_INC( tb -> tb_sb, can_node_be_removed[ h ] );
- return !NO_BALANCING_NEEDED;
+ PROC_INFO_INC(tb->tb_sb, can_node_be_removed[h]);
+ return !NO_BALANCING_NEEDED;
}
-
-
/* Check whether current node S[h] is balanced when increasing its size by
* Inserting or Pasting.
* Calculate parameters for balancing for current level h.
@@ -1182,154 +1210,157 @@ static inline int can_node_be_removed (int mode, int lfree, int sfree, int rfree
* -2 - no disk space.
*/
/* ip means Inserting or Pasting */
-static int ip_check_balance (struct tree_balance * tb, int h)
+static int ip_check_balance(struct tree_balance *tb, int h)
{
- struct virtual_node * vn = tb->tb_vn;
- int levbytes, /* Number of bytes that must be inserted into (value
- is negative if bytes are deleted) buffer which
- contains node being balanced. The mnemonic is
- that the attempted change in node space used level
- is levbytes bytes. */
- n_ret_value;
-
- int lfree, sfree, rfree /* free space in L, S and R */;
-
- /* nver is short for number of vertixes, and lnver is the number if
- we shift to the left, rnver is the number if we shift to the
- right, and lrnver is the number if we shift in both directions.
- The goal is to minimize first the number of vertixes, and second,
- the number of vertixes whose contents are changed by shifting,
- and third the number of uncached vertixes whose contents are
- changed by shifting and must be read from disk. */
- int nver, lnver, rnver, lrnver;
-
- /* used at leaf level only, S0 = S[0] is the node being balanced,
- sInum [ I = 0,1,2 ] is the number of items that will
- remain in node SI after balancing. S1 and S2 are new
- nodes that might be created. */
-
- /* we perform 8 calls to get_num_ver(). For each call we calculate five parameters.
- where 4th parameter is s1bytes and 5th - s2bytes
- */
- short snum012[40] = {0,}; /* s0num, s1num, s2num for 8 cases
- 0,1 - do not shift and do not shift but bottle
- 2 - shift only whole item to left
- 3 - shift to left and bottle as much as possible
- 4,5 - shift to right (whole items and as much as possible
- 6,7 - shift to both directions (whole items and as much as possible)
- */
-
- /* Sh is the node whose balance is currently being checked */
- struct buffer_head * Sh;
-
- Sh = PATH_H_PBUFFER (tb->tb_path, h);
- levbytes = tb->insert_size[h];
-
- /* Calculate balance parameters for creating new root. */
- if ( ! Sh ) {
- if ( ! h )
- reiserfs_panic (tb->tb_sb, "vs-8210: ip_check_balance: S[0] can not be 0");
- switch ( n_ret_value = get_empty_nodes (tb, h) ) {
- case CARRY_ON:
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */
-
- case NO_DISK_SPACE:
- case REPEAT_SEARCH:
- return n_ret_value;
- default:
- reiserfs_panic(tb->tb_sb, "vs-8215: ip_check_balance: incorrect return value of get_empty_nodes");
+ struct virtual_node *vn = tb->tb_vn;
+ int levbytes, /* Number of bytes that must be inserted into (value
+ is negative if bytes are deleted) buffer which
+ contains node being balanced. The mnemonic is
+ that the attempted change in node space used level
+ is levbytes bytes. */
+ n_ret_value;
+
+ int lfree, sfree, rfree /* free space in L, S and R */ ;
+
+ /* nver is short for number of vertixes, and lnver is the number if
+ we shift to the left, rnver is the number if we shift to the
+ right, and lrnver is the number if we shift in both directions.
+ The goal is to minimize first the number of vertixes, and second,
+ the number of vertixes whose contents are changed by shifting,
+ and third the number of uncached vertixes whose contents are
+ changed by shifting and must be read from disk. */
+ int nver, lnver, rnver, lrnver;
+
+ /* used at leaf level only, S0 = S[0] is the node being balanced,
+ sInum [ I = 0,1,2 ] is the number of items that will
+ remain in node SI after balancing. S1 and S2 are new
+ nodes that might be created. */
+
+ /* we perform 8 calls to get_num_ver(). For each call we calculate five parameters.
+ where 4th parameter is s1bytes and 5th - s2bytes
+ */
+ short snum012[40] = { 0, }; /* s0num, s1num, s2num for 8 cases
+ 0,1 - do not shift and do not shift but bottle
+ 2 - shift only whole item to left
+ 3 - shift to left and bottle as much as possible
+ 4,5 - shift to right (whole items and as much as possible
+ 6,7 - shift to both directions (whole items and as much as possible)
+ */
+
+ /* Sh is the node whose balance is currently being checked */
+ struct buffer_head *Sh;
+
+ Sh = PATH_H_PBUFFER(tb->tb_path, h);
+ levbytes = tb->insert_size[h];
+
+ /* Calculate balance parameters for creating new root. */
+ if (!Sh) {
+ if (!h)
+ reiserfs_panic(tb->tb_sb,
+ "vs-8210: ip_check_balance: S[0] can not be 0");
+ switch (n_ret_value = get_empty_nodes(tb, h)) {
+ case CARRY_ON:
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */
+
+ case NO_DISK_SPACE:
+ case REPEAT_SEARCH:
+ return n_ret_value;
+ default:
+ reiserfs_panic(tb->tb_sb,
+ "vs-8215: ip_check_balance: incorrect return value of get_empty_nodes");
+ }
}
- }
-
- if ( (n_ret_value = get_parents (tb, h)) != CARRY_ON ) /* get parents of S[h] neighbors. */
- return n_ret_value;
-
- sfree = B_FREE_SPACE (Sh);
-
- /* get free space of neighbors */
- rfree = get_rfree (tb, h);
- lfree = get_lfree (tb, h);
-
- if (can_node_be_removed (vn->vn_mode, lfree, sfree, rfree, tb, h) == NO_BALANCING_NEEDED)
- /* and new item fits into node S[h] without any shifting */
- return NO_BALANCING_NEEDED;
-
- create_virtual_node (tb, h);
-
- /*
- determine maximal number of items we can shift to the left neighbor (in tb structure)
- and the maximal number of bytes that can flow to the left neighbor
- from the left most liquid item that cannot be shifted from S[0] entirely (returned value)
- */
- check_left (tb, h, lfree);
-
- /*
- determine maximal number of items we can shift to the right neighbor (in tb structure)
- and the maximal number of bytes that can flow to the right neighbor
- from the right most liquid item that cannot be shifted from S[0] entirely (returned value)
- */
- check_right (tb, h, rfree);
-
-
- /* all contents of internal node S[h] can be moved into its
- neighbors, S[h] will be removed after balancing */
- if (h && (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1)) {
- int to_r;
-
- /* Since we are working on internal nodes, and our internal
- nodes have fixed size entries, then we can balance by the
- number of items rather than the space they consume. In this
- routine we set the left node equal to the right node,
- allowing a difference of less than or equal to 1 child
- pointer. */
- to_r = ((MAX_NR_KEY(Sh)<<1)+2-tb->lnum[h]-tb->rnum[h]+vn->vn_nr_item+1)/2 -
- (MAX_NR_KEY(Sh) + 1 - tb->rnum[h]);
- set_parameters (tb, h, vn->vn_nr_item + 1 - to_r, to_r, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- /* this checks balance condition, that any two neighboring nodes can not fit in one node */
- RFALSE( h &&
- ( tb->lnum[h] >= vn->vn_nr_item + 1 ||
- tb->rnum[h] >= vn->vn_nr_item + 1),
- "vs-8220: tree is not balanced on internal level");
- RFALSE( ! h && ((tb->lnum[h] >= vn->vn_nr_item && (tb->lbytes == -1)) ||
- (tb->rnum[h] >= vn->vn_nr_item && (tb->rbytes == -1)) ),
- "vs-8225: tree is not balanced on leaf level");
-
- /* all contents of S[0] can be moved into its neighbors
- S[0] will be removed after balancing. */
- if (!h && is_leaf_removable (tb))
- return CARRY_ON;
+ if ((n_ret_value = get_parents(tb, h)) != CARRY_ON) /* get parents of S[h] neighbors. */
+ return n_ret_value;
- /* why do we perform this check here rather than earlier??
- Answer: we can win 1 node in some cases above. Moreover we
- checked it above, when we checked, that S[0] is not removable
- in principle */
- if (sfree >= levbytes) { /* new item fits into node S[h] without any shifting */
- if ( ! h )
- tb->s0num = vn->vn_nr_item;
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED;
- }
+ sfree = B_FREE_SPACE(Sh);
+
+ /* get free space of neighbors */
+ rfree = get_rfree(tb, h);
+ lfree = get_lfree(tb, h);
+
+ if (can_node_be_removed(vn->vn_mode, lfree, sfree, rfree, tb, h) ==
+ NO_BALANCING_NEEDED)
+ /* and new item fits into node S[h] without any shifting */
+ return NO_BALANCING_NEEDED;
+ create_virtual_node(tb, h);
- {
- int lpar, rpar, nset, lset, rset, lrset;
- /*
- * regular overflowing of the node
+ /*
+ determine maximal number of items we can shift to the left neighbor (in tb structure)
+ and the maximal number of bytes that can flow to the left neighbor
+ from the left most liquid item that cannot be shifted from S[0] entirely (returned value)
*/
+ check_left(tb, h, lfree);
- /* get_num_ver works in 2 modes (FLOW & NO_FLOW)
- lpar, rpar - number of items we can shift to left/right neighbor (including splitting item)
- nset, lset, rset, lrset - shows, whether flowing items give better packing
- */
+ /*
+ determine maximal number of items we can shift to the right neighbor (in tb structure)
+ and the maximal number of bytes that can flow to the right neighbor
+ from the right most liquid item that cannot be shifted from S[0] entirely (returned value)
+ */
+ check_right(tb, h, rfree);
+
+ /* all contents of internal node S[h] can be moved into its
+ neighbors, S[h] will be removed after balancing */
+ if (h && (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1)) {
+ int to_r;
+
+ /* Since we are working on internal nodes, and our internal
+ nodes have fixed size entries, then we can balance by the
+ number of items rather than the space they consume. In this
+ routine we set the left node equal to the right node,
+ allowing a difference of less than or equal to 1 child
+ pointer. */
+ to_r =
+ ((MAX_NR_KEY(Sh) << 1) + 2 - tb->lnum[h] - tb->rnum[h] +
+ vn->vn_nr_item + 1) / 2 - (MAX_NR_KEY(Sh) + 1 -
+ tb->rnum[h]);
+ set_parameters(tb, h, vn->vn_nr_item + 1 - to_r, to_r, 0, NULL,
+ -1, -1);
+ return CARRY_ON;
+ }
+
+ /* this checks balance condition, that any two neighboring nodes can not fit in one node */
+ RFALSE(h &&
+ (tb->lnum[h] >= vn->vn_nr_item + 1 ||
+ tb->rnum[h] >= vn->vn_nr_item + 1),
+ "vs-8220: tree is not balanced on internal level");
+ RFALSE(!h && ((tb->lnum[h] >= vn->vn_nr_item && (tb->lbytes == -1)) ||
+ (tb->rnum[h] >= vn->vn_nr_item && (tb->rbytes == -1))),
+ "vs-8225: tree is not balanced on leaf level");
+
+ /* all contents of S[0] can be moved into its neighbors
+ S[0] will be removed after balancing. */
+ if (!h && is_leaf_removable(tb))
+ return CARRY_ON;
+
+ /* why do we perform this check here rather than earlier??
+ Answer: we can win 1 node in some cases above. Moreover we
+ checked it above, when we checked, that S[0] is not removable
+ in principle */
+ if (sfree >= levbytes) { /* new item fits into node S[h] without any shifting */
+ if (!h)
+ tb->s0num = vn->vn_nr_item;
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED;
+ }
+
+ {
+ int lpar, rpar, nset, lset, rset, lrset;
+ /*
+ * regular overflowing of the node
+ */
+
+ /* get_num_ver works in 2 modes (FLOW & NO_FLOW)
+ lpar, rpar - number of items we can shift to left/right neighbor (including splitting item)
+ nset, lset, rset, lrset - shows, whether flowing items give better packing
+ */
#define FLOW 1
-#define NO_FLOW 0 /* do not any splitting */
+#define NO_FLOW 0 /* do not any splitting */
- /* we choose one the following */
+ /* we choose one the following */
#define NOTHING_SHIFT_NO_FLOW 0
#define NOTHING_SHIFT_FLOW 5
#define LEFT_SHIFT_NO_FLOW 10
@@ -1339,164 +1370,173 @@ static int ip_check_balance (struct tree_balance * tb, int h)
#define LR_SHIFT_NO_FLOW 30
#define LR_SHIFT_FLOW 35
+ lpar = tb->lnum[h];
+ rpar = tb->rnum[h];
+
+ /* calculate number of blocks S[h] must be split into when
+ nothing is shifted to the neighbors,
+ as well as number of items in each part of the split node (s012 numbers),
+ and number of bytes (s1bytes) of the shared drop which flow to S1 if any */
+ nset = NOTHING_SHIFT_NO_FLOW;
+ nver = get_num_ver(vn->vn_mode, tb, h,
+ 0, -1, h ? vn->vn_nr_item : 0, -1,
+ snum012, NO_FLOW);
+
+ if (!h) {
+ int nver1;
+
+ /* note, that in this case we try to bottle between S[0] and S1 (S1 - the first new node) */
+ nver1 = get_num_ver(vn->vn_mode, tb, h,
+ 0, -1, 0, -1,
+ snum012 + NOTHING_SHIFT_FLOW, FLOW);
+ if (nver > nver1)
+ nset = NOTHING_SHIFT_FLOW, nver = nver1;
+ }
- lpar = tb->lnum[h];
- rpar = tb->rnum[h];
-
-
- /* calculate number of blocks S[h] must be split into when
- nothing is shifted to the neighbors,
- as well as number of items in each part of the split node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any */
- nset = NOTHING_SHIFT_NO_FLOW;
- nver = get_num_ver (vn->vn_mode, tb, h,
- 0, -1, h?vn->vn_nr_item:0, -1,
- snum012, NO_FLOW);
-
- if (!h)
- {
- int nver1;
-
- /* note, that in this case we try to bottle between S[0] and S1 (S1 - the first new node) */
- nver1 = get_num_ver (vn->vn_mode, tb, h,
- 0, -1, 0, -1,
- snum012 + NOTHING_SHIFT_FLOW, FLOW);
- if (nver > nver1)
- nset = NOTHING_SHIFT_FLOW, nver = nver1;
- }
-
-
- /* calculate number of blocks S[h] must be split into when
- l_shift_num first items and l_shift_bytes of the right most
- liquid item to be shifted are shifted to the left neighbor,
- as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
- */
- lset = LEFT_SHIFT_NO_FLOW;
- lnver = get_num_ver (vn->vn_mode, tb, h,
- lpar - (( h || tb->lbytes == -1 ) ? 0 : 1), -1, h ? vn->vn_nr_item:0, -1,
- snum012 + LEFT_SHIFT_NO_FLOW, NO_FLOW);
- if (!h)
- {
- int lnver1;
-
- lnver1 = get_num_ver (vn->vn_mode, tb, h,
- lpar - ((tb->lbytes != -1) ? 1 : 0), tb->lbytes, 0, -1,
- snum012 + LEFT_SHIFT_FLOW, FLOW);
- if (lnver > lnver1)
- lset = LEFT_SHIFT_FLOW, lnver = lnver1;
- }
-
-
- /* calculate number of blocks S[h] must be split into when
- r_shift_num first items and r_shift_bytes of the left most
- liquid item to be shifted are shifted to the right neighbor,
- as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
- */
- rset = RIGHT_SHIFT_NO_FLOW;
- rnver = get_num_ver (vn->vn_mode, tb, h,
- 0, -1, h ? (vn->vn_nr_item-rpar) : (rpar - (( tb->rbytes != -1 ) ? 1 : 0)), -1,
- snum012 + RIGHT_SHIFT_NO_FLOW, NO_FLOW);
- if (!h)
- {
- int rnver1;
-
- rnver1 = get_num_ver (vn->vn_mode, tb, h,
- 0, -1, (rpar - ((tb->rbytes != -1) ? 1 : 0)), tb->rbytes,
- snum012 + RIGHT_SHIFT_FLOW, FLOW);
-
- if (rnver > rnver1)
- rset = RIGHT_SHIFT_FLOW, rnver = rnver1;
- }
-
-
- /* calculate number of blocks S[h] must be split into when
- items are shifted in both directions,
- as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
- */
- lrset = LR_SHIFT_NO_FLOW;
- lrnver = get_num_ver (vn->vn_mode, tb, h,
- lpar - ((h || tb->lbytes == -1) ? 0 : 1), -1, h ? (vn->vn_nr_item-rpar):(rpar - ((tb->rbytes != -1) ? 1 : 0)), -1,
- snum012 + LR_SHIFT_NO_FLOW, NO_FLOW);
- if (!h)
- {
- int lrnver1;
-
- lrnver1 = get_num_ver (vn->vn_mode, tb, h,
- lpar - ((tb->lbytes != -1) ? 1 : 0), tb->lbytes, (rpar - ((tb->rbytes != -1) ? 1 : 0)), tb->rbytes,
- snum012 + LR_SHIFT_FLOW, FLOW);
- if (lrnver > lrnver1)
- lrset = LR_SHIFT_FLOW, lrnver = lrnver1;
- }
-
-
+ /* calculate number of blocks S[h] must be split into when
+ l_shift_num first items and l_shift_bytes of the right most
+ liquid item to be shifted are shifted to the left neighbor,
+ as well as number of items in each part of the splitted node (s012 numbers),
+ and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ */
+ lset = LEFT_SHIFT_NO_FLOW;
+ lnver = get_num_ver(vn->vn_mode, tb, h,
+ lpar - ((h || tb->lbytes == -1) ? 0 : 1),
+ -1, h ? vn->vn_nr_item : 0, -1,
+ snum012 + LEFT_SHIFT_NO_FLOW, NO_FLOW);
+ if (!h) {
+ int lnver1;
+
+ lnver1 = get_num_ver(vn->vn_mode, tb, h,
+ lpar -
+ ((tb->lbytes != -1) ? 1 : 0),
+ tb->lbytes, 0, -1,
+ snum012 + LEFT_SHIFT_FLOW, FLOW);
+ if (lnver > lnver1)
+ lset = LEFT_SHIFT_FLOW, lnver = lnver1;
+ }
- /* Our general shifting strategy is:
- 1) to minimized number of new nodes;
- 2) to minimized number of neighbors involved in shifting;
- 3) to minimized number of disk reads; */
+ /* calculate number of blocks S[h] must be split into when
+ r_shift_num first items and r_shift_bytes of the left most
+ liquid item to be shifted are shifted to the right neighbor,
+ as well as number of items in each part of the splitted node (s012 numbers),
+ and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ */
+ rset = RIGHT_SHIFT_NO_FLOW;
+ rnver = get_num_ver(vn->vn_mode, tb, h,
+ 0, -1,
+ h ? (vn->vn_nr_item - rpar) : (rpar -
+ ((tb->
+ rbytes !=
+ -1) ? 1 :
+ 0)), -1,
+ snum012 + RIGHT_SHIFT_NO_FLOW, NO_FLOW);
+ if (!h) {
+ int rnver1;
+
+ rnver1 = get_num_ver(vn->vn_mode, tb, h,
+ 0, -1,
+ (rpar -
+ ((tb->rbytes != -1) ? 1 : 0)),
+ tb->rbytes,
+ snum012 + RIGHT_SHIFT_FLOW, FLOW);
+
+ if (rnver > rnver1)
+ rset = RIGHT_SHIFT_FLOW, rnver = rnver1;
+ }
- /* we can win TWO or ONE nodes by shifting in both directions */
- if (lrnver < lnver && lrnver < rnver)
- {
- RFALSE( h &&
- (tb->lnum[h] != 1 ||
- tb->rnum[h] != 1 ||
- lrnver != 1 || rnver != 2 || lnver != 2 || h != 1),
- "vs-8230: bad h");
- if (lrset == LR_SHIFT_FLOW)
- set_parameters (tb, h, tb->lnum[h], tb->rnum[h], lrnver, snum012 + lrset,
- tb->lbytes, tb->rbytes);
- else
- set_parameters (tb, h, tb->lnum[h] - ((tb->lbytes == -1) ? 0 : 1),
- tb->rnum[h] - ((tb->rbytes == -1) ? 0 : 1), lrnver, snum012 + lrset, -1, -1);
-
- return CARRY_ON;
- }
+ /* calculate number of blocks S[h] must be split into when
+ items are shifted in both directions,
+ as well as number of items in each part of the splitted node (s012 numbers),
+ and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ */
+ lrset = LR_SHIFT_NO_FLOW;
+ lrnver = get_num_ver(vn->vn_mode, tb, h,
+ lpar - ((h || tb->lbytes == -1) ? 0 : 1),
+ -1,
+ h ? (vn->vn_nr_item - rpar) : (rpar -
+ ((tb->
+ rbytes !=
+ -1) ? 1 :
+ 0)), -1,
+ snum012 + LR_SHIFT_NO_FLOW, NO_FLOW);
+ if (!h) {
+ int lrnver1;
+
+ lrnver1 = get_num_ver(vn->vn_mode, tb, h,
+ lpar -
+ ((tb->lbytes != -1) ? 1 : 0),
+ tb->lbytes,
+ (rpar -
+ ((tb->rbytes != -1) ? 1 : 0)),
+ tb->rbytes,
+ snum012 + LR_SHIFT_FLOW, FLOW);
+ if (lrnver > lrnver1)
+ lrset = LR_SHIFT_FLOW, lrnver = lrnver1;
+ }
- /* if shifting doesn't lead to better packing then don't shift */
- if (nver == lrnver)
- {
- set_parameters (tb, h, 0, 0, nver, snum012 + nset, -1, -1);
- return CARRY_ON;
- }
+ /* Our general shifting strategy is:
+ 1) to minimized number of new nodes;
+ 2) to minimized number of neighbors involved in shifting;
+ 3) to minimized number of disk reads; */
+
+ /* we can win TWO or ONE nodes by shifting in both directions */
+ if (lrnver < lnver && lrnver < rnver) {
+ RFALSE(h &&
+ (tb->lnum[h] != 1 ||
+ tb->rnum[h] != 1 ||
+ lrnver != 1 || rnver != 2 || lnver != 2
+ || h != 1), "vs-8230: bad h");
+ if (lrset == LR_SHIFT_FLOW)
+ set_parameters(tb, h, tb->lnum[h], tb->rnum[h],
+ lrnver, snum012 + lrset,
+ tb->lbytes, tb->rbytes);
+ else
+ set_parameters(tb, h,
+ tb->lnum[h] -
+ ((tb->lbytes == -1) ? 0 : 1),
+ tb->rnum[h] -
+ ((tb->rbytes == -1) ? 0 : 1),
+ lrnver, snum012 + lrset, -1, -1);
+
+ return CARRY_ON;
+ }
+ /* if shifting doesn't lead to better packing then don't shift */
+ if (nver == lrnver) {
+ set_parameters(tb, h, 0, 0, nver, snum012 + nset, -1,
+ -1);
+ return CARRY_ON;
+ }
- /* now we know that for better packing shifting in only one
- direction either to the left or to the right is required */
+ /* now we know that for better packing shifting in only one
+ direction either to the left or to the right is required */
- /* if shifting to the left is better than shifting to the right */
- if (lnver < rnver)
- {
- SET_PAR_SHIFT_LEFT;
- return CARRY_ON;
- }
+ /* if shifting to the left is better than shifting to the right */
+ if (lnver < rnver) {
+ SET_PAR_SHIFT_LEFT;
+ return CARRY_ON;
+ }
- /* if shifting to the right is better than shifting to the left */
- if (lnver > rnver)
- {
- SET_PAR_SHIFT_RIGHT;
- return CARRY_ON;
- }
+ /* if shifting to the right is better than shifting to the left */
+ if (lnver > rnver) {
+ SET_PAR_SHIFT_RIGHT;
+ return CARRY_ON;
+ }
+ /* now shifting in either direction gives the same number
+ of nodes and we can make use of the cached neighbors */
+ if (is_left_neighbor_in_cache(tb, h)) {
+ SET_PAR_SHIFT_LEFT;
+ return CARRY_ON;
+ }
- /* now shifting in either direction gives the same number
- of nodes and we can make use of the cached neighbors */
- if (is_left_neighbor_in_cache (tb,h))
- {
- SET_PAR_SHIFT_LEFT;
- return CARRY_ON;
+ /* shift to the right independently on whether the right neighbor in cache or not */
+ SET_PAR_SHIFT_RIGHT;
+ return CARRY_ON;
}
-
- /* shift to the right independently on whether the right neighbor in cache or not */
- SET_PAR_SHIFT_RIGHT;
- return CARRY_ON;
- }
}
-
/* Check whether current node S[h] is balanced when Decreasing its size by
* Deleting or Cutting for INTERNAL node of S+tree.
* Calculate parameters for balancing for current level h.
@@ -1513,157 +1553,173 @@ static int ip_check_balance (struct tree_balance * tb, int h)
* Note: Items of internal nodes have fixed size, so the balance condition for
* the internal part of S+tree is as for the B-trees.
*/
-static int dc_check_balance_internal (struct tree_balance * tb, int h)
+static int dc_check_balance_internal(struct tree_balance *tb, int h)
{
- struct virtual_node * vn = tb->tb_vn;
+ struct virtual_node *vn = tb->tb_vn;
- /* Sh is the node whose balance is currently being checked,
- and Fh is its father. */
- struct buffer_head * Sh, * Fh;
- int maxsize,
- n_ret_value;
- int lfree, rfree /* free space in L and R */;
+ /* Sh is the node whose balance is currently being checked,
+ and Fh is its father. */
+ struct buffer_head *Sh, *Fh;
+ int maxsize, n_ret_value;
+ int lfree, rfree /* free space in L and R */ ;
- Sh = PATH_H_PBUFFER (tb->tb_path, h);
- Fh = PATH_H_PPARENT (tb->tb_path, h);
+ Sh = PATH_H_PBUFFER(tb->tb_path, h);
+ Fh = PATH_H_PPARENT(tb->tb_path, h);
- maxsize = MAX_CHILD_SIZE(Sh);
+ maxsize = MAX_CHILD_SIZE(Sh);
/* using tb->insert_size[h], which is negative in this case, create_virtual_node calculates: */
/* new_nr_item = number of items node would have if operation is */
/* performed without balancing (new_nr_item); */
- create_virtual_node (tb, h);
+ create_virtual_node(tb, h);
- if ( ! Fh )
- { /* S[h] is the root. */
- if ( vn->vn_nr_item > 0 )
- {
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */
+ if (!Fh) { /* S[h] is the root. */
+ if (vn->vn_nr_item > 0) {
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */
+ }
+ /* new_nr_item == 0.
+ * Current root will be deleted resulting in
+ * decrementing the tree height. */
+ set_parameters(tb, h, 0, 0, 0, NULL, -1, -1);
+ return CARRY_ON;
+ }
+
+ if ((n_ret_value = get_parents(tb, h)) != CARRY_ON)
+ return n_ret_value;
+
+ /* get free space of neighbors */
+ rfree = get_rfree(tb, h);
+ lfree = get_lfree(tb, h);
+
+ /* determine maximal number of items we can fit into neighbors */
+ check_left(tb, h, lfree);
+ check_right(tb, h, rfree);
+
+ if (vn->vn_nr_item >= MIN_NR_KEY(Sh)) { /* Balance condition for the internal node is valid.
+ * In this case we balance only if it leads to better packing. */
+ if (vn->vn_nr_item == MIN_NR_KEY(Sh)) { /* Here we join S[h] with one of its neighbors,
+ * which is impossible with greater values of new_nr_item. */
+ if (tb->lnum[h] >= vn->vn_nr_item + 1) {
+ /* All contents of S[h] can be moved to L[h]. */
+ int n;
+ int order_L;
+
+ order_L =
+ ((n =
+ PATH_H_B_ITEM_ORDER(tb->tb_path,
+ h)) ==
+ 0) ? B_NR_ITEMS(tb->FL[h]) : n - 1;
+ n = dc_size(B_N_CHILD(tb->FL[h], order_L)) /
+ (DC_SIZE + KEY_SIZE);
+ set_parameters(tb, h, -n - 1, 0, 0, NULL, -1,
+ -1);
+ return CARRY_ON;
+ }
+
+ if (tb->rnum[h] >= vn->vn_nr_item + 1) {
+ /* All contents of S[h] can be moved to R[h]. */
+ int n;
+ int order_R;
+
+ order_R =
+ ((n =
+ PATH_H_B_ITEM_ORDER(tb->tb_path,
+ h)) ==
+ B_NR_ITEMS(Fh)) ? 0 : n + 1;
+ n = dc_size(B_N_CHILD(tb->FR[h], order_R)) /
+ (DC_SIZE + KEY_SIZE);
+ set_parameters(tb, h, 0, -n - 1, 0, NULL, -1,
+ -1);
+ return CARRY_ON;
+ }
+ }
+
+ if (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1) {
+ /* All contents of S[h] can be moved to the neighbors (L[h] & R[h]). */
+ int to_r;
+
+ to_r =
+ ((MAX_NR_KEY(Sh) << 1) + 2 - tb->lnum[h] -
+ tb->rnum[h] + vn->vn_nr_item + 1) / 2 -
+ (MAX_NR_KEY(Sh) + 1 - tb->rnum[h]);
+ set_parameters(tb, h, vn->vn_nr_item + 1 - to_r, to_r,
+ 0, NULL, -1, -1);
+ return CARRY_ON;
+ }
+
+ /* Balancing does not lead to better packing. */
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED;
}
- /* new_nr_item == 0.
- * Current root will be deleted resulting in
- * decrementing the tree height. */
- set_parameters (tb, h, 0, 0, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- if ( (n_ret_value = get_parents(tb,h)) != CARRY_ON )
- return n_ret_value;
-
-
- /* get free space of neighbors */
- rfree = get_rfree (tb, h);
- lfree = get_lfree (tb, h);
-
- /* determine maximal number of items we can fit into neighbors */
- check_left (tb, h, lfree);
- check_right (tb, h, rfree);
-
-
- if ( vn->vn_nr_item >= MIN_NR_KEY(Sh) )
- { /* Balance condition for the internal node is valid.
- * In this case we balance only if it leads to better packing. */
- if ( vn->vn_nr_item == MIN_NR_KEY(Sh) )
- { /* Here we join S[h] with one of its neighbors,
- * which is impossible with greater values of new_nr_item. */
- if ( tb->lnum[h] >= vn->vn_nr_item + 1 )
- {
- /* All contents of S[h] can be moved to L[h]. */
- int n;
- int order_L;
-
- order_L = ((n=PATH_H_B_ITEM_ORDER(tb->tb_path, h))==0) ? B_NR_ITEMS(tb->FL[h]) : n - 1;
- n = dc_size(B_N_CHILD(tb->FL[h],order_L)) / (DC_SIZE + KEY_SIZE);
- set_parameters (tb, h, -n-1, 0, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- if ( tb->rnum[h] >= vn->vn_nr_item + 1 )
- {
- /* All contents of S[h] can be moved to R[h]. */
- int n;
- int order_R;
-
- order_R = ((n=PATH_H_B_ITEM_ORDER(tb->tb_path, h))==B_NR_ITEMS(Fh)) ? 0 : n + 1;
- n = dc_size(B_N_CHILD(tb->FR[h],order_R)) / (DC_SIZE + KEY_SIZE);
- set_parameters (tb, h, 0, -n-1, 0, NULL, -1, -1);
- return CARRY_ON;
- }
+
+ /* Current node contain insufficient number of items. Balancing is required. */
+ /* Check whether we can merge S[h] with left neighbor. */
+ if (tb->lnum[h] >= vn->vn_nr_item + 1)
+ if (is_left_neighbor_in_cache(tb, h)
+ || tb->rnum[h] < vn->vn_nr_item + 1 || !tb->FR[h]) {
+ int n;
+ int order_L;
+
+ order_L =
+ ((n =
+ PATH_H_B_ITEM_ORDER(tb->tb_path,
+ h)) ==
+ 0) ? B_NR_ITEMS(tb->FL[h]) : n - 1;
+ n = dc_size(B_N_CHILD(tb->FL[h], order_L)) / (DC_SIZE +
+ KEY_SIZE);
+ set_parameters(tb, h, -n - 1, 0, 0, NULL, -1, -1);
+ return CARRY_ON;
+ }
+
+ /* Check whether we can merge S[h] with right neighbor. */
+ if (tb->rnum[h] >= vn->vn_nr_item + 1) {
+ int n;
+ int order_R;
+
+ order_R =
+ ((n =
+ PATH_H_B_ITEM_ORDER(tb->tb_path,
+ h)) == B_NR_ITEMS(Fh)) ? 0 : (n + 1);
+ n = dc_size(B_N_CHILD(tb->FR[h], order_R)) / (DC_SIZE +
+ KEY_SIZE);
+ set_parameters(tb, h, 0, -n - 1, 0, NULL, -1, -1);
+ return CARRY_ON;
}
- if (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1)
- {
- /* All contents of S[h] can be moved to the neighbors (L[h] & R[h]). */
- int to_r;
+ /* All contents of S[h] can be moved to the neighbors (L[h] & R[h]). */
+ if (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1) {
+ int to_r;
+
+ to_r =
+ ((MAX_NR_KEY(Sh) << 1) + 2 - tb->lnum[h] - tb->rnum[h] +
+ vn->vn_nr_item + 1) / 2 - (MAX_NR_KEY(Sh) + 1 -
+ tb->rnum[h]);
+ set_parameters(tb, h, vn->vn_nr_item + 1 - to_r, to_r, 0, NULL,
+ -1, -1);
+ return CARRY_ON;
+ }
- to_r = ((MAX_NR_KEY(Sh)<<1)+2-tb->lnum[h]-tb->rnum[h]+vn->vn_nr_item+1)/2 -
- (MAX_NR_KEY(Sh) + 1 - tb->rnum[h]);
- set_parameters (tb, h, vn->vn_nr_item + 1 - to_r, to_r, 0, NULL, -1, -1);
- return CARRY_ON;
+ /* For internal nodes try to borrow item from a neighbor */
+ RFALSE(!tb->FL[h] && !tb->FR[h], "vs-8235: trying to borrow for root");
+
+ /* Borrow one or two items from caching neighbor */
+ if (is_left_neighbor_in_cache(tb, h) || !tb->FR[h]) {
+ int from_l;
+
+ from_l =
+ (MAX_NR_KEY(Sh) + 1 - tb->lnum[h] + vn->vn_nr_item +
+ 1) / 2 - (vn->vn_nr_item + 1);
+ set_parameters(tb, h, -from_l, 0, 1, NULL, -1, -1);
+ return CARRY_ON;
}
- /* Balancing does not lead to better packing. */
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED;
- }
-
- /* Current node contain insufficient number of items. Balancing is required. */
- /* Check whether we can merge S[h] with left neighbor. */
- if (tb->lnum[h] >= vn->vn_nr_item + 1)
- if (is_left_neighbor_in_cache (tb,h) || tb->rnum[h] < vn->vn_nr_item + 1 || !tb->FR[h])
- {
- int n;
- int order_L;
-
- order_L = ((n=PATH_H_B_ITEM_ORDER(tb->tb_path, h))==0) ? B_NR_ITEMS(tb->FL[h]) : n - 1;
- n = dc_size(B_N_CHILD(tb->FL[h],order_L)) / (DC_SIZE + KEY_SIZE);
- set_parameters (tb, h, -n-1, 0, 0, NULL, -1, -1);
+ set_parameters(tb, h, 0,
+ -((MAX_NR_KEY(Sh) + 1 - tb->rnum[h] + vn->vn_nr_item +
+ 1) / 2 - (vn->vn_nr_item + 1)), 1, NULL, -1, -1);
return CARRY_ON;
- }
-
- /* Check whether we can merge S[h] with right neighbor. */
- if (tb->rnum[h] >= vn->vn_nr_item + 1)
- {
- int n;
- int order_R;
-
- order_R = ((n=PATH_H_B_ITEM_ORDER(tb->tb_path, h))==B_NR_ITEMS(Fh)) ? 0 : (n + 1);
- n = dc_size(B_N_CHILD(tb->FR[h],order_R)) / (DC_SIZE + KEY_SIZE);
- set_parameters (tb, h, 0, -n-1, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- /* All contents of S[h] can be moved to the neighbors (L[h] & R[h]). */
- if (tb->rnum[h] + tb->lnum[h] >= vn->vn_nr_item + 1)
- {
- int to_r;
-
- to_r = ((MAX_NR_KEY(Sh)<<1)+2-tb->lnum[h]-tb->rnum[h]+vn->vn_nr_item+1)/2 -
- (MAX_NR_KEY(Sh) + 1 - tb->rnum[h]);
- set_parameters (tb, h, vn->vn_nr_item + 1 - to_r, to_r, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- /* For internal nodes try to borrow item from a neighbor */
- RFALSE( !tb->FL[h] && !tb->FR[h], "vs-8235: trying to borrow for root");
-
- /* Borrow one or two items from caching neighbor */
- if (is_left_neighbor_in_cache (tb,h) || !tb->FR[h])
- {
- int from_l;
-
- from_l = (MAX_NR_KEY(Sh) + 1 - tb->lnum[h] + vn->vn_nr_item + 1) / 2 - (vn->vn_nr_item + 1);
- set_parameters (tb, h, -from_l, 0, 1, NULL, -1, -1);
- return CARRY_ON;
- }
-
- set_parameters (tb, h, 0, -((MAX_NR_KEY(Sh)+1-tb->rnum[h]+vn->vn_nr_item+1)/2-(vn->vn_nr_item+1)), 1,
- NULL, -1, -1);
- return CARRY_ON;
}
-
/* Check whether current node S[h] is balanced when Decreasing its size by
* Deleting or Truncating for LEAF node of S+tree.
* Calculate parameters for balancing for current level h.
@@ -1677,90 +1733,86 @@ static int dc_check_balance_internal (struct tree_balance * tb, int h)
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
*/
-static int dc_check_balance_leaf (struct tree_balance * tb, int h)
+static int dc_check_balance_leaf(struct tree_balance *tb, int h)
{
- struct virtual_node * vn = tb->tb_vn;
-
- /* Number of bytes that must be deleted from
- (value is negative if bytes are deleted) buffer which
- contains node being balanced. The mnemonic is that the
- attempted change in node space used level is levbytes bytes. */
- int levbytes;
- /* the maximal item size */
- int maxsize,
- n_ret_value;
- /* S0 is the node whose balance is currently being checked,
- and F0 is its father. */
- struct buffer_head * S0, * F0;
- int lfree, rfree /* free space in L and R */;
-
- S0 = PATH_H_PBUFFER (tb->tb_path, 0);
- F0 = PATH_H_PPARENT (tb->tb_path, 0);
-
- levbytes = tb->insert_size[h];
-
- maxsize = MAX_CHILD_SIZE(S0); /* maximal possible size of an item */
-
- if ( ! F0 )
- { /* S[0] is the root now. */
-
- RFALSE( -levbytes >= maxsize - B_FREE_SPACE (S0),
- "vs-8240: attempt to create empty buffer tree");
-
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED;
- }
-
- if ( (n_ret_value = get_parents(tb,h)) != CARRY_ON )
- return n_ret_value;
-
- /* get free space of neighbors */
- rfree = get_rfree (tb, h);
- lfree = get_lfree (tb, h);
-
- create_virtual_node (tb, h);
-
- /* if 3 leaves can be merge to one, set parameters and return */
- if (are_leaves_removable (tb, lfree, rfree))
- return CARRY_ON;
-
- /* determine maximal number of items we can shift to the left/right neighbor
- and the maximal number of bytes that can flow to the left/right neighbor
- from the left/right most liquid item that cannot be shifted from S[0] entirely
- */
- check_left (tb, h, lfree);
- check_right (tb, h, rfree);
-
- /* check whether we can merge S with left neighbor. */
- if (tb->lnum[0] >= vn->vn_nr_item && tb->lbytes == -1)
- if (is_left_neighbor_in_cache (tb,h) ||
- ((tb->rnum[0] - ((tb->rbytes == -1) ? 0 : 1)) < vn->vn_nr_item) || /* S can not be merged with R */
- !tb->FR[h]) {
-
- RFALSE( !tb->FL[h], "vs-8245: dc_check_balance_leaf: FL[h] must exist");
-
- /* set parameter to merge S[0] with its left neighbor */
- set_parameters (tb, h, -1, 0, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- /* check whether we can merge S[0] with right neighbor. */
- if (tb->rnum[0] >= vn->vn_nr_item && tb->rbytes == -1) {
- set_parameters (tb, h, 0, -1, 0, NULL, -1, -1);
- return CARRY_ON;
- }
-
- /* All contents of S[0] can be moved to the neighbors (L[0] & R[0]). Set parameters and return */
- if (is_leaf_removable (tb))
- return CARRY_ON;
-
- /* Balancing is not required. */
- tb->s0num = vn->vn_nr_item;
- set_parameters (tb, h, 0, 0, 1, NULL, -1, -1);
- return NO_BALANCING_NEEDED;
-}
+ struct virtual_node *vn = tb->tb_vn;
+
+ /* Number of bytes that must be deleted from
+ (value is negative if bytes are deleted) buffer which
+ contains node being balanced. The mnemonic is that the
+ attempted change in node space used level is levbytes bytes. */
+ int levbytes;
+ /* the maximal item size */
+ int maxsize, n_ret_value;
+ /* S0 is the node whose balance is currently being checked,
+ and F0 is its father. */
+ struct buffer_head *S0, *F0;
+ int lfree, rfree /* free space in L and R */ ;
+
+ S0 = PATH_H_PBUFFER(tb->tb_path, 0);
+ F0 = PATH_H_PPARENT(tb->tb_path, 0);
+ levbytes = tb->insert_size[h];
+ maxsize = MAX_CHILD_SIZE(S0); /* maximal possible size of an item */
+
+ if (!F0) { /* S[0] is the root now. */
+
+ RFALSE(-levbytes >= maxsize - B_FREE_SPACE(S0),
+ "vs-8240: attempt to create empty buffer tree");
+
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED;
+ }
+
+ if ((n_ret_value = get_parents(tb, h)) != CARRY_ON)
+ return n_ret_value;
+
+ /* get free space of neighbors */
+ rfree = get_rfree(tb, h);
+ lfree = get_lfree(tb, h);
+
+ create_virtual_node(tb, h);
+
+ /* if 3 leaves can be merge to one, set parameters and return */
+ if (are_leaves_removable(tb, lfree, rfree))
+ return CARRY_ON;
+
+ /* determine maximal number of items we can shift to the left/right neighbor
+ and the maximal number of bytes that can flow to the left/right neighbor
+ from the left/right most liquid item that cannot be shifted from S[0] entirely
+ */
+ check_left(tb, h, lfree);
+ check_right(tb, h, rfree);
+
+ /* check whether we can merge S with left neighbor. */
+ if (tb->lnum[0] >= vn->vn_nr_item && tb->lbytes == -1)
+ if (is_left_neighbor_in_cache(tb, h) || ((tb->rnum[0] - ((tb->rbytes == -1) ? 0 : 1)) < vn->vn_nr_item) || /* S can not be merged with R */
+ !tb->FR[h]) {
+
+ RFALSE(!tb->FL[h],
+ "vs-8245: dc_check_balance_leaf: FL[h] must exist");
+
+ /* set parameter to merge S[0] with its left neighbor */
+ set_parameters(tb, h, -1, 0, 0, NULL, -1, -1);
+ return CARRY_ON;
+ }
+
+ /* check whether we can merge S[0] with right neighbor. */
+ if (tb->rnum[0] >= vn->vn_nr_item && tb->rbytes == -1) {
+ set_parameters(tb, h, 0, -1, 0, NULL, -1, -1);
+ return CARRY_ON;
+ }
+
+ /* All contents of S[0] can be moved to the neighbors (L[0] & R[0]). Set parameters and return */
+ if (is_leaf_removable(tb))
+ return CARRY_ON;
+
+ /* Balancing is not required. */
+ tb->s0num = vn->vn_nr_item;
+ set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
+ return NO_BALANCING_NEEDED;
+}
/* Check whether current node S[h] is balanced when Decreasing its size by
* Deleting or Cutting.
@@ -1775,18 +1827,17 @@ static int dc_check_balance_leaf (struct tree_balance * tb, int h)
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
*/
-static int dc_check_balance (struct tree_balance * tb, int h)
+static int dc_check_balance(struct tree_balance *tb, int h)
{
- RFALSE( ! (PATH_H_PBUFFER (tb->tb_path, h)), "vs-8250: S is not initialized");
+ RFALSE(!(PATH_H_PBUFFER(tb->tb_path, h)),
+ "vs-8250: S is not initialized");
- if ( h )
- return dc_check_balance_internal (tb, h);
- else
- return dc_check_balance_leaf (tb, h);
+ if (h)
+ return dc_check_balance_internal(tb, h);
+ else
+ return dc_check_balance_leaf(tb, h);
}
-
-
/* Check whether current node S[h] is balanced.
* Calculate parameters for balancing for current level h.
* Parameters:
@@ -1805,83 +1856,80 @@ static int dc_check_balance (struct tree_balance * tb, int h)
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
*/
-static int check_balance (int mode,
- struct tree_balance * tb,
- int h,
- int inum,
- int pos_in_item,
- struct item_head * ins_ih,
- const void * data
- )
+static int check_balance(int mode,
+ struct tree_balance *tb,
+ int h,
+ int inum,
+ int pos_in_item,
+ struct item_head *ins_ih, const void *data)
{
- struct virtual_node * vn;
+ struct virtual_node *vn;
- vn = tb->tb_vn = (struct virtual_node *)(tb->vn_buf);
- vn->vn_free_ptr = (char *)(tb->tb_vn + 1);
- vn->vn_mode = mode;
- vn->vn_affected_item_num = inum;
- vn->vn_pos_in_item = pos_in_item;
- vn->vn_ins_ih = ins_ih;
- vn->vn_data = data;
+ vn = tb->tb_vn = (struct virtual_node *)(tb->vn_buf);
+ vn->vn_free_ptr = (char *)(tb->tb_vn + 1);
+ vn->vn_mode = mode;
+ vn->vn_affected_item_num = inum;
+ vn->vn_pos_in_item = pos_in_item;
+ vn->vn_ins_ih = ins_ih;
+ vn->vn_data = data;
- RFALSE( mode == M_INSERT && !vn->vn_ins_ih,
- "vs-8255: ins_ih can not be 0 in insert mode");
+ RFALSE(mode == M_INSERT && !vn->vn_ins_ih,
+ "vs-8255: ins_ih can not be 0 in insert mode");
- if ( tb->insert_size[h] > 0 )
- /* Calculate balance parameters when size of node is increasing. */
- return ip_check_balance (tb, h);
+ if (tb->insert_size[h] > 0)
+ /* Calculate balance parameters when size of node is increasing. */
+ return ip_check_balance(tb, h);
- /* Calculate balance parameters when size of node is decreasing. */
- return dc_check_balance (tb, h);
+ /* Calculate balance parameters when size of node is decreasing. */
+ return dc_check_balance(tb, h);
}
+/* Check whether parent at the path is the really parent of the current node.*/
+static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
+{
+ struct buffer_head *p_s_bh;
+ struct path *p_s_path = p_s_tb->tb_path;
+ int n_position,
+ n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
+
+ /* We are in the root or in the new root. */
+ if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
+
+ RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
+ "PAP-8260: invalid offset in the path");
+
+ if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)->
+ b_blocknr == SB_ROOT_BLOCK(p_s_tb->tb_sb)) {
+ /* Root is not changed. */
+ PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL;
+ PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0;
+ return CARRY_ON;
+ }
+ return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */
+ }
+
+ if (!B_IS_IN_TREE
+ (p_s_bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
+ return REPEAT_SEARCH; /* Parent in the path is not in the tree. */
+ if ((n_position =
+ PATH_OFFSET_POSITION(p_s_path,
+ n_path_offset - 1)) > B_NR_ITEMS(p_s_bh))
+ return REPEAT_SEARCH;
-/* Check whether parent at the path is the really parent of the current node.*/
-static int get_direct_parent(
- struct tree_balance * p_s_tb,
- int n_h
- ) {
- struct buffer_head * p_s_bh;
- struct path * p_s_path = p_s_tb->tb_path;
- int n_position,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
-
- /* We are in the root or in the new root. */
- if ( n_path_offset <= FIRST_PATH_ELEMENT_OFFSET ) {
-
- RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
- "PAP-8260: invalid offset in the path");
-
- if ( PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
- SB_ROOT_BLOCK (p_s_tb->tb_sb) ) {
- /* Root is not changed. */
- PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL;
- PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0;
- return CARRY_ON;
+ if (B_N_CHILD_NUM(p_s_bh, n_position) !=
+ PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr)
+ /* Parent in the path is not parent of the current node in the tree. */
+ return REPEAT_SEARCH;
+
+ if (buffer_locked(p_s_bh)) {
+ __wait_on_buffer(p_s_bh);
+ if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ return REPEAT_SEARCH;
}
- return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */
- }
-
- if ( ! B_IS_IN_TREE(p_s_bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)) )
- return REPEAT_SEARCH; /* Parent in the path is not in the tree. */
-
- if ( (n_position = PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1)) > B_NR_ITEMS(p_s_bh) )
- return REPEAT_SEARCH;
-
- if ( B_N_CHILD_NUM(p_s_bh, n_position) != PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr )
- /* Parent in the path is not parent of the current node in the tree. */
- return REPEAT_SEARCH;
-
- if ( buffer_locked(p_s_bh) ) {
- __wait_on_buffer(p_s_bh);
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) )
- return REPEAT_SEARCH;
- }
-
- return CARRY_ON; /* Parent in the path is unlocked and really parent of the current node. */
-}
+ return CARRY_ON; /* Parent in the path is unlocked and really parent of the current node. */
+}
/* Using lnum[n_h] and rnum[n_h] we should determine what neighbors
* of S[n_h] we
@@ -1889,356 +1937,401 @@ static int get_direct_parent(
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_neighbors(
- struct tree_balance * p_s_tb,
- int n_h
- ) {
- int n_child_position,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1);
- unsigned long n_son_number;
- struct super_block * p_s_sb = p_s_tb->tb_sb;
- struct buffer_head * p_s_bh;
-
-
- PROC_INFO_INC( p_s_sb, get_neighbors[ n_h ] );
-
- if ( p_s_tb->lnum[n_h] ) {
- /* We need left neighbor to balance S[n_h]. */
- PROC_INFO_INC( p_s_sb, need_l_neighbor[ n_h ] );
- p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
-
- RFALSE( p_s_bh == p_s_tb->FL[n_h] &&
- ! PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
- "PAP-8270: invalid position in the parent");
-
- n_child_position = ( p_s_bh == p_s_tb->FL[n_h] ) ? p_s_tb->lkey[n_h] : B_NR_ITEMS (p_s_tb->FL[n_h]);
- n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position);
- p_s_bh = sb_bread(p_s_sb, n_son_number);
- if (!p_s_bh)
- return IO_ERROR;
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) {
- decrement_bcount(p_s_bh);
- PROC_INFO_INC( p_s_sb, get_neighbors_restart[ n_h ] );
- return REPEAT_SEARCH;
+static int get_neighbors(struct tree_balance *p_s_tb, int n_h)
+{
+ int n_child_position,
+ n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1);
+ unsigned long n_son_number;
+ struct super_block *p_s_sb = p_s_tb->tb_sb;
+ struct buffer_head *p_s_bh;
+
+ PROC_INFO_INC(p_s_sb, get_neighbors[n_h]);
+
+ if (p_s_tb->lnum[n_h]) {
+ /* We need left neighbor to balance S[n_h]. */
+ PROC_INFO_INC(p_s_sb, need_l_neighbor[n_h]);
+ p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+
+ RFALSE(p_s_bh == p_s_tb->FL[n_h] &&
+ !PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
+ "PAP-8270: invalid position in the parent");
+
+ n_child_position =
+ (p_s_bh ==
+ p_s_tb->FL[n_h]) ? p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->
+ FL[n_h]);
+ n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position);
+ p_s_bh = sb_bread(p_s_sb, n_son_number);
+ if (!p_s_bh)
+ return IO_ERROR;
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ decrement_bcount(p_s_bh);
+ PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]);
+ return REPEAT_SEARCH;
+ }
+
+ RFALSE(!B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
+ n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) ||
+ B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) !=
+ p_s_bh->b_blocknr, "PAP-8275: invalid parent");
+ RFALSE(!B_IS_IN_TREE(p_s_bh), "PAP-8280: invalid child");
+ RFALSE(!n_h &&
+ B_FREE_SPACE(p_s_bh) !=
+ MAX_CHILD_SIZE(p_s_bh) -
+ dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)),
+ "PAP-8290: invalid child size of left neighbor");
+
+ decrement_bcount(p_s_tb->L[n_h]);
+ p_s_tb->L[n_h] = p_s_bh;
}
-
- RFALSE( ! B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
- n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) ||
- B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) !=
- p_s_bh->b_blocknr, "PAP-8275: invalid parent");
- RFALSE( ! B_IS_IN_TREE(p_s_bh), "PAP-8280: invalid child");
- RFALSE( ! n_h &&
- B_FREE_SPACE (p_s_bh) != MAX_CHILD_SIZE (p_s_bh) - dc_size(B_N_CHILD (p_s_tb->FL[0],n_child_position)),
- "PAP-8290: invalid child size of left neighbor");
-
- decrement_bcount(p_s_tb->L[n_h]);
- p_s_tb->L[n_h] = p_s_bh;
- }
-
-
- if ( p_s_tb->rnum[n_h] ) { /* We need right neighbor to balance S[n_path_offset]. */
- PROC_INFO_INC( p_s_sb, need_r_neighbor[ n_h ] );
- p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
-
- RFALSE( p_s_bh == p_s_tb->FR[n_h] &&
- PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset) >= B_NR_ITEMS(p_s_bh),
- "PAP-8295: invalid position in the parent");
-
- n_child_position = ( p_s_bh == p_s_tb->FR[n_h] ) ? p_s_tb->rkey[n_h] + 1 : 0;
- n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position);
- p_s_bh = sb_bread(p_s_sb, n_son_number);
- if (!p_s_bh)
- return IO_ERROR;
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) {
- decrement_bcount(p_s_bh);
- PROC_INFO_INC( p_s_sb, get_neighbors_restart[ n_h ] );
- return REPEAT_SEARCH;
+
+ if (p_s_tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
+ PROC_INFO_INC(p_s_sb, need_r_neighbor[n_h]);
+ p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+
+ RFALSE(p_s_bh == p_s_tb->FR[n_h] &&
+ PATH_OFFSET_POSITION(p_s_tb->tb_path,
+ n_path_offset) >=
+ B_NR_ITEMS(p_s_bh),
+ "PAP-8295: invalid position in the parent");
+
+ n_child_position =
+ (p_s_bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
+ n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position);
+ p_s_bh = sb_bread(p_s_sb, n_son_number);
+ if (!p_s_bh)
+ return IO_ERROR;
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ decrement_bcount(p_s_bh);
+ PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]);
+ return REPEAT_SEARCH;
+ }
+ decrement_bcount(p_s_tb->R[n_h]);
+ p_s_tb->R[n_h] = p_s_bh;
+
+ RFALSE(!n_h
+ && B_FREE_SPACE(p_s_bh) !=
+ MAX_CHILD_SIZE(p_s_bh) -
+ dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)),
+ "PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
+ B_FREE_SPACE(p_s_bh), MAX_CHILD_SIZE(p_s_bh),
+ dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)));
+
}
- decrement_bcount(p_s_tb->R[n_h]);
- p_s_tb->R[n_h] = p_s_bh;
-
- RFALSE( ! n_h && B_FREE_SPACE (p_s_bh) != MAX_CHILD_SIZE (p_s_bh) - dc_size(B_N_CHILD (p_s_tb->FR[0],n_child_position)),
- "PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
- B_FREE_SPACE (p_s_bh), MAX_CHILD_SIZE (p_s_bh),
- dc_size(B_N_CHILD (p_s_tb->FR[0],n_child_position)));
-
- }
- return CARRY_ON;
+ return CARRY_ON;
}
#ifdef CONFIG_REISERFS_CHECK
-void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s)
+void *reiserfs_kmalloc(size_t size, int flags, struct super_block *s)
{
- void * vp;
- static size_t malloced;
-
-
- vp = kmalloc (size, flags);
- if (vp) {
- REISERFS_SB(s)->s_kmallocs += size;
- if (REISERFS_SB(s)->s_kmallocs > malloced + 200000) {
- reiserfs_warning (s,
- "vs-8301: reiserfs_kmalloc: allocated memory %d",
- REISERFS_SB(s)->s_kmallocs);
- malloced = REISERFS_SB(s)->s_kmallocs;
+ void *vp;
+ static size_t malloced;
+
+ vp = kmalloc(size, flags);
+ if (vp) {
+ REISERFS_SB(s)->s_kmallocs += size;
+ if (REISERFS_SB(s)->s_kmallocs > malloced + 200000) {
+ reiserfs_warning(s,
+ "vs-8301: reiserfs_kmalloc: allocated memory %d",
+ REISERFS_SB(s)->s_kmallocs);
+ malloced = REISERFS_SB(s)->s_kmallocs;
+ }
}
- }
- return vp;
+ return vp;
}
-void reiserfs_kfree (const void * vp, size_t size, struct super_block * s)
+void reiserfs_kfree(const void *vp, size_t size, struct super_block *s)
{
- kfree (vp);
-
- REISERFS_SB(s)->s_kmallocs -= size;
- if (REISERFS_SB(s)->s_kmallocs < 0)
- reiserfs_warning (s, "vs-8302: reiserfs_kfree: allocated memory %d",
- REISERFS_SB(s)->s_kmallocs);
+ kfree(vp);
+
+ REISERFS_SB(s)->s_kmallocs -= size;
+ if (REISERFS_SB(s)->s_kmallocs < 0)
+ reiserfs_warning(s,
+ "vs-8302: reiserfs_kfree: allocated memory %d",
+ REISERFS_SB(s)->s_kmallocs);
}
#endif
-
-static int get_virtual_node_size (struct super_block * sb, struct buffer_head * bh)
+static int get_virtual_node_size(struct super_block *sb, struct buffer_head *bh)
{
- int max_num_of_items;
- int max_num_of_entries;
- unsigned long blocksize = sb->s_blocksize;
+ int max_num_of_items;
+ int max_num_of_entries;
+ unsigned long blocksize = sb->s_blocksize;
#define MIN_NAME_LEN 1
- max_num_of_items = (blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN);
- max_num_of_entries = (blocksize - BLKH_SIZE - IH_SIZE) /
- (DEH_SIZE + MIN_NAME_LEN);
+ max_num_of_items = (blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN);
+ max_num_of_entries = (blocksize - BLKH_SIZE - IH_SIZE) /
+ (DEH_SIZE + MIN_NAME_LEN);
- return sizeof(struct virtual_node) +
- max(max_num_of_items * sizeof (struct virtual_item),
- sizeof (struct virtual_item) + sizeof(struct direntry_uarea) +
- (max_num_of_entries - 1) * sizeof (__u16));
+ return sizeof(struct virtual_node) +
+ max(max_num_of_items * sizeof(struct virtual_item),
+ sizeof(struct virtual_item) + sizeof(struct direntry_uarea) +
+ (max_num_of_entries - 1) * sizeof(__u16));
}
-
-
/* maybe we should fail balancing we are going to perform when kmalloc
fails several times. But now it will loop until kmalloc gets
required memory */
-static int get_mem_for_virtual_node (struct tree_balance * tb)
+static int get_mem_for_virtual_node(struct tree_balance *tb)
{
- int check_fs = 0;
- int size;
- char * buf;
-
- size = get_virtual_node_size (tb->tb_sb, PATH_PLAST_BUFFER (tb->tb_path));
-
- if (size > tb->vn_buf_size) {
- /* we have to allocate more memory for virtual node */
- if (tb->vn_buf) {
- /* free memory allocated before */
- reiserfs_kfree (tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
- /* this is not needed if kfree is atomic */
- check_fs = 1;
- }
+ int check_fs = 0;
+ int size;
+ char *buf;
+
+ size = get_virtual_node_size(tb->tb_sb, PATH_PLAST_BUFFER(tb->tb_path));
+
+ if (size > tb->vn_buf_size) {
+ /* we have to allocate more memory for virtual node */
+ if (tb->vn_buf) {
+ /* free memory allocated before */
+ reiserfs_kfree(tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
+ /* this is not needed if kfree is atomic */
+ check_fs = 1;
+ }
- /* virtual node requires now more memory */
- tb->vn_buf_size = size;
-
- /* get memory for virtual item */
- buf = reiserfs_kmalloc(size, GFP_ATOMIC | __GFP_NOWARN, tb->tb_sb);
- if ( ! buf ) {
- /* getting memory with GFP_KERNEL priority may involve
- balancing now (due to indirect_to_direct conversion on
- dcache shrinking). So, release path and collected
- resources here */
- free_buffers_in_tb (tb);
- buf = reiserfs_kmalloc(size, GFP_NOFS, tb->tb_sb);
- if ( !buf ) {
+ /* virtual node requires now more memory */
+ tb->vn_buf_size = size;
+
+ /* get memory for virtual item */
+ buf =
+ reiserfs_kmalloc(size, GFP_ATOMIC | __GFP_NOWARN,
+ tb->tb_sb);
+ if (!buf) {
+ /* getting memory with GFP_KERNEL priority may involve
+ balancing now (due to indirect_to_direct conversion on
+ dcache shrinking). So, release path and collected
+ resources here */
+ free_buffers_in_tb(tb);
+ buf = reiserfs_kmalloc(size, GFP_NOFS, tb->tb_sb);
+ if (!buf) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning (tb->tb_sb,
- "vs-8345: get_mem_for_virtual_node: "
- "kmalloc failed. reiserfs kmalloced %d bytes",
- REISERFS_SB(tb->tb_sb)->s_kmallocs);
+ reiserfs_warning(tb->tb_sb,
+ "vs-8345: get_mem_for_virtual_node: "
+ "kmalloc failed. reiserfs kmalloced %d bytes",
+ REISERFS_SB(tb->tb_sb)->
+ s_kmallocs);
#endif
- tb->vn_buf_size = 0;
- }
- tb->vn_buf = buf;
- schedule() ;
- return REPEAT_SEARCH;
- }
+ tb->vn_buf_size = 0;
+ }
+ tb->vn_buf = buf;
+ schedule();
+ return REPEAT_SEARCH;
+ }
- tb->vn_buf = buf;
- }
+ tb->vn_buf = buf;
+ }
- if ( check_fs && FILESYSTEM_CHANGED_TB (tb) )
- return REPEAT_SEARCH;
+ if (check_fs && FILESYSTEM_CHANGED_TB(tb))
+ return REPEAT_SEARCH;
- return CARRY_ON;
+ return CARRY_ON;
}
-
#ifdef CONFIG_REISERFS_CHECK
-static void tb_buffer_sanity_check (struct super_block * p_s_sb,
- struct buffer_head * p_s_bh,
- const char *descr, int level) {
- if (p_s_bh) {
- if (atomic_read (&(p_s_bh->b_count)) <= 0) {
-
- reiserfs_panic (p_s_sb, "jmacd-1: tb_buffer_sanity_check(): negative or zero reference counter for buffer %s[%d] (%b)\n", descr, level, p_s_bh);
- }
-
- if ( ! buffer_uptodate (p_s_bh) ) {
- reiserfs_panic (p_s_sb, "jmacd-2: tb_buffer_sanity_check(): buffer is not up to date %s[%d] (%b)\n", descr, level, p_s_bh);
- }
-
- if ( ! B_IS_IN_TREE (p_s_bh) ) {
- reiserfs_panic (p_s_sb, "jmacd-3: tb_buffer_sanity_check(): buffer is not in tree %s[%d] (%b)\n", descr, level, p_s_bh);
- }
-
- if (p_s_bh->b_bdev != p_s_sb->s_bdev) {
- reiserfs_panic (p_s_sb, "jmacd-4: tb_buffer_sanity_check(): buffer has wrong device %s[%d] (%b)\n", descr, level, p_s_bh);
- }
-
- if (p_s_bh->b_size != p_s_sb->s_blocksize) {
- reiserfs_panic (p_s_sb, "jmacd-5: tb_buffer_sanity_check(): buffer has wrong blocksize %s[%d] (%b)\n", descr, level, p_s_bh);
- }
-
- if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
- reiserfs_panic (p_s_sb, "jmacd-6: tb_buffer_sanity_check(): buffer block number too high %s[%d] (%b)\n", descr, level, p_s_bh);
- }
- }
-}
-#else
-static void tb_buffer_sanity_check (struct super_block * p_s_sb,
- struct buffer_head * p_s_bh,
- const char *descr, int level)
-{;}
-#endif
-
-static int clear_all_dirty_bits(struct super_block *s,
- struct buffer_head *bh) {
- return reiserfs_prepare_for_journal(s, bh, 0) ;
-}
-
-static int wait_tb_buffers_until_unlocked (struct tree_balance * p_s_tb)
+static void tb_buffer_sanity_check(struct super_block *p_s_sb,
+ struct buffer_head *p_s_bh,
+ const char *descr, int level)
{
- struct buffer_head * locked;
-#ifdef CONFIG_REISERFS_CHECK
- int repeat_counter = 0;
-#endif
- int i;
+ if (p_s_bh) {
+ if (atomic_read(&(p_s_bh->b_count)) <= 0) {
- do {
-
- locked = NULL;
-
- for ( i = p_s_tb->tb_path->path_length; !locked && i > ILLEGAL_PATH_ELEMENT_OFFSET; i-- ) {
- if ( PATH_OFFSET_PBUFFER (p_s_tb->tb_path, i) ) {
- /* if I understand correctly, we can only be sure the last buffer
- ** in the path is in the tree --clm
- */
-#ifdef CONFIG_REISERFS_CHECK
- if (PATH_PLAST_BUFFER(p_s_tb->tb_path) ==
- PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) {
- tb_buffer_sanity_check (p_s_tb->tb_sb,
- PATH_OFFSET_PBUFFER (p_s_tb->tb_path, i),
- "S",
- p_s_tb->tb_path->path_length - i);
+ reiserfs_panic(p_s_sb,
+ "jmacd-1: tb_buffer_sanity_check(): negative or zero reference counter for buffer %s[%d] (%b)\n",
+ descr, level, p_s_bh);
}
-#endif
- if (!clear_all_dirty_bits(p_s_tb->tb_sb,
- PATH_OFFSET_PBUFFER (p_s_tb->tb_path, i)))
- {
- locked = PATH_OFFSET_PBUFFER (p_s_tb->tb_path, i);
- }
- }
- }
- for ( i = 0; !locked && i < MAX_HEIGHT && p_s_tb->insert_size[i]; i++ ) {
+ if (!buffer_uptodate(p_s_bh)) {
+ reiserfs_panic(p_s_sb,
+ "jmacd-2: tb_buffer_sanity_check(): buffer is not up to date %s[%d] (%b)\n",
+ descr, level, p_s_bh);
+ }
- if (p_s_tb->lnum[i] ) {
+ if (!B_IS_IN_TREE(p_s_bh)) {
+ reiserfs_panic(p_s_sb,
+ "jmacd-3: tb_buffer_sanity_check(): buffer is not in tree %s[%d] (%b)\n",
+ descr, level, p_s_bh);
+ }
- if ( p_s_tb->L[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->L[i], "L", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->L[i]))
- locked = p_s_tb->L[i];
+ if (p_s_bh->b_bdev != p_s_sb->s_bdev) {
+ reiserfs_panic(p_s_sb,
+ "jmacd-4: tb_buffer_sanity_check(): buffer has wrong device %s[%d] (%b)\n",
+ descr, level, p_s_bh);
}
- if ( !locked && p_s_tb->FL[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->FL[i], "FL", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->FL[i]))
- locked = p_s_tb->FL[i];
+ if (p_s_bh->b_size != p_s_sb->s_blocksize) {
+ reiserfs_panic(p_s_sb,
+ "jmacd-5: tb_buffer_sanity_check(): buffer has wrong blocksize %s[%d] (%b)\n",
+ descr, level, p_s_bh);
}
- if ( !locked && p_s_tb->CFL[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->CFL[i], "CFL", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->CFL[i]))
- locked = p_s_tb->CFL[i];
+ if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
+ reiserfs_panic(p_s_sb,
+ "jmacd-6: tb_buffer_sanity_check(): buffer block number too high %s[%d] (%b)\n",
+ descr, level, p_s_bh);
}
+ }
+}
+#else
+static void tb_buffer_sanity_check(struct super_block *p_s_sb,
+ struct buffer_head *p_s_bh,
+ const char *descr, int level)
+{;
+}
+#endif
- }
+static int clear_all_dirty_bits(struct super_block *s, struct buffer_head *bh)
+{
+ return reiserfs_prepare_for_journal(s, bh, 0);
+}
- if ( !locked && (p_s_tb->rnum[i]) ) {
+static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb)
+{
+ struct buffer_head *locked;
+#ifdef CONFIG_REISERFS_CHECK
+ int repeat_counter = 0;
+#endif
+ int i;
- if ( p_s_tb->R[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->R[i], "R", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->R[i]))
- locked = p_s_tb->R[i];
- }
+ do {
-
- if ( !locked && p_s_tb->FR[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->FR[i], "FR", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->FR[i]))
- locked = p_s_tb->FR[i];
+ locked = NULL;
+
+ for (i = p_s_tb->tb_path->path_length;
+ !locked && i > ILLEGAL_PATH_ELEMENT_OFFSET; i--) {
+ if (PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) {
+ /* if I understand correctly, we can only be sure the last buffer
+ ** in the path is in the tree --clm
+ */
+#ifdef CONFIG_REISERFS_CHECK
+ if (PATH_PLAST_BUFFER(p_s_tb->tb_path) ==
+ PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ PATH_OFFSET_PBUFFER
+ (p_s_tb->tb_path,
+ i), "S",
+ p_s_tb->tb_path->
+ path_length - i);
+ }
+#endif
+ if (!clear_all_dirty_bits(p_s_tb->tb_sb,
+ PATH_OFFSET_PBUFFER
+ (p_s_tb->tb_path,
+ i))) {
+ locked =
+ PATH_OFFSET_PBUFFER(p_s_tb->tb_path,
+ i);
+ }
+ }
}
- if ( !locked && p_s_tb->CFR[i] ) {
- tb_buffer_sanity_check (p_s_tb->tb_sb, p_s_tb->CFR[i], "CFR", i);
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->CFR[i]))
- locked = p_s_tb->CFR[i];
+ for (i = 0; !locked && i < MAX_HEIGHT && p_s_tb->insert_size[i];
+ i++) {
+
+ if (p_s_tb->lnum[i]) {
+
+ if (p_s_tb->L[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->L[i],
+ "L", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->L[i]))
+ locked = p_s_tb->L[i];
+ }
+
+ if (!locked && p_s_tb->FL[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->FL[i],
+ "FL", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->FL[i]))
+ locked = p_s_tb->FL[i];
+ }
+
+ if (!locked && p_s_tb->CFL[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->CFL[i],
+ "CFL", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->CFL[i]))
+ locked = p_s_tb->CFL[i];
+ }
+
+ }
+
+ if (!locked && (p_s_tb->rnum[i])) {
+
+ if (p_s_tb->R[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->R[i],
+ "R", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->R[i]))
+ locked = p_s_tb->R[i];
+ }
+
+ if (!locked && p_s_tb->FR[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->FR[i],
+ "FR", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->FR[i]))
+ locked = p_s_tb->FR[i];
+ }
+
+ if (!locked && p_s_tb->CFR[i]) {
+ tb_buffer_sanity_check(p_s_tb->tb_sb,
+ p_s_tb->CFR[i],
+ "CFR", i);
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->CFR[i]))
+ locked = p_s_tb->CFR[i];
+ }
+ }
+ }
+ /* as far as I can tell, this is not required. The FEB list seems
+ ** to be full of newly allocated nodes, which will never be locked,
+ ** dirty, or anything else.
+ ** To be safe, I'm putting in the checks and waits in. For the moment,
+ ** they are needed to keep the code in journal.c from complaining
+ ** about the buffer. That code is inside CONFIG_REISERFS_CHECK as well.
+ ** --clm
+ */
+ for (i = 0; !locked && i < MAX_FEB_SIZE; i++) {
+ if (p_s_tb->FEB[i]) {
+ if (!clear_all_dirty_bits
+ (p_s_tb->tb_sb, p_s_tb->FEB[i]))
+ locked = p_s_tb->FEB[i];
+ }
}
- }
- }
- /* as far as I can tell, this is not required. The FEB list seems
- ** to be full of newly allocated nodes, which will never be locked,
- ** dirty, or anything else.
- ** To be safe, I'm putting in the checks and waits in. For the moment,
- ** they are needed to keep the code in journal.c from complaining
- ** about the buffer. That code is inside CONFIG_REISERFS_CHECK as well.
- ** --clm
- */
- for ( i = 0; !locked && i < MAX_FEB_SIZE; i++ ) {
- if ( p_s_tb->FEB[i] ) {
- if (!clear_all_dirty_bits(p_s_tb->tb_sb, p_s_tb->FEB[i]))
- locked = p_s_tb->FEB[i] ;
- }
- }
- if (locked) {
+ if (locked) {
#ifdef CONFIG_REISERFS_CHECK
- repeat_counter++;
- if ( (repeat_counter % 10000) == 0) {
- reiserfs_warning (p_s_tb->tb_sb,
- "wait_tb_buffers_until_released(): too many "
- "iterations waiting for buffer to unlock "
- "(%b)", locked);
-
- /* Don't loop forever. Try to recover from possible error. */
-
- return ( FILESYSTEM_CHANGED_TB (p_s_tb) ) ? REPEAT_SEARCH : CARRY_ON;
- }
+ repeat_counter++;
+ if ((repeat_counter % 10000) == 0) {
+ reiserfs_warning(p_s_tb->tb_sb,
+ "wait_tb_buffers_until_released(): too many "
+ "iterations waiting for buffer to unlock "
+ "(%b)", locked);
+
+ /* Don't loop forever. Try to recover from possible error. */
+
+ return (FILESYSTEM_CHANGED_TB(p_s_tb)) ?
+ REPEAT_SEARCH : CARRY_ON;
+ }
#endif
- __wait_on_buffer (locked);
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) ) {
- return REPEAT_SEARCH;
- }
- }
+ __wait_on_buffer(locked);
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ return REPEAT_SEARCH;
+ }
+ }
- } while (locked);
+ } while (locked);
- return CARRY_ON;
+ return CARRY_ON;
}
-
/* Prepare for balancing, that is
* get all necessary parents, and neighbors;
* analyze what and where should be moved;
@@ -2267,252 +2360,266 @@ static int wait_tb_buffers_until_unlocked (struct tree_balance * p_s_tb)
* -1 - if no_disk_space
*/
+int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ins_ih, // item head of item being inserted
+ const void *data // inserted item or data to be pasted
+ )
+{
+ int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(p_s_tb->tb_path);
+ int n_pos_in_item;
-int fix_nodes (int n_op_mode,
- struct tree_balance * p_s_tb,
- struct item_head * p_s_ins_ih, // item head of item being inserted
- const void * data // inserted item or data to be pasted
- ) {
- int n_ret_value,
- n_h,
- n_item_num = PATH_LAST_POSITION(p_s_tb->tb_path);
- int n_pos_in_item;
-
- /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared
- ** during wait_tb_buffers_run
- */
- int wait_tb_buffers_run = 0 ;
- struct buffer_head * p_s_tbS0 = PATH_PLAST_BUFFER(p_s_tb->tb_path);
-
- ++ REISERFS_SB(p_s_tb -> tb_sb) -> s_fix_nodes;
-
- n_pos_in_item = p_s_tb->tb_path->pos_in_item;
-
-
- p_s_tb->fs_gen = get_generation (p_s_tb->tb_sb);
-
- /* we prepare and log the super here so it will already be in the
- ** transaction when do_balance needs to change it.
- ** This way do_balance won't have to schedule when trying to prepare
- ** the super for logging
- */
- reiserfs_prepare_for_journal(p_s_tb->tb_sb,
- SB_BUFFER_WITH_SB(p_s_tb->tb_sb), 1) ;
- journal_mark_dirty(p_s_tb->transaction_handle, p_s_tb->tb_sb,
- SB_BUFFER_WITH_SB(p_s_tb->tb_sb)) ;
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) )
- return REPEAT_SEARCH;
-
- /* if it possible in indirect_to_direct conversion */
- if (buffer_locked (p_s_tbS0)) {
- __wait_on_buffer (p_s_tbS0);
- if ( FILESYSTEM_CHANGED_TB (p_s_tb) )
- return REPEAT_SEARCH;
- }
+ /* we set wait_tb_buffers_run when we have to restore any dirty bits cleared
+ ** during wait_tb_buffers_run
+ */
+ int wait_tb_buffers_run = 0;
+ struct buffer_head *p_s_tbS0 = PATH_PLAST_BUFFER(p_s_tb->tb_path);
-#ifdef CONFIG_REISERFS_CHECK
- if ( cur_tb ) {
- print_cur_tb ("fix_nodes");
- reiserfs_panic(p_s_tb->tb_sb,"PAP-8305: fix_nodes: there is pending do_balance");
- }
-
- if (!buffer_uptodate (p_s_tbS0) || !B_IS_IN_TREE (p_s_tbS0)) {
- reiserfs_panic (p_s_tb->tb_sb, "PAP-8320: fix_nodes: S[0] (%b %z) is not uptodate "
- "at the beginning of fix_nodes or not in tree (mode %c)", p_s_tbS0, p_s_tbS0, n_op_mode);
- }
-
- /* Check parameters. */
- switch (n_op_mode) {
- case M_INSERT:
- if ( n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0) )
- reiserfs_panic(p_s_tb->tb_sb,"PAP-8330: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
- n_item_num, B_NR_ITEMS(p_s_tbS0));
- break;
- case M_PASTE:
- case M_DELETE:
- case M_CUT:
- if ( n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0) ) {
- print_block (p_s_tbS0, 0, -1, -1);
- reiserfs_panic(p_s_tb->tb_sb,"PAP-8335: fix_nodes: Incorrect item number(%d); mode = %c insert_size = %d\n", n_item_num, n_op_mode, p_s_tb->insert_size[0]);
- }
- break;
- default:
- reiserfs_panic(p_s_tb->tb_sb,"PAP-8340: fix_nodes: Incorrect mode of operation");
- }
-#endif
+ ++REISERFS_SB(p_s_tb->tb_sb)->s_fix_nodes;
+
+ n_pos_in_item = p_s_tb->tb_path->pos_in_item;
+
+ p_s_tb->fs_gen = get_generation(p_s_tb->tb_sb);
- if (get_mem_for_virtual_node (p_s_tb) == REPEAT_SEARCH)
- // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat
- return REPEAT_SEARCH;
+ /* we prepare and log the super here so it will already be in the
+ ** transaction when do_balance needs to change it.
+ ** This way do_balance won't have to schedule when trying to prepare
+ ** the super for logging
+ */
+ reiserfs_prepare_for_journal(p_s_tb->tb_sb,
+ SB_BUFFER_WITH_SB(p_s_tb->tb_sb), 1);
+ journal_mark_dirty(p_s_tb->transaction_handle, p_s_tb->tb_sb,
+ SB_BUFFER_WITH_SB(p_s_tb->tb_sb));
+ if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ return REPEAT_SEARCH;
+ /* if it possible in indirect_to_direct conversion */
+ if (buffer_locked(p_s_tbS0)) {
+ __wait_on_buffer(p_s_tbS0);
+ if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ return REPEAT_SEARCH;
+ }
+#ifdef CONFIG_REISERFS_CHECK
+ if (cur_tb) {
+ print_cur_tb("fix_nodes");
+ reiserfs_panic(p_s_tb->tb_sb,
+ "PAP-8305: fix_nodes: there is pending do_balance");
+ }
- /* Starting from the leaf level; for all levels n_h of the tree. */
- for ( n_h = 0; n_h < MAX_HEIGHT && p_s_tb->insert_size[n_h]; n_h++ ) {
- if ( (n_ret_value = get_direct_parent(p_s_tb, n_h)) != CARRY_ON ) {
- goto repeat;
+ if (!buffer_uptodate(p_s_tbS0) || !B_IS_IN_TREE(p_s_tbS0)) {
+ reiserfs_panic(p_s_tb->tb_sb,
+ "PAP-8320: fix_nodes: S[0] (%b %z) is not uptodate "
+ "at the beginning of fix_nodes or not in tree (mode %c)",
+ p_s_tbS0, p_s_tbS0, n_op_mode);
}
- if ( (n_ret_value = check_balance (n_op_mode, p_s_tb, n_h, n_item_num,
- n_pos_in_item, p_s_ins_ih, data)) != CARRY_ON ) {
- if ( n_ret_value == NO_BALANCING_NEEDED ) {
- /* No balancing for higher levels needed. */
- if ( (n_ret_value = get_neighbors(p_s_tb, n_h)) != CARRY_ON ) {
- goto repeat;
+ /* Check parameters. */
+ switch (n_op_mode) {
+ case M_INSERT:
+ if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0))
+ reiserfs_panic(p_s_tb->tb_sb,
+ "PAP-8330: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
+ n_item_num, B_NR_ITEMS(p_s_tbS0));
+ break;
+ case M_PASTE:
+ case M_DELETE:
+ case M_CUT:
+ if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0)) {
+ print_block(p_s_tbS0, 0, -1, -1);
+ reiserfs_panic(p_s_tb->tb_sb,
+ "PAP-8335: fix_nodes: Incorrect item number(%d); mode = %c insert_size = %d\n",
+ n_item_num, n_op_mode,
+ p_s_tb->insert_size[0]);
}
- if ( n_h != MAX_HEIGHT - 1 )
- p_s_tb->insert_size[n_h + 1] = 0;
- /* ok, analysis and resource gathering are complete */
break;
- }
- goto repeat;
+ default:
+ reiserfs_panic(p_s_tb->tb_sb,
+ "PAP-8340: fix_nodes: Incorrect mode of operation");
}
+#endif
- if ( (n_ret_value = get_neighbors(p_s_tb, n_h)) != CARRY_ON ) {
- goto repeat;
- }
+ if (get_mem_for_virtual_node(p_s_tb) == REPEAT_SEARCH)
+ // FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat
+ return REPEAT_SEARCH;
- if ( (n_ret_value = get_empty_nodes(p_s_tb, n_h)) != CARRY_ON ) {
- goto repeat; /* No disk space, or schedule occurred and
- analysis may be invalid and needs to be redone. */
- }
-
- if ( ! PATH_H_PBUFFER(p_s_tb->tb_path, n_h) ) {
- /* We have a positive insert size but no nodes exist on this
- level, this means that we are creating a new root. */
+ /* Starting from the leaf level; for all levels n_h of the tree. */
+ for (n_h = 0; n_h < MAX_HEIGHT && p_s_tb->insert_size[n_h]; n_h++) {
+ if ((n_ret_value = get_direct_parent(p_s_tb, n_h)) != CARRY_ON) {
+ goto repeat;
+ }
- RFALSE( p_s_tb->blknum[n_h] != 1,
- "PAP-8350: creating new empty root");
+ if ((n_ret_value =
+ check_balance(n_op_mode, p_s_tb, n_h, n_item_num,
+ n_pos_in_item, p_s_ins_ih,
+ data)) != CARRY_ON) {
+ if (n_ret_value == NO_BALANCING_NEEDED) {
+ /* No balancing for higher levels needed. */
+ if ((n_ret_value =
+ get_neighbors(p_s_tb, n_h)) != CARRY_ON) {
+ goto repeat;
+ }
+ if (n_h != MAX_HEIGHT - 1)
+ p_s_tb->insert_size[n_h + 1] = 0;
+ /* ok, analysis and resource gathering are complete */
+ break;
+ }
+ goto repeat;
+ }
- if ( n_h < MAX_HEIGHT - 1 )
- p_s_tb->insert_size[n_h + 1] = 0;
- }
- else
- if ( ! PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1) ) {
- if ( p_s_tb->blknum[n_h] > 1 ) {
- /* The tree needs to be grown, so this node S[n_h]
- which is the root node is split into two nodes,
- and a new node (S[n_h+1]) will be created to
- become the root node. */
-
- RFALSE( n_h == MAX_HEIGHT - 1,
- "PAP-8355: attempt to create too high of a tree");
-
- p_s_tb->insert_size[n_h + 1] = (DC_SIZE + KEY_SIZE) * (p_s_tb->blknum[n_h] - 1) + DC_SIZE;
+ if ((n_ret_value = get_neighbors(p_s_tb, n_h)) != CARRY_ON) {
+ goto repeat;
}
- else
- if ( n_h < MAX_HEIGHT - 1 )
- p_s_tb->insert_size[n_h + 1] = 0;
- }
- else
- p_s_tb->insert_size[n_h + 1] = (DC_SIZE + KEY_SIZE) * (p_s_tb->blknum[n_h] - 1);
- }
-
- if ((n_ret_value = wait_tb_buffers_until_unlocked (p_s_tb)) == CARRY_ON) {
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- wait_tb_buffers_run = 1 ;
- n_ret_value = REPEAT_SEARCH ;
- goto repeat;
- } else {
- return CARRY_ON;
+
+ if ((n_ret_value = get_empty_nodes(p_s_tb, n_h)) != CARRY_ON) {
+ goto repeat; /* No disk space, or schedule occurred and
+ analysis may be invalid and needs to be redone. */
+ }
+
+ if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h)) {
+ /* We have a positive insert size but no nodes exist on this
+ level, this means that we are creating a new root. */
+
+ RFALSE(p_s_tb->blknum[n_h] != 1,
+ "PAP-8350: creating new empty root");
+
+ if (n_h < MAX_HEIGHT - 1)
+ p_s_tb->insert_size[n_h + 1] = 0;
+ } else if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1)) {
+ if (p_s_tb->blknum[n_h] > 1) {
+ /* The tree needs to be grown, so this node S[n_h]
+ which is the root node is split into two nodes,
+ and a new node (S[n_h+1]) will be created to
+ become the root node. */
+
+ RFALSE(n_h == MAX_HEIGHT - 1,
+ "PAP-8355: attempt to create too high of a tree");
+
+ p_s_tb->insert_size[n_h + 1] =
+ (DC_SIZE +
+ KEY_SIZE) * (p_s_tb->blknum[n_h] - 1) +
+ DC_SIZE;
+ } else if (n_h < MAX_HEIGHT - 1)
+ p_s_tb->insert_size[n_h + 1] = 0;
+ } else
+ p_s_tb->insert_size[n_h + 1] =
+ (DC_SIZE + KEY_SIZE) * (p_s_tb->blknum[n_h] - 1);
}
- } else {
- wait_tb_buffers_run = 1 ;
- goto repeat;
- }
-
- repeat:
- // fix_nodes was unable to perform its calculation due to
- // filesystem got changed under us, lack of free disk space or i/o
- // failure. If the first is the case - the search will be
- // repeated. For now - free all resources acquired so far except
- // for the new allocated nodes
- {
- int i;
- /* Release path buffers. */
- if (wait_tb_buffers_run) {
- pathrelse_and_restore(p_s_tb->tb_sb, p_s_tb->tb_path) ;
+ if ((n_ret_value = wait_tb_buffers_until_unlocked(p_s_tb)) == CARRY_ON) {
+ if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ wait_tb_buffers_run = 1;
+ n_ret_value = REPEAT_SEARCH;
+ goto repeat;
+ } else {
+ return CARRY_ON;
+ }
} else {
- pathrelse (p_s_tb->tb_path);
- }
- /* brelse all resources collected for balancing */
- for ( i = 0; i < MAX_HEIGHT; i++ ) {
- if (wait_tb_buffers_run) {
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->L[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->R[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->FL[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->FR[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->CFL[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb, p_s_tb->CFR[i]);
- }
-
- brelse (p_s_tb->L[i]);p_s_tb->L[i] = NULL;
- brelse (p_s_tb->R[i]);p_s_tb->R[i] = NULL;
- brelse (p_s_tb->FL[i]);p_s_tb->FL[i] = NULL;
- brelse (p_s_tb->FR[i]);p_s_tb->FR[i] = NULL;
- brelse (p_s_tb->CFL[i]);p_s_tb->CFL[i] = NULL;
- brelse (p_s_tb->CFR[i]);p_s_tb->CFR[i] = NULL;
+ wait_tb_buffers_run = 1;
+ goto repeat;
}
- if (wait_tb_buffers_run) {
- for ( i = 0; i < MAX_FEB_SIZE; i++ ) {
- if ( p_s_tb->FEB[i] ) {
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->FEB[i]) ;
+ repeat:
+ // fix_nodes was unable to perform its calculation due to
+ // filesystem got changed under us, lack of free disk space or i/o
+ // failure. If the first is the case - the search will be
+ // repeated. For now - free all resources acquired so far except
+ // for the new allocated nodes
+ {
+ int i;
+
+ /* Release path buffers. */
+ if (wait_tb_buffers_run) {
+ pathrelse_and_restore(p_s_tb->tb_sb, p_s_tb->tb_path);
+ } else {
+ pathrelse(p_s_tb->tb_path);
+ }
+ /* brelse all resources collected for balancing */
+ for (i = 0; i < MAX_HEIGHT; i++) {
+ if (wait_tb_buffers_run) {
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->L[i]);
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->R[i]);
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->FL[i]);
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->FR[i]);
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->
+ CFL[i]);
+ reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
+ p_s_tb->
+ CFR[i]);
+ }
+
+ brelse(p_s_tb->L[i]);
+ p_s_tb->L[i] = NULL;
+ brelse(p_s_tb->R[i]);
+ p_s_tb->R[i] = NULL;
+ brelse(p_s_tb->FL[i]);
+ p_s_tb->FL[i] = NULL;
+ brelse(p_s_tb->FR[i]);
+ p_s_tb->FR[i] = NULL;
+ brelse(p_s_tb->CFL[i]);
+ p_s_tb->CFL[i] = NULL;
+ brelse(p_s_tb->CFR[i]);
+ p_s_tb->CFR[i] = NULL;
+ }
+
+ if (wait_tb_buffers_run) {
+ for (i = 0; i < MAX_FEB_SIZE; i++) {
+ if (p_s_tb->FEB[i]) {
+ reiserfs_restore_prepared_buffer
+ (p_s_tb->tb_sb, p_s_tb->FEB[i]);
+ }
+ }
}
- }
+ return n_ret_value;
}
- return n_ret_value;
- }
}
-
/* Anatoly will probably forgive me renaming p_s_tb to tb. I just
wanted to make lines shorter */
-void unfix_nodes (struct tree_balance * tb)
+void unfix_nodes(struct tree_balance *tb)
{
- int i;
-
- /* Release path buffers. */
- pathrelse_and_restore (tb->tb_sb, tb->tb_path);
-
- /* brelse all resources collected for balancing */
- for ( i = 0; i < MAX_HEIGHT; i++ ) {
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->L[i]);
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->R[i]);
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->FL[i]);
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->FR[i]);
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->CFL[i]);
- reiserfs_restore_prepared_buffer (tb->tb_sb, tb->CFR[i]);
-
- brelse (tb->L[i]);
- brelse (tb->R[i]);
- brelse (tb->FL[i]);
- brelse (tb->FR[i]);
- brelse (tb->CFL[i]);
- brelse (tb->CFR[i]);
- }
-
- /* deal with list of allocated (used and unused) nodes */
- for ( i = 0; i < MAX_FEB_SIZE; i++ ) {
- if ( tb->FEB[i] ) {
- b_blocknr_t blocknr = tb->FEB[i]->b_blocknr ;
- /* de-allocated block which was not used by balancing and
- bforget about buffer for it */
- brelse (tb->FEB[i]);
- reiserfs_free_block (tb->transaction_handle, NULL, blocknr, 0);
- }
- if (tb->used[i]) {
- /* release used as new nodes including a new root */
- brelse (tb->used[i]);
- }
- }
+ int i;
- if (tb->vn_buf)
- reiserfs_kfree (tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
+ /* Release path buffers. */
+ pathrelse_and_restore(tb->tb_sb, tb->tb_path);
-}
+ /* brelse all resources collected for balancing */
+ for (i = 0; i < MAX_HEIGHT; i++) {
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->L[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->R[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->FL[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->FR[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->CFL[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb, tb->CFR[i]);
+
+ brelse(tb->L[i]);
+ brelse(tb->R[i]);
+ brelse(tb->FL[i]);
+ brelse(tb->FR[i]);
+ brelse(tb->CFL[i]);
+ brelse(tb->CFR[i]);
+ }
+ /* deal with list of allocated (used and unused) nodes */
+ for (i = 0; i < MAX_FEB_SIZE; i++) {
+ if (tb->FEB[i]) {
+ b_blocknr_t blocknr = tb->FEB[i]->b_blocknr;
+ /* de-allocated block which was not used by balancing and
+ bforget about buffer for it */
+ brelse(tb->FEB[i]);
+ reiserfs_free_block(tb->transaction_handle, NULL,
+ blocknr, 0);
+ }
+ if (tb->used[i]) {
+ /* release used as new nodes including a new root */
+ brelse(tb->used[i]);
+ }
+ }
+ if (tb->vn_buf)
+ reiserfs_kfree(tb->vn_buf, tb->vn_buf_size, tb->tb_sb);
+}
diff --git a/fs/reiserfs/hashes.c b/fs/reiserfs/hashes.c
index 08d0508c2d3..37c1306eb9b 100644
--- a/fs/reiserfs/hashes.c
+++ b/fs/reiserfs/hashes.c
@@ -22,7 +22,6 @@
#include <asm/types.h>
#include <asm/bug.h>
-
#define DELTA 0x9E3779B9
#define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
#define PARTROUNDS 6 /* 6 gets complete mixing */
@@ -48,105 +47,75 @@
h1 += b1; \
} while(0)
-
u32 keyed_hash(const signed char *msg, int len)
{
- u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3};
+ u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3 };
u32 h0 = k[0], h1 = k[1];
u32 a, b, c, d;
u32 pad;
int i;
-
- // assert(len >= 0 && len < 256);
- pad = (u32)len | ((u32)len << 8);
+ // assert(len >= 0 && len < 256);
+
+ pad = (u32) len | ((u32) len << 8);
pad |= pad << 16;
- while(len >= 16)
- {
- a = (u32)msg[ 0] |
- (u32)msg[ 1] << 8 |
- (u32)msg[ 2] << 16|
- (u32)msg[ 3] << 24;
- b = (u32)msg[ 4] |
- (u32)msg[ 5] << 8 |
- (u32)msg[ 6] << 16|
- (u32)msg[ 7] << 24;
- c = (u32)msg[ 8] |
- (u32)msg[ 9] << 8 |
- (u32)msg[10] << 16|
- (u32)msg[11] << 24;
- d = (u32)msg[12] |
- (u32)msg[13] << 8 |
- (u32)msg[14] << 16|
- (u32)msg[15] << 24;
-
+ while (len >= 16) {
+ a = (u32) msg[0] |
+ (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
+ b = (u32) msg[4] |
+ (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
+ c = (u32) msg[8] |
+ (u32) msg[9] << 8 |
+ (u32) msg[10] << 16 | (u32) msg[11] << 24;
+ d = (u32) msg[12] |
+ (u32) msg[13] << 8 |
+ (u32) msg[14] << 16 | (u32) msg[15] << 24;
+
TEACORE(PARTROUNDS);
len -= 16;
msg += 16;
}
- if (len >= 12)
- {
- a = (u32)msg[ 0] |
- (u32)msg[ 1] << 8 |
- (u32)msg[ 2] << 16|
- (u32)msg[ 3] << 24;
- b = (u32)msg[ 4] |
- (u32)msg[ 5] << 8 |
- (u32)msg[ 6] << 16|
- (u32)msg[ 7] << 24;
- c = (u32)msg[ 8] |
- (u32)msg[ 9] << 8 |
- (u32)msg[10] << 16|
- (u32)msg[11] << 24;
+ if (len >= 12) {
+ a = (u32) msg[0] |
+ (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
+ b = (u32) msg[4] |
+ (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
+ c = (u32) msg[8] |
+ (u32) msg[9] << 8 |
+ (u32) msg[10] << 16 | (u32) msg[11] << 24;
d = pad;
- for(i = 12; i < len; i++)
- {
+ for (i = 12; i < len; i++) {
d <<= 8;
d |= msg[i];
}
- }
- else if (len >= 8)
- {
- a = (u32)msg[ 0] |
- (u32)msg[ 1] << 8 |
- (u32)msg[ 2] << 16|
- (u32)msg[ 3] << 24;
- b = (u32)msg[ 4] |
- (u32)msg[ 5] << 8 |
- (u32)msg[ 6] << 16|
- (u32)msg[ 7] << 24;
+ } else if (len >= 8) {
+ a = (u32) msg[0] |
+ (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
+ b = (u32) msg[4] |
+ (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
c = d = pad;
- for(i = 8; i < len; i++)
- {
+ for (i = 8; i < len; i++) {
c <<= 8;
c |= msg[i];
}
- }
- else if (len >= 4)
- {
- a = (u32)msg[ 0] |
- (u32)msg[ 1] << 8 |
- (u32)msg[ 2] << 16|
- (u32)msg[ 3] << 24;
+ } else if (len >= 4) {
+ a = (u32) msg[0] |
+ (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
b = c = d = pad;
- for(i = 4; i < len; i++)
- {
+ for (i = 4; i < len; i++) {
b <<= 8;
b |= msg[i];
}
- }
- else
- {
+ } else {
a = b = c = d = pad;
- for(i = 0; i < len; i++)
- {
+ for (i = 0; i < len; i++) {
a <<= 8;
a |= msg[i];
}
@@ -155,55 +124,59 @@ u32 keyed_hash(const signed char *msg, int len)
TEACORE(FULLROUNDS);
/* return 0;*/
- return h0^h1;
+ return h0 ^ h1;
}
/* What follows in this file is copyright 2000 by Hans Reiser, and the
* licensing of what follows is governed by reiserfs/README */
-u32 yura_hash (const signed char *msg, int len)
+u32 yura_hash(const signed char *msg, int len)
{
- int j, pow;
- u32 a, c;
- int i;
-
- for (pow=1,i=1; i < len; i++) pow = pow * 10;
-
- if (len == 1)
- a = msg[0]-48;
- else
- a = (msg[0] - 48) * pow;
-
- for (i=1; i < len; i++) {
- c = msg[i] - 48;
- for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
- a = a + c * pow;
- }
-
- for (; i < 40; i++) {
- c = '0' - 48;
- for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
- a = a + c * pow;
- }
-
- for (; i < 256; i++) {
- c = i;
- for (pow=1,j=i; j < len-1; j++) pow = pow * 10;
- a = a + c * pow;
- }
-
- a = a << 7;
- return a;
+ int j, pow;
+ u32 a, c;
+ int i;
+
+ for (pow = 1, i = 1; i < len; i++)
+ pow = pow * 10;
+
+ if (len == 1)
+ a = msg[0] - 48;
+ else
+ a = (msg[0] - 48) * pow;
+
+ for (i = 1; i < len; i++) {
+ c = msg[i] - 48;
+ for (pow = 1, j = i; j < len - 1; j++)
+ pow = pow * 10;
+ a = a + c * pow;
+ }
+
+ for (; i < 40; i++) {
+ c = '0' - 48;
+ for (pow = 1, j = i; j < len - 1; j++)
+ pow = pow * 10;
+ a = a + c * pow;
+ }
+
+ for (; i < 256; i++) {
+ c = i;
+ for (pow = 1, j = i; j < len - 1; j++)
+ pow = pow * 10;
+ a = a + c * pow;
+ }
+
+ a = a << 7;
+ return a;
}
-u32 r5_hash (const signed char *msg, int len)
+u32 r5_hash(const signed char *msg, int len)
{
- u32 a=0;
- while(*msg) {
- a += *msg << 4;
- a += *msg >> 4;
- a *= 11;
- msg++;
- }
- return a;
+ u32 a = 0;
+ while (*msg) {
+ a += *msg << 4;
+ a += *msg >> 4;
+ a *= 11;
+ msg++;
+ }
+ return a;
}
diff --git a/fs/reiserfs/ibalance.c b/fs/reiserfs/ibalance.c
index a362125da0d..6c5a726fd34 100644
--- a/fs/reiserfs/ibalance.c
+++ b/fs/reiserfs/ibalance.c
@@ -10,13 +10,8 @@
#include <linux/buffer_head.h>
/* this is one and only function that is used outside (do_balance.c) */
-int balance_internal (
- struct tree_balance * ,
- int,
- int,
- struct item_head * ,
- struct buffer_head **
- );
+int balance_internal(struct tree_balance *,
+ int, int, struct item_head *, struct buffer_head **);
/* modes of internal_shift_left, internal_shift_right and internal_insert_childs */
#define INTERNAL_SHIFT_FROM_S_TO_L 0
@@ -27,464 +22,474 @@ int balance_internal (
#define INTERNAL_INSERT_TO_L 5
#define INTERNAL_INSERT_TO_R 6
-static void internal_define_dest_src_infos (
- int shift_mode,
- struct tree_balance * tb,
- int h,
- struct buffer_info * dest_bi,
- struct buffer_info * src_bi,
- int * d_key,
- struct buffer_head ** cf
- )
+static void internal_define_dest_src_infos(int shift_mode,
+ struct tree_balance *tb,
+ int h,
+ struct buffer_info *dest_bi,
+ struct buffer_info *src_bi,
+ int *d_key, struct buffer_head **cf)
{
- memset (dest_bi, 0, sizeof (struct buffer_info));
- memset (src_bi, 0, sizeof (struct buffer_info));
- /* define dest, src, dest parent, dest position */
- switch (shift_mode) {
- case INTERNAL_SHIFT_FROM_S_TO_L: /* used in internal_shift_left */
- src_bi->tb = tb;
- src_bi->bi_bh = PATH_H_PBUFFER (tb->tb_path, h);
- src_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- src_bi->bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->L[h];
- dest_bi->bi_parent = tb->FL[h];
- dest_bi->bi_position = get_left_neighbor_position (tb, h);
- *d_key = tb->lkey[h];
- *cf = tb->CFL[h];
- break;
- case INTERNAL_SHIFT_FROM_L_TO_S:
- src_bi->tb = tb;
- src_bi->bi_bh = tb->L[h];
- src_bi->bi_parent = tb->FL[h];
- src_bi->bi_position = get_left_neighbor_position (tb, h);
- dest_bi->tb = tb;
- dest_bi->bi_bh = PATH_H_PBUFFER (tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION (tb->tb_path, h + 1); /* dest position is analog of dest->b_item_order */
- *d_key = tb->lkey[h];
- *cf = tb->CFL[h];
- break;
-
- case INTERNAL_SHIFT_FROM_R_TO_S: /* used in internal_shift_left */
- src_bi->tb = tb;
- src_bi->bi_bh = tb->R[h];
- src_bi->bi_parent = tb->FR[h];
- src_bi->bi_position = get_right_neighbor_position (tb, h);
- dest_bi->tb = tb;
- dest_bi->bi_bh = PATH_H_PBUFFER (tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
- *d_key = tb->rkey[h];
- *cf = tb->CFR[h];
- break;
-
- case INTERNAL_SHIFT_FROM_S_TO_R:
- src_bi->tb = tb;
- src_bi->bi_bh = PATH_H_PBUFFER (tb->tb_path, h);
- src_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- src_bi->bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->R[h];
- dest_bi->bi_parent = tb->FR[h];
- dest_bi->bi_position = get_right_neighbor_position (tb, h);
- *d_key = tb->rkey[h];
- *cf = tb->CFR[h];
- break;
-
- case INTERNAL_INSERT_TO_L:
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->L[h];
- dest_bi->bi_parent = tb->FL[h];
- dest_bi->bi_position = get_left_neighbor_position (tb, h);
- break;
-
- case INTERNAL_INSERT_TO_S:
- dest_bi->tb = tb;
- dest_bi->bi_bh = PATH_H_PBUFFER (tb->tb_path, h);
- dest_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- dest_bi->bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
- break;
-
- case INTERNAL_INSERT_TO_R:
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->R[h];
- dest_bi->bi_parent = tb->FR[h];
- dest_bi->bi_position = get_right_neighbor_position (tb, h);
- break;
-
- default:
- reiserfs_panic (tb->tb_sb, "internal_define_dest_src_infos: shift type is unknown (%d)", shift_mode);
- }
+ memset(dest_bi, 0, sizeof(struct buffer_info));
+ memset(src_bi, 0, sizeof(struct buffer_info));
+ /* define dest, src, dest parent, dest position */
+ switch (shift_mode) {
+ case INTERNAL_SHIFT_FROM_S_TO_L: /* used in internal_shift_left */
+ src_bi->tb = tb;
+ src_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ src_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->L[h];
+ dest_bi->bi_parent = tb->FL[h];
+ dest_bi->bi_position = get_left_neighbor_position(tb, h);
+ *d_key = tb->lkey[h];
+ *cf = tb->CFL[h];
+ break;
+ case INTERNAL_SHIFT_FROM_L_TO_S:
+ src_bi->tb = tb;
+ src_bi->bi_bh = tb->L[h];
+ src_bi->bi_parent = tb->FL[h];
+ src_bi->bi_position = get_left_neighbor_position(tb, h);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1); /* dest position is analog of dest->b_item_order */
+ *d_key = tb->lkey[h];
+ *cf = tb->CFL[h];
+ break;
+
+ case INTERNAL_SHIFT_FROM_R_TO_S: /* used in internal_shift_left */
+ src_bi->tb = tb;
+ src_bi->bi_bh = tb->R[h];
+ src_bi->bi_parent = tb->FR[h];
+ src_bi->bi_position = get_right_neighbor_position(tb, h);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ *d_key = tb->rkey[h];
+ *cf = tb->CFR[h];
+ break;
+
+ case INTERNAL_SHIFT_FROM_S_TO_R:
+ src_bi->tb = tb;
+ src_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ src_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->R[h];
+ dest_bi->bi_parent = tb->FR[h];
+ dest_bi->bi_position = get_right_neighbor_position(tb, h);
+ *d_key = tb->rkey[h];
+ *cf = tb->CFR[h];
+ break;
+
+ case INTERNAL_INSERT_TO_L:
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->L[h];
+ dest_bi->bi_parent = tb->FL[h];
+ dest_bi->bi_position = get_left_neighbor_position(tb, h);
+ break;
+
+ case INTERNAL_INSERT_TO_S:
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = PATH_H_PBUFFER(tb->tb_path, h);
+ dest_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ dest_bi->bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ break;
+
+ case INTERNAL_INSERT_TO_R:
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->R[h];
+ dest_bi->bi_parent = tb->FR[h];
+ dest_bi->bi_position = get_right_neighbor_position(tb, h);
+ break;
+
+ default:
+ reiserfs_panic(tb->tb_sb,
+ "internal_define_dest_src_infos: shift type is unknown (%d)",
+ shift_mode);
+ }
}
-
-
/* Insert count node pointers into buffer cur before position to + 1.
* Insert count items into buffer cur before position to.
* Items and node pointers are specified by inserted and bh respectively.
- */
-static void internal_insert_childs (struct buffer_info * cur_bi,
- int to, int count,
- struct item_head * inserted,
- struct buffer_head ** bh
- )
+ */
+static void internal_insert_childs(struct buffer_info *cur_bi,
+ int to, int count,
+ struct item_head *inserted,
+ struct buffer_head **bh)
{
- struct buffer_head * cur = cur_bi->bi_bh;
- struct block_head * blkh;
- int nr;
- struct reiserfs_key * ih;
- struct disk_child new_dc[2];
- struct disk_child * dc;
- int i;
-
- if (count <= 0)
- return;
-
- blkh = B_BLK_HEAD(cur);
- nr = blkh_nr_item(blkh);
-
- RFALSE( count > 2,
- "too many children (%d) are to be inserted", count);
- RFALSE( B_FREE_SPACE (cur) < count * (KEY_SIZE + DC_SIZE),
- "no enough free space (%d), needed %d bytes",
- B_FREE_SPACE (cur), count * (KEY_SIZE + DC_SIZE));
-
- /* prepare space for count disk_child */
- dc = B_N_CHILD(cur,to+1);
-
- memmove (dc + count, dc, (nr+1-(to+1)) * DC_SIZE);
-
- /* copy to_be_insert disk children */
- for (i = 0; i < count; i ++) {
- put_dc_size( &(new_dc[i]), MAX_CHILD_SIZE(bh[i]) - B_FREE_SPACE(bh[i]));
- put_dc_block_number( &(new_dc[i]), bh[i]->b_blocknr );
- }
- memcpy (dc, new_dc, DC_SIZE * count);
-
-
- /* prepare space for count items */
- ih = B_N_PDELIM_KEY (cur, ((to == -1) ? 0 : to));
-
- memmove (ih + count, ih, (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
-
- /* copy item headers (keys) */
- memcpy (ih, inserted, KEY_SIZE);
- if ( count > 1 )
- memcpy (ih + 1, inserted + 1, KEY_SIZE);
-
- /* sizes, item number */
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) + count );
- set_blkh_free_space( blkh,
- blkh_free_space(blkh) - count * (DC_SIZE + KEY_SIZE ) );
-
- do_balance_mark_internal_dirty (cur_bi->tb, cur,0);
-
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (cur);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
-
- if (cur_bi->bi_parent) {
- struct disk_child *t_dc = B_N_CHILD (cur_bi->bi_parent,cur_bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) + (count * (DC_SIZE + KEY_SIZE)));
- do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent, 0);
-
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (cur_bi->bi_parent);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- }
+ struct buffer_head *cur = cur_bi->bi_bh;
+ struct block_head *blkh;
+ int nr;
+ struct reiserfs_key *ih;
+ struct disk_child new_dc[2];
+ struct disk_child *dc;
+ int i;
+
+ if (count <= 0)
+ return;
+
+ blkh = B_BLK_HEAD(cur);
+ nr = blkh_nr_item(blkh);
+
+ RFALSE(count > 2, "too many children (%d) are to be inserted", count);
+ RFALSE(B_FREE_SPACE(cur) < count * (KEY_SIZE + DC_SIZE),
+ "no enough free space (%d), needed %d bytes",
+ B_FREE_SPACE(cur), count * (KEY_SIZE + DC_SIZE));
+
+ /* prepare space for count disk_child */
+ dc = B_N_CHILD(cur, to + 1);
+
+ memmove(dc + count, dc, (nr + 1 - (to + 1)) * DC_SIZE);
+
+ /* copy to_be_insert disk children */
+ for (i = 0; i < count; i++) {
+ put_dc_size(&(new_dc[i]),
+ MAX_CHILD_SIZE(bh[i]) - B_FREE_SPACE(bh[i]));
+ put_dc_block_number(&(new_dc[i]), bh[i]->b_blocknr);
+ }
+ memcpy(dc, new_dc, DC_SIZE * count);
+
+ /* prepare space for count items */
+ ih = B_N_PDELIM_KEY(cur, ((to == -1) ? 0 : to));
+
+ memmove(ih + count, ih,
+ (nr - to) * KEY_SIZE + (nr + 1 + count) * DC_SIZE);
+
+ /* copy item headers (keys) */
+ memcpy(ih, inserted, KEY_SIZE);
+ if (count > 1)
+ memcpy(ih + 1, inserted + 1, KEY_SIZE);
+
+ /* sizes, item number */
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) + count);
+ set_blkh_free_space(blkh,
+ blkh_free_space(blkh) - count * (DC_SIZE +
+ KEY_SIZE));
+
+ do_balance_mark_internal_dirty(cur_bi->tb, cur, 0);
+
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(cur);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+
+ if (cur_bi->bi_parent) {
+ struct disk_child *t_dc =
+ B_N_CHILD(cur_bi->bi_parent, cur_bi->bi_position);
+ put_dc_size(t_dc,
+ dc_size(t_dc) + (count * (DC_SIZE + KEY_SIZE)));
+ do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent,
+ 0);
+
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(cur_bi->bi_parent);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ }
}
-
/* Delete del_num items and node pointers from buffer cur starting from *
* the first_i'th item and first_p'th pointers respectively. */
-static void internal_delete_pointers_items (
- struct buffer_info * cur_bi,
- int first_p,
- int first_i,
- int del_num
- )
+static void internal_delete_pointers_items(struct buffer_info *cur_bi,
+ int first_p,
+ int first_i, int del_num)
{
- struct buffer_head * cur = cur_bi->bi_bh;
- int nr;
- struct block_head * blkh;
- struct reiserfs_key * key;
- struct disk_child * dc;
-
- RFALSE( cur == NULL, "buffer is 0");
- RFALSE( del_num < 0,
- "negative number of items (%d) can not be deleted", del_num);
- RFALSE( first_p < 0 || first_p + del_num > B_NR_ITEMS (cur) + 1 || first_i < 0,
- "first pointer order (%d) < 0 or "
- "no so many pointers (%d), only (%d) or "
- "first key order %d < 0", first_p,
- first_p + del_num, B_NR_ITEMS (cur) + 1, first_i);
- if ( del_num == 0 )
- return;
-
- blkh = B_BLK_HEAD(cur);
- nr = blkh_nr_item(blkh);
-
- if ( first_p == 0 && del_num == nr + 1 ) {
- RFALSE( first_i != 0, "1st deleted key must have order 0, not %d", first_i);
- make_empty_node (cur_bi);
- return;
- }
-
- RFALSE( first_i + del_num > B_NR_ITEMS (cur),
- "first_i = %d del_num = %d "
- "no so many keys (%d) in the node (%b)(%z)",
- first_i, del_num, first_i + del_num, cur, cur);
-
-
- /* deleting */
- dc = B_N_CHILD (cur, first_p);
-
- memmove (dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE);
- key = B_N_PDELIM_KEY (cur, first_i);
- memmove (key, key + del_num, (nr - first_i - del_num) * KEY_SIZE + (nr + 1 - del_num) * DC_SIZE);
-
-
- /* sizes, item number */
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) - del_num );
- set_blkh_free_space( blkh,
- blkh_free_space(blkh) + (del_num * (KEY_SIZE + DC_SIZE) ) );
-
- do_balance_mark_internal_dirty (cur_bi->tb, cur, 0);
- /*&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (cur);
- /*&&&&&&&&&&&&&&&&&&&&&&&*/
-
- if (cur_bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD (cur_bi->bi_parent, cur_bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) - (del_num * (KEY_SIZE + DC_SIZE) ) );
-
- do_balance_mark_internal_dirty (cur_bi->tb, cur_bi->bi_parent,0);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (cur_bi->bi_parent);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- }
-}
+ struct buffer_head *cur = cur_bi->bi_bh;
+ int nr;
+ struct block_head *blkh;
+ struct reiserfs_key *key;
+ struct disk_child *dc;
+
+ RFALSE(cur == NULL, "buffer is 0");
+ RFALSE(del_num < 0,
+ "negative number of items (%d) can not be deleted", del_num);
+ RFALSE(first_p < 0 || first_p + del_num > B_NR_ITEMS(cur) + 1
+ || first_i < 0,
+ "first pointer order (%d) < 0 or "
+ "no so many pointers (%d), only (%d) or "
+ "first key order %d < 0", first_p, first_p + del_num,
+ B_NR_ITEMS(cur) + 1, first_i);
+ if (del_num == 0)
+ return;
+
+ blkh = B_BLK_HEAD(cur);
+ nr = blkh_nr_item(blkh);
+
+ if (first_p == 0 && del_num == nr + 1) {
+ RFALSE(first_i != 0,
+ "1st deleted key must have order 0, not %d", first_i);
+ make_empty_node(cur_bi);
+ return;
+ }
+ RFALSE(first_i + del_num > B_NR_ITEMS(cur),
+ "first_i = %d del_num = %d "
+ "no so many keys (%d) in the node (%b)(%z)",
+ first_i, del_num, first_i + del_num, cur, cur);
+
+ /* deleting */
+ dc = B_N_CHILD(cur, first_p);
+
+ memmove(dc, dc + del_num, (nr + 1 - first_p - del_num) * DC_SIZE);
+ key = B_N_PDELIM_KEY(cur, first_i);
+ memmove(key, key + del_num,
+ (nr - first_i - del_num) * KEY_SIZE + (nr + 1 -
+ del_num) * DC_SIZE);
+
+ /* sizes, item number */
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) - del_num);
+ set_blkh_free_space(blkh,
+ blkh_free_space(blkh) +
+ (del_num * (KEY_SIZE + DC_SIZE)));
+
+ do_balance_mark_internal_dirty(cur_bi->tb, cur, 0);
+ /*&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(cur);
+ /*&&&&&&&&&&&&&&&&&&&&&&& */
+
+ if (cur_bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(cur_bi->bi_parent, cur_bi->bi_position);
+ put_dc_size(t_dc,
+ dc_size(t_dc) - (del_num * (KEY_SIZE + DC_SIZE)));
+
+ do_balance_mark_internal_dirty(cur_bi->tb, cur_bi->bi_parent,
+ 0);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(cur_bi->bi_parent);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ }
+}
/* delete n node pointers and items starting from given position */
-static void internal_delete_childs (struct buffer_info * cur_bi,
- int from, int n)
+static void internal_delete_childs(struct buffer_info *cur_bi, int from, int n)
{
- int i_from;
+ int i_from;
- i_from = (from == 0) ? from : from - 1;
+ i_from = (from == 0) ? from : from - 1;
- /* delete n pointers starting from `from' position in CUR;
- delete n keys starting from 'i_from' position in CUR;
- */
- internal_delete_pointers_items (cur_bi, from, i_from, n);
+ /* delete n pointers starting from `from' position in CUR;
+ delete n keys starting from 'i_from' position in CUR;
+ */
+ internal_delete_pointers_items(cur_bi, from, i_from, n);
}
-
/* copy cpy_num node pointers and cpy_num - 1 items from buffer src to buffer dest
* last_first == FIRST_TO_LAST means, that we copy first items from src to tail of dest
* last_first == LAST_TO_FIRST means, that we copy last items from src to head of dest
*/
-static void internal_copy_pointers_items (
- struct buffer_info * dest_bi,
- struct buffer_head * src,
- int last_first, int cpy_num
- )
+static void internal_copy_pointers_items(struct buffer_info *dest_bi,
+ struct buffer_head *src,
+ int last_first, int cpy_num)
{
- /* ATTENTION! Number of node pointers in DEST is equal to number of items in DEST *
- * as delimiting key have already inserted to buffer dest.*/
- struct buffer_head * dest = dest_bi->bi_bh;
- int nr_dest, nr_src;
- int dest_order, src_order;
- struct block_head * blkh;
- struct reiserfs_key * key;
- struct disk_child * dc;
-
- nr_src = B_NR_ITEMS (src);
-
- RFALSE( dest == NULL || src == NULL,
- "src (%p) or dest (%p) buffer is 0", src, dest);
- RFALSE( last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST,
- "invalid last_first parameter (%d)", last_first);
- RFALSE( nr_src < cpy_num - 1,
- "no so many items (%d) in src (%d)", cpy_num, nr_src);
- RFALSE( cpy_num < 0, "cpy_num less than 0 (%d)", cpy_num);
- RFALSE( cpy_num - 1 + B_NR_ITEMS(dest) > (int)MAX_NR_KEY(dest),
- "cpy_num (%d) + item number in dest (%d) can not be > MAX_NR_KEY(%d)",
- cpy_num, B_NR_ITEMS(dest), MAX_NR_KEY(dest));
-
- if ( cpy_num == 0 )
- return;
+ /* ATTENTION! Number of node pointers in DEST is equal to number of items in DEST *
+ * as delimiting key have already inserted to buffer dest.*/
+ struct buffer_head *dest = dest_bi->bi_bh;
+ int nr_dest, nr_src;
+ int dest_order, src_order;
+ struct block_head *blkh;
+ struct reiserfs_key *key;
+ struct disk_child *dc;
+
+ nr_src = B_NR_ITEMS(src);
+
+ RFALSE(dest == NULL || src == NULL,
+ "src (%p) or dest (%p) buffer is 0", src, dest);
+ RFALSE(last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST,
+ "invalid last_first parameter (%d)", last_first);
+ RFALSE(nr_src < cpy_num - 1,
+ "no so many items (%d) in src (%d)", cpy_num, nr_src);
+ RFALSE(cpy_num < 0, "cpy_num less than 0 (%d)", cpy_num);
+ RFALSE(cpy_num - 1 + B_NR_ITEMS(dest) > (int)MAX_NR_KEY(dest),
+ "cpy_num (%d) + item number in dest (%d) can not be > MAX_NR_KEY(%d)",
+ cpy_num, B_NR_ITEMS(dest), MAX_NR_KEY(dest));
+
+ if (cpy_num == 0)
+ return;
/* coping */
- blkh = B_BLK_HEAD(dest);
- nr_dest = blkh_nr_item(blkh);
+ blkh = B_BLK_HEAD(dest);
+ nr_dest = blkh_nr_item(blkh);
- /*dest_order = (last_first == LAST_TO_FIRST) ? 0 : nr_dest;*/
- /*src_order = (last_first == LAST_TO_FIRST) ? (nr_src - cpy_num + 1) : 0;*/
- (last_first == LAST_TO_FIRST) ? (dest_order = 0, src_order = nr_src - cpy_num + 1) :
- (dest_order = nr_dest, src_order = 0);
+ /*dest_order = (last_first == LAST_TO_FIRST) ? 0 : nr_dest; */
+ /*src_order = (last_first == LAST_TO_FIRST) ? (nr_src - cpy_num + 1) : 0; */
+ (last_first == LAST_TO_FIRST) ? (dest_order = 0, src_order =
+ nr_src - cpy_num + 1) : (dest_order =
+ nr_dest,
+ src_order =
+ 0);
- /* prepare space for cpy_num pointers */
- dc = B_N_CHILD (dest, dest_order);
+ /* prepare space for cpy_num pointers */
+ dc = B_N_CHILD(dest, dest_order);
- memmove (dc + cpy_num, dc, (nr_dest - dest_order) * DC_SIZE);
+ memmove(dc + cpy_num, dc, (nr_dest - dest_order) * DC_SIZE);
/* insert pointers */
- memcpy (dc, B_N_CHILD (src, src_order), DC_SIZE * cpy_num);
-
-
- /* prepare space for cpy_num - 1 item headers */
- key = B_N_PDELIM_KEY(dest, dest_order);
- memmove (key + cpy_num - 1, key,
- KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest + cpy_num));
-
-
- /* insert headers */
- memcpy (key, B_N_PDELIM_KEY (src, src_order), KEY_SIZE * (cpy_num - 1));
-
- /* sizes, item number */
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) + (cpy_num - 1 ) );
- set_blkh_free_space( blkh,
- blkh_free_space(blkh) - (KEY_SIZE * (cpy_num - 1) + DC_SIZE * cpy_num ) );
-
- do_balance_mark_internal_dirty (dest_bi->tb, dest, 0);
-
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (dest);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
-
- if (dest_bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD(dest_bi->bi_parent,dest_bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) + (KEY_SIZE * (cpy_num - 1) + DC_SIZE * cpy_num) );
-
- do_balance_mark_internal_dirty (dest_bi->tb, dest_bi->bi_parent,0);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (dest_bi->bi_parent);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- }
+ memcpy(dc, B_N_CHILD(src, src_order), DC_SIZE * cpy_num);
+
+ /* prepare space for cpy_num - 1 item headers */
+ key = B_N_PDELIM_KEY(dest, dest_order);
+ memmove(key + cpy_num - 1, key,
+ KEY_SIZE * (nr_dest - dest_order) + DC_SIZE * (nr_dest +
+ cpy_num));
+
+ /* insert headers */
+ memcpy(key, B_N_PDELIM_KEY(src, src_order), KEY_SIZE * (cpy_num - 1));
+
+ /* sizes, item number */
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) + (cpy_num - 1));
+ set_blkh_free_space(blkh,
+ blkh_free_space(blkh) - (KEY_SIZE * (cpy_num - 1) +
+ DC_SIZE * cpy_num));
+
+ do_balance_mark_internal_dirty(dest_bi->tb, dest, 0);
+
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(dest);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+
+ if (dest_bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(dest_bi->bi_parent, dest_bi->bi_position);
+ put_dc_size(t_dc,
+ dc_size(t_dc) + (KEY_SIZE * (cpy_num - 1) +
+ DC_SIZE * cpy_num));
+
+ do_balance_mark_internal_dirty(dest_bi->tb, dest_bi->bi_parent,
+ 0);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(dest_bi->bi_parent);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ }
}
-
/* Copy cpy_num node pointers and cpy_num - 1 items from buffer src to buffer dest.
* Delete cpy_num - del_par items and node pointers from buffer src.
* last_first == FIRST_TO_LAST means, that we copy/delete first items from src.
* last_first == LAST_TO_FIRST means, that we copy/delete last items from src.
*/
-static void internal_move_pointers_items (struct buffer_info * dest_bi,
- struct buffer_info * src_bi,
- int last_first, int cpy_num, int del_par)
+static void internal_move_pointers_items(struct buffer_info *dest_bi,
+ struct buffer_info *src_bi,
+ int last_first, int cpy_num,
+ int del_par)
{
- int first_pointer;
- int first_item;
-
- internal_copy_pointers_items (dest_bi, src_bi->bi_bh, last_first, cpy_num);
-
- if (last_first == FIRST_TO_LAST) { /* shift_left occurs */
- first_pointer = 0;
- first_item = 0;
- /* delete cpy_num - del_par pointers and keys starting for pointers with first_pointer,
- for key - with first_item */
- internal_delete_pointers_items (src_bi, first_pointer, first_item, cpy_num - del_par);
- } else { /* shift_right occurs */
- int i, j;
-
- i = ( cpy_num - del_par == ( j = B_NR_ITEMS(src_bi->bi_bh)) + 1 ) ? 0 : j - cpy_num + del_par;
-
- internal_delete_pointers_items (src_bi, j + 1 - cpy_num + del_par, i, cpy_num - del_par);
- }
+ int first_pointer;
+ int first_item;
+
+ internal_copy_pointers_items(dest_bi, src_bi->bi_bh, last_first,
+ cpy_num);
+
+ if (last_first == FIRST_TO_LAST) { /* shift_left occurs */
+ first_pointer = 0;
+ first_item = 0;
+ /* delete cpy_num - del_par pointers and keys starting for pointers with first_pointer,
+ for key - with first_item */
+ internal_delete_pointers_items(src_bi, first_pointer,
+ first_item, cpy_num - del_par);
+ } else { /* shift_right occurs */
+ int i, j;
+
+ i = (cpy_num - del_par ==
+ (j =
+ B_NR_ITEMS(src_bi->bi_bh)) + 1) ? 0 : j - cpy_num +
+ del_par;
+
+ internal_delete_pointers_items(src_bi,
+ j + 1 - cpy_num + del_par, i,
+ cpy_num - del_par);
+ }
}
/* Insert n_src'th key of buffer src before n_dest'th key of buffer dest. */
-static void internal_insert_key (struct buffer_info * dest_bi,
- int dest_position_before, /* insert key before key with n_dest number */
- struct buffer_head * src,
- int src_position)
+static void internal_insert_key(struct buffer_info *dest_bi, int dest_position_before, /* insert key before key with n_dest number */
+ struct buffer_head *src, int src_position)
{
- struct buffer_head * dest = dest_bi->bi_bh;
- int nr;
- struct block_head * blkh;
- struct reiserfs_key * key;
-
- RFALSE( dest == NULL || src == NULL,
- "source(%p) or dest(%p) buffer is 0", src, dest);
- RFALSE( dest_position_before < 0 || src_position < 0,
- "source(%d) or dest(%d) key number less than 0",
- src_position, dest_position_before);
- RFALSE( dest_position_before > B_NR_ITEMS (dest) ||
- src_position >= B_NR_ITEMS(src),
- "invalid position in dest (%d (key number %d)) or in src (%d (key number %d))",
- dest_position_before, B_NR_ITEMS (dest),
- src_position, B_NR_ITEMS(src));
- RFALSE( B_FREE_SPACE (dest) < KEY_SIZE,
- "no enough free space (%d) in dest buffer", B_FREE_SPACE (dest));
-
- blkh = B_BLK_HEAD(dest);
- nr = blkh_nr_item(blkh);
-
- /* prepare space for inserting key */
- key = B_N_PDELIM_KEY (dest, dest_position_before);
- memmove (key + 1, key, (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
-
- /* insert key */
- memcpy (key, B_N_PDELIM_KEY(src, src_position), KEY_SIZE);
-
- /* Change dirt, free space, item number fields. */
-
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) + 1 );
- set_blkh_free_space( blkh, blkh_free_space(blkh) - KEY_SIZE );
-
- do_balance_mark_internal_dirty (dest_bi->tb, dest, 0);
-
- if (dest_bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD(dest_bi->bi_parent,dest_bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) + KEY_SIZE );
-
- do_balance_mark_internal_dirty (dest_bi->tb, dest_bi->bi_parent,0);
- }
+ struct buffer_head *dest = dest_bi->bi_bh;
+ int nr;
+ struct block_head *blkh;
+ struct reiserfs_key *key;
+
+ RFALSE(dest == NULL || src == NULL,
+ "source(%p) or dest(%p) buffer is 0", src, dest);
+ RFALSE(dest_position_before < 0 || src_position < 0,
+ "source(%d) or dest(%d) key number less than 0",
+ src_position, dest_position_before);
+ RFALSE(dest_position_before > B_NR_ITEMS(dest) ||
+ src_position >= B_NR_ITEMS(src),
+ "invalid position in dest (%d (key number %d)) or in src (%d (key number %d))",
+ dest_position_before, B_NR_ITEMS(dest),
+ src_position, B_NR_ITEMS(src));
+ RFALSE(B_FREE_SPACE(dest) < KEY_SIZE,
+ "no enough free space (%d) in dest buffer", B_FREE_SPACE(dest));
+
+ blkh = B_BLK_HEAD(dest);
+ nr = blkh_nr_item(blkh);
+
+ /* prepare space for inserting key */
+ key = B_N_PDELIM_KEY(dest, dest_position_before);
+ memmove(key + 1, key,
+ (nr - dest_position_before) * KEY_SIZE + (nr + 1) * DC_SIZE);
+
+ /* insert key */
+ memcpy(key, B_N_PDELIM_KEY(src, src_position), KEY_SIZE);
+
+ /* Change dirt, free space, item number fields. */
+
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) + 1);
+ set_blkh_free_space(blkh, blkh_free_space(blkh) - KEY_SIZE);
+
+ do_balance_mark_internal_dirty(dest_bi->tb, dest, 0);
+
+ if (dest_bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(dest_bi->bi_parent, dest_bi->bi_position);
+ put_dc_size(t_dc, dc_size(t_dc) + KEY_SIZE);
+
+ do_balance_mark_internal_dirty(dest_bi->tb, dest_bi->bi_parent,
+ 0);
+ }
}
-
-
/* Insert d_key'th (delimiting) key from buffer cfl to tail of dest.
* Copy pointer_amount node pointers and pointer_amount - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfl.
* Delete pointer_amount items and node pointers from buffer src.
*/
/* this can be invoked both to shift from S to L and from R to S */
-static void internal_shift_left (
- int mode, /* INTERNAL_FROM_S_TO_L | INTERNAL_FROM_R_TO_S */
- struct tree_balance * tb,
- int h,
- int pointer_amount
- )
+static void internal_shift_left(int mode, /* INTERNAL_FROM_S_TO_L | INTERNAL_FROM_R_TO_S */
+ struct tree_balance *tb,
+ int h, int pointer_amount)
{
- struct buffer_info dest_bi, src_bi;
- struct buffer_head * cf;
- int d_key_position;
-
- internal_define_dest_src_infos (mode, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
-
- /*printk("pointer_amount = %d\n",pointer_amount);*/
-
- if (pointer_amount) {
- /* insert delimiting key from common father of dest and src to node dest into position B_NR_ITEM(dest) */
- internal_insert_key (&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf, d_key_position);
-
- if (B_NR_ITEMS(src_bi.bi_bh) == pointer_amount - 1) {
- if (src_bi.bi_position/*src->b_item_order*/ == 0)
- replace_key (tb, cf, d_key_position, src_bi.bi_parent/*src->b_parent*/, 0);
- } else
- replace_key (tb, cf, d_key_position, src_bi.bi_bh, pointer_amount - 1);
- }
- /* last parameter is del_parameter */
- internal_move_pointers_items (&dest_bi, &src_bi, FIRST_TO_LAST, pointer_amount, 0);
+ struct buffer_info dest_bi, src_bi;
+ struct buffer_head *cf;
+ int d_key_position;
+
+ internal_define_dest_src_infos(mode, tb, h, &dest_bi, &src_bi,
+ &d_key_position, &cf);
+
+ /*printk("pointer_amount = %d\n",pointer_amount); */
+
+ if (pointer_amount) {
+ /* insert delimiting key from common father of dest and src to node dest into position B_NR_ITEM(dest) */
+ internal_insert_key(&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf,
+ d_key_position);
+
+ if (B_NR_ITEMS(src_bi.bi_bh) == pointer_amount - 1) {
+ if (src_bi.bi_position /*src->b_item_order */ == 0)
+ replace_key(tb, cf, d_key_position,
+ src_bi.
+ bi_parent /*src->b_parent */ , 0);
+ } else
+ replace_key(tb, cf, d_key_position, src_bi.bi_bh,
+ pointer_amount - 1);
+ }
+ /* last parameter is del_parameter */
+ internal_move_pointers_items(&dest_bi, &src_bi, FIRST_TO_LAST,
+ pointer_amount, 0);
}
@@ -493,67 +498,66 @@ static void internal_shift_left (
* Delete n - 1 items and node pointers from buffer S[h].
*/
/* it always shifts from S[h] to L[h] */
-static void internal_shift1_left (
- struct tree_balance * tb,
- int h,
- int pointer_amount
- )
+static void internal_shift1_left(struct tree_balance *tb,
+ int h, int pointer_amount)
{
- struct buffer_info dest_bi, src_bi;
- struct buffer_head * cf;
- int d_key_position;
+ struct buffer_info dest_bi, src_bi;
+ struct buffer_head *cf;
+ int d_key_position;
- internal_define_dest_src_infos (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
+ internal_define_dest_src_infos(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
+ &dest_bi, &src_bi, &d_key_position, &cf);
- if ( pointer_amount > 0 ) /* insert lkey[h]-th key from CFL[h] to left neighbor L[h] */
- internal_insert_key (&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf, d_key_position);
- /* internal_insert_key (tb->L[h], B_NR_ITEM(tb->L[h]), tb->CFL[h], tb->lkey[h]);*/
+ if (pointer_amount > 0) /* insert lkey[h]-th key from CFL[h] to left neighbor L[h] */
+ internal_insert_key(&dest_bi, B_NR_ITEMS(dest_bi.bi_bh), cf,
+ d_key_position);
+ /* internal_insert_key (tb->L[h], B_NR_ITEM(tb->L[h]), tb->CFL[h], tb->lkey[h]); */
- /* last parameter is del_parameter */
- internal_move_pointers_items (&dest_bi, &src_bi, FIRST_TO_LAST, pointer_amount, 1);
- /* internal_move_pointers_items (tb->L[h], tb->S[h], FIRST_TO_LAST, pointer_amount, 1);*/
+ /* last parameter is del_parameter */
+ internal_move_pointers_items(&dest_bi, &src_bi, FIRST_TO_LAST,
+ pointer_amount, 1);
+ /* internal_move_pointers_items (tb->L[h], tb->S[h], FIRST_TO_LAST, pointer_amount, 1); */
}
-
/* Insert d_key'th (delimiting) key from buffer cfr to head of dest.
* Copy n node pointers and n - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfr.
* Delete n items and node pointers from buffer src.
*/
-static void internal_shift_right (
- int mode, /* INTERNAL_FROM_S_TO_R | INTERNAL_FROM_L_TO_S */
- struct tree_balance * tb,
- int h,
- int pointer_amount
- )
+static void internal_shift_right(int mode, /* INTERNAL_FROM_S_TO_R | INTERNAL_FROM_L_TO_S */
+ struct tree_balance *tb,
+ int h, int pointer_amount)
{
- struct buffer_info dest_bi, src_bi;
- struct buffer_head * cf;
- int d_key_position;
- int nr;
-
-
- internal_define_dest_src_infos (mode, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
-
- nr = B_NR_ITEMS (src_bi.bi_bh);
-
- if (pointer_amount > 0) {
- /* insert delimiting key from common father of dest and src to dest node into position 0 */
- internal_insert_key (&dest_bi, 0, cf, d_key_position);
- if (nr == pointer_amount - 1) {
- RFALSE( src_bi.bi_bh != PATH_H_PBUFFER (tb->tb_path, h)/*tb->S[h]*/ ||
- dest_bi.bi_bh != tb->R[h],
- "src (%p) must be == tb->S[h](%p) when it disappears",
- src_bi.bi_bh, PATH_H_PBUFFER (tb->tb_path, h));
- /* when S[h] disappers replace left delemiting key as well */
- if (tb->CFL[h])
- replace_key (tb, cf, d_key_position, tb->CFL[h], tb->lkey[h]);
- } else
- replace_key (tb, cf, d_key_position, src_bi.bi_bh, nr - pointer_amount);
- }
-
- /* last parameter is del_parameter */
- internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, pointer_amount, 0);
+ struct buffer_info dest_bi, src_bi;
+ struct buffer_head *cf;
+ int d_key_position;
+ int nr;
+
+ internal_define_dest_src_infos(mode, tb, h, &dest_bi, &src_bi,
+ &d_key_position, &cf);
+
+ nr = B_NR_ITEMS(src_bi.bi_bh);
+
+ if (pointer_amount > 0) {
+ /* insert delimiting key from common father of dest and src to dest node into position 0 */
+ internal_insert_key(&dest_bi, 0, cf, d_key_position);
+ if (nr == pointer_amount - 1) {
+ RFALSE(src_bi.bi_bh != PATH_H_PBUFFER(tb->tb_path, h) /*tb->S[h] */ ||
+ dest_bi.bi_bh != tb->R[h],
+ "src (%p) must be == tb->S[h](%p) when it disappears",
+ src_bi.bi_bh, PATH_H_PBUFFER(tb->tb_path, h));
+ /* when S[h] disappers replace left delemiting key as well */
+ if (tb->CFL[h])
+ replace_key(tb, cf, d_key_position, tb->CFL[h],
+ tb->lkey[h]);
+ } else
+ replace_key(tb, cf, d_key_position, src_bi.bi_bh,
+ nr - pointer_amount);
+ }
+
+ /* last parameter is del_parameter */
+ internal_move_pointers_items(&dest_bi, &src_bi, LAST_TO_FIRST,
+ pointer_amount, 0);
}
/* Insert delimiting key to R[h].
@@ -561,498 +565,526 @@ static void internal_shift_right (
* Delete n - 1 items and node pointers from buffer S[h].
*/
/* it always shift from S[h] to R[h] */
-static void internal_shift1_right (
- struct tree_balance * tb,
- int h,
- int pointer_amount
- )
+static void internal_shift1_right(struct tree_balance *tb,
+ int h, int pointer_amount)
{
- struct buffer_info dest_bi, src_bi;
- struct buffer_head * cf;
- int d_key_position;
-
- internal_define_dest_src_infos (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, &dest_bi, &src_bi, &d_key_position, &cf);
-
- if (pointer_amount > 0) /* insert rkey from CFR[h] to right neighbor R[h] */
- internal_insert_key (&dest_bi, 0, cf, d_key_position);
- /* internal_insert_key (tb->R[h], 0, tb->CFR[h], tb->rkey[h]);*/
-
- /* last parameter is del_parameter */
- internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, pointer_amount, 1);
- /* internal_move_pointers_items (tb->R[h], tb->S[h], LAST_TO_FIRST, pointer_amount, 1);*/
-}
+ struct buffer_info dest_bi, src_bi;
+ struct buffer_head *cf;
+ int d_key_position;
+
+ internal_define_dest_src_infos(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
+ &dest_bi, &src_bi, &d_key_position, &cf);
+
+ if (pointer_amount > 0) /* insert rkey from CFR[h] to right neighbor R[h] */
+ internal_insert_key(&dest_bi, 0, cf, d_key_position);
+ /* internal_insert_key (tb->R[h], 0, tb->CFR[h], tb->rkey[h]); */
+ /* last parameter is del_parameter */
+ internal_move_pointers_items(&dest_bi, &src_bi, LAST_TO_FIRST,
+ pointer_amount, 1);
+ /* internal_move_pointers_items (tb->R[h], tb->S[h], LAST_TO_FIRST, pointer_amount, 1); */
+}
/* Delete insert_num node pointers together with their left items
* and balance current node.*/
-static void balance_internal_when_delete (struct tree_balance * tb,
- int h, int child_pos)
+static void balance_internal_when_delete(struct tree_balance *tb,
+ int h, int child_pos)
{
- int insert_num;
- int n;
- struct buffer_head * tbSh = PATH_H_PBUFFER (tb->tb_path, h);
- struct buffer_info bi;
-
- insert_num = tb->insert_size[h] / ((int)(DC_SIZE + KEY_SIZE));
-
- /* delete child-node-pointer(s) together with their left item(s) */
- bi.tb = tb;
- bi.bi_bh = tbSh;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
-
- internal_delete_childs (&bi, child_pos, -insert_num);
-
- RFALSE( tb->blknum[h] > 1,
- "tb->blknum[%d]=%d when insert_size < 0", h, tb->blknum[h]);
-
- n = B_NR_ITEMS(tbSh);
-
- if ( tb->lnum[h] == 0 && tb->rnum[h] == 0 ) {
- if ( tb->blknum[h] == 0 ) {
- /* node S[h] (root of the tree) is empty now */
- struct buffer_head *new_root;
-
- RFALSE( n || B_FREE_SPACE (tbSh) != MAX_CHILD_SIZE(tbSh) - DC_SIZE,
- "buffer must have only 0 keys (%d)", n);
- RFALSE( bi.bi_parent, "root has parent (%p)", bi.bi_parent);
-
- /* choose a new root */
- if ( ! tb->L[h-1] || ! B_NR_ITEMS(tb->L[h-1]) )
- new_root = tb->R[h-1];
- else
- new_root = tb->L[h-1];
- /* switch super block's tree root block number to the new value */
- PUT_SB_ROOT_BLOCK( tb->tb_sb, new_root->b_blocknr );
- //REISERFS_SB(tb->tb_sb)->s_rs->s_tree_height --;
- PUT_SB_TREE_HEIGHT( tb->tb_sb, SB_TREE_HEIGHT(tb->tb_sb) - 1 );
-
- do_balance_mark_sb_dirty (tb, REISERFS_SB(tb->tb_sb)->s_sbh, 1);
- /*&&&&&&&&&&&&&&&&&&&&&&*/
- if (h > 1)
- /* use check_internal if new root is an internal node */
- check_internal (new_root);
- /*&&&&&&&&&&&&&&&&&&&&&&*/
-
- /* do what is needed for buffer thrown from tree */
- reiserfs_invalidate_buffer(tb, tbSh);
- return;
+ int insert_num;
+ int n;
+ struct buffer_head *tbSh = PATH_H_PBUFFER(tb->tb_path, h);
+ struct buffer_info bi;
+
+ insert_num = tb->insert_size[h] / ((int)(DC_SIZE + KEY_SIZE));
+
+ /* delete child-node-pointer(s) together with their left item(s) */
+ bi.tb = tb;
+ bi.bi_bh = tbSh;
+ bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+
+ internal_delete_childs(&bi, child_pos, -insert_num);
+
+ RFALSE(tb->blknum[h] > 1,
+ "tb->blknum[%d]=%d when insert_size < 0", h, tb->blknum[h]);
+
+ n = B_NR_ITEMS(tbSh);
+
+ if (tb->lnum[h] == 0 && tb->rnum[h] == 0) {
+ if (tb->blknum[h] == 0) {
+ /* node S[h] (root of the tree) is empty now */
+ struct buffer_head *new_root;
+
+ RFALSE(n
+ || B_FREE_SPACE(tbSh) !=
+ MAX_CHILD_SIZE(tbSh) - DC_SIZE,
+ "buffer must have only 0 keys (%d)", n);
+ RFALSE(bi.bi_parent, "root has parent (%p)",
+ bi.bi_parent);
+
+ /* choose a new root */
+ if (!tb->L[h - 1] || !B_NR_ITEMS(tb->L[h - 1]))
+ new_root = tb->R[h - 1];
+ else
+ new_root = tb->L[h - 1];
+ /* switch super block's tree root block number to the new value */
+ PUT_SB_ROOT_BLOCK(tb->tb_sb, new_root->b_blocknr);
+ //REISERFS_SB(tb->tb_sb)->s_rs->s_tree_height --;
+ PUT_SB_TREE_HEIGHT(tb->tb_sb,
+ SB_TREE_HEIGHT(tb->tb_sb) - 1);
+
+ do_balance_mark_sb_dirty(tb,
+ REISERFS_SB(tb->tb_sb)->s_sbh,
+ 1);
+ /*&&&&&&&&&&&&&&&&&&&&&& */
+ if (h > 1)
+ /* use check_internal if new root is an internal node */
+ check_internal(new_root);
+ /*&&&&&&&&&&&&&&&&&&&&&& */
+
+ /* do what is needed for buffer thrown from tree */
+ reiserfs_invalidate_buffer(tb, tbSh);
+ return;
+ }
+ return;
+ }
+
+ if (tb->L[h] && tb->lnum[h] == -B_NR_ITEMS(tb->L[h]) - 1) { /* join S[h] with L[h] */
+
+ RFALSE(tb->rnum[h] != 0,
+ "invalid tb->rnum[%d]==%d when joining S[h] with L[h]",
+ h, tb->rnum[h]);
+
+ internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h, n + 1);
+ reiserfs_invalidate_buffer(tb, tbSh);
+
+ return;
+ }
+
+ if (tb->R[h] && tb->rnum[h] == -B_NR_ITEMS(tb->R[h]) - 1) { /* join S[h] with R[h] */
+ RFALSE(tb->lnum[h] != 0,
+ "invalid tb->lnum[%d]==%d when joining S[h] with R[h]",
+ h, tb->lnum[h]);
+
+ internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h, n + 1);
+
+ reiserfs_invalidate_buffer(tb, tbSh);
+ return;
}
- return;
- }
-
- if ( tb->L[h] && tb->lnum[h] == -B_NR_ITEMS(tb->L[h]) - 1 ) { /* join S[h] with L[h] */
-
- RFALSE( tb->rnum[h] != 0,
- "invalid tb->rnum[%d]==%d when joining S[h] with L[h]",
- h, tb->rnum[h]);
-
- internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, n + 1);
- reiserfs_invalidate_buffer(tb, tbSh);
-
- return;
- }
-
- if ( tb->R[h] && tb->rnum[h] == -B_NR_ITEMS(tb->R[h]) - 1 ) { /* join S[h] with R[h] */
- RFALSE( tb->lnum[h] != 0,
- "invalid tb->lnum[%d]==%d when joining S[h] with R[h]",
- h, tb->lnum[h]);
-
- internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, n + 1);
-
- reiserfs_invalidate_buffer(tb,tbSh);
- return;
- }
-
- if ( tb->lnum[h] < 0 ) { /* borrow from left neighbor L[h] */
- RFALSE( tb->rnum[h] != 0,
- "wrong tb->rnum[%d]==%d when borrow from L[h]", h, tb->rnum[h]);
- /*internal_shift_right (tb, h, tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], -tb->lnum[h]);*/
- internal_shift_right (INTERNAL_SHIFT_FROM_L_TO_S, tb, h, -tb->lnum[h]);
- return;
- }
-
- if ( tb->rnum[h] < 0 ) { /* borrow from right neighbor R[h] */
- RFALSE( tb->lnum[h] != 0,
- "invalid tb->lnum[%d]==%d when borrow from R[h]",
- h, tb->lnum[h]);
- internal_shift_left (INTERNAL_SHIFT_FROM_R_TO_S, tb, h, -tb->rnum[h]);/*tb->S[h], tb->CFR[h], tb->rkey[h], tb->R[h], -tb->rnum[h]);*/
- return;
- }
-
- if ( tb->lnum[h] > 0 ) { /* split S[h] into two parts and put them into neighbors */
- RFALSE( tb->rnum[h] == 0 || tb->lnum[h] + tb->rnum[h] != n + 1,
- "invalid tb->lnum[%d]==%d or tb->rnum[%d]==%d when S[h](item number == %d) is split between them",
- h, tb->lnum[h], h, tb->rnum[h], n);
-
- internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]);/*tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], tb->lnum[h]);*/
- internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h]);
-
- reiserfs_invalidate_buffer (tb, tbSh);
-
- return;
- }
- reiserfs_panic (tb->tb_sb, "balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
- h, tb->lnum[h], h, tb->rnum[h]);
-}
+ if (tb->lnum[h] < 0) { /* borrow from left neighbor L[h] */
+ RFALSE(tb->rnum[h] != 0,
+ "wrong tb->rnum[%d]==%d when borrow from L[h]", h,
+ tb->rnum[h]);
+ /*internal_shift_right (tb, h, tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], -tb->lnum[h]); */
+ internal_shift_right(INTERNAL_SHIFT_FROM_L_TO_S, tb, h,
+ -tb->lnum[h]);
+ return;
+ }
+
+ if (tb->rnum[h] < 0) { /* borrow from right neighbor R[h] */
+ RFALSE(tb->lnum[h] != 0,
+ "invalid tb->lnum[%d]==%d when borrow from R[h]",
+ h, tb->lnum[h]);
+ internal_shift_left(INTERNAL_SHIFT_FROM_R_TO_S, tb, h, -tb->rnum[h]); /*tb->S[h], tb->CFR[h], tb->rkey[h], tb->R[h], -tb->rnum[h]); */
+ return;
+ }
+
+ if (tb->lnum[h] > 0) { /* split S[h] into two parts and put them into neighbors */
+ RFALSE(tb->rnum[h] == 0 || tb->lnum[h] + tb->rnum[h] != n + 1,
+ "invalid tb->lnum[%d]==%d or tb->rnum[%d]==%d when S[h](item number == %d) is split between them",
+ h, tb->lnum[h], h, tb->rnum[h], n);
+
+ internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]); /*tb->L[h], tb->CFL[h], tb->lkey[h], tb->S[h], tb->lnum[h]); */
+ internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
+ tb->rnum[h]);
+
+ reiserfs_invalidate_buffer(tb, tbSh);
+
+ return;
+ }
+ reiserfs_panic(tb->tb_sb,
+ "balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
+ h, tb->lnum[h], h, tb->rnum[h]);
+}
/* Replace delimiting key of buffers L[h] and S[h] by the given key.*/
-static void replace_lkey (
- struct tree_balance * tb,
- int h,
- struct item_head * key
- )
+static void replace_lkey(struct tree_balance *tb, int h, struct item_head *key)
{
- RFALSE( tb->L[h] == NULL || tb->CFL[h] == NULL,
- "L[h](%p) and CFL[h](%p) must exist in replace_lkey",
- tb->L[h], tb->CFL[h]);
+ RFALSE(tb->L[h] == NULL || tb->CFL[h] == NULL,
+ "L[h](%p) and CFL[h](%p) must exist in replace_lkey",
+ tb->L[h], tb->CFL[h]);
- if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0)
- return;
+ if (B_NR_ITEMS(PATH_H_PBUFFER(tb->tb_path, h)) == 0)
+ return;
- memcpy (B_N_PDELIM_KEY(tb->CFL[h],tb->lkey[h]), key, KEY_SIZE);
+ memcpy(B_N_PDELIM_KEY(tb->CFL[h], tb->lkey[h]), key, KEY_SIZE);
- do_balance_mark_internal_dirty (tb, tb->CFL[h],0);
+ do_balance_mark_internal_dirty(tb, tb->CFL[h], 0);
}
-
/* Replace delimiting key of buffers S[h] and R[h] by the given key.*/
-static void replace_rkey (
- struct tree_balance * tb,
- int h,
- struct item_head * key
- )
+static void replace_rkey(struct tree_balance *tb, int h, struct item_head *key)
{
- RFALSE( tb->R[h] == NULL || tb->CFR[h] == NULL,
- "R[h](%p) and CFR[h](%p) must exist in replace_rkey",
- tb->R[h], tb->CFR[h]);
- RFALSE( B_NR_ITEMS(tb->R[h]) == 0,
- "R[h] can not be empty if it exists (item number=%d)",
- B_NR_ITEMS(tb->R[h]));
+ RFALSE(tb->R[h] == NULL || tb->CFR[h] == NULL,
+ "R[h](%p) and CFR[h](%p) must exist in replace_rkey",
+ tb->R[h], tb->CFR[h]);
+ RFALSE(B_NR_ITEMS(tb->R[h]) == 0,
+ "R[h] can not be empty if it exists (item number=%d)",
+ B_NR_ITEMS(tb->R[h]));
- memcpy (B_N_PDELIM_KEY(tb->CFR[h],tb->rkey[h]), key, KEY_SIZE);
+ memcpy(B_N_PDELIM_KEY(tb->CFR[h], tb->rkey[h]), key, KEY_SIZE);
- do_balance_mark_internal_dirty (tb, tb->CFR[h], 0);
+ do_balance_mark_internal_dirty(tb, tb->CFR[h], 0);
}
-
-int balance_internal (struct tree_balance * tb, /* tree_balance structure */
- int h, /* level of the tree */
- int child_pos,
- struct item_head * insert_key, /* key for insertion on higher level */
- struct buffer_head ** insert_ptr /* node for insertion on higher level*/
+int balance_internal(struct tree_balance *tb, /* tree_balance structure */
+ int h, /* level of the tree */
+ int child_pos, struct item_head *insert_key, /* key for insertion on higher level */
+ struct buffer_head **insert_ptr /* node for insertion on higher level */
)
/* if inserting/pasting
{
- child_pos is the position of the node-pointer in S[h] that *
- pointed to S[h-1] before balancing of the h-1 level; *
+ child_pos is the position of the node-pointer in S[h] that *
+ pointed to S[h-1] before balancing of the h-1 level; *
this means that new pointers and items must be inserted AFTER *
child_pos
}
else
{
- it is the position of the leftmost pointer that must be deleted (together with
- its corresponding key to the left of the pointer)
- as a result of the previous level's balancing.
- }
-*/
+ it is the position of the leftmost pointer that must be deleted (together with
+ its corresponding key to the left of the pointer)
+ as a result of the previous level's balancing.
+ }
+ */
{
- struct buffer_head * tbSh = PATH_H_PBUFFER (tb->tb_path, h);
- struct buffer_info bi;
- int order; /* we return this: it is 0 if there is no S[h], else it is tb->S[h]->b_item_order */
- int insert_num, n, k;
- struct buffer_head * S_new;
- struct item_head new_insert_key;
- struct buffer_head * new_insert_ptr = NULL;
- struct item_head * new_insert_key_addr = insert_key;
-
- RFALSE( h < 1, "h (%d) can not be < 1 on internal level", h);
-
- PROC_INFO_INC( tb -> tb_sb, balance_at[ h ] );
-
- order = ( tbSh ) ? PATH_H_POSITION (tb->tb_path, h + 1)/*tb->S[h]->b_item_order*/ : 0;
-
- /* Using insert_size[h] calculate the number insert_num of items
- that must be inserted to or deleted from S[h]. */
- insert_num = tb->insert_size[h]/((int)(KEY_SIZE + DC_SIZE));
-
- /* Check whether insert_num is proper **/
- RFALSE( insert_num < -2 || insert_num > 2,
- "incorrect number of items inserted to the internal node (%d)",
- insert_num);
- RFALSE( h > 1 && (insert_num > 1 || insert_num < -1),
- "incorrect number of items (%d) inserted to the internal node on a level (h=%d) higher than last internal level",
- insert_num, h);
-
- /* Make balance in case insert_num < 0 */
- if ( insert_num < 0 ) {
- balance_internal_when_delete (tb, h, child_pos);
- return order;
- }
-
- k = 0;
- if ( tb->lnum[h] > 0 ) {
- /* shift lnum[h] items from S[h] to the left neighbor L[h].
- check how many of new items fall into L[h] or CFL[h] after
- shifting */
- n = B_NR_ITEMS (tb->L[h]); /* number of items in L[h] */
- if ( tb->lnum[h] <= child_pos ) {
- /* new items don't fall into L[h] or CFL[h] */
- internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h]);
- /*internal_shift_left (tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,tb->lnum[h]);*/
- child_pos -= tb->lnum[h];
- } else if ( tb->lnum[h] > child_pos + insert_num ) {
- /* all new items fall into L[h] */
- internal_shift_left (INTERNAL_SHIFT_FROM_S_TO_L, tb, h, tb->lnum[h] - insert_num);
- /* internal_shift_left(tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,
- tb->lnum[h]-insert_num);
- */
- /* insert insert_num keys and node-pointers into L[h] */
- bi.tb = tb;
- bi.bi_bh = tb->L[h];
- bi.bi_parent = tb->FL[h];
- bi.bi_position = get_left_neighbor_position (tb, h);
- internal_insert_childs (&bi,/*tb->L[h], tb->S[h-1]->b_next*/ n + child_pos + 1,
- insert_num,insert_key,insert_ptr);
-
- insert_num = 0;
- } else {
- struct disk_child * dc;
-
- /* some items fall into L[h] or CFL[h], but some don't fall */
- internal_shift1_left(tb,h,child_pos+1);
- /* calculate number of new items that fall into L[h] */
- k = tb->lnum[h] - child_pos - 1;
- bi.tb = tb;
- bi.bi_bh = tb->L[h];
- bi.bi_parent = tb->FL[h];
- bi.bi_position = get_left_neighbor_position (tb, h);
- internal_insert_childs (&bi,/*tb->L[h], tb->S[h-1]->b_next,*/ n + child_pos + 1,k,
- insert_key,insert_ptr);
-
- replace_lkey(tb,h,insert_key + k);
-
- /* replace the first node-ptr in S[h] by node-ptr to insert_ptr[k] */
- dc = B_N_CHILD(tbSh, 0);
- put_dc_size( dc, MAX_CHILD_SIZE(insert_ptr[k]) - B_FREE_SPACE (insert_ptr[k]));
- put_dc_block_number( dc, insert_ptr[k]->b_blocknr );
-
- do_balance_mark_internal_dirty (tb, tbSh, 0);
-
- k++;
- insert_key += k;
- insert_ptr += k;
- insert_num -= k;
- child_pos = 0;
+ struct buffer_head *tbSh = PATH_H_PBUFFER(tb->tb_path, h);
+ struct buffer_info bi;
+ int order; /* we return this: it is 0 if there is no S[h], else it is tb->S[h]->b_item_order */
+ int insert_num, n, k;
+ struct buffer_head *S_new;
+ struct item_head new_insert_key;
+ struct buffer_head *new_insert_ptr = NULL;
+ struct item_head *new_insert_key_addr = insert_key;
+
+ RFALSE(h < 1, "h (%d) can not be < 1 on internal level", h);
+
+ PROC_INFO_INC(tb->tb_sb, balance_at[h]);
+
+ order =
+ (tbSh) ? PATH_H_POSITION(tb->tb_path,
+ h + 1) /*tb->S[h]->b_item_order */ : 0;
+
+ /* Using insert_size[h] calculate the number insert_num of items
+ that must be inserted to or deleted from S[h]. */
+ insert_num = tb->insert_size[h] / ((int)(KEY_SIZE + DC_SIZE));
+
+ /* Check whether insert_num is proper * */
+ RFALSE(insert_num < -2 || insert_num > 2,
+ "incorrect number of items inserted to the internal node (%d)",
+ insert_num);
+ RFALSE(h > 1 && (insert_num > 1 || insert_num < -1),
+ "incorrect number of items (%d) inserted to the internal node on a level (h=%d) higher than last internal level",
+ insert_num, h);
+
+ /* Make balance in case insert_num < 0 */
+ if (insert_num < 0) {
+ balance_internal_when_delete(tb, h, child_pos);
+ return order;
}
- } /* tb->lnum[h] > 0 */
-
- if ( tb->rnum[h] > 0 ) {
- /*shift rnum[h] items from S[h] to the right neighbor R[h]*/
- /* check how many of new items fall into R or CFR after shifting */
- n = B_NR_ITEMS (tbSh); /* number of items in S[h] */
- if ( n - tb->rnum[h] >= child_pos )
- /* new items fall into S[h] */
- /*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],tb->rnum[h]);*/
- internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h]);
- else
- if ( n + insert_num - tb->rnum[h] < child_pos )
- {
- /* all new items fall into R[h] */
- /*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],
- tb->rnum[h] - insert_num);*/
- internal_shift_right (INTERNAL_SHIFT_FROM_S_TO_R, tb, h, tb->rnum[h] - insert_num);
-
- /* insert insert_num keys and node-pointers into R[h] */
- bi.tb = tb;
- bi.bi_bh = tb->R[h];
- bi.bi_parent = tb->FR[h];
- bi.bi_position = get_right_neighbor_position (tb, h);
- internal_insert_childs (&bi, /*tb->R[h],tb->S[h-1]->b_next*/ child_pos - n - insert_num + tb->rnum[h] - 1,
- insert_num,insert_key,insert_ptr);
- insert_num = 0;
- }
- else
- {
- struct disk_child * dc;
-
- /* one of the items falls into CFR[h] */
- internal_shift1_right(tb,h,n - child_pos + 1);
- /* calculate number of new items that fall into R[h] */
- k = tb->rnum[h] - n + child_pos - 1;
- bi.tb = tb;
- bi.bi_bh = tb->R[h];
- bi.bi_parent = tb->FR[h];
- bi.bi_position = get_right_neighbor_position (tb, h);
- internal_insert_childs (&bi, /*tb->R[h], tb->R[h]->b_child,*/ 0, k, insert_key + 1, insert_ptr + 1);
- replace_rkey(tb,h,insert_key + insert_num - k - 1);
+ k = 0;
+ if (tb->lnum[h] > 0) {
+ /* shift lnum[h] items from S[h] to the left neighbor L[h].
+ check how many of new items fall into L[h] or CFL[h] after
+ shifting */
+ n = B_NR_ITEMS(tb->L[h]); /* number of items in L[h] */
+ if (tb->lnum[h] <= child_pos) {
+ /* new items don't fall into L[h] or CFL[h] */
+ internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
+ tb->lnum[h]);
+ /*internal_shift_left (tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,tb->lnum[h]); */
+ child_pos -= tb->lnum[h];
+ } else if (tb->lnum[h] > child_pos + insert_num) {
+ /* all new items fall into L[h] */
+ internal_shift_left(INTERNAL_SHIFT_FROM_S_TO_L, tb, h,
+ tb->lnum[h] - insert_num);
+ /* internal_shift_left(tb->L[h],tb->CFL[h],tb->lkey[h],tbSh,
+ tb->lnum[h]-insert_num);
+ */
+ /* insert insert_num keys and node-pointers into L[h] */
+ bi.tb = tb;
+ bi.bi_bh = tb->L[h];
+ bi.bi_parent = tb->FL[h];
+ bi.bi_position = get_left_neighbor_position(tb, h);
+ internal_insert_childs(&bi,
+ /*tb->L[h], tb->S[h-1]->b_next */
+ n + child_pos + 1,
+ insert_num, insert_key,
+ insert_ptr);
+
+ insert_num = 0;
+ } else {
+ struct disk_child *dc;
+
+ /* some items fall into L[h] or CFL[h], but some don't fall */
+ internal_shift1_left(tb, h, child_pos + 1);
+ /* calculate number of new items that fall into L[h] */
+ k = tb->lnum[h] - child_pos - 1;
+ bi.tb = tb;
+ bi.bi_bh = tb->L[h];
+ bi.bi_parent = tb->FL[h];
+ bi.bi_position = get_left_neighbor_position(tb, h);
+ internal_insert_childs(&bi,
+ /*tb->L[h], tb->S[h-1]->b_next, */
+ n + child_pos + 1, k,
+ insert_key, insert_ptr);
+
+ replace_lkey(tb, h, insert_key + k);
+
+ /* replace the first node-ptr in S[h] by node-ptr to insert_ptr[k] */
+ dc = B_N_CHILD(tbSh, 0);
+ put_dc_size(dc,
+ MAX_CHILD_SIZE(insert_ptr[k]) -
+ B_FREE_SPACE(insert_ptr[k]));
+ put_dc_block_number(dc, insert_ptr[k]->b_blocknr);
+
+ do_balance_mark_internal_dirty(tb, tbSh, 0);
+
+ k++;
+ insert_key += k;
+ insert_ptr += k;
+ insert_num -= k;
+ child_pos = 0;
+ }
+ }
+ /* tb->lnum[h] > 0 */
+ if (tb->rnum[h] > 0) {
+ /*shift rnum[h] items from S[h] to the right neighbor R[h] */
+ /* check how many of new items fall into R or CFR after shifting */
+ n = B_NR_ITEMS(tbSh); /* number of items in S[h] */
+ if (n - tb->rnum[h] >= child_pos)
+ /* new items fall into S[h] */
+ /*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],tb->rnum[h]); */
+ internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
+ tb->rnum[h]);
+ else if (n + insert_num - tb->rnum[h] < child_pos) {
+ /* all new items fall into R[h] */
+ /*internal_shift_right(tb,h,tbSh,tb->CFR[h],tb->rkey[h],tb->R[h],
+ tb->rnum[h] - insert_num); */
+ internal_shift_right(INTERNAL_SHIFT_FROM_S_TO_R, tb, h,
+ tb->rnum[h] - insert_num);
+
+ /* insert insert_num keys and node-pointers into R[h] */
+ bi.tb = tb;
+ bi.bi_bh = tb->R[h];
+ bi.bi_parent = tb->FR[h];
+ bi.bi_position = get_right_neighbor_position(tb, h);
+ internal_insert_childs(&bi,
+ /*tb->R[h],tb->S[h-1]->b_next */
+ child_pos - n - insert_num +
+ tb->rnum[h] - 1,
+ insert_num, insert_key,
+ insert_ptr);
+ insert_num = 0;
+ } else {
+ struct disk_child *dc;
+
+ /* one of the items falls into CFR[h] */
+ internal_shift1_right(tb, h, n - child_pos + 1);
+ /* calculate number of new items that fall into R[h] */
+ k = tb->rnum[h] - n + child_pos - 1;
+ bi.tb = tb;
+ bi.bi_bh = tb->R[h];
+ bi.bi_parent = tb->FR[h];
+ bi.bi_position = get_right_neighbor_position(tb, h);
+ internal_insert_childs(&bi,
+ /*tb->R[h], tb->R[h]->b_child, */
+ 0, k, insert_key + 1,
+ insert_ptr + 1);
+
+ replace_rkey(tb, h, insert_key + insert_num - k - 1);
+
+ /* replace the first node-ptr in R[h] by node-ptr insert_ptr[insert_num-k-1] */
+ dc = B_N_CHILD(tb->R[h], 0);
+ put_dc_size(dc,
+ MAX_CHILD_SIZE(insert_ptr
+ [insert_num - k - 1]) -
+ B_FREE_SPACE(insert_ptr
+ [insert_num - k - 1]));
+ put_dc_block_number(dc,
+ insert_ptr[insert_num - k -
+ 1]->b_blocknr);
+
+ do_balance_mark_internal_dirty(tb, tb->R[h], 0);
+
+ insert_num -= (k + 1);
+ }
+ }
- /* replace the first node-ptr in R[h] by node-ptr insert_ptr[insert_num-k-1]*/
- dc = B_N_CHILD(tb->R[h], 0);
- put_dc_size( dc, MAX_CHILD_SIZE(insert_ptr[insert_num-k-1]) -
- B_FREE_SPACE (insert_ptr[insert_num-k-1]));
- put_dc_block_number( dc, insert_ptr[insert_num-k-1]->b_blocknr );
+ /** Fill new node that appears instead of S[h] **/
+ RFALSE(tb->blknum[h] > 2, "blknum can not be > 2 for internal level");
+ RFALSE(tb->blknum[h] < 0, "blknum can not be < 0");
- do_balance_mark_internal_dirty (tb, tb->R[h],0);
+ if (!tb->blknum[h]) { /* node S[h] is empty now */
+ RFALSE(!tbSh, "S[h] is equal NULL");
- insert_num -= (k + 1);
- }
- }
+ /* do what is needed for buffer thrown from tree */
+ reiserfs_invalidate_buffer(tb, tbSh);
+ return order;
+ }
- /** Fill new node that appears instead of S[h] **/
- RFALSE( tb->blknum[h] > 2, "blknum can not be > 2 for internal level");
- RFALSE( tb->blknum[h] < 0, "blknum can not be < 0");
+ if (!tbSh) {
+ /* create new root */
+ struct disk_child *dc;
+ struct buffer_head *tbSh_1 = PATH_H_PBUFFER(tb->tb_path, h - 1);
+ struct block_head *blkh;
- if ( ! tb->blknum[h] )
- { /* node S[h] is empty now */
- RFALSE( ! tbSh, "S[h] is equal NULL");
+ if (tb->blknum[h] != 1)
+ reiserfs_panic(NULL,
+ "balance_internal: One new node required for creating the new root");
+ /* S[h] = empty buffer from the list FEB. */
+ tbSh = get_FEB(tb);
+ blkh = B_BLK_HEAD(tbSh);
+ set_blkh_level(blkh, h + 1);
- /* do what is needed for buffer thrown from tree */
- reiserfs_invalidate_buffer(tb,tbSh);
- return order;
- }
-
- if ( ! tbSh ) {
- /* create new root */
- struct disk_child * dc;
- struct buffer_head * tbSh_1 = PATH_H_PBUFFER (tb->tb_path, h - 1);
- struct block_head * blkh;
-
-
- if ( tb->blknum[h] != 1 )
- reiserfs_panic(NULL, "balance_internal: One new node required for creating the new root");
- /* S[h] = empty buffer from the list FEB. */
- tbSh = get_FEB (tb);
- blkh = B_BLK_HEAD(tbSh);
- set_blkh_level( blkh, h + 1 );
-
- /* Put the unique node-pointer to S[h] that points to S[h-1]. */
-
- dc = B_N_CHILD(tbSh, 0);
- put_dc_block_number( dc, tbSh_1->b_blocknr );
- put_dc_size( dc, (MAX_CHILD_SIZE (tbSh_1) - B_FREE_SPACE (tbSh_1)));
-
- tb->insert_size[h] -= DC_SIZE;
- set_blkh_free_space( blkh, blkh_free_space(blkh) - DC_SIZE );
-
- do_balance_mark_internal_dirty (tb, tbSh, 0);
-
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
- check_internal (tbSh);
- /*&&&&&&&&&&&&&&&&&&&&&&&&*/
-
- /* put new root into path structure */
- PATH_OFFSET_PBUFFER(tb->tb_path, ILLEGAL_PATH_ELEMENT_OFFSET) = tbSh;
-
- /* Change root in structure super block. */
- PUT_SB_ROOT_BLOCK( tb->tb_sb, tbSh->b_blocknr );
- PUT_SB_TREE_HEIGHT( tb->tb_sb, SB_TREE_HEIGHT(tb->tb_sb) + 1 );
- do_balance_mark_sb_dirty (tb, REISERFS_SB(tb->tb_sb)->s_sbh, 1);
- }
-
- if ( tb->blknum[h] == 2 ) {
- int snum;
- struct buffer_info dest_bi, src_bi;
+ /* Put the unique node-pointer to S[h] that points to S[h-1]. */
+
+ dc = B_N_CHILD(tbSh, 0);
+ put_dc_block_number(dc, tbSh_1->b_blocknr);
+ put_dc_size(dc,
+ (MAX_CHILD_SIZE(tbSh_1) - B_FREE_SPACE(tbSh_1)));
+
+ tb->insert_size[h] -= DC_SIZE;
+ set_blkh_free_space(blkh, blkh_free_space(blkh) - DC_SIZE);
+ do_balance_mark_internal_dirty(tb, tbSh, 0);
- /* S_new = free buffer from list FEB */
- S_new = get_FEB(tb);
-
- set_blkh_level( B_BLK_HEAD(S_new), h + 1 );
-
- dest_bi.tb = tb;
- dest_bi.bi_bh = S_new;
- dest_bi.bi_parent = NULL;
- dest_bi.bi_position = 0;
- src_bi.tb = tb;
- src_bi.bi_bh = tbSh;
- src_bi.bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- src_bi.bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
-
- n = B_NR_ITEMS (tbSh); /* number of items in S[h] */
- snum = (insert_num + n + 1)/2;
- if ( n - snum >= child_pos ) {
- /* new items don't fall into S_new */
- /* store the delimiting key for the next level */
- /* new_insert_key = (n - snum)'th key in S[h] */
- memcpy (&new_insert_key,B_N_PDELIM_KEY(tbSh,n - snum),
- KEY_SIZE);
- /* last parameter is del_par */
- internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, snum, 0);
- /* internal_move_pointers_items(S_new, tbSh, LAST_TO_FIRST, snum, 0);*/
- } else if ( n + insert_num - snum < child_pos ) {
- /* all new items fall into S_new */
- /* store the delimiting key for the next level */
- /* new_insert_key = (n + insert_item - snum)'th key in S[h] */
- memcpy(&new_insert_key,B_N_PDELIM_KEY(tbSh,n + insert_num - snum),
- KEY_SIZE);
- /* last parameter is del_par */
- internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, snum - insert_num, 0);
- /* internal_move_pointers_items(S_new,tbSh,1,snum - insert_num,0);*/
-
- /* insert insert_num keys and node-pointers into S_new */
- internal_insert_childs (&dest_bi, /*S_new,tb->S[h-1]->b_next,*/child_pos - n - insert_num + snum - 1,
- insert_num,insert_key,insert_ptr);
-
- insert_num = 0;
- } else {
- struct disk_child * dc;
-
- /* some items fall into S_new, but some don't fall */
- /* last parameter is del_par */
- internal_move_pointers_items (&dest_bi, &src_bi, LAST_TO_FIRST, n - child_pos + 1, 1);
- /* internal_move_pointers_items(S_new,tbSh,1,n - child_pos + 1,1);*/
- /* calculate number of new items that fall into S_new */
- k = snum - n + child_pos - 1;
-
- internal_insert_childs (&dest_bi, /*S_new,*/ 0, k, insert_key + 1, insert_ptr+1);
-
- /* new_insert_key = insert_key[insert_num - k - 1] */
- memcpy(&new_insert_key,insert_key + insert_num - k - 1,
- KEY_SIZE);
- /* replace first node-ptr in S_new by node-ptr to insert_ptr[insert_num-k-1] */
-
- dc = B_N_CHILD(S_new,0);
- put_dc_size( dc, (MAX_CHILD_SIZE(insert_ptr[insert_num-k-1]) -
- B_FREE_SPACE(insert_ptr[insert_num-k-1])) );
- put_dc_block_number( dc, insert_ptr[insert_num-k-1]->b_blocknr );
-
- do_balance_mark_internal_dirty (tb, S_new,0);
-
- insert_num -= (k + 1);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+ check_internal(tbSh);
+ /*&&&&&&&&&&&&&&&&&&&&&&&& */
+
+ /* put new root into path structure */
+ PATH_OFFSET_PBUFFER(tb->tb_path, ILLEGAL_PATH_ELEMENT_OFFSET) =
+ tbSh;
+
+ /* Change root in structure super block. */
+ PUT_SB_ROOT_BLOCK(tb->tb_sb, tbSh->b_blocknr);
+ PUT_SB_TREE_HEIGHT(tb->tb_sb, SB_TREE_HEIGHT(tb->tb_sb) + 1);
+ do_balance_mark_sb_dirty(tb, REISERFS_SB(tb->tb_sb)->s_sbh, 1);
}
- /* new_insert_ptr = node_pointer to S_new */
- new_insert_ptr = S_new;
-
- RFALSE (!buffer_journaled(S_new) || buffer_journal_dirty(S_new) ||
- buffer_dirty (S_new),
- "cm-00001: bad S_new (%b)", S_new);
-
- // S_new is released in unfix_nodes
- }
-
- n = B_NR_ITEMS (tbSh); /*number of items in S[h] */
-
- if ( 0 <= child_pos && child_pos <= n && insert_num > 0 ) {
- bi.tb = tb;
- bi.bi_bh = tbSh;
- bi.bi_parent = PATH_H_PPARENT (tb->tb_path, h);
- bi.bi_position = PATH_H_POSITION (tb->tb_path, h + 1);
- internal_insert_childs (
- &bi,/*tbSh,*/
- /* ( tb->S[h-1]->b_parent == tb->S[h] ) ? tb->S[h-1]->b_next : tb->S[h]->b_child->b_next,*/
- child_pos,insert_num,insert_key,insert_ptr
- );
+
+ if (tb->blknum[h] == 2) {
+ int snum;
+ struct buffer_info dest_bi, src_bi;
+
+ /* S_new = free buffer from list FEB */
+ S_new = get_FEB(tb);
+
+ set_blkh_level(B_BLK_HEAD(S_new), h + 1);
+
+ dest_bi.tb = tb;
+ dest_bi.bi_bh = S_new;
+ dest_bi.bi_parent = NULL;
+ dest_bi.bi_position = 0;
+ src_bi.tb = tb;
+ src_bi.bi_bh = tbSh;
+ src_bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ src_bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+
+ n = B_NR_ITEMS(tbSh); /* number of items in S[h] */
+ snum = (insert_num + n + 1) / 2;
+ if (n - snum >= child_pos) {
+ /* new items don't fall into S_new */
+ /* store the delimiting key for the next level */
+ /* new_insert_key = (n - snum)'th key in S[h] */
+ memcpy(&new_insert_key, B_N_PDELIM_KEY(tbSh, n - snum),
+ KEY_SIZE);
+ /* last parameter is del_par */
+ internal_move_pointers_items(&dest_bi, &src_bi,
+ LAST_TO_FIRST, snum, 0);
+ /* internal_move_pointers_items(S_new, tbSh, LAST_TO_FIRST, snum, 0); */
+ } else if (n + insert_num - snum < child_pos) {
+ /* all new items fall into S_new */
+ /* store the delimiting key for the next level */
+ /* new_insert_key = (n + insert_item - snum)'th key in S[h] */
+ memcpy(&new_insert_key,
+ B_N_PDELIM_KEY(tbSh, n + insert_num - snum),
+ KEY_SIZE);
+ /* last parameter is del_par */
+ internal_move_pointers_items(&dest_bi, &src_bi,
+ LAST_TO_FIRST,
+ snum - insert_num, 0);
+ /* internal_move_pointers_items(S_new,tbSh,1,snum - insert_num,0); */
+
+ /* insert insert_num keys and node-pointers into S_new */
+ internal_insert_childs(&dest_bi,
+ /*S_new,tb->S[h-1]->b_next, */
+ child_pos - n - insert_num +
+ snum - 1,
+ insert_num, insert_key,
+ insert_ptr);
+
+ insert_num = 0;
+ } else {
+ struct disk_child *dc;
+
+ /* some items fall into S_new, but some don't fall */
+ /* last parameter is del_par */
+ internal_move_pointers_items(&dest_bi, &src_bi,
+ LAST_TO_FIRST,
+ n - child_pos + 1, 1);
+ /* internal_move_pointers_items(S_new,tbSh,1,n - child_pos + 1,1); */
+ /* calculate number of new items that fall into S_new */
+ k = snum - n + child_pos - 1;
+
+ internal_insert_childs(&dest_bi, /*S_new, */ 0, k,
+ insert_key + 1, insert_ptr + 1);
+
+ /* new_insert_key = insert_key[insert_num - k - 1] */
+ memcpy(&new_insert_key, insert_key + insert_num - k - 1,
+ KEY_SIZE);
+ /* replace first node-ptr in S_new by node-ptr to insert_ptr[insert_num-k-1] */
+
+ dc = B_N_CHILD(S_new, 0);
+ put_dc_size(dc,
+ (MAX_CHILD_SIZE
+ (insert_ptr[insert_num - k - 1]) -
+ B_FREE_SPACE(insert_ptr
+ [insert_num - k - 1])));
+ put_dc_block_number(dc,
+ insert_ptr[insert_num - k -
+ 1]->b_blocknr);
+
+ do_balance_mark_internal_dirty(tb, S_new, 0);
+
+ insert_num -= (k + 1);
+ }
+ /* new_insert_ptr = node_pointer to S_new */
+ new_insert_ptr = S_new;
+
+ RFALSE(!buffer_journaled(S_new) || buffer_journal_dirty(S_new)
+ || buffer_dirty(S_new), "cm-00001: bad S_new (%b)",
+ S_new);
+
+ // S_new is released in unfix_nodes
}
+ n = B_NR_ITEMS(tbSh); /*number of items in S[h] */
- memcpy (new_insert_key_addr,&new_insert_key,KEY_SIZE);
+ if (0 <= child_pos && child_pos <= n && insert_num > 0) {
+ bi.tb = tb;
+ bi.bi_bh = tbSh;
+ bi.bi_parent = PATH_H_PPARENT(tb->tb_path, h);
+ bi.bi_position = PATH_H_POSITION(tb->tb_path, h + 1);
+ internal_insert_childs(&bi, /*tbSh, */
+ /* ( tb->S[h-1]->b_parent == tb->S[h] ) ? tb->S[h-1]->b_next : tb->S[h]->b_child->b_next, */
+ child_pos, insert_num, insert_key,
+ insert_ptr);
+ }
+
+ memcpy(new_insert_key_addr, &new_insert_key, KEY_SIZE);
insert_ptr[0] = new_insert_ptr;
return order;
- }
-
-
-
+}
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 289d864fe73..1aaf2c7d44e 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -18,107 +18,109 @@
#include <linux/writeback.h>
#include <linux/quotaops.h>
-extern int reiserfs_default_io_size; /* default io size devuned in super.c */
+extern int reiserfs_default_io_size; /* default io size devuned in super.c */
static int reiserfs_commit_write(struct file *f, struct page *page,
- unsigned from, unsigned to);
+ unsigned from, unsigned to);
static int reiserfs_prepare_write(struct file *f, struct page *page,
unsigned from, unsigned to);
-void reiserfs_delete_inode (struct inode * inode)
+void reiserfs_delete_inode(struct inode *inode)
{
- /* We need blocks for transaction + (user+group) quota update (possibly delete) */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb);
- struct reiserfs_transaction_handle th ;
-
- reiserfs_write_lock(inode->i_sb);
+ /* We need blocks for transaction + (user+group) quota update (possibly delete) */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 2 +
+ 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb);
+ struct reiserfs_transaction_handle th;
- /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
- if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */
- down (&inode->i_sem);
+ reiserfs_write_lock(inode->i_sb);
- reiserfs_delete_xattrs (inode);
+ /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
+ if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */
+ down(&inode->i_sem);
- if (journal_begin(&th, inode->i_sb, jbegin_count)) {
- up (&inode->i_sem);
- goto out;
- }
- reiserfs_update_inode_transaction(inode) ;
+ reiserfs_delete_xattrs(inode);
- if (reiserfs_delete_object (&th, inode)) {
- up (&inode->i_sem);
- goto out;
- }
+ if (journal_begin(&th, inode->i_sb, jbegin_count)) {
+ up(&inode->i_sem);
+ goto out;
+ }
+ reiserfs_update_inode_transaction(inode);
- /* Do quota update inside a transaction for journaled quotas. We must do that
- * after delete_object so that quota updates go into the same transaction as
- * stat data deletion */
- DQUOT_FREE_INODE(inode);
+ if (reiserfs_delete_object(&th, inode)) {
+ up(&inode->i_sem);
+ goto out;
+ }
- if (journal_end(&th, inode->i_sb, jbegin_count)) {
- up (&inode->i_sem);
- goto out;
- }
+ /* Do quota update inside a transaction for journaled quotas. We must do that
+ * after delete_object so that quota updates go into the same transaction as
+ * stat data deletion */
+ DQUOT_FREE_INODE(inode);
+
+ if (journal_end(&th, inode->i_sb, jbegin_count)) {
+ up(&inode->i_sem);
+ goto out;
+ }
- up (&inode->i_sem);
+ up(&inode->i_sem);
- /* all items of file are deleted, so we can remove "save" link */
- remove_save_link (inode, 0/* not truncate */); /* we can't do anything
- * about an error here */
- } else {
- /* no object items are in the tree */
- ;
- }
-out:
- clear_inode (inode); /* note this must go after the journal_end to prevent deadlock */
- inode->i_blocks = 0;
- reiserfs_write_unlock(inode->i_sb);
+ /* all items of file are deleted, so we can remove "save" link */
+ remove_save_link(inode, 0 /* not truncate */ ); /* we can't do anything
+ * about an error here */
+ } else {
+ /* no object items are in the tree */
+ ;
+ }
+ out:
+ clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */
+ inode->i_blocks = 0;
+ reiserfs_write_unlock(inode->i_sb);
}
-static void _make_cpu_key (struct cpu_key * key, int version, __u32 dirid, __u32 objectid,
- loff_t offset, int type, int length )
+static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid,
+ __u32 objectid, loff_t offset, int type, int length)
{
- key->version = version;
+ key->version = version;
- key->on_disk_key.k_dir_id = dirid;
- key->on_disk_key.k_objectid = objectid;
- set_cpu_key_k_offset (key, offset);
- set_cpu_key_k_type (key, type);
- key->key_length = length;
+ key->on_disk_key.k_dir_id = dirid;
+ key->on_disk_key.k_objectid = objectid;
+ set_cpu_key_k_offset(key, offset);
+ set_cpu_key_k_type(key, type);
+ key->key_length = length;
}
-
/* take base of inode_key (it comes from inode always) (dirid, objectid) and version from an inode, set
offset and type of key */
-void make_cpu_key (struct cpu_key * key, struct inode * inode, loff_t offset,
- int type, int length )
+void make_cpu_key(struct cpu_key *key, struct inode *inode, loff_t offset,
+ int type, int length)
{
- _make_cpu_key (key, get_inode_item_key_version (inode), le32_to_cpu (INODE_PKEY (inode)->k_dir_id),
- le32_to_cpu (INODE_PKEY (inode)->k_objectid),
- offset, type, length);
+ _make_cpu_key(key, get_inode_item_key_version(inode),
+ le32_to_cpu(INODE_PKEY(inode)->k_dir_id),
+ le32_to_cpu(INODE_PKEY(inode)->k_objectid), offset, type,
+ length);
}
-
//
// when key is 0, do not set version and short key
//
-inline void make_le_item_head (struct item_head * ih, const struct cpu_key * key,
- int version,
- loff_t offset, int type, int length,
- int entry_count/*or ih_free_space*/)
+inline void make_le_item_head(struct item_head *ih, const struct cpu_key *key,
+ int version,
+ loff_t offset, int type, int length,
+ int entry_count /*or ih_free_space */ )
{
- if (key) {
- ih->ih_key.k_dir_id = cpu_to_le32 (key->on_disk_key.k_dir_id);
- ih->ih_key.k_objectid = cpu_to_le32 (key->on_disk_key.k_objectid);
- }
- put_ih_version( ih, version );
- set_le_ih_k_offset (ih, offset);
- set_le_ih_k_type (ih, type);
- put_ih_item_len( ih, length );
- /* set_ih_free_space (ih, 0);*/
- // for directory items it is entry count, for directs and stat
- // datas - 0xffff, for indirects - 0
- put_ih_entry_count( ih, entry_count );
+ if (key) {
+ ih->ih_key.k_dir_id = cpu_to_le32(key->on_disk_key.k_dir_id);
+ ih->ih_key.k_objectid =
+ cpu_to_le32(key->on_disk_key.k_objectid);
+ }
+ put_ih_version(ih, version);
+ set_le_ih_k_offset(ih, offset);
+ set_le_ih_k_type(ih, type);
+ put_ih_item_len(ih, length);
+ /* set_ih_free_space (ih, 0); */
+ // for directory items it is entry count, for directs and stat
+ // datas - 0xffff, for indirects - 0
+ put_ih_entry_count(ih, entry_count);
}
//
@@ -153,84 +155,84 @@ inline void make_le_item_head (struct item_head * ih, const struct cpu_key * key
** to be unmapped, so that block_prepare_write will correctly call
** reiserfs_get_block to convert the tail into an unformatted node
*/
-static inline void fix_tail_page_for_writing(struct page *page) {
- struct buffer_head *head, *next, *bh ;
-
- if (page && page_has_buffers(page)) {
- head = page_buffers(page) ;
- bh = head ;
- do {
- next = bh->b_this_page ;
- if (buffer_mapped(bh) && bh->b_blocknr == 0) {
- reiserfs_unmap_buffer(bh) ;
- }
- bh = next ;
- } while (bh != head) ;
- }
+static inline void fix_tail_page_for_writing(struct page *page)
+{
+ struct buffer_head *head, *next, *bh;
+
+ if (page && page_has_buffers(page)) {
+ head = page_buffers(page);
+ bh = head;
+ do {
+ next = bh->b_this_page;
+ if (buffer_mapped(bh) && bh->b_blocknr == 0) {
+ reiserfs_unmap_buffer(bh);
+ }
+ bh = next;
+ } while (bh != head);
+ }
}
/* reiserfs_get_block does not need to allocate a block only if it has been
done already or non-hole position has been found in the indirect item */
-static inline int allocation_needed (int retval, b_blocknr_t allocated,
- struct item_head * ih,
- __le32 * item, int pos_in_item)
+static inline int allocation_needed(int retval, b_blocknr_t allocated,
+ struct item_head *ih,
+ __le32 * item, int pos_in_item)
{
- if (allocated)
- return 0;
- if (retval == POSITION_FOUND && is_indirect_le_ih (ih) &&
- get_block_num(item, pos_in_item))
- return 0;
- return 1;
+ if (allocated)
+ return 0;
+ if (retval == POSITION_FOUND && is_indirect_le_ih(ih) &&
+ get_block_num(item, pos_in_item))
+ return 0;
+ return 1;
}
-static inline int indirect_item_found (int retval, struct item_head * ih)
+static inline int indirect_item_found(int retval, struct item_head *ih)
{
- return (retval == POSITION_FOUND) && is_indirect_le_ih (ih);
+ return (retval == POSITION_FOUND) && is_indirect_le_ih(ih);
}
-
-static inline void set_block_dev_mapped (struct buffer_head * bh,
- b_blocknr_t block, struct inode * inode)
+static inline void set_block_dev_mapped(struct buffer_head *bh,
+ b_blocknr_t block, struct inode *inode)
{
map_bh(bh, inode->i_sb, block);
}
-
//
// files which were created in the earlier version can not be longer,
// than 2 gb
//
-static int file_capable (struct inode * inode, long block)
+static int file_capable(struct inode *inode, long block)
{
- if (get_inode_item_key_version (inode) != KEY_FORMAT_3_5 || // it is new file.
- block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb
- return 1;
+ if (get_inode_item_key_version(inode) != KEY_FORMAT_3_5 || // it is new file.
+ block < (1 << (31 - inode->i_sb->s_blocksize_bits))) // old file, but 'block' is inside of 2gb
+ return 1;
- return 0;
+ return 0;
}
/*static*/ int restart_transaction(struct reiserfs_transaction_handle *th,
- struct inode *inode, struct path *path) {
- struct super_block *s = th->t_super ;
- int len = th->t_blocks_allocated ;
- int err;
-
- BUG_ON (!th->t_trans_id);
- BUG_ON (!th->t_refcount);
-
- /* we cannot restart while nested */
- if (th->t_refcount > 1) {
- return 0 ;
- }
- pathrelse(path) ;
- reiserfs_update_sd(th, inode) ;
- err = journal_end(th, s, len) ;
- if (!err) {
- err = journal_begin(th, s, JOURNAL_PER_BALANCE_CNT * 6) ;
- if (!err)
- reiserfs_update_inode_transaction(inode) ;
- }
- return err;
+ struct inode *inode, struct path *path)
+{
+ struct super_block *s = th->t_super;
+ int len = th->t_blocks_allocated;
+ int err;
+
+ BUG_ON(!th->t_trans_id);
+ BUG_ON(!th->t_refcount);
+
+ /* we cannot restart while nested */
+ if (th->t_refcount > 1) {
+ return 0;
+ }
+ pathrelse(path);
+ reiserfs_update_sd(th, inode);
+ err = journal_end(th, s, len);
+ if (!err) {
+ err = journal_begin(th, s, JOURNAL_PER_BALANCE_CNT * 6);
+ if (!err)
+ reiserfs_update_inode_transaction(inode);
+ }
+ return err;
}
// it is called by get_block when create == 0. Returns block number
@@ -241,190 +243,192 @@ static int file_capable (struct inode * inode, long block)
// Please improve the english/clarity in the comment above, as it is
// hard to understand.
-static int _get_block_create_0 (struct inode * inode, long block,
- struct buffer_head * bh_result,
- int args)
+static int _get_block_create_0(struct inode *inode, long block,
+ struct buffer_head *bh_result, int args)
{
- INITIALIZE_PATH (path);
- struct cpu_key key;
- struct buffer_head * bh;
- struct item_head * ih, tmp_ih;
- int fs_gen ;
- int blocknr;
- char * p = NULL;
- int chars;
- int ret ;
- int result ;
- int done = 0 ;
- unsigned long offset ;
-
- // prepare the key to look for the 'block'-th block of file
- make_cpu_key (&key, inode,
- (loff_t)block * inode->i_sb->s_blocksize + 1, TYPE_ANY, 3);
-
-research:
- result = search_for_position_by_key (inode->i_sb, &key, &path) ;
- if (result != POSITION_FOUND) {
- pathrelse (&path);
- if (p)
- kunmap(bh_result->b_page) ;
- if (result == IO_ERROR)
- return -EIO;
- // We do not return -ENOENT if there is a hole but page is uptodate, because it means
- // That there is some MMAPED data associated with it that is yet to be written to disk.
- if ((args & GET_BLOCK_NO_HOLE) && !PageUptodate(bh_result->b_page) ) {
- return -ENOENT ;
- }
- return 0 ;
- }
-
- //
- bh = get_last_bh (&path);
- ih = get_ih (&path);
- if (is_indirect_le_ih (ih)) {
- __le32 * ind_item = (__le32 *)B_I_PITEM (bh, ih);
-
- /* FIXME: here we could cache indirect item or part of it in
- the inode to avoid search_by_key in case of subsequent
- access to file */
- blocknr = get_block_num(ind_item, path.pos_in_item) ;
- ret = 0 ;
- if (blocknr) {
- map_bh(bh_result, inode->i_sb, blocknr);
- if (path.pos_in_item == ((ih_item_len(ih) / UNFM_P_SIZE) - 1)) {
- set_buffer_boundary(bh_result);
- }
- } else
- // We do not return -ENOENT if there is a hole but page is uptodate, because it means
- // That there is some MMAPED data associated with it that is yet to be written to disk.
- if ((args & GET_BLOCK_NO_HOLE) && !PageUptodate(bh_result->b_page) ) {
- ret = -ENOENT ;
- }
-
- pathrelse (&path);
- if (p)
- kunmap(bh_result->b_page) ;
- return ret ;
- }
-
- // requested data are in direct item(s)
- if (!(args & GET_BLOCK_READ_DIRECT)) {
- // we are called by bmap. FIXME: we can not map block of file
- // when it is stored in direct item(s)
- pathrelse (&path);
- if (p)
- kunmap(bh_result->b_page) ;
- return -ENOENT;
- }
-
- /* if we've got a direct item, and the buffer or page was uptodate,
- ** we don't want to pull data off disk again. skip to the
- ** end, where we map the buffer and return
- */
- if (buffer_uptodate(bh_result)) {
- goto finished ;
- } else
- /*
- ** grab_tail_page can trigger calls to reiserfs_get_block on up to date
- ** pages without any buffers. If the page is up to date, we don't want
- ** read old data off disk. Set the up to date bit on the buffer instead
- ** and jump to the end
- */
- if (!bh_result->b_page || PageUptodate(bh_result->b_page)) {
+ INITIALIZE_PATH(path);
+ struct cpu_key key;
+ struct buffer_head *bh;
+ struct item_head *ih, tmp_ih;
+ int fs_gen;
+ int blocknr;
+ char *p = NULL;
+ int chars;
+ int ret;
+ int result;
+ int done = 0;
+ unsigned long offset;
+
+ // prepare the key to look for the 'block'-th block of file
+ make_cpu_key(&key, inode,
+ (loff_t) block * inode->i_sb->s_blocksize + 1, TYPE_ANY,
+ 3);
+
+ research:
+ result = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (result != POSITION_FOUND) {
+ pathrelse(&path);
+ if (p)
+ kunmap(bh_result->b_page);
+ if (result == IO_ERROR)
+ return -EIO;
+ // We do not return -ENOENT if there is a hole but page is uptodate, because it means
+ // That there is some MMAPED data associated with it that is yet to be written to disk.
+ if ((args & GET_BLOCK_NO_HOLE)
+ && !PageUptodate(bh_result->b_page)) {
+ return -ENOENT;
+ }
+ return 0;
+ }
+ //
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ if (is_indirect_le_ih(ih)) {
+ __le32 *ind_item = (__le32 *) B_I_PITEM(bh, ih);
+
+ /* FIXME: here we could cache indirect item or part of it in
+ the inode to avoid search_by_key in case of subsequent
+ access to file */
+ blocknr = get_block_num(ind_item, path.pos_in_item);
+ ret = 0;
+ if (blocknr) {
+ map_bh(bh_result, inode->i_sb, blocknr);
+ if (path.pos_in_item ==
+ ((ih_item_len(ih) / UNFM_P_SIZE) - 1)) {
+ set_buffer_boundary(bh_result);
+ }
+ } else
+ // We do not return -ENOENT if there is a hole but page is uptodate, because it means
+ // That there is some MMAPED data associated with it that is yet to be written to disk.
+ if ((args & GET_BLOCK_NO_HOLE)
+ && !PageUptodate(bh_result->b_page)) {
+ ret = -ENOENT;
+ }
+
+ pathrelse(&path);
+ if (p)
+ kunmap(bh_result->b_page);
+ return ret;
+ }
+ // requested data are in direct item(s)
+ if (!(args & GET_BLOCK_READ_DIRECT)) {
+ // we are called by bmap. FIXME: we can not map block of file
+ // when it is stored in direct item(s)
+ pathrelse(&path);
+ if (p)
+ kunmap(bh_result->b_page);
+ return -ENOENT;
+ }
+
+ /* if we've got a direct item, and the buffer or page was uptodate,
+ ** we don't want to pull data off disk again. skip to the
+ ** end, where we map the buffer and return
+ */
+ if (buffer_uptodate(bh_result)) {
+ goto finished;
+ } else
+ /*
+ ** grab_tail_page can trigger calls to reiserfs_get_block on up to date
+ ** pages without any buffers. If the page is up to date, we don't want
+ ** read old data off disk. Set the up to date bit on the buffer instead
+ ** and jump to the end
+ */
+ if (!bh_result->b_page || PageUptodate(bh_result->b_page)) {
set_buffer_uptodate(bh_result);
- goto finished ;
- }
-
- // read file tail into part of page
- offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1) ;
- fs_gen = get_generation(inode->i_sb) ;
- copy_item_head (&tmp_ih, ih);
-
- /* we only want to kmap if we are reading the tail into the page.
- ** this is not the common case, so we don't kmap until we are
- ** sure we need to. But, this means the item might move if
- ** kmap schedules
- */
- if (!p) {
- p = (char *)kmap(bh_result->b_page) ;
- if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
- goto research;
- }
- }
- p += offset ;
- memset (p, 0, inode->i_sb->s_blocksize);
- do {
- if (!is_direct_le_ih (ih)) {
- BUG ();
- }
- /* make sure we don't read more bytes than actually exist in
- ** the file. This can happen in odd cases where i_size isn't
- ** correct, and when direct item padding results in a few
- ** extra bytes at the end of the direct item
- */
- if ((le_ih_k_offset(ih) + path.pos_in_item) > inode->i_size)
- break ;
- if ((le_ih_k_offset(ih) - 1 + ih_item_len(ih)) > inode->i_size) {
- chars = inode->i_size - (le_ih_k_offset(ih) - 1) - path.pos_in_item;
- done = 1 ;
- } else {
- chars = ih_item_len(ih) - path.pos_in_item;
- }
- memcpy (p, B_I_PITEM (bh, ih) + path.pos_in_item, chars);
-
- if (done)
- break ;
-
- p += chars;
-
- if (PATH_LAST_POSITION (&path) != (B_NR_ITEMS (bh) - 1))
- // we done, if read direct item is not the last item of
- // node FIXME: we could try to check right delimiting key
- // to see whether direct item continues in the right
- // neighbor or rely on i_size
- break;
-
- // update key to look for the next piece
- set_cpu_key_k_offset (&key, cpu_key_k_offset (&key) + chars);
- result = search_for_position_by_key (inode->i_sb, &key, &path);
- if (result != POSITION_FOUND)
- // i/o error most likely
- break;
- bh = get_last_bh (&path);
- ih = get_ih (&path);
- } while (1);
-
- flush_dcache_page(bh_result->b_page) ;
- kunmap(bh_result->b_page) ;
-
-finished:
- pathrelse (&path);
-
- if (result == IO_ERROR)
- return -EIO;
-
- /* this buffer has valid data, but isn't valid for io. mapping it to
- * block #0 tells the rest of reiserfs it just has a tail in it
- */
- map_bh(bh_result, inode->i_sb, 0);
- set_buffer_uptodate (bh_result);
- return 0;
-}
+ goto finished;
+ }
+ // read file tail into part of page
+ offset = (cpu_key_k_offset(&key) - 1) & (PAGE_CACHE_SIZE - 1);
+ fs_gen = get_generation(inode->i_sb);
+ copy_item_head(&tmp_ih, ih);
+
+ /* we only want to kmap if we are reading the tail into the page.
+ ** this is not the common case, so we don't kmap until we are
+ ** sure we need to. But, this means the item might move if
+ ** kmap schedules
+ */
+ if (!p) {
+ p = (char *)kmap(bh_result->b_page);
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ goto research;
+ }
+ }
+ p += offset;
+ memset(p, 0, inode->i_sb->s_blocksize);
+ do {
+ if (!is_direct_le_ih(ih)) {
+ BUG();
+ }
+ /* make sure we don't read more bytes than actually exist in
+ ** the file. This can happen in odd cases where i_size isn't
+ ** correct, and when direct item padding results in a few
+ ** extra bytes at the end of the direct item
+ */
+ if ((le_ih_k_offset(ih) + path.pos_in_item) > inode->i_size)
+ break;
+ if ((le_ih_k_offset(ih) - 1 + ih_item_len(ih)) > inode->i_size) {
+ chars =
+ inode->i_size - (le_ih_k_offset(ih) - 1) -
+ path.pos_in_item;
+ done = 1;
+ } else {
+ chars = ih_item_len(ih) - path.pos_in_item;
+ }
+ memcpy(p, B_I_PITEM(bh, ih) + path.pos_in_item, chars);
+
+ if (done)
+ break;
+
+ p += chars;
+
+ if (PATH_LAST_POSITION(&path) != (B_NR_ITEMS(bh) - 1))
+ // we done, if read direct item is not the last item of
+ // node FIXME: we could try to check right delimiting key
+ // to see whether direct item continues in the right
+ // neighbor or rely on i_size
+ break;
+
+ // update key to look for the next piece
+ set_cpu_key_k_offset(&key, cpu_key_k_offset(&key) + chars);
+ result = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (result != POSITION_FOUND)
+ // i/o error most likely
+ break;
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ } while (1);
+
+ flush_dcache_page(bh_result->b_page);
+ kunmap(bh_result->b_page);
+
+ finished:
+ pathrelse(&path);
+
+ if (result == IO_ERROR)
+ return -EIO;
+ /* this buffer has valid data, but isn't valid for io. mapping it to
+ * block #0 tells the rest of reiserfs it just has a tail in it
+ */
+ map_bh(bh_result, inode->i_sb, 0);
+ set_buffer_uptodate(bh_result);
+ return 0;
+}
// this is called to create file map. So, _get_block_create_0 will not
// read direct item
-static int reiserfs_bmap (struct inode * inode, sector_t block,
- struct buffer_head * bh_result, int create)
+static int reiserfs_bmap(struct inode *inode, sector_t block,
+ struct buffer_head *bh_result, int create)
{
- if (!file_capable (inode, block))
- return -EFBIG;
-
- reiserfs_write_lock(inode->i_sb);
- /* do not read the direct item */
- _get_block_create_0 (inode, block, bh_result, 0) ;
- reiserfs_write_unlock(inode->i_sb);
- return 0;
+ if (!file_capable(inode, block))
+ return -EFBIG;
+
+ reiserfs_write_lock(inode->i_sb);
+ /* do not read the direct item */
+ _get_block_create_0(inode, block, bh_result, 0);
+ reiserfs_write_unlock(inode->i_sb);
+ return 0;
}
/* special version of get_block that is only used by grab_tail_page right
@@ -444,9 +448,11 @@ static int reiserfs_bmap (struct inode * inode, sector_t block,
** don't want to send create == GET_BLOCK_NO_HOLE to reiserfs_get_block,
** don't use this function.
*/
-static int reiserfs_get_block_create_0 (struct inode * inode, sector_t block,
- struct buffer_head * bh_result, int create) {
- return reiserfs_get_block(inode, block, bh_result, GET_BLOCK_NO_HOLE) ;
+static int reiserfs_get_block_create_0(struct inode *inode, sector_t block,
+ struct buffer_head *bh_result,
+ int create)
+{
+ return reiserfs_get_block(inode, block, bh_result, GET_BLOCK_NO_HOLE);
}
/* This is special helper for reiserfs_get_block in case we are executing
@@ -457,43 +463,42 @@ static int reiserfs_get_blocks_direct_io(struct inode *inode,
struct buffer_head *bh_result,
int create)
{
- int ret ;
-
- bh_result->b_page = NULL;
-
- /* We set the b_size before reiserfs_get_block call since it is
- referenced in convert_tail_for_hole() that may be called from
- reiserfs_get_block() */
- bh_result->b_size = (1 << inode->i_blkbits);
-
- ret = reiserfs_get_block(inode, iblock, bh_result,
- create | GET_BLOCK_NO_DANGLE) ;
- if (ret)
- goto out;
-
- /* don't allow direct io onto tail pages */
- if (buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
- /* make sure future calls to the direct io funcs for this offset
- ** in the file fail by unmapping the buffer
- */
- clear_buffer_mapped(bh_result);
- ret = -EINVAL ;
- }
- /* Possible unpacked tail. Flush the data before pages have
- disappeared */
- if (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) {
- int err;
- lock_kernel();
- err = reiserfs_commit_for_inode(inode);
- REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
- unlock_kernel();
- if (err < 0)
- ret = err;
- }
-out:
- return ret ;
-}
+ int ret;
+
+ bh_result->b_page = NULL;
+ /* We set the b_size before reiserfs_get_block call since it is
+ referenced in convert_tail_for_hole() that may be called from
+ reiserfs_get_block() */
+ bh_result->b_size = (1 << inode->i_blkbits);
+
+ ret = reiserfs_get_block(inode, iblock, bh_result,
+ create | GET_BLOCK_NO_DANGLE);
+ if (ret)
+ goto out;
+
+ /* don't allow direct io onto tail pages */
+ if (buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
+ /* make sure future calls to the direct io funcs for this offset
+ ** in the file fail by unmapping the buffer
+ */
+ clear_buffer_mapped(bh_result);
+ ret = -EINVAL;
+ }
+ /* Possible unpacked tail. Flush the data before pages have
+ disappeared */
+ if (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) {
+ int err;
+ lock_kernel();
+ err = reiserfs_commit_for_inode(inode);
+ REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
+ unlock_kernel();
+ if (err < 0)
+ ret = err;
+ }
+ out:
+ return ret;
+}
/*
** helper function for when reiserfs_get_block is called for a hole
@@ -505,490 +510,547 @@ out:
** you should not be in a transaction, or have any paths held when you
** call this.
*/
-static int convert_tail_for_hole(struct inode *inode,
- struct buffer_head *bh_result,
- loff_t tail_offset) {
- unsigned long index ;
- unsigned long tail_end ;
- unsigned long tail_start ;
- struct page * tail_page ;
- struct page * hole_page = bh_result->b_page ;
- int retval = 0 ;
-
- if ((tail_offset & (bh_result->b_size - 1)) != 1)
- return -EIO ;
-
- /* always try to read until the end of the block */
- tail_start = tail_offset & (PAGE_CACHE_SIZE - 1) ;
- tail_end = (tail_start | (bh_result->b_size - 1)) + 1 ;
-
- index = tail_offset >> PAGE_CACHE_SHIFT ;
- /* hole_page can be zero in case of direct_io, we are sure
- that we cannot get here if we write with O_DIRECT into
- tail page */
- if (!hole_page || index != hole_page->index) {
- tail_page = grab_cache_page(inode->i_mapping, index) ;
- retval = -ENOMEM;
- if (!tail_page) {
- goto out ;
- }
- } else {
- tail_page = hole_page ;
- }
-
- /* we don't have to make sure the conversion did not happen while
- ** we were locking the page because anyone that could convert
- ** must first take i_sem.
- **
- ** We must fix the tail page for writing because it might have buffers
- ** that are mapped, but have a block number of 0. This indicates tail
- ** data that has been read directly into the page, and block_prepare_write
- ** won't trigger a get_block in this case.
- */
- fix_tail_page_for_writing(tail_page) ;
- retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end);
- if (retval)
- goto unlock ;
-
- /* tail conversion might change the data in the page */
- flush_dcache_page(tail_page) ;
-
- retval = reiserfs_commit_write(NULL, tail_page, tail_start, tail_end) ;
-
-unlock:
- if (tail_page != hole_page) {
- unlock_page(tail_page) ;
- page_cache_release(tail_page) ;
- }
-out:
- return retval ;
+static int convert_tail_for_hole(struct inode *inode,
+ struct buffer_head *bh_result,
+ loff_t tail_offset)
+{
+ unsigned long index;
+ unsigned long tail_end;
+ unsigned long tail_start;
+ struct page *tail_page;
+ struct page *hole_page = bh_result->b_page;
+ int retval = 0;
+
+ if ((tail_offset & (bh_result->b_size - 1)) != 1)
+ return -EIO;
+
+ /* always try to read until the end of the block */
+ tail_start = tail_offset & (PAGE_CACHE_SIZE - 1);
+ tail_end = (tail_start | (bh_result->b_size - 1)) + 1;
+
+ index = tail_offset >> PAGE_CACHE_SHIFT;
+ /* hole_page can be zero in case of direct_io, we are sure
+ that we cannot get here if we write with O_DIRECT into
+ tail page */
+ if (!hole_page || index != hole_page->index) {
+ tail_page = grab_cache_page(inode->i_mapping, index);
+ retval = -ENOMEM;
+ if (!tail_page) {
+ goto out;
+ }
+ } else {
+ tail_page = hole_page;
+ }
+
+ /* we don't have to make sure the conversion did not happen while
+ ** we were locking the page because anyone that could convert
+ ** must first take i_sem.
+ **
+ ** We must fix the tail page for writing because it might have buffers
+ ** that are mapped, but have a block number of 0. This indicates tail
+ ** data that has been read directly into the page, and block_prepare_write
+ ** won't trigger a get_block in this case.
+ */
+ fix_tail_page_for_writing(tail_page);
+ retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end);
+ if (retval)
+ goto unlock;
+
+ /* tail conversion might change the data in the page */
+ flush_dcache_page(tail_page);
+
+ retval = reiserfs_commit_write(NULL, tail_page, tail_start, tail_end);
+
+ unlock:
+ if (tail_page != hole_page) {
+ unlock_page(tail_page);
+ page_cache_release(tail_page);
+ }
+ out:
+ return retval;
}
static inline int _allocate_block(struct reiserfs_transaction_handle *th,
- long block,
- struct inode *inode,
- b_blocknr_t *allocated_block_nr,
- struct path * path,
- int flags) {
- BUG_ON (!th->t_trans_id);
-
+ long block,
+ struct inode *inode,
+ b_blocknr_t * allocated_block_nr,
+ struct path *path, int flags)
+{
+ BUG_ON(!th->t_trans_id);
+
#ifdef REISERFS_PREALLOCATE
- if (!(flags & GET_BLOCK_NO_ISEM)) {
- return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr, path, block);
- }
+ if (!(flags & GET_BLOCK_NO_ISEM)) {
+ return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr,
+ path, block);
+ }
#endif
- return reiserfs_new_unf_blocknrs (th, inode, allocated_block_nr, path, block);
+ return reiserfs_new_unf_blocknrs(th, inode, allocated_block_nr, path,
+ block);
}
-int reiserfs_get_block (struct inode * inode, sector_t block,
- struct buffer_head * bh_result, int create)
+int reiserfs_get_block(struct inode *inode, sector_t block,
+ struct buffer_head *bh_result, int create)
{
- int repeat, retval = 0;
- b_blocknr_t allocated_block_nr = 0;// b_blocknr_t is (unsigned) 32 bit int
- INITIALIZE_PATH(path);
- int pos_in_item;
- struct cpu_key key;
- struct buffer_head * bh, * unbh = NULL;
- struct item_head * ih, tmp_ih;
- __le32 * item;
- int done;
- int fs_gen;
- struct reiserfs_transaction_handle *th = NULL;
- /* space reserved in transaction batch:
- . 3 balancings in direct->indirect conversion
- . 1 block involved into reiserfs_update_sd()
- XXX in practically impossible worst case direct2indirect()
- can incur (much) more than 3 balancings.
- quota update for user, group */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 1 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
- int version;
- int dangle = 1;
- loff_t new_offset = (((loff_t)block) << inode->i_sb->s_blocksize_bits) + 1 ;
-
- /* bad.... */
- reiserfs_write_lock(inode->i_sb);
- version = get_inode_item_key_version (inode);
-
- if (block < 0) {
- reiserfs_write_unlock(inode->i_sb);
- return -EIO;
- }
+ int repeat, retval = 0;
+ b_blocknr_t allocated_block_nr = 0; // b_blocknr_t is (unsigned) 32 bit int
+ INITIALIZE_PATH(path);
+ int pos_in_item;
+ struct cpu_key key;
+ struct buffer_head *bh, *unbh = NULL;
+ struct item_head *ih, tmp_ih;
+ __le32 *item;
+ int done;
+ int fs_gen;
+ struct reiserfs_transaction_handle *th = NULL;
+ /* space reserved in transaction batch:
+ . 3 balancings in direct->indirect conversion
+ . 1 block involved into reiserfs_update_sd()
+ XXX in practically impossible worst case direct2indirect()
+ can incur (much) more than 3 balancings.
+ quota update for user, group */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 + 1 +
+ 2 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
+ int version;
+ int dangle = 1;
+ loff_t new_offset =
+ (((loff_t) block) << inode->i_sb->s_blocksize_bits) + 1;
+
+ /* bad.... */
+ reiserfs_write_lock(inode->i_sb);
+ version = get_inode_item_key_version(inode);
- if (!file_capable (inode, block)) {
- reiserfs_write_unlock(inode->i_sb);
- return -EFBIG;
- }
-
- /* if !create, we aren't changing the FS, so we don't need to
- ** log anything, so we don't need to start a transaction
- */
- if (!(create & GET_BLOCK_CREATE)) {
- int ret ;
- /* find number of block-th logical block of the file */
- ret = _get_block_create_0 (inode, block, bh_result,
- create | GET_BLOCK_READ_DIRECT) ;
- reiserfs_write_unlock(inode->i_sb);
- return ret;
- }
- /*
- * if we're already in a transaction, make sure to close
- * any new transactions we start in this func
- */
- if ((create & GET_BLOCK_NO_DANGLE) ||
- reiserfs_transaction_running(inode->i_sb))
- dangle = 0;
-
- /* If file is of such a size, that it might have a tail and tails are enabled
- ** we should mark it as possibly needing tail packing on close
- */
- if ( (have_large_tails (inode->i_sb) && inode->i_size < i_block_size (inode)*4) ||
- (have_small_tails (inode->i_sb) && inode->i_size < i_block_size(inode)) )
- REISERFS_I(inode)->i_flags |= i_pack_on_close_mask ;
-
- /* set the key of the first byte in the 'block'-th block of file */
- make_cpu_key (&key, inode, new_offset,
- TYPE_ANY, 3/*key length*/);
- if ((new_offset + inode->i_sb->s_blocksize - 1) > inode->i_size) {
-start_trans:
- th = reiserfs_persistent_transaction(inode->i_sb, jbegin_count);
- if (!th) {
- retval = -ENOMEM;
- goto failure;
- }
- reiserfs_update_inode_transaction(inode) ;
- }
- research:
-
- retval = search_for_position_by_key (inode->i_sb, &key, &path);
- if (retval == IO_ERROR) {
- retval = -EIO;
- goto failure;
- }
-
- bh = get_last_bh (&path);
- ih = get_ih (&path);
- item = get_item (&path);
- pos_in_item = path.pos_in_item;
-
- fs_gen = get_generation (inode->i_sb);
- copy_item_head (&tmp_ih, ih);
-
- if (allocation_needed (retval, allocated_block_nr, ih, item, pos_in_item)) {
- /* we have to allocate block for the unformatted node */
- if (!th) {
- pathrelse(&path) ;
- goto start_trans;
- }
-
- repeat = _allocate_block(th, block, inode, &allocated_block_nr, &path, create);
-
- if (repeat == NO_DISK_SPACE || repeat == QUOTA_EXCEEDED) {
- /* restart the transaction to give the journal a chance to free
- ** some blocks. releases the path, so we have to go back to
- ** research if we succeed on the second try
- */
- SB_JOURNAL(inode->i_sb)->j_next_async_flush = 1;
- retval = restart_transaction(th, inode, &path) ;
- if (retval)
- goto failure;
- repeat = _allocate_block(th, block, inode, &allocated_block_nr, NULL, create);
-
- if (repeat != NO_DISK_SPACE && repeat != QUOTA_EXCEEDED) {
- goto research ;
- }
- if (repeat == QUOTA_EXCEEDED)
- retval = -EDQUOT;
- else
- retval = -ENOSPC;
- goto failure;
- }
-
- if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
- goto research;
- }
- }
-
- if (indirect_item_found (retval, ih)) {
- b_blocknr_t unfm_ptr;
- /* 'block'-th block is in the file already (there is
- corresponding cell in some indirect item). But it may be
- zero unformatted node pointer (hole) */
- unfm_ptr = get_block_num (item, pos_in_item);
- if (unfm_ptr == 0) {
- /* use allocated block to plug the hole */
- reiserfs_prepare_for_journal(inode->i_sb, bh, 1) ;
- if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
- reiserfs_restore_prepared_buffer(inode->i_sb, bh) ;
- goto research;
- }
- set_buffer_new(bh_result);
- if (buffer_dirty(bh_result) && reiserfs_data_ordered(inode->i_sb))
- reiserfs_add_ordered_list(inode, bh_result);
- put_block_num(item, pos_in_item, allocated_block_nr) ;
- unfm_ptr = allocated_block_nr;
- journal_mark_dirty (th, inode->i_sb, bh);
- reiserfs_update_sd(th, inode) ;
- }
- set_block_dev_mapped(bh_result, unfm_ptr, inode);
- pathrelse (&path);
- retval = 0;
- if (!dangle && th)
- retval = reiserfs_end_persistent_transaction(th);
+ if (block < 0) {
+ reiserfs_write_unlock(inode->i_sb);
+ return -EIO;
+ }
- reiserfs_write_unlock(inode->i_sb);
-
- /* the item was found, so new blocks were not added to the file
- ** there is no need to make sure the inode is updated with this
- ** transaction
- */
- return retval;
- }
-
- if (!th) {
- pathrelse(&path) ;
- goto start_trans;
- }
-
- /* desired position is not found or is in the direct item. We have
- to append file with holes up to 'block'-th block converting
- direct items to indirect one if necessary */
- done = 0;
- do {
- if (is_statdata_le_ih (ih)) {
- __le32 unp = 0;
- struct cpu_key tmp_key;
-
- /* indirect item has to be inserted */
- make_le_item_head (&tmp_ih, &key, version, 1, TYPE_INDIRECT,
- UNFM_P_SIZE, 0/* free_space */);
-
- if (cpu_key_k_offset (&key) == 1) {
- /* we are going to add 'block'-th block to the file. Use
- allocated block for that */
- unp = cpu_to_le32 (allocated_block_nr);
- set_block_dev_mapped (bh_result, allocated_block_nr, inode);
- set_buffer_new(bh_result);
- done = 1;
- }
- tmp_key = key; // ;)
- set_cpu_key_k_offset (&tmp_key, 1);
- PATH_LAST_POSITION(&path) ++;
-
- retval = reiserfs_insert_item (th, &path, &tmp_key, &tmp_ih, inode, (char *)&unp);
- if (retval) {
- reiserfs_free_block (th, inode, allocated_block_nr, 1);
- goto failure; // retval == -ENOSPC, -EDQUOT or -EIO or -EEXIST
- }
- //mark_tail_converted (inode);
- } else if (is_direct_le_ih (ih)) {
- /* direct item has to be converted */
- loff_t tail_offset;
-
- tail_offset = ((le_ih_k_offset (ih) - 1) & ~(inode->i_sb->s_blocksize - 1)) + 1;
- if (tail_offset == cpu_key_k_offset (&key)) {
- /* direct item we just found fits into block we have
- to map. Convert it into unformatted node: use
- bh_result for the conversion */
- set_block_dev_mapped (bh_result, allocated_block_nr, inode);
- unbh = bh_result;
- done = 1;
- } else {
- /* we have to padd file tail stored in direct item(s)
- up to block size and convert it to unformatted
- node. FIXME: this should also get into page cache */
-
- pathrelse(&path) ;
- /*
- * ugly, but we can only end the transaction if
- * we aren't nested
- */
- BUG_ON (!th->t_refcount);
- if (th->t_refcount == 1) {
- retval = reiserfs_end_persistent_transaction(th);
- th = NULL;
- if (retval)
+ if (!file_capable(inode, block)) {
+ reiserfs_write_unlock(inode->i_sb);
+ return -EFBIG;
+ }
+
+ /* if !create, we aren't changing the FS, so we don't need to
+ ** log anything, so we don't need to start a transaction
+ */
+ if (!(create & GET_BLOCK_CREATE)) {
+ int ret;
+ /* find number of block-th logical block of the file */
+ ret = _get_block_create_0(inode, block, bh_result,
+ create | GET_BLOCK_READ_DIRECT);
+ reiserfs_write_unlock(inode->i_sb);
+ return ret;
+ }
+ /*
+ * if we're already in a transaction, make sure to close
+ * any new transactions we start in this func
+ */
+ if ((create & GET_BLOCK_NO_DANGLE) ||
+ reiserfs_transaction_running(inode->i_sb))
+ dangle = 0;
+
+ /* If file is of such a size, that it might have a tail and tails are enabled
+ ** we should mark it as possibly needing tail packing on close
+ */
+ if ((have_large_tails(inode->i_sb)
+ && inode->i_size < i_block_size(inode) * 4)
+ || (have_small_tails(inode->i_sb)
+ && inode->i_size < i_block_size(inode)))
+ REISERFS_I(inode)->i_flags |= i_pack_on_close_mask;
+
+ /* set the key of the first byte in the 'block'-th block of file */
+ make_cpu_key(&key, inode, new_offset, TYPE_ANY, 3 /*key length */ );
+ if ((new_offset + inode->i_sb->s_blocksize - 1) > inode->i_size) {
+ start_trans:
+ th = reiserfs_persistent_transaction(inode->i_sb, jbegin_count);
+ if (!th) {
+ retval = -ENOMEM;
goto failure;
}
+ reiserfs_update_inode_transaction(inode);
+ }
+ research:
- retval = convert_tail_for_hole(inode, bh_result, tail_offset) ;
- if (retval) {
- if ( retval != -ENOSPC )
- reiserfs_warning (inode->i_sb, "clm-6004: convert tail failed inode %lu, error %d", inode->i_ino, retval) ;
- if (allocated_block_nr) {
- /* the bitmap, the super, and the stat data == 3 */
- if (!th)
- th = reiserfs_persistent_transaction(inode->i_sb,3);
- if (th)
- reiserfs_free_block (th,inode,allocated_block_nr,1);
- }
- goto failure ;
- }
- goto research ;
- }
- retval = direct2indirect (th, inode, &path, unbh, tail_offset);
- if (retval) {
- reiserfs_unmap_buffer(unbh);
- reiserfs_free_block (th, inode, allocated_block_nr, 1);
- goto failure;
- }
- /* it is important the set_buffer_uptodate is done after
- ** the direct2indirect. The buffer might contain valid
- ** data newer than the data on disk (read by readpage, changed,
- ** and then sent here by writepage). direct2indirect needs
- ** to know if unbh was already up to date, so it can decide
- ** if the data in unbh needs to be replaced with data from
- ** the disk
- */
- set_buffer_uptodate (unbh);
-
- /* unbh->b_page == NULL in case of DIRECT_IO request, this means
- buffer will disappear shortly, so it should not be added to
- */
- if ( unbh->b_page ) {
- /* we've converted the tail, so we must
- ** flush unbh before the transaction commits
- */
- reiserfs_add_tail_list(inode, unbh) ;
-
- /* mark it dirty now to prevent commit_write from adding
- ** this buffer to the inode's dirty buffer list
- */
- /*
- * AKPM: changed __mark_buffer_dirty to mark_buffer_dirty().
- * It's still atomic, but it sets the page dirty too,
- * which makes it eligible for writeback at any time by the
- * VM (which was also the case with __mark_buffer_dirty())
- */
- mark_buffer_dirty(unbh) ;
- }
- } else {
- /* append indirect item with holes if needed, when appending
- pointer to 'block'-th block use block, which is already
- allocated */
- struct cpu_key tmp_key;
- unp_t unf_single=0; // We use this in case we need to allocate only
- // one block which is a fastpath
- unp_t *un;
- __u64 max_to_insert=MAX_ITEM_LEN(inode->i_sb->s_blocksize)/UNFM_P_SIZE;
- __u64 blocks_needed;
-
- RFALSE( pos_in_item != ih_item_len(ih) / UNFM_P_SIZE,
- "vs-804: invalid position for append");
- /* indirect item has to be appended, set up key of that position */
- make_cpu_key (&tmp_key, inode,
- le_key_k_offset (version, &(ih->ih_key)) + op_bytes_number (ih, inode->i_sb->s_blocksize),
- //pos_in_item * inode->i_sb->s_blocksize,
- TYPE_INDIRECT, 3);// key type is unimportant
-
- blocks_needed = 1 + ((cpu_key_k_offset (&key) - cpu_key_k_offset (&tmp_key)) >> inode->i_sb->s_blocksize_bits);
- RFALSE( blocks_needed < 0, "green-805: invalid offset");
-
- if ( blocks_needed == 1 ) {
- un = &unf_single;
- } else {
- un=kmalloc( min(blocks_needed,max_to_insert)*UNFM_P_SIZE,
- GFP_ATOMIC); // We need to avoid scheduling.
- if ( !un) {
- un = &unf_single;
- blocks_needed = 1;
- max_to_insert = 0;
- } else
- memset(un, 0, UNFM_P_SIZE * min(blocks_needed,max_to_insert));
- }
- if ( blocks_needed <= max_to_insert) {
- /* we are going to add target block to the file. Use allocated
- block for that */
- un[blocks_needed-1] = cpu_to_le32 (allocated_block_nr);
- set_block_dev_mapped (bh_result, allocated_block_nr, inode);
- set_buffer_new(bh_result);
- done = 1;
- } else {
- /* paste hole to the indirect item */
- /* If kmalloc failed, max_to_insert becomes zero and it means we
- only have space for one block */
- blocks_needed=max_to_insert?max_to_insert:1;
- }
- retval = reiserfs_paste_into_item (th, &path, &tmp_key, inode, (char *)un, UNFM_P_SIZE * blocks_needed);
-
- if (blocks_needed != 1)
- kfree(un);
-
- if (retval) {
- reiserfs_free_block (th, inode, allocated_block_nr, 1);
- goto failure;
- }
- if (!done) {
- /* We need to mark new file size in case this function will be
- interrupted/aborted later on. And we may do this only for
- holes. */
- inode->i_size += inode->i_sb->s_blocksize * blocks_needed;
- }
- }
-
- if (done == 1)
- break;
-
- /* this loop could log more blocks than we had originally asked
- ** for. So, we have to allow the transaction to end if it is
- ** too big or too full. Update the inode so things are
- ** consistent if we crash before the function returns
- **
- ** release the path so that anybody waiting on the path before
- ** ending their transaction will be able to continue.
- */
- if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
- retval = restart_transaction(th, inode, &path) ;
- if (retval)
- goto failure;
- }
- /* inserting indirect pointers for a hole can take a
- ** long time. reschedule if needed
- */
- cond_resched();
-
- retval = search_for_position_by_key (inode->i_sb, &key, &path);
+ retval = search_for_position_by_key(inode->i_sb, &key, &path);
if (retval == IO_ERROR) {
- retval = -EIO;
- goto failure;
- }
- if (retval == POSITION_FOUND) {
- reiserfs_warning (inode->i_sb, "vs-825: reiserfs_get_block: "
- "%K should not be found", &key);
- retval = -EEXIST;
- if (allocated_block_nr)
- reiserfs_free_block (th, inode, allocated_block_nr, 1);
- pathrelse(&path) ;
- goto failure;
- }
- bh = get_last_bh (&path);
- ih = get_ih (&path);
- item = get_item (&path);
+ retval = -EIO;
+ goto failure;
+ }
+
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
pos_in_item = path.pos_in_item;
- } while (1);
+ fs_gen = get_generation(inode->i_sb);
+ copy_item_head(&tmp_ih, ih);
+
+ if (allocation_needed
+ (retval, allocated_block_nr, ih, item, pos_in_item)) {
+ /* we have to allocate block for the unformatted node */
+ if (!th) {
+ pathrelse(&path);
+ goto start_trans;
+ }
+
+ repeat =
+ _allocate_block(th, block, inode, &allocated_block_nr,
+ &path, create);
+
+ if (repeat == NO_DISK_SPACE || repeat == QUOTA_EXCEEDED) {
+ /* restart the transaction to give the journal a chance to free
+ ** some blocks. releases the path, so we have to go back to
+ ** research if we succeed on the second try
+ */
+ SB_JOURNAL(inode->i_sb)->j_next_async_flush = 1;
+ retval = restart_transaction(th, inode, &path);
+ if (retval)
+ goto failure;
+ repeat =
+ _allocate_block(th, block, inode,
+ &allocated_block_nr, NULL, create);
+
+ if (repeat != NO_DISK_SPACE && repeat != QUOTA_EXCEEDED) {
+ goto research;
+ }
+ if (repeat == QUOTA_EXCEEDED)
+ retval = -EDQUOT;
+ else
+ retval = -ENOSPC;
+ goto failure;
+ }
+
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ goto research;
+ }
+ }
+
+ if (indirect_item_found(retval, ih)) {
+ b_blocknr_t unfm_ptr;
+ /* 'block'-th block is in the file already (there is
+ corresponding cell in some indirect item). But it may be
+ zero unformatted node pointer (hole) */
+ unfm_ptr = get_block_num(item, pos_in_item);
+ if (unfm_ptr == 0) {
+ /* use allocated block to plug the hole */
+ reiserfs_prepare_for_journal(inode->i_sb, bh, 1);
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ reiserfs_restore_prepared_buffer(inode->i_sb,
+ bh);
+ goto research;
+ }
+ set_buffer_new(bh_result);
+ if (buffer_dirty(bh_result)
+ && reiserfs_data_ordered(inode->i_sb))
+ reiserfs_add_ordered_list(inode, bh_result);
+ put_block_num(item, pos_in_item, allocated_block_nr);
+ unfm_ptr = allocated_block_nr;
+ journal_mark_dirty(th, inode->i_sb, bh);
+ reiserfs_update_sd(th, inode);
+ }
+ set_block_dev_mapped(bh_result, unfm_ptr, inode);
+ pathrelse(&path);
+ retval = 0;
+ if (!dangle && th)
+ retval = reiserfs_end_persistent_transaction(th);
+
+ reiserfs_write_unlock(inode->i_sb);
+
+ /* the item was found, so new blocks were not added to the file
+ ** there is no need to make sure the inode is updated with this
+ ** transaction
+ */
+ return retval;
+ }
+
+ if (!th) {
+ pathrelse(&path);
+ goto start_trans;
+ }
+
+ /* desired position is not found or is in the direct item. We have
+ to append file with holes up to 'block'-th block converting
+ direct items to indirect one if necessary */
+ done = 0;
+ do {
+ if (is_statdata_le_ih(ih)) {
+ __le32 unp = 0;
+ struct cpu_key tmp_key;
+
+ /* indirect item has to be inserted */
+ make_le_item_head(&tmp_ih, &key, version, 1,
+ TYPE_INDIRECT, UNFM_P_SIZE,
+ 0 /* free_space */ );
+
+ if (cpu_key_k_offset(&key) == 1) {
+ /* we are going to add 'block'-th block to the file. Use
+ allocated block for that */
+ unp = cpu_to_le32(allocated_block_nr);
+ set_block_dev_mapped(bh_result,
+ allocated_block_nr, inode);
+ set_buffer_new(bh_result);
+ done = 1;
+ }
+ tmp_key = key; // ;)
+ set_cpu_key_k_offset(&tmp_key, 1);
+ PATH_LAST_POSITION(&path)++;
+
+ retval =
+ reiserfs_insert_item(th, &path, &tmp_key, &tmp_ih,
+ inode, (char *)&unp);
+ if (retval) {
+ reiserfs_free_block(th, inode,
+ allocated_block_nr, 1);
+ goto failure; // retval == -ENOSPC, -EDQUOT or -EIO or -EEXIST
+ }
+ //mark_tail_converted (inode);
+ } else if (is_direct_le_ih(ih)) {
+ /* direct item has to be converted */
+ loff_t tail_offset;
+
+ tail_offset =
+ ((le_ih_k_offset(ih) -
+ 1) & ~(inode->i_sb->s_blocksize - 1)) + 1;
+ if (tail_offset == cpu_key_k_offset(&key)) {
+ /* direct item we just found fits into block we have
+ to map. Convert it into unformatted node: use
+ bh_result for the conversion */
+ set_block_dev_mapped(bh_result,
+ allocated_block_nr, inode);
+ unbh = bh_result;
+ done = 1;
+ } else {
+ /* we have to padd file tail stored in direct item(s)
+ up to block size and convert it to unformatted
+ node. FIXME: this should also get into page cache */
+
+ pathrelse(&path);
+ /*
+ * ugly, but we can only end the transaction if
+ * we aren't nested
+ */
+ BUG_ON(!th->t_refcount);
+ if (th->t_refcount == 1) {
+ retval =
+ reiserfs_end_persistent_transaction
+ (th);
+ th = NULL;
+ if (retval)
+ goto failure;
+ }
+
+ retval =
+ convert_tail_for_hole(inode, bh_result,
+ tail_offset);
+ if (retval) {
+ if (retval != -ENOSPC)
+ reiserfs_warning(inode->i_sb,
+ "clm-6004: convert tail failed inode %lu, error %d",
+ inode->i_ino,
+ retval);
+ if (allocated_block_nr) {
+ /* the bitmap, the super, and the stat data == 3 */
+ if (!th)
+ th = reiserfs_persistent_transaction(inode->i_sb, 3);
+ if (th)
+ reiserfs_free_block(th,
+ inode,
+ allocated_block_nr,
+ 1);
+ }
+ goto failure;
+ }
+ goto research;
+ }
+ retval =
+ direct2indirect(th, inode, &path, unbh,
+ tail_offset);
+ if (retval) {
+ reiserfs_unmap_buffer(unbh);
+ reiserfs_free_block(th, inode,
+ allocated_block_nr, 1);
+ goto failure;
+ }
+ /* it is important the set_buffer_uptodate is done after
+ ** the direct2indirect. The buffer might contain valid
+ ** data newer than the data on disk (read by readpage, changed,
+ ** and then sent here by writepage). direct2indirect needs
+ ** to know if unbh was already up to date, so it can decide
+ ** if the data in unbh needs to be replaced with data from
+ ** the disk
+ */
+ set_buffer_uptodate(unbh);
+
+ /* unbh->b_page == NULL in case of DIRECT_IO request, this means
+ buffer will disappear shortly, so it should not be added to
+ */
+ if (unbh->b_page) {
+ /* we've converted the tail, so we must
+ ** flush unbh before the transaction commits
+ */
+ reiserfs_add_tail_list(inode, unbh);
+
+ /* mark it dirty now to prevent commit_write from adding
+ ** this buffer to the inode's dirty buffer list
+ */
+ /*
+ * AKPM: changed __mark_buffer_dirty to mark_buffer_dirty().
+ * It's still atomic, but it sets the page dirty too,
+ * which makes it eligible for writeback at any time by the
+ * VM (which was also the case with __mark_buffer_dirty())
+ */
+ mark_buffer_dirty(unbh);
+ }
+ } else {
+ /* append indirect item with holes if needed, when appending
+ pointer to 'block'-th block use block, which is already
+ allocated */
+ struct cpu_key tmp_key;
+ unp_t unf_single = 0; // We use this in case we need to allocate only
+ // one block which is a fastpath
+ unp_t *un;
+ __u64 max_to_insert =
+ MAX_ITEM_LEN(inode->i_sb->s_blocksize) /
+ UNFM_P_SIZE;
+ __u64 blocks_needed;
+
+ RFALSE(pos_in_item != ih_item_len(ih) / UNFM_P_SIZE,
+ "vs-804: invalid position for append");
+ /* indirect item has to be appended, set up key of that position */
+ make_cpu_key(&tmp_key, inode,
+ le_key_k_offset(version,
+ &(ih->ih_key)) +
+ op_bytes_number(ih,
+ inode->i_sb->s_blocksize),
+ //pos_in_item * inode->i_sb->s_blocksize,
+ TYPE_INDIRECT, 3); // key type is unimportant
+
+ blocks_needed =
+ 1 +
+ ((cpu_key_k_offset(&key) -
+ cpu_key_k_offset(&tmp_key)) >> inode->i_sb->
+ s_blocksize_bits);
+ RFALSE(blocks_needed < 0, "green-805: invalid offset");
+
+ if (blocks_needed == 1) {
+ un = &unf_single;
+ } else {
+ un = kmalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC); // We need to avoid scheduling.
+ if (!un) {
+ un = &unf_single;
+ blocks_needed = 1;
+ max_to_insert = 0;
+ } else
+ memset(un, 0,
+ UNFM_P_SIZE * min(blocks_needed,
+ max_to_insert));
+ }
+ if (blocks_needed <= max_to_insert) {
+ /* we are going to add target block to the file. Use allocated
+ block for that */
+ un[blocks_needed - 1] =
+ cpu_to_le32(allocated_block_nr);
+ set_block_dev_mapped(bh_result,
+ allocated_block_nr, inode);
+ set_buffer_new(bh_result);
+ done = 1;
+ } else {
+ /* paste hole to the indirect item */
+ /* If kmalloc failed, max_to_insert becomes zero and it means we
+ only have space for one block */
+ blocks_needed =
+ max_to_insert ? max_to_insert : 1;
+ }
+ retval =
+ reiserfs_paste_into_item(th, &path, &tmp_key, inode,
+ (char *)un,
+ UNFM_P_SIZE *
+ blocks_needed);
+
+ if (blocks_needed != 1)
+ kfree(un);
+
+ if (retval) {
+ reiserfs_free_block(th, inode,
+ allocated_block_nr, 1);
+ goto failure;
+ }
+ if (!done) {
+ /* We need to mark new file size in case this function will be
+ interrupted/aborted later on. And we may do this only for
+ holes. */
+ inode->i_size +=
+ inode->i_sb->s_blocksize * blocks_needed;
+ }
+ }
- retval = 0;
+ if (done == 1)
+ break;
- failure:
- if (th && (!dangle || (retval && !th->t_trans_id))) {
- int err;
- if (th->t_trans_id)
- reiserfs_update_sd(th, inode);
- err = reiserfs_end_persistent_transaction(th);
- if (err)
- retval = err;
- }
+ /* this loop could log more blocks than we had originally asked
+ ** for. So, we have to allow the transaction to end if it is
+ ** too big or too full. Update the inode so things are
+ ** consistent if we crash before the function returns
+ **
+ ** release the path so that anybody waiting on the path before
+ ** ending their transaction will be able to continue.
+ */
+ if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
+ retval = restart_transaction(th, inode, &path);
+ if (retval)
+ goto failure;
+ }
+ /* inserting indirect pointers for a hole can take a
+ ** long time. reschedule if needed
+ */
+ cond_resched();
- reiserfs_write_unlock(inode->i_sb);
- reiserfs_check_path(&path) ;
- return retval;
+ retval = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (retval == IO_ERROR) {
+ retval = -EIO;
+ goto failure;
+ }
+ if (retval == POSITION_FOUND) {
+ reiserfs_warning(inode->i_sb,
+ "vs-825: reiserfs_get_block: "
+ "%K should not be found", &key);
+ retval = -EEXIST;
+ if (allocated_block_nr)
+ reiserfs_free_block(th, inode,
+ allocated_block_nr, 1);
+ pathrelse(&path);
+ goto failure;
+ }
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ pos_in_item = path.pos_in_item;
+ } while (1);
+
+ retval = 0;
+
+ failure:
+ if (th && (!dangle || (retval && !th->t_trans_id))) {
+ int err;
+ if (th->t_trans_id)
+ reiserfs_update_sd(th, inode);
+ err = reiserfs_end_persistent_transaction(th);
+ if (err)
+ retval = err;
+ }
+
+ reiserfs_write_unlock(inode->i_sb);
+ reiserfs_check_path(&path);
+ return retval;
}
static int
reiserfs_readpages(struct file *file, struct address_space *mapping,
- struct list_head *pages, unsigned nr_pages)
+ struct list_head *pages, unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, reiserfs_get_block);
+ return mpage_readpages(mapping, pages, nr_pages, reiserfs_get_block);
}
/* Compute real number of used bytes by file
@@ -996,51 +1058,56 @@ reiserfs_readpages(struct file *file, struct address_space *mapping,
*/
static int real_space_diff(struct inode *inode, int sd_size)
{
- int bytes;
- loff_t blocksize = inode->i_sb->s_blocksize ;
-
- if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode))
- return sd_size ;
-
- /* End of file is also in full block with indirect reference, so round
- ** up to the next block.
- **
- ** there is just no way to know if the tail is actually packed
- ** on the file, so we have to assume it isn't. When we pack the
- ** tail, we add 4 bytes to pretend there really is an unformatted
- ** node pointer
- */
- bytes = ((inode->i_size + (blocksize-1)) >> inode->i_sb->s_blocksize_bits) * UNFM_P_SIZE + sd_size;
- return bytes ;
+ int bytes;
+ loff_t blocksize = inode->i_sb->s_blocksize;
+
+ if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode))
+ return sd_size;
+
+ /* End of file is also in full block with indirect reference, so round
+ ** up to the next block.
+ **
+ ** there is just no way to know if the tail is actually packed
+ ** on the file, so we have to assume it isn't. When we pack the
+ ** tail, we add 4 bytes to pretend there really is an unformatted
+ ** node pointer
+ */
+ bytes =
+ ((inode->i_size +
+ (blocksize - 1)) >> inode->i_sb->s_blocksize_bits) * UNFM_P_SIZE +
+ sd_size;
+ return bytes;
}
static inline loff_t to_real_used_space(struct inode *inode, ulong blocks,
- int sd_size)
+ int sd_size)
{
- if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode)) {
- return inode->i_size + (loff_t)(real_space_diff(inode, sd_size)) ;
- }
- return ((loff_t)real_space_diff(inode, sd_size)) + (((loff_t)blocks) << 9);
+ if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode)) {
+ return inode->i_size +
+ (loff_t) (real_space_diff(inode, sd_size));
+ }
+ return ((loff_t) real_space_diff(inode, sd_size)) +
+ (((loff_t) blocks) << 9);
}
/* Compute number of blocks used by file in ReiserFS counting */
static inline ulong to_fake_used_blocks(struct inode *inode, int sd_size)
{
- loff_t bytes = inode_get_bytes(inode) ;
- loff_t real_space = real_space_diff(inode, sd_size) ;
-
- /* keeps fsck and non-quota versions of reiserfs happy */
- if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode)) {
- bytes += (loff_t)511 ;
- }
-
- /* files from before the quota patch might i_blocks such that
- ** bytes < real_space. Deal with that here to prevent it from
- ** going negative.
- */
- if (bytes < real_space)
- return 0 ;
- return (bytes - real_space) >> 9;
+ loff_t bytes = inode_get_bytes(inode);
+ loff_t real_space = real_space_diff(inode, sd_size);
+
+ /* keeps fsck and non-quota versions of reiserfs happy */
+ if (S_ISLNK(inode->i_mode) || S_ISDIR(inode->i_mode)) {
+ bytes += (loff_t) 511;
+ }
+
+ /* files from before the quota patch might i_blocks such that
+ ** bytes < real_space. Deal with that here to prevent it from
+ ** going negative.
+ */
+ if (bytes < real_space)
+ return 0;
+ return (bytes - real_space) >> 9;
}
//
@@ -1051,263 +1118,269 @@ static inline ulong to_fake_used_blocks(struct inode *inode, int sd_size)
//
// called by read_locked_inode
-static void init_inode (struct inode * inode, struct path * path)
+static void init_inode(struct inode *inode, struct path *path)
{
- struct buffer_head * bh;
- struct item_head * ih;
- __u32 rdev;
- //int version = ITEM_VERSION_1;
-
- bh = PATH_PLAST_BUFFER (path);
- ih = PATH_PITEM_HEAD (path);
-
-
- copy_key (INODE_PKEY (inode), &(ih->ih_key));
- inode->i_blksize = reiserfs_default_io_size;
-
- INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list ));
- REISERFS_I(inode)->i_flags = 0;
- REISERFS_I(inode)->i_prealloc_block = 0;
- REISERFS_I(inode)->i_prealloc_count = 0;
- REISERFS_I(inode)->i_trans_id = 0;
- REISERFS_I(inode)->i_jl = NULL;
- REISERFS_I(inode)->i_acl_access = NULL;
- REISERFS_I(inode)->i_acl_default = NULL;
- init_rwsem (&REISERFS_I(inode)->xattr_sem);
-
- if (stat_data_v1 (ih)) {
- struct stat_data_v1 * sd = (struct stat_data_v1 *)B_I_PITEM (bh, ih);
- unsigned long blocks;
-
- set_inode_item_key_version (inode, KEY_FORMAT_3_5);
- set_inode_sd_version (inode, STAT_DATA_V1);
- inode->i_mode = sd_v1_mode(sd);
- inode->i_nlink = sd_v1_nlink(sd);
- inode->i_uid = sd_v1_uid(sd);
- inode->i_gid = sd_v1_gid(sd);
- inode->i_size = sd_v1_size(sd);
- inode->i_atime.tv_sec = sd_v1_atime(sd);
- inode->i_mtime.tv_sec = sd_v1_mtime(sd);
- inode->i_ctime.tv_sec = sd_v1_ctime(sd);
- inode->i_atime.tv_nsec = 0;
- inode->i_ctime.tv_nsec = 0;
- inode->i_mtime.tv_nsec = 0;
-
- inode->i_blocks = sd_v1_blocks(sd);
- inode->i_generation = le32_to_cpu (INODE_PKEY (inode)->k_dir_id);
- blocks = (inode->i_size + 511) >> 9;
- blocks = _ROUND_UP (blocks, inode->i_sb->s_blocksize >> 9);
- if (inode->i_blocks > blocks) {
- // there was a bug in <=3.5.23 when i_blocks could take negative
- // values. Starting from 3.5.17 this value could even be stored in
- // stat data. For such files we set i_blocks based on file
- // size. Just 2 notes: this can be wrong for sparce files. On-disk value will be
- // only updated if file's inode will ever change
- inode->i_blocks = blocks;
- }
-
- rdev = sd_v1_rdev(sd);
- REISERFS_I(inode)->i_first_direct_byte = sd_v1_first_direct_byte(sd);
- /* an early bug in the quota code can give us an odd number for the
- ** block count. This is incorrect, fix it here.
- */
- if (inode->i_blocks & 1) {
- inode->i_blocks++ ;
- }
- inode_set_bytes(inode, to_real_used_space(inode, inode->i_blocks,
- SD_V1_SIZE));
- /* nopack is initially zero for v1 objects. For v2 objects,
- nopack is initialised from sd_attrs */
- REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
- } else {
- // new stat data found, but object may have old items
- // (directories and symlinks)
- struct stat_data * sd = (struct stat_data *)B_I_PITEM (bh, ih);
-
- inode->i_mode = sd_v2_mode(sd);
- inode->i_nlink = sd_v2_nlink(sd);
- inode->i_uid = sd_v2_uid(sd);
- inode->i_size = sd_v2_size(sd);
- inode->i_gid = sd_v2_gid(sd);
- inode->i_mtime.tv_sec = sd_v2_mtime(sd);
- inode->i_atime.tv_sec = sd_v2_atime(sd);
- inode->i_ctime.tv_sec = sd_v2_ctime(sd);
- inode->i_ctime.tv_nsec = 0;
- inode->i_mtime.tv_nsec = 0;
- inode->i_atime.tv_nsec = 0;
- inode->i_blocks = sd_v2_blocks(sd);
- rdev = sd_v2_rdev(sd);
- if( S_ISCHR( inode -> i_mode ) || S_ISBLK( inode -> i_mode ) )
- inode->i_generation = le32_to_cpu (INODE_PKEY (inode)->k_dir_id);
- else
- inode->i_generation = sd_v2_generation(sd);
+ struct buffer_head *bh;
+ struct item_head *ih;
+ __u32 rdev;
+ //int version = ITEM_VERSION_1;
+
+ bh = PATH_PLAST_BUFFER(path);
+ ih = PATH_PITEM_HEAD(path);
+
+ copy_key(INODE_PKEY(inode), &(ih->ih_key));
+ inode->i_blksize = reiserfs_default_io_size;
+
+ INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list));
+ REISERFS_I(inode)->i_flags = 0;
+ REISERFS_I(inode)->i_prealloc_block = 0;
+ REISERFS_I(inode)->i_prealloc_count = 0;
+ REISERFS_I(inode)->i_trans_id = 0;
+ REISERFS_I(inode)->i_jl = NULL;
+ REISERFS_I(inode)->i_acl_access = NULL;
+ REISERFS_I(inode)->i_acl_default = NULL;
+ init_rwsem(&REISERFS_I(inode)->xattr_sem);
+
+ if (stat_data_v1(ih)) {
+ struct stat_data_v1 *sd =
+ (struct stat_data_v1 *)B_I_PITEM(bh, ih);
+ unsigned long blocks;
+
+ set_inode_item_key_version(inode, KEY_FORMAT_3_5);
+ set_inode_sd_version(inode, STAT_DATA_V1);
+ inode->i_mode = sd_v1_mode(sd);
+ inode->i_nlink = sd_v1_nlink(sd);
+ inode->i_uid = sd_v1_uid(sd);
+ inode->i_gid = sd_v1_gid(sd);
+ inode->i_size = sd_v1_size(sd);
+ inode->i_atime.tv_sec = sd_v1_atime(sd);
+ inode->i_mtime.tv_sec = sd_v1_mtime(sd);
+ inode->i_ctime.tv_sec = sd_v1_ctime(sd);
+ inode->i_atime.tv_nsec = 0;
+ inode->i_ctime.tv_nsec = 0;
+ inode->i_mtime.tv_nsec = 0;
+
+ inode->i_blocks = sd_v1_blocks(sd);
+ inode->i_generation = le32_to_cpu(INODE_PKEY(inode)->k_dir_id);
+ blocks = (inode->i_size + 511) >> 9;
+ blocks = _ROUND_UP(blocks, inode->i_sb->s_blocksize >> 9);
+ if (inode->i_blocks > blocks) {
+ // there was a bug in <=3.5.23 when i_blocks could take negative
+ // values. Starting from 3.5.17 this value could even be stored in
+ // stat data. For such files we set i_blocks based on file
+ // size. Just 2 notes: this can be wrong for sparce files. On-disk value will be
+ // only updated if file's inode will ever change
+ inode->i_blocks = blocks;
+ }
- if (S_ISDIR (inode->i_mode) || S_ISLNK (inode->i_mode))
- set_inode_item_key_version (inode, KEY_FORMAT_3_5);
- else
- set_inode_item_key_version (inode, KEY_FORMAT_3_6);
- REISERFS_I(inode)->i_first_direct_byte = 0;
- set_inode_sd_version (inode, STAT_DATA_V2);
- inode_set_bytes(inode, to_real_used_space(inode, inode->i_blocks,
- SD_V2_SIZE));
- /* read persistent inode attributes from sd and initalise
- generic inode flags from them */
- REISERFS_I(inode)->i_attrs = sd_v2_attrs( sd );
- sd_attrs_to_i_attrs( sd_v2_attrs( sd ), inode );
- }
-
- pathrelse (path);
- if (S_ISREG (inode->i_mode)) {
- inode->i_op = &reiserfs_file_inode_operations;
- inode->i_fop = &reiserfs_file_operations;
- inode->i_mapping->a_ops = &reiserfs_address_space_operations ;
- } else if (S_ISDIR (inode->i_mode)) {
- inode->i_op = &reiserfs_dir_inode_operations;
- inode->i_fop = &reiserfs_dir_operations;
- } else if (S_ISLNK (inode->i_mode)) {
- inode->i_op = &reiserfs_symlink_inode_operations;
- inode->i_mapping->a_ops = &reiserfs_address_space_operations;
- } else {
- inode->i_blocks = 0;
- inode->i_op = &reiserfs_special_inode_operations;
- init_special_inode(inode, inode->i_mode, new_decode_dev(rdev));
- }
-}
+ rdev = sd_v1_rdev(sd);
+ REISERFS_I(inode)->i_first_direct_byte =
+ sd_v1_first_direct_byte(sd);
+ /* an early bug in the quota code can give us an odd number for the
+ ** block count. This is incorrect, fix it here.
+ */
+ if (inode->i_blocks & 1) {
+ inode->i_blocks++;
+ }
+ inode_set_bytes(inode,
+ to_real_used_space(inode, inode->i_blocks,
+ SD_V1_SIZE));
+ /* nopack is initially zero for v1 objects. For v2 objects,
+ nopack is initialised from sd_attrs */
+ REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
+ } else {
+ // new stat data found, but object may have old items
+ // (directories and symlinks)
+ struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
+
+ inode->i_mode = sd_v2_mode(sd);
+ inode->i_nlink = sd_v2_nlink(sd);
+ inode->i_uid = sd_v2_uid(sd);
+ inode->i_size = sd_v2_size(sd);
+ inode->i_gid = sd_v2_gid(sd);
+ inode->i_mtime.tv_sec = sd_v2_mtime(sd);
+ inode->i_atime.tv_sec = sd_v2_atime(sd);
+ inode->i_ctime.tv_sec = sd_v2_ctime(sd);
+ inode->i_ctime.tv_nsec = 0;
+ inode->i_mtime.tv_nsec = 0;
+ inode->i_atime.tv_nsec = 0;
+ inode->i_blocks = sd_v2_blocks(sd);
+ rdev = sd_v2_rdev(sd);
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ inode->i_generation =
+ le32_to_cpu(INODE_PKEY(inode)->k_dir_id);
+ else
+ inode->i_generation = sd_v2_generation(sd);
+ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
+ set_inode_item_key_version(inode, KEY_FORMAT_3_5);
+ else
+ set_inode_item_key_version(inode, KEY_FORMAT_3_6);
+ REISERFS_I(inode)->i_first_direct_byte = 0;
+ set_inode_sd_version(inode, STAT_DATA_V2);
+ inode_set_bytes(inode,
+ to_real_used_space(inode, inode->i_blocks,
+ SD_V2_SIZE));
+ /* read persistent inode attributes from sd and initalise
+ generic inode flags from them */
+ REISERFS_I(inode)->i_attrs = sd_v2_attrs(sd);
+ sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
+ }
+
+ pathrelse(path);
+ if (S_ISREG(inode->i_mode)) {
+ inode->i_op = &reiserfs_file_inode_operations;
+ inode->i_fop = &reiserfs_file_operations;
+ inode->i_mapping->a_ops = &reiserfs_address_space_operations;
+ } else if (S_ISDIR(inode->i_mode)) {
+ inode->i_op = &reiserfs_dir_inode_operations;
+ inode->i_fop = &reiserfs_dir_operations;
+ } else if (S_ISLNK(inode->i_mode)) {
+ inode->i_op = &reiserfs_symlink_inode_operations;
+ inode->i_mapping->a_ops = &reiserfs_address_space_operations;
+ } else {
+ inode->i_blocks = 0;
+ inode->i_op = &reiserfs_special_inode_operations;
+ init_special_inode(inode, inode->i_mode, new_decode_dev(rdev));
+ }
+}
// update new stat data with inode fields
-static void inode2sd (void * sd, struct inode * inode, loff_t size)
+static void inode2sd(void *sd, struct inode *inode, loff_t size)
{
- struct stat_data * sd_v2 = (struct stat_data *)sd;
- __u16 flags;
-
- set_sd_v2_mode(sd_v2, inode->i_mode );
- set_sd_v2_nlink(sd_v2, inode->i_nlink );
- set_sd_v2_uid(sd_v2, inode->i_uid );
- set_sd_v2_size(sd_v2, size );
- set_sd_v2_gid(sd_v2, inode->i_gid );
- set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec );
- set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec );
- set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec );
- set_sd_v2_blocks(sd_v2, to_fake_used_blocks(inode, SD_V2_SIZE));
- if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
- set_sd_v2_rdev(sd_v2, new_encode_dev(inode->i_rdev));
- else
- set_sd_v2_generation(sd_v2, inode->i_generation);
- flags = REISERFS_I(inode)->i_attrs;
- i_attrs_to_sd_attrs( inode, &flags );
- set_sd_v2_attrs( sd_v2, flags );
+ struct stat_data *sd_v2 = (struct stat_data *)sd;
+ __u16 flags;
+
+ set_sd_v2_mode(sd_v2, inode->i_mode);
+ set_sd_v2_nlink(sd_v2, inode->i_nlink);
+ set_sd_v2_uid(sd_v2, inode->i_uid);
+ set_sd_v2_size(sd_v2, size);
+ set_sd_v2_gid(sd_v2, inode->i_gid);
+ set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
+ set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
+ set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
+ set_sd_v2_blocks(sd_v2, to_fake_used_blocks(inode, SD_V2_SIZE));
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ set_sd_v2_rdev(sd_v2, new_encode_dev(inode->i_rdev));
+ else
+ set_sd_v2_generation(sd_v2, inode->i_generation);
+ flags = REISERFS_I(inode)->i_attrs;
+ i_attrs_to_sd_attrs(inode, &flags);
+ set_sd_v2_attrs(sd_v2, flags);
}
-
// used to copy inode's fields to old stat data
-static void inode2sd_v1 (void * sd, struct inode * inode, loff_t size)
+static void inode2sd_v1(void *sd, struct inode *inode, loff_t size)
{
- struct stat_data_v1 * sd_v1 = (struct stat_data_v1 *)sd;
-
- set_sd_v1_mode(sd_v1, inode->i_mode );
- set_sd_v1_uid(sd_v1, inode->i_uid );
- set_sd_v1_gid(sd_v1, inode->i_gid );
- set_sd_v1_nlink(sd_v1, inode->i_nlink );
- set_sd_v1_size(sd_v1, size );
- set_sd_v1_atime(sd_v1, inode->i_atime.tv_sec );
- set_sd_v1_ctime(sd_v1, inode->i_ctime.tv_sec );
- set_sd_v1_mtime(sd_v1, inode->i_mtime.tv_sec );
-
- if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
- set_sd_v1_rdev(sd_v1, new_encode_dev(inode->i_rdev));
- else
- set_sd_v1_blocks(sd_v1, to_fake_used_blocks(inode, SD_V1_SIZE));
-
- // Sigh. i_first_direct_byte is back
- set_sd_v1_first_direct_byte(sd_v1, REISERFS_I(inode)->i_first_direct_byte);
-}
+ struct stat_data_v1 *sd_v1 = (struct stat_data_v1 *)sd;
+
+ set_sd_v1_mode(sd_v1, inode->i_mode);
+ set_sd_v1_uid(sd_v1, inode->i_uid);
+ set_sd_v1_gid(sd_v1, inode->i_gid);
+ set_sd_v1_nlink(sd_v1, inode->i_nlink);
+ set_sd_v1_size(sd_v1, size);
+ set_sd_v1_atime(sd_v1, inode->i_atime.tv_sec);
+ set_sd_v1_ctime(sd_v1, inode->i_ctime.tv_sec);
+ set_sd_v1_mtime(sd_v1, inode->i_mtime.tv_sec);
+
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ set_sd_v1_rdev(sd_v1, new_encode_dev(inode->i_rdev));
+ else
+ set_sd_v1_blocks(sd_v1, to_fake_used_blocks(inode, SD_V1_SIZE));
+ // Sigh. i_first_direct_byte is back
+ set_sd_v1_first_direct_byte(sd_v1,
+ REISERFS_I(inode)->i_first_direct_byte);
+}
/* NOTE, you must prepare the buffer head before sending it here,
** and then log it after the call
*/
-static void update_stat_data (struct path * path, struct inode * inode,
- loff_t size)
+static void update_stat_data(struct path *path, struct inode *inode,
+ loff_t size)
{
- struct buffer_head * bh;
- struct item_head * ih;
-
- bh = PATH_PLAST_BUFFER (path);
- ih = PATH_PITEM_HEAD (path);
-
- if (!is_statdata_le_ih (ih))
- reiserfs_panic (inode->i_sb, "vs-13065: update_stat_data: key %k, found item %h",
- INODE_PKEY (inode), ih);
-
- if (stat_data_v1 (ih)) {
- // path points to old stat data
- inode2sd_v1 (B_I_PITEM (bh, ih), inode, size);
- } else {
- inode2sd (B_I_PITEM (bh, ih), inode, size);
- }
-
- return;
-}
+ struct buffer_head *bh;
+ struct item_head *ih;
+
+ bh = PATH_PLAST_BUFFER(path);
+ ih = PATH_PITEM_HEAD(path);
+
+ if (!is_statdata_le_ih(ih))
+ reiserfs_panic(inode->i_sb,
+ "vs-13065: update_stat_data: key %k, found item %h",
+ INODE_PKEY(inode), ih);
+
+ if (stat_data_v1(ih)) {
+ // path points to old stat data
+ inode2sd_v1(B_I_PITEM(bh, ih), inode, size);
+ } else {
+ inode2sd(B_I_PITEM(bh, ih), inode, size);
+ }
+ return;
+}
-void reiserfs_update_sd_size (struct reiserfs_transaction_handle *th,
- struct inode * inode, loff_t size)
+void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
+ struct inode *inode, loff_t size)
{
- struct cpu_key key;
- INITIALIZE_PATH(path);
- struct buffer_head *bh ;
- int fs_gen ;
- struct item_head *ih, tmp_ih ;
- int retval;
-
- BUG_ON (!th->t_trans_id);
-
- make_cpu_key (&key, inode, SD_OFFSET, TYPE_STAT_DATA, 3);//key type is unimportant
-
- for(;;) {
- int pos;
- /* look for the object's stat data */
- retval = search_item (inode->i_sb, &key, &path);
- if (retval == IO_ERROR) {
- reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: "
- "i/o failure occurred trying to update %K stat data",
- &key);
- return;
- }
- if (retval == ITEM_NOT_FOUND) {
- pos = PATH_LAST_POSITION (&path);
- pathrelse(&path) ;
- if (inode->i_nlink == 0) {
- /*reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: i_nlink == 0, stat data not found");*/
- return;
- }
- reiserfs_warning (inode->i_sb, "vs-13060: reiserfs_update_sd: "
- "stat data of object %k (nlink == %d) not found (pos %d)",
- INODE_PKEY (inode), inode->i_nlink, pos);
- reiserfs_check_path(&path) ;
- return;
- }
-
- /* sigh, prepare_for_journal might schedule. When it schedules the
- ** FS might change. We have to detect that, and loop back to the
- ** search if the stat data item has moved
- */
- bh = get_last_bh(&path) ;
- ih = get_ih(&path) ;
- copy_item_head (&tmp_ih, ih);
- fs_gen = get_generation (inode->i_sb);
- reiserfs_prepare_for_journal(inode->i_sb, bh, 1) ;
- if (fs_changed (fs_gen, inode->i_sb) && item_moved(&tmp_ih, &path)) {
- reiserfs_restore_prepared_buffer(inode->i_sb, bh) ;
- continue ; /* Stat_data item has been moved after scheduling. */
- }
- break;
- }
- update_stat_data (&path, inode, size);
- journal_mark_dirty(th, th->t_super, bh) ;
- pathrelse (&path);
- return;
+ struct cpu_key key;
+ INITIALIZE_PATH(path);
+ struct buffer_head *bh;
+ int fs_gen;
+ struct item_head *ih, tmp_ih;
+ int retval;
+
+ BUG_ON(!th->t_trans_id);
+
+ make_cpu_key(&key, inode, SD_OFFSET, TYPE_STAT_DATA, 3); //key type is unimportant
+
+ for (;;) {
+ int pos;
+ /* look for the object's stat data */
+ retval = search_item(inode->i_sb, &key, &path);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(inode->i_sb,
+ "vs-13050: reiserfs_update_sd: "
+ "i/o failure occurred trying to update %K stat data",
+ &key);
+ return;
+ }
+ if (retval == ITEM_NOT_FOUND) {
+ pos = PATH_LAST_POSITION(&path);
+ pathrelse(&path);
+ if (inode->i_nlink == 0) {
+ /*reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: i_nlink == 0, stat data not found"); */
+ return;
+ }
+ reiserfs_warning(inode->i_sb,
+ "vs-13060: reiserfs_update_sd: "
+ "stat data of object %k (nlink == %d) not found (pos %d)",
+ INODE_PKEY(inode), inode->i_nlink,
+ pos);
+ reiserfs_check_path(&path);
+ return;
+ }
+
+ /* sigh, prepare_for_journal might schedule. When it schedules the
+ ** FS might change. We have to detect that, and loop back to the
+ ** search if the stat data item has moved
+ */
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ copy_item_head(&tmp_ih, ih);
+ fs_gen = get_generation(inode->i_sb);
+ reiserfs_prepare_for_journal(inode->i_sb, bh, 1);
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ reiserfs_restore_prepared_buffer(inode->i_sb, bh);
+ continue; /* Stat_data item has been moved after scheduling. */
+ }
+ break;
+ }
+ update_stat_data(&path, inode, size);
+ journal_mark_dirty(th, th->t_super, bh);
+ pathrelse(&path);
+ return;
}
/* reiserfs_read_locked_inode is called to read the inode off disk, and it
@@ -1316,9 +1389,10 @@ void reiserfs_update_sd_size (struct reiserfs_transaction_handle *th,
** corresponding iput might try to delete whatever object the inode last
** represented.
*/
-static void reiserfs_make_bad_inode(struct inode *inode) {
- memset(INODE_PKEY(inode), 0, KEY_SIZE);
- make_bad_inode(inode);
+static void reiserfs_make_bad_inode(struct inode *inode)
+{
+ memset(INODE_PKEY(inode), 0, KEY_SIZE);
+ make_bad_inode(inode);
}
//
@@ -1326,77 +1400,79 @@ static void reiserfs_make_bad_inode(struct inode *inode) {
// evolved as the prototype did
//
-int reiserfs_init_locked_inode (struct inode * inode, void *p)
+int reiserfs_init_locked_inode(struct inode *inode, void *p)
{
- struct reiserfs_iget_args *args = (struct reiserfs_iget_args *)p ;
- inode->i_ino = args->objectid;
- INODE_PKEY(inode)->k_dir_id = cpu_to_le32(args->dirid);
- return 0;
+ struct reiserfs_iget_args *args = (struct reiserfs_iget_args *)p;
+ inode->i_ino = args->objectid;
+ INODE_PKEY(inode)->k_dir_id = cpu_to_le32(args->dirid);
+ return 0;
}
/* looks for stat data in the tree, and fills up the fields of in-core
inode stat data fields */
-void reiserfs_read_locked_inode (struct inode * inode, struct reiserfs_iget_args *args)
+void reiserfs_read_locked_inode(struct inode *inode,
+ struct reiserfs_iget_args *args)
{
- INITIALIZE_PATH (path_to_sd);
- struct cpu_key key;
- unsigned long dirino;
- int retval;
-
- dirino = args->dirid ;
-
- /* set version 1, version 2 could be used too, because stat data
- key is the same in both versions */
- key.version = KEY_FORMAT_3_5;
- key.on_disk_key.k_dir_id = dirino;
- key.on_disk_key.k_objectid = inode->i_ino;
- key.on_disk_key.k_offset = 0;
- key.on_disk_key.k_type = 0;
-
- /* look for the object's stat data */
- retval = search_item (inode->i_sb, &key, &path_to_sd);
- if (retval == IO_ERROR) {
- reiserfs_warning (inode->i_sb, "vs-13070: reiserfs_read_locked_inode: "
- "i/o failure occurred trying to find stat data of %K",
- &key);
- reiserfs_make_bad_inode(inode) ;
- return;
- }
- if (retval != ITEM_FOUND) {
- /* a stale NFS handle can trigger this without it being an error */
- pathrelse (&path_to_sd);
- reiserfs_make_bad_inode(inode) ;
- inode->i_nlink = 0;
- return;
- }
-
- init_inode (inode, &path_to_sd);
-
- /* It is possible that knfsd is trying to access inode of a file
- that is being removed from the disk by some other thread. As we
- update sd on unlink all that is required is to check for nlink
- here. This bug was first found by Sizif when debugging
- SquidNG/Butterfly, forgotten, and found again after Philippe
- Gramoulle <philippe.gramoulle@mmania.com> reproduced it.
-
- More logical fix would require changes in fs/inode.c:iput() to
- remove inode from hash-table _after_ fs cleaned disk stuff up and
- in iget() to return NULL if I_FREEING inode is found in
- hash-table. */
- /* Currently there is one place where it's ok to meet inode with
- nlink==0: processing of open-unlinked and half-truncated files
- during mount (fs/reiserfs/super.c:finish_unfinished()). */
- if( ( inode -> i_nlink == 0 ) &&
- ! REISERFS_SB(inode -> i_sb) -> s_is_unlinked_ok ) {
- reiserfs_warning (inode->i_sb,
- "vs-13075: reiserfs_read_locked_inode: "
- "dead inode read from disk %K. "
- "This is likely to be race with knfsd. Ignore",
- &key );
- reiserfs_make_bad_inode( inode );
- }
-
- reiserfs_check_path(&path_to_sd) ; /* init inode should be relsing */
+ INITIALIZE_PATH(path_to_sd);
+ struct cpu_key key;
+ unsigned long dirino;
+ int retval;
+
+ dirino = args->dirid;
+
+ /* set version 1, version 2 could be used too, because stat data
+ key is the same in both versions */
+ key.version = KEY_FORMAT_3_5;
+ key.on_disk_key.k_dir_id = dirino;
+ key.on_disk_key.k_objectid = inode->i_ino;
+ key.on_disk_key.k_offset = 0;
+ key.on_disk_key.k_type = 0;
+
+ /* look for the object's stat data */
+ retval = search_item(inode->i_sb, &key, &path_to_sd);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(inode->i_sb,
+ "vs-13070: reiserfs_read_locked_inode: "
+ "i/o failure occurred trying to find stat data of %K",
+ &key);
+ reiserfs_make_bad_inode(inode);
+ return;
+ }
+ if (retval != ITEM_FOUND) {
+ /* a stale NFS handle can trigger this without it being an error */
+ pathrelse(&path_to_sd);
+ reiserfs_make_bad_inode(inode);
+ inode->i_nlink = 0;
+ return;
+ }
+
+ init_inode(inode, &path_to_sd);
+
+ /* It is possible that knfsd is trying to access inode of a file
+ that is being removed from the disk by some other thread. As we
+ update sd on unlink all that is required is to check for nlink
+ here. This bug was first found by Sizif when debugging
+ SquidNG/Butterfly, forgotten, and found again after Philippe
+ Gramoulle <philippe.gramoulle@mmania.com> reproduced it.
+
+ More logical fix would require changes in fs/inode.c:iput() to
+ remove inode from hash-table _after_ fs cleaned disk stuff up and
+ in iget() to return NULL if I_FREEING inode is found in
+ hash-table. */
+ /* Currently there is one place where it's ok to meet inode with
+ nlink==0: processing of open-unlinked and half-truncated files
+ during mount (fs/reiserfs/super.c:finish_unfinished()). */
+ if ((inode->i_nlink == 0) &&
+ !REISERFS_SB(inode->i_sb)->s_is_unlinked_ok) {
+ reiserfs_warning(inode->i_sb,
+ "vs-13075: reiserfs_read_locked_inode: "
+ "dead inode read from disk %K. "
+ "This is likely to be race with knfsd. Ignore",
+ &key);
+ reiserfs_make_bad_inode(inode);
+ }
+
+ reiserfs_check_path(&path_to_sd); /* init inode should be relsing */
}
@@ -1412,140 +1488,148 @@ void reiserfs_read_locked_inode (struct inode * inode, struct reiserfs_iget_args
* inode numbers (objectids) are distinguished by parent directory ids.
*
*/
-int reiserfs_find_actor( struct inode *inode, void *opaque )
+int reiserfs_find_actor(struct inode *inode, void *opaque)
{
- struct reiserfs_iget_args *args;
+ struct reiserfs_iget_args *args;
- args = opaque;
- /* args is already in CPU order */
- return (inode->i_ino == args->objectid) &&
- (le32_to_cpu(INODE_PKEY(inode)->k_dir_id) == args->dirid);
+ args = opaque;
+ /* args is already in CPU order */
+ return (inode->i_ino == args->objectid) &&
+ (le32_to_cpu(INODE_PKEY(inode)->k_dir_id) == args->dirid);
}
-struct inode * reiserfs_iget (struct super_block * s, const struct cpu_key * key)
+struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key)
{
- struct inode * inode;
- struct reiserfs_iget_args args ;
-
- args.objectid = key->on_disk_key.k_objectid ;
- args.dirid = key->on_disk_key.k_dir_id ;
- inode = iget5_locked (s, key->on_disk_key.k_objectid,
- reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
- if (!inode)
- return ERR_PTR(-ENOMEM) ;
-
- if (inode->i_state & I_NEW) {
- reiserfs_read_locked_inode(inode, &args);
- unlock_new_inode(inode);
- }
-
- if (comp_short_keys (INODE_PKEY (inode), key) || is_bad_inode (inode)) {
- /* either due to i/o error or a stale NFS handle */
- iput (inode);
- inode = NULL;
- }
- return inode;
+ struct inode *inode;
+ struct reiserfs_iget_args args;
+
+ args.objectid = key->on_disk_key.k_objectid;
+ args.dirid = key->on_disk_key.k_dir_id;
+ inode = iget5_locked(s, key->on_disk_key.k_objectid,
+ reiserfs_find_actor, reiserfs_init_locked_inode,
+ (void *)(&args));
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+ if (inode->i_state & I_NEW) {
+ reiserfs_read_locked_inode(inode, &args);
+ unlock_new_inode(inode);
+ }
+
+ if (comp_short_keys(INODE_PKEY(inode), key) || is_bad_inode(inode)) {
+ /* either due to i/o error or a stale NFS handle */
+ iput(inode);
+ inode = NULL;
+ }
+ return inode;
}
struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp)
{
- __u32 *data = vobjp;
- struct cpu_key key ;
- struct dentry *result;
- struct inode *inode;
-
- key.on_disk_key.k_objectid = data[0] ;
- key.on_disk_key.k_dir_id = data[1] ;
- reiserfs_write_lock(sb);
- inode = reiserfs_iget(sb, &key) ;
- if (inode && !IS_ERR(inode) && data[2] != 0 &&
- data[2] != inode->i_generation) {
- iput(inode) ;
- inode = NULL ;
- }
- reiserfs_write_unlock(sb);
- if (!inode)
- inode = ERR_PTR(-ESTALE);
- if (IS_ERR(inode))
- return ERR_PTR(PTR_ERR(inode));
- result = d_alloc_anon(inode);
- if (!result) {
- iput(inode);
- return ERR_PTR(-ENOMEM);
- }
- return result;
+ __u32 *data = vobjp;
+ struct cpu_key key;
+ struct dentry *result;
+ struct inode *inode;
+
+ key.on_disk_key.k_objectid = data[0];
+ key.on_disk_key.k_dir_id = data[1];
+ reiserfs_write_lock(sb);
+ inode = reiserfs_iget(sb, &key);
+ if (inode && !IS_ERR(inode) && data[2] != 0 &&
+ data[2] != inode->i_generation) {
+ iput(inode);
+ inode = NULL;
+ }
+ reiserfs_write_unlock(sb);
+ if (!inode)
+ inode = ERR_PTR(-ESTALE);
+ if (IS_ERR(inode))
+ return ERR_PTR(PTR_ERR(inode));
+ result = d_alloc_anon(inode);
+ if (!result) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+ return result;
}
-struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 *data,
- int len, int fhtype,
- int (*acceptable)(void *contect, struct dentry *de),
- void *context) {
- __u32 obj[3], parent[3];
-
- /* fhtype happens to reflect the number of u32s encoded.
- * due to a bug in earlier code, fhtype might indicate there
- * are more u32s then actually fitted.
- * so if fhtype seems to be more than len, reduce fhtype.
- * Valid types are:
- * 2 - objectid + dir_id - legacy support
- * 3 - objectid + dir_id + generation
- * 4 - objectid + dir_id + objectid and dirid of parent - legacy
- * 5 - objectid + dir_id + generation + objectid and dirid of parent
- * 6 - as above plus generation of directory
- * 6 does not fit in NFSv2 handles
- */
- if (fhtype > len) {
- if (fhtype != 6 || len != 5)
- reiserfs_warning (sb, "nfsd/reiserfs, fhtype=%d, len=%d - odd",
- fhtype, len);
- fhtype = 5;
- }
-
- obj[0] = data[0];
- obj[1] = data[1];
- if (fhtype == 3 || fhtype >= 5)
- obj[2] = data[2];
- else obj[2] = 0; /* generation number */
-
- if (fhtype >= 4) {
- parent[0] = data[fhtype>=5?3:2] ;
- parent[1] = data[fhtype>=5?4:3] ;
- if (fhtype == 6)
- parent[2] = data[5];
- else parent[2] = 0;
- }
- return sb->s_export_op->find_exported_dentry(sb, obj, fhtype < 4 ? NULL : parent,
- acceptable, context);
-}
+struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
+ int len, int fhtype,
+ int (*acceptable) (void *contect,
+ struct dentry * de),
+ void *context)
+{
+ __u32 obj[3], parent[3];
+
+ /* fhtype happens to reflect the number of u32s encoded.
+ * due to a bug in earlier code, fhtype might indicate there
+ * are more u32s then actually fitted.
+ * so if fhtype seems to be more than len, reduce fhtype.
+ * Valid types are:
+ * 2 - objectid + dir_id - legacy support
+ * 3 - objectid + dir_id + generation
+ * 4 - objectid + dir_id + objectid and dirid of parent - legacy
+ * 5 - objectid + dir_id + generation + objectid and dirid of parent
+ * 6 - as above plus generation of directory
+ * 6 does not fit in NFSv2 handles
+ */
+ if (fhtype > len) {
+ if (fhtype != 6 || len != 5)
+ reiserfs_warning(sb,
+ "nfsd/reiserfs, fhtype=%d, len=%d - odd",
+ fhtype, len);
+ fhtype = 5;
+ }
+
+ obj[0] = data[0];
+ obj[1] = data[1];
+ if (fhtype == 3 || fhtype >= 5)
+ obj[2] = data[2];
+ else
+ obj[2] = 0; /* generation number */
-int reiserfs_encode_fh(struct dentry *dentry, __u32 *data, int *lenp, int need_parent) {
- struct inode *inode = dentry->d_inode ;
- int maxlen = *lenp;
-
- if (maxlen < 3)
- return 255 ;
-
- data[0] = inode->i_ino ;
- data[1] = le32_to_cpu(INODE_PKEY (inode)->k_dir_id) ;
- data[2] = inode->i_generation ;
- *lenp = 3 ;
- /* no room for directory info? return what we've stored so far */
- if (maxlen < 5 || ! need_parent)
- return 3 ;
-
- spin_lock(&dentry->d_lock);
- inode = dentry->d_parent->d_inode ;
- data[3] = inode->i_ino ;
- data[4] = le32_to_cpu(INODE_PKEY (inode)->k_dir_id) ;
- *lenp = 5 ;
- if (maxlen >= 6) {
- data[5] = inode->i_generation ;
- *lenp = 6 ;
- }
- spin_unlock(&dentry->d_lock);
- return *lenp ;
+ if (fhtype >= 4) {
+ parent[0] = data[fhtype >= 5 ? 3 : 2];
+ parent[1] = data[fhtype >= 5 ? 4 : 3];
+ if (fhtype == 6)
+ parent[2] = data[5];
+ else
+ parent[2] = 0;
+ }
+ return sb->s_export_op->find_exported_dentry(sb, obj,
+ fhtype < 4 ? NULL : parent,
+ acceptable, context);
}
+int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
+ int need_parent)
+{
+ struct inode *inode = dentry->d_inode;
+ int maxlen = *lenp;
+
+ if (maxlen < 3)
+ return 255;
+
+ data[0] = inode->i_ino;
+ data[1] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id);
+ data[2] = inode->i_generation;
+ *lenp = 3;
+ /* no room for directory info? return what we've stored so far */
+ if (maxlen < 5 || !need_parent)
+ return 3;
+
+ spin_lock(&dentry->d_lock);
+ inode = dentry->d_parent->d_inode;
+ data[3] = inode->i_ino;
+ data[4] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id);
+ *lenp = 5;
+ if (maxlen >= 6) {
+ data[5] = inode->i_generation;
+ *lenp = 6;
+ }
+ spin_unlock(&dentry->d_lock);
+ return *lenp;
+}
/* looks for stat data, then copies fields to it, marks the buffer
containing stat data as dirty */
@@ -1554,120 +1638,127 @@ int reiserfs_encode_fh(struct dentry *dentry, __u32 *data, int *lenp, int need_p
** to properly mark inodes for datasync and such, but only actually
** does something when called for a synchronous update.
*/
-int reiserfs_write_inode (struct inode * inode, int do_sync) {
- struct reiserfs_transaction_handle th ;
- int jbegin_count = 1 ;
-
- if (inode->i_sb->s_flags & MS_RDONLY)
- return -EROFS;
- /* memory pressure can sometimes initiate write_inode calls with sync == 1,
- ** these cases are just when the system needs ram, not when the
- ** inode needs to reach disk for safety, and they can safely be
- ** ignored because the altered inode has already been logged.
- */
- if (do_sync && !(current->flags & PF_MEMALLOC)) {
- reiserfs_write_lock(inode->i_sb);
- if (!journal_begin(&th, inode->i_sb, jbegin_count)) {
- reiserfs_update_sd (&th, inode);
- journal_end_sync(&th, inode->i_sb, jbegin_count) ;
- }
- reiserfs_write_unlock(inode->i_sb);
- }
- return 0;
+int reiserfs_write_inode(struct inode *inode, int do_sync)
+{
+ struct reiserfs_transaction_handle th;
+ int jbegin_count = 1;
+
+ if (inode->i_sb->s_flags & MS_RDONLY)
+ return -EROFS;
+ /* memory pressure can sometimes initiate write_inode calls with sync == 1,
+ ** these cases are just when the system needs ram, not when the
+ ** inode needs to reach disk for safety, and they can safely be
+ ** ignored because the altered inode has already been logged.
+ */
+ if (do_sync && !(current->flags & PF_MEMALLOC)) {
+ reiserfs_write_lock(inode->i_sb);
+ if (!journal_begin(&th, inode->i_sb, jbegin_count)) {
+ reiserfs_update_sd(&th, inode);
+ journal_end_sync(&th, inode->i_sb, jbegin_count);
+ }
+ reiserfs_write_unlock(inode->i_sb);
+ }
+ return 0;
}
/* stat data of new object is inserted already, this inserts the item
containing "." and ".." entries */
-static int reiserfs_new_directory (struct reiserfs_transaction_handle *th,
- struct inode *inode,
- struct item_head * ih, struct path * path,
- struct inode * dir)
+static int reiserfs_new_directory(struct reiserfs_transaction_handle *th,
+ struct inode *inode,
+ struct item_head *ih, struct path *path,
+ struct inode *dir)
{
- struct super_block * sb = th->t_super;
- char empty_dir [EMPTY_DIR_SIZE];
- char * body = empty_dir;
- struct cpu_key key;
- int retval;
-
- BUG_ON (!th->t_trans_id);
-
- _make_cpu_key (&key, KEY_FORMAT_3_5, le32_to_cpu (ih->ih_key.k_dir_id),
- le32_to_cpu (ih->ih_key.k_objectid), DOT_OFFSET, TYPE_DIRENTRY, 3/*key length*/);
-
- /* compose item head for new item. Directories consist of items of
- old type (ITEM_VERSION_1). Do not set key (second arg is 0), it
- is done by reiserfs_new_inode */
- if (old_format_only (sb)) {
- make_le_item_head (ih, NULL, KEY_FORMAT_3_5, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2);
-
- make_empty_dir_item_v1 (body, ih->ih_key.k_dir_id, ih->ih_key.k_objectid,
- INODE_PKEY (dir)->k_dir_id,
- INODE_PKEY (dir)->k_objectid );
- } else {
- make_le_item_head (ih, NULL, KEY_FORMAT_3_5, DOT_OFFSET, TYPE_DIRENTRY, EMPTY_DIR_SIZE, 2);
-
- make_empty_dir_item (body, ih->ih_key.k_dir_id, ih->ih_key.k_objectid,
- INODE_PKEY (dir)->k_dir_id,
- INODE_PKEY (dir)->k_objectid );
- }
-
- /* look for place in the tree for new item */
- retval = search_item (sb, &key, path);
- if (retval == IO_ERROR) {
- reiserfs_warning (sb, "vs-13080: reiserfs_new_directory: "
- "i/o failure occurred creating new directory");
- return -EIO;
- }
- if (retval == ITEM_FOUND) {
- pathrelse (path);
- reiserfs_warning (sb, "vs-13070: reiserfs_new_directory: "
- "object with this key exists (%k)", &(ih->ih_key));
- return -EEXIST;
- }
-
- /* insert item, that is empty directory item */
- return reiserfs_insert_item (th, path, &key, ih, inode, body);
-}
+ struct super_block *sb = th->t_super;
+ char empty_dir[EMPTY_DIR_SIZE];
+ char *body = empty_dir;
+ struct cpu_key key;
+ int retval;
+
+ BUG_ON(!th->t_trans_id);
+
+ _make_cpu_key(&key, KEY_FORMAT_3_5, le32_to_cpu(ih->ih_key.k_dir_id),
+ le32_to_cpu(ih->ih_key.k_objectid), DOT_OFFSET,
+ TYPE_DIRENTRY, 3 /*key length */ );
+
+ /* compose item head for new item. Directories consist of items of
+ old type (ITEM_VERSION_1). Do not set key (second arg is 0), it
+ is done by reiserfs_new_inode */
+ if (old_format_only(sb)) {
+ make_le_item_head(ih, NULL, KEY_FORMAT_3_5, DOT_OFFSET,
+ TYPE_DIRENTRY, EMPTY_DIR_SIZE_V1, 2);
+
+ make_empty_dir_item_v1(body, ih->ih_key.k_dir_id,
+ ih->ih_key.k_objectid,
+ INODE_PKEY(dir)->k_dir_id,
+ INODE_PKEY(dir)->k_objectid);
+ } else {
+ make_le_item_head(ih, NULL, KEY_FORMAT_3_5, DOT_OFFSET,
+ TYPE_DIRENTRY, EMPTY_DIR_SIZE, 2);
+
+ make_empty_dir_item(body, ih->ih_key.k_dir_id,
+ ih->ih_key.k_objectid,
+ INODE_PKEY(dir)->k_dir_id,
+ INODE_PKEY(dir)->k_objectid);
+ }
+
+ /* look for place in the tree for new item */
+ retval = search_item(sb, &key, path);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(sb, "vs-13080: reiserfs_new_directory: "
+ "i/o failure occurred creating new directory");
+ return -EIO;
+ }
+ if (retval == ITEM_FOUND) {
+ pathrelse(path);
+ reiserfs_warning(sb, "vs-13070: reiserfs_new_directory: "
+ "object with this key exists (%k)",
+ &(ih->ih_key));
+ return -EEXIST;
+ }
+ /* insert item, that is empty directory item */
+ return reiserfs_insert_item(th, path, &key, ih, inode, body);
+}
/* stat data of object has been inserted, this inserts the item
containing the body of symlink */
-static int reiserfs_new_symlink (struct reiserfs_transaction_handle *th,
- struct inode *inode, /* Inode of symlink */
- struct item_head * ih,
- struct path * path, const char * symname, int item_len)
+static int reiserfs_new_symlink(struct reiserfs_transaction_handle *th, struct inode *inode, /* Inode of symlink */
+ struct item_head *ih,
+ struct path *path, const char *symname,
+ int item_len)
{
- struct super_block * sb = th->t_super;
- struct cpu_key key;
- int retval;
-
- BUG_ON (!th->t_trans_id);
-
- _make_cpu_key (&key, KEY_FORMAT_3_5,
- le32_to_cpu (ih->ih_key.k_dir_id),
- le32_to_cpu (ih->ih_key.k_objectid),
- 1, TYPE_DIRECT, 3/*key length*/);
-
- make_le_item_head (ih, NULL, KEY_FORMAT_3_5, 1, TYPE_DIRECT, item_len, 0/*free_space*/);
-
- /* look for place in the tree for new item */
- retval = search_item (sb, &key, path);
- if (retval == IO_ERROR) {
- reiserfs_warning (sb, "vs-13080: reiserfs_new_symlinik: "
- "i/o failure occurred creating new symlink");
- return -EIO;
- }
- if (retval == ITEM_FOUND) {
- pathrelse (path);
- reiserfs_warning (sb, "vs-13080: reiserfs_new_symlink: "
- "object with this key exists (%k)", &(ih->ih_key));
- return -EEXIST;
- }
-
- /* insert item, that is body of symlink */
- return reiserfs_insert_item (th, path, &key, ih, inode, symname);
-}
+ struct super_block *sb = th->t_super;
+ struct cpu_key key;
+ int retval;
+
+ BUG_ON(!th->t_trans_id);
+
+ _make_cpu_key(&key, KEY_FORMAT_3_5,
+ le32_to_cpu(ih->ih_key.k_dir_id),
+ le32_to_cpu(ih->ih_key.k_objectid),
+ 1, TYPE_DIRECT, 3 /*key length */ );
+
+ make_le_item_head(ih, NULL, KEY_FORMAT_3_5, 1, TYPE_DIRECT, item_len,
+ 0 /*free_space */ );
+
+ /* look for place in the tree for new item */
+ retval = search_item(sb, &key, path);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(sb, "vs-13080: reiserfs_new_symlinik: "
+ "i/o failure occurred creating new symlink");
+ return -EIO;
+ }
+ if (retval == ITEM_FOUND) {
+ pathrelse(path);
+ reiserfs_warning(sb, "vs-13080: reiserfs_new_symlink: "
+ "object with this key exists (%k)",
+ &(ih->ih_key));
+ return -EEXIST;
+ }
+ /* insert item, that is body of symlink */
+ return reiserfs_insert_item(th, path, &key, ih, inode, symname);
+}
/* inserts the stat data into the tree, and then calls
reiserfs_new_directory (to insert ".", ".." item if new object is
@@ -1678,213 +1769,219 @@ static int reiserfs_new_symlink (struct reiserfs_transaction_handle *th,
non-zero due to an error, we have to drop the quota previously allocated
for the fresh inode. This can only be done outside a transaction, so
if we return non-zero, we also end the transaction. */
-int reiserfs_new_inode (struct reiserfs_transaction_handle *th,
- struct inode * dir, int mode,
- const char * symname,
- /* 0 for regular, EMTRY_DIR_SIZE for dirs,
- strlen (symname) for symlinks)*/
- loff_t i_size, struct dentry *dentry,
- struct inode *inode)
+int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
+ struct inode *dir, int mode, const char *symname,
+ /* 0 for regular, EMTRY_DIR_SIZE for dirs,
+ strlen (symname) for symlinks) */
+ loff_t i_size, struct dentry *dentry,
+ struct inode *inode)
{
- struct super_block * sb;
- INITIALIZE_PATH (path_to_key);
- struct cpu_key key;
- struct item_head ih;
- struct stat_data sd;
- int retval;
- int err;
-
- BUG_ON (!th->t_trans_id);
-
- if (DQUOT_ALLOC_INODE(inode)) {
- err = -EDQUOT;
- goto out_end_trans;
- }
- if (!dir || !dir->i_nlink) {
- err = -EPERM;
- goto out_bad_inode;
- }
-
- sb = dir->i_sb;
-
- /* item head of new item */
- ih.ih_key.k_dir_id = reiserfs_choose_packing(dir);
- ih.ih_key.k_objectid = cpu_to_le32 (reiserfs_get_unused_objectid (th));
- if (!ih.ih_key.k_objectid) {
- err = -ENOMEM;
- goto out_bad_inode ;
- }
- if (old_format_only (sb))
- /* not a perfect generation count, as object ids can be reused, but
- ** this is as good as reiserfs can do right now.
- ** note that the private part of inode isn't filled in yet, we have
- ** to use the directory.
- */
- inode->i_generation = le32_to_cpu (INODE_PKEY (dir)->k_objectid);
- else
+ struct super_block *sb;
+ INITIALIZE_PATH(path_to_key);
+ struct cpu_key key;
+ struct item_head ih;
+ struct stat_data sd;
+ int retval;
+ int err;
+
+ BUG_ON(!th->t_trans_id);
+
+ if (DQUOT_ALLOC_INODE(inode)) {
+ err = -EDQUOT;
+ goto out_end_trans;
+ }
+ if (!dir || !dir->i_nlink) {
+ err = -EPERM;
+ goto out_bad_inode;
+ }
+
+ sb = dir->i_sb;
+
+ /* item head of new item */
+ ih.ih_key.k_dir_id = reiserfs_choose_packing(dir);
+ ih.ih_key.k_objectid = cpu_to_le32(reiserfs_get_unused_objectid(th));
+ if (!ih.ih_key.k_objectid) {
+ err = -ENOMEM;
+ goto out_bad_inode;
+ }
+ if (old_format_only(sb))
+ /* not a perfect generation count, as object ids can be reused, but
+ ** this is as good as reiserfs can do right now.
+ ** note that the private part of inode isn't filled in yet, we have
+ ** to use the directory.
+ */
+ inode->i_generation = le32_to_cpu(INODE_PKEY(dir)->k_objectid);
+ else
#if defined( USE_INODE_GENERATION_COUNTER )
- inode->i_generation = le32_to_cpu(REISERFS_SB(sb)->s_rs->s_inode_generation);
+ inode->i_generation =
+ le32_to_cpu(REISERFS_SB(sb)->s_rs->s_inode_generation);
#else
- inode->i_generation = ++event;
+ inode->i_generation = ++event;
#endif
- /* fill stat data */
- inode->i_nlink = (S_ISDIR (mode) ? 2 : 1);
-
- /* uid and gid must already be set by the caller for quota init */
-
- /* symlink cannot be immutable or append only, right? */
- if( S_ISLNK( inode -> i_mode ) )
- inode -> i_flags &= ~ ( S_IMMUTABLE | S_APPEND );
-
- inode->i_mtime = inode->i_atime = inode->i_ctime =
- CURRENT_TIME_SEC;
- inode->i_size = i_size;
- inode->i_blocks = 0;
- inode->i_bytes = 0;
- REISERFS_I(inode)->i_first_direct_byte = S_ISLNK(mode) ? 1 :
- U32_MAX/*NO_BYTES_IN_DIRECT_ITEM*/;
-
- INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list ));
- REISERFS_I(inode)->i_flags = 0;
- REISERFS_I(inode)->i_prealloc_block = 0;
- REISERFS_I(inode)->i_prealloc_count = 0;
- REISERFS_I(inode)->i_trans_id = 0;
- REISERFS_I(inode)->i_jl = NULL;
- REISERFS_I(inode)->i_attrs =
- REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK;
- sd_attrs_to_i_attrs( REISERFS_I(inode) -> i_attrs, inode );
- REISERFS_I(inode)->i_acl_access = NULL;
- REISERFS_I(inode)->i_acl_default = NULL;
- init_rwsem (&REISERFS_I(inode)->xattr_sem);
-
- if (old_format_only (sb))
- make_le_item_head (&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET, TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
- else
- make_le_item_head (&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET, TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
-
- /* key to search for correct place for new stat data */
- _make_cpu_key (&key, KEY_FORMAT_3_6, le32_to_cpu (ih.ih_key.k_dir_id),
- le32_to_cpu (ih.ih_key.k_objectid), SD_OFFSET, TYPE_STAT_DATA, 3/*key length*/);
-
- /* find proper place for inserting of stat data */
- retval = search_item (sb, &key, &path_to_key);
- if (retval == IO_ERROR) {
- err = -EIO;
- goto out_bad_inode;
- }
- if (retval == ITEM_FOUND) {
- pathrelse (&path_to_key);
- err = -EEXIST;
- goto out_bad_inode;
- }
- if (old_format_only (sb)) {
- if (inode->i_uid & ~0xffff || inode->i_gid & ~0xffff) {
- pathrelse (&path_to_key);
- /* i_uid or i_gid is too big to be stored in stat data v3.5 */
- err = -EINVAL;
- goto out_bad_inode;
- }
- inode2sd_v1 (&sd, inode, inode->i_size);
- } else {
- inode2sd (&sd, inode, inode->i_size);
- }
- // these do not go to on-disk stat data
- inode->i_ino = le32_to_cpu (ih.ih_key.k_objectid);
- inode->i_blksize = reiserfs_default_io_size;
-
- // store in in-core inode the key of stat data and version all
- // object items will have (directory items will have old offset
- // format, other new objects will consist of new items)
- memcpy (INODE_PKEY (inode), &(ih.ih_key), KEY_SIZE);
- if (old_format_only (sb) || S_ISDIR(mode) || S_ISLNK(mode))
- set_inode_item_key_version (inode, KEY_FORMAT_3_5);
- else
- set_inode_item_key_version (inode, KEY_FORMAT_3_6);
- if (old_format_only (sb))
- set_inode_sd_version (inode, STAT_DATA_V1);
- else
- set_inode_sd_version (inode, STAT_DATA_V2);
-
- /* insert the stat data into the tree */
+ /* fill stat data */
+ inode->i_nlink = (S_ISDIR(mode) ? 2 : 1);
+
+ /* uid and gid must already be set by the caller for quota init */
+
+ /* symlink cannot be immutable or append only, right? */
+ if (S_ISLNK(inode->i_mode))
+ inode->i_flags &= ~(S_IMMUTABLE | S_APPEND);
+
+ inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
+ inode->i_size = i_size;
+ inode->i_blocks = 0;
+ inode->i_bytes = 0;
+ REISERFS_I(inode)->i_first_direct_byte = S_ISLNK(mode) ? 1 :
+ U32_MAX /*NO_BYTES_IN_DIRECT_ITEM */ ;
+
+ INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list));
+ REISERFS_I(inode)->i_flags = 0;
+ REISERFS_I(inode)->i_prealloc_block = 0;
+ REISERFS_I(inode)->i_prealloc_count = 0;
+ REISERFS_I(inode)->i_trans_id = 0;
+ REISERFS_I(inode)->i_jl = NULL;
+ REISERFS_I(inode)->i_attrs =
+ REISERFS_I(dir)->i_attrs & REISERFS_INHERIT_MASK;
+ sd_attrs_to_i_attrs(REISERFS_I(inode)->i_attrs, inode);
+ REISERFS_I(inode)->i_acl_access = NULL;
+ REISERFS_I(inode)->i_acl_default = NULL;
+ init_rwsem(&REISERFS_I(inode)->xattr_sem);
+
+ if (old_format_only(sb))
+ make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
+ TYPE_STAT_DATA, SD_V1_SIZE, MAX_US_INT);
+ else
+ make_le_item_head(&ih, NULL, KEY_FORMAT_3_6, SD_OFFSET,
+ TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
+
+ /* key to search for correct place for new stat data */
+ _make_cpu_key(&key, KEY_FORMAT_3_6, le32_to_cpu(ih.ih_key.k_dir_id),
+ le32_to_cpu(ih.ih_key.k_objectid), SD_OFFSET,
+ TYPE_STAT_DATA, 3 /*key length */ );
+
+ /* find proper place for inserting of stat data */
+ retval = search_item(sb, &key, &path_to_key);
+ if (retval == IO_ERROR) {
+ err = -EIO;
+ goto out_bad_inode;
+ }
+ if (retval == ITEM_FOUND) {
+ pathrelse(&path_to_key);
+ err = -EEXIST;
+ goto out_bad_inode;
+ }
+ if (old_format_only(sb)) {
+ if (inode->i_uid & ~0xffff || inode->i_gid & ~0xffff) {
+ pathrelse(&path_to_key);
+ /* i_uid or i_gid is too big to be stored in stat data v3.5 */
+ err = -EINVAL;
+ goto out_bad_inode;
+ }
+ inode2sd_v1(&sd, inode, inode->i_size);
+ } else {
+ inode2sd(&sd, inode, inode->i_size);
+ }
+ // these do not go to on-disk stat data
+ inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid);
+ inode->i_blksize = reiserfs_default_io_size;
+
+ // store in in-core inode the key of stat data and version all
+ // object items will have (directory items will have old offset
+ // format, other new objects will consist of new items)
+ memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
+ if (old_format_only(sb) || S_ISDIR(mode) || S_ISLNK(mode))
+ set_inode_item_key_version(inode, KEY_FORMAT_3_5);
+ else
+ set_inode_item_key_version(inode, KEY_FORMAT_3_6);
+ if (old_format_only(sb))
+ set_inode_sd_version(inode, STAT_DATA_V1);
+ else
+ set_inode_sd_version(inode, STAT_DATA_V2);
+
+ /* insert the stat data into the tree */
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- if (REISERFS_I(dir)->new_packing_locality)
- th->displace_new_blocks = 1;
+ if (REISERFS_I(dir)->new_packing_locality)
+ th->displace_new_blocks = 1;
#endif
- retval = reiserfs_insert_item (th, &path_to_key, &key, &ih, inode, (char *)(&sd));
- if (retval) {
- err = retval;
- reiserfs_check_path(&path_to_key) ;
- goto out_bad_inode;
- }
-
+ retval =
+ reiserfs_insert_item(th, &path_to_key, &key, &ih, inode,
+ (char *)(&sd));
+ if (retval) {
+ err = retval;
+ reiserfs_check_path(&path_to_key);
+ goto out_bad_inode;
+ }
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- if (!th->displace_new_blocks)
- REISERFS_I(dir)->new_packing_locality = 0;
+ if (!th->displace_new_blocks)
+ REISERFS_I(dir)->new_packing_locality = 0;
#endif
- if (S_ISDIR(mode)) {
- /* insert item with "." and ".." */
- retval = reiserfs_new_directory (th, inode, &ih, &path_to_key, dir);
- }
-
- if (S_ISLNK(mode)) {
- /* insert body of symlink */
- if (!old_format_only (sb))
- i_size = ROUND_UP(i_size);
- retval = reiserfs_new_symlink (th, inode, &ih, &path_to_key, symname, i_size);
- }
- if (retval) {
- err = retval;
- reiserfs_check_path(&path_to_key) ;
- journal_end(th, th->t_super, th->t_blocks_allocated);
- goto out_inserted_sd;
- }
-
- /* XXX CHECK THIS */
- if (reiserfs_posixacl (inode->i_sb)) {
- retval = reiserfs_inherit_default_acl (dir, dentry, inode);
- if (retval) {
- err = retval;
- reiserfs_check_path(&path_to_key) ;
- journal_end(th, th->t_super, th->t_blocks_allocated);
- goto out_inserted_sd;
- }
- } else if (inode->i_sb->s_flags & MS_POSIXACL) {
- reiserfs_warning (inode->i_sb, "ACLs aren't enabled in the fs, "
- "but vfs thinks they are!");
- } else if (is_reiserfs_priv_object (dir)) {
- reiserfs_mark_inode_private (inode);
- }
-
- insert_inode_hash (inode);
- reiserfs_update_sd(th, inode);
- reiserfs_check_path(&path_to_key) ;
-
- return 0;
+ if (S_ISDIR(mode)) {
+ /* insert item with "." and ".." */
+ retval =
+ reiserfs_new_directory(th, inode, &ih, &path_to_key, dir);
+ }
+
+ if (S_ISLNK(mode)) {
+ /* insert body of symlink */
+ if (!old_format_only(sb))
+ i_size = ROUND_UP(i_size);
+ retval =
+ reiserfs_new_symlink(th, inode, &ih, &path_to_key, symname,
+ i_size);
+ }
+ if (retval) {
+ err = retval;
+ reiserfs_check_path(&path_to_key);
+ journal_end(th, th->t_super, th->t_blocks_allocated);
+ goto out_inserted_sd;
+ }
+
+ /* XXX CHECK THIS */
+ if (reiserfs_posixacl(inode->i_sb)) {
+ retval = reiserfs_inherit_default_acl(dir, dentry, inode);
+ if (retval) {
+ err = retval;
+ reiserfs_check_path(&path_to_key);
+ journal_end(th, th->t_super, th->t_blocks_allocated);
+ goto out_inserted_sd;
+ }
+ } else if (inode->i_sb->s_flags & MS_POSIXACL) {
+ reiserfs_warning(inode->i_sb, "ACLs aren't enabled in the fs, "
+ "but vfs thinks they are!");
+ } else if (is_reiserfs_priv_object(dir)) {
+ reiserfs_mark_inode_private(inode);
+ }
+
+ insert_inode_hash(inode);
+ reiserfs_update_sd(th, inode);
+ reiserfs_check_path(&path_to_key);
+
+ return 0;
/* it looks like you can easily compress these two goto targets into
* one. Keeping it like this doesn't actually hurt anything, and they
* are place holders for what the quota code actually needs.
*/
-out_bad_inode:
- /* Invalidate the object, nothing was inserted yet */
- INODE_PKEY(inode)->k_objectid = 0;
-
- /* Quota change must be inside a transaction for journaling */
- DQUOT_FREE_INODE(inode);
-
-out_end_trans:
- journal_end(th, th->t_super, th->t_blocks_allocated) ;
- /* Drop can be outside and it needs more credits so it's better to have it outside */
- DQUOT_DROP(inode);
- inode->i_flags |= S_NOQUOTA;
- make_bad_inode(inode);
-
-out_inserted_sd:
- inode->i_nlink = 0;
- th->t_trans_id = 0; /* so the caller can't use this handle later */
- iput(inode);
- return err;
+ out_bad_inode:
+ /* Invalidate the object, nothing was inserted yet */
+ INODE_PKEY(inode)->k_objectid = 0;
+
+ /* Quota change must be inside a transaction for journaling */
+ DQUOT_FREE_INODE(inode);
+
+ out_end_trans:
+ journal_end(th, th->t_super, th->t_blocks_allocated);
+ /* Drop can be outside and it needs more credits so it's better to have it outside */
+ DQUOT_DROP(inode);
+ inode->i_flags |= S_NOQUOTA;
+ make_bad_inode(inode);
+
+ out_inserted_sd:
+ inode->i_nlink = 0;
+ th->t_trans_id = 0; /* so the caller can't use this handle later */
+ iput(inode);
+ return err;
}
/*
@@ -1900,77 +1997,78 @@ out_inserted_sd:
**
** on failure, nonzero is returned, page_result and bh_result are untouched.
*/
-static int grab_tail_page(struct inode *p_s_inode,
- struct page **page_result,
- struct buffer_head **bh_result) {
-
- /* we want the page with the last byte in the file,
- ** not the page that will hold the next byte for appending
- */
- unsigned long index = (p_s_inode->i_size-1) >> PAGE_CACHE_SHIFT ;
- unsigned long pos = 0 ;
- unsigned long start = 0 ;
- unsigned long blocksize = p_s_inode->i_sb->s_blocksize ;
- unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1) ;
- struct buffer_head *bh ;
- struct buffer_head *head ;
- struct page * page ;
- int error ;
-
- /* we know that we are only called with inode->i_size > 0.
- ** we also know that a file tail can never be as big as a block
- ** If i_size % blocksize == 0, our file is currently block aligned
- ** and it won't need converting or zeroing after a truncate.
- */
- if ((offset & (blocksize - 1)) == 0) {
- return -ENOENT ;
- }
- page = grab_cache_page(p_s_inode->i_mapping, index) ;
- error = -ENOMEM ;
- if (!page) {
- goto out ;
- }
- /* start within the page of the last block in the file */
- start = (offset / blocksize) * blocksize ;
-
- error = block_prepare_write(page, start, offset,
- reiserfs_get_block_create_0) ;
- if (error)
- goto unlock ;
-
- head = page_buffers(page) ;
- bh = head;
- do {
- if (pos >= start) {
- break ;
- }
- bh = bh->b_this_page ;
- pos += blocksize ;
- } while(bh != head) ;
-
- if (!buffer_uptodate(bh)) {
- /* note, this should never happen, prepare_write should
- ** be taking care of this for us. If the buffer isn't up to date,
- ** I've screwed up the code to find the buffer, or the code to
- ** call prepare_write
- */
- reiserfs_warning (p_s_inode->i_sb,
- "clm-6000: error reading block %lu on dev %s",
- bh->b_blocknr,
- reiserfs_bdevname (p_s_inode->i_sb)) ;
- error = -EIO ;
- goto unlock ;
- }
- *bh_result = bh ;
- *page_result = page ;
-
-out:
- return error ;
-
-unlock:
- unlock_page(page) ;
- page_cache_release(page) ;
- return error ;
+static int grab_tail_page(struct inode *p_s_inode,
+ struct page **page_result,
+ struct buffer_head **bh_result)
+{
+
+ /* we want the page with the last byte in the file,
+ ** not the page that will hold the next byte for appending
+ */
+ unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT;
+ unsigned long pos = 0;
+ unsigned long start = 0;
+ unsigned long blocksize = p_s_inode->i_sb->s_blocksize;
+ unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1);
+ struct buffer_head *bh;
+ struct buffer_head *head;
+ struct page *page;
+ int error;
+
+ /* we know that we are only called with inode->i_size > 0.
+ ** we also know that a file tail can never be as big as a block
+ ** If i_size % blocksize == 0, our file is currently block aligned
+ ** and it won't need converting or zeroing after a truncate.
+ */
+ if ((offset & (blocksize - 1)) == 0) {
+ return -ENOENT;
+ }
+ page = grab_cache_page(p_s_inode->i_mapping, index);
+ error = -ENOMEM;
+ if (!page) {
+ goto out;
+ }
+ /* start within the page of the last block in the file */
+ start = (offset / blocksize) * blocksize;
+
+ error = block_prepare_write(page, start, offset,
+ reiserfs_get_block_create_0);
+ if (error)
+ goto unlock;
+
+ head = page_buffers(page);
+ bh = head;
+ do {
+ if (pos >= start) {
+ break;
+ }
+ bh = bh->b_this_page;
+ pos += blocksize;
+ } while (bh != head);
+
+ if (!buffer_uptodate(bh)) {
+ /* note, this should never happen, prepare_write should
+ ** be taking care of this for us. If the buffer isn't up to date,
+ ** I've screwed up the code to find the buffer, or the code to
+ ** call prepare_write
+ */
+ reiserfs_warning(p_s_inode->i_sb,
+ "clm-6000: error reading block %lu on dev %s",
+ bh->b_blocknr,
+ reiserfs_bdevname(p_s_inode->i_sb));
+ error = -EIO;
+ goto unlock;
+ }
+ *bh_result = bh;
+ *page_result = page;
+
+ out:
+ return error;
+
+ unlock:
+ unlock_page(page);
+ page_cache_release(page);
+ return error;
}
/*
@@ -1979,235 +2077,247 @@ unlock:
**
** some code taken from block_truncate_page
*/
-int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
- struct reiserfs_transaction_handle th ;
- /* we want the offset for the first byte after the end of the file */
- unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1) ;
- unsigned blocksize = p_s_inode->i_sb->s_blocksize ;
- unsigned length ;
- struct page *page = NULL ;
- int error ;
- struct buffer_head *bh = NULL ;
-
- reiserfs_write_lock(p_s_inode->i_sb);
-
- if (p_s_inode->i_size > 0) {
- if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
- // -ENOENT means we truncated past the end of the file,
- // and get_block_create_0 could not find a block to read in,
- // which is ok.
- if (error != -ENOENT)
- reiserfs_warning (p_s_inode->i_sb,
- "clm-6001: grab_tail_page failed %d",
- error);
- page = NULL ;
- bh = NULL ;
- }
- }
-
- /* so, if page != NULL, we have a buffer head for the offset at
- ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0,
- ** then we have an unformatted node. Otherwise, we have a direct item,
- ** and no zeroing is required on disk. We zero after the truncate,
- ** because the truncate might pack the item anyway
- ** (it will unmap bh if it packs).
- */
- /* it is enough to reserve space in transaction for 2 balancings:
- one for "save" link adding and another for the first
- cut_from_item. 1 is for update_sd */
- error = journal_begin (&th, p_s_inode->i_sb,
- JOURNAL_PER_BALANCE_CNT * 2 + 1);
- if (error)
- goto out;
- reiserfs_update_inode_transaction(p_s_inode) ;
- if (update_timestamps)
- /* we are doing real truncate: if the system crashes before the last
- transaction of truncating gets committed - on reboot the file
- either appears truncated properly or not truncated at all */
- add_save_link (&th, p_s_inode, 1);
- error = reiserfs_do_truncate (&th, p_s_inode, page, update_timestamps) ;
- if (error)
- goto out;
- error = journal_end (&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
- if (error)
- goto out;
-
- if (update_timestamps) {
- error = remove_save_link (p_s_inode, 1/* truncate */);
- if (error)
- goto out;
- }
-
- if (page) {
- length = offset & (blocksize - 1) ;
- /* if we are not on a block boundary */
- if (length) {
- char *kaddr;
-
- length = blocksize - length ;
- kaddr = kmap_atomic(page, KM_USER0) ;
- memset(kaddr + offset, 0, length) ;
- flush_dcache_page(page) ;
- kunmap_atomic(kaddr, KM_USER0) ;
- if (buffer_mapped(bh) && bh->b_blocknr != 0) {
- mark_buffer_dirty(bh) ;
- }
- }
- unlock_page(page) ;
- page_cache_release(page) ;
- }
-
- reiserfs_write_unlock(p_s_inode->i_sb);
- return 0;
-out:
- if (page) {
- unlock_page (page);
- page_cache_release (page);
- }
- reiserfs_write_unlock(p_s_inode->i_sb);
- return error;
-}
+int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
+{
+ struct reiserfs_transaction_handle th;
+ /* we want the offset for the first byte after the end of the file */
+ unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1);
+ unsigned blocksize = p_s_inode->i_sb->s_blocksize;
+ unsigned length;
+ struct page *page = NULL;
+ int error;
+ struct buffer_head *bh = NULL;
+
+ reiserfs_write_lock(p_s_inode->i_sb);
+
+ if (p_s_inode->i_size > 0) {
+ if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
+ // -ENOENT means we truncated past the end of the file,
+ // and get_block_create_0 could not find a block to read in,
+ // which is ok.
+ if (error != -ENOENT)
+ reiserfs_warning(p_s_inode->i_sb,
+ "clm-6001: grab_tail_page failed %d",
+ error);
+ page = NULL;
+ bh = NULL;
+ }
+ }
-static int map_block_for_writepage(struct inode *inode,
- struct buffer_head *bh_result,
- unsigned long block) {
- struct reiserfs_transaction_handle th ;
- int fs_gen ;
- struct item_head tmp_ih ;
- struct item_head *ih ;
- struct buffer_head *bh ;
- __le32 *item ;
- struct cpu_key key ;
- INITIALIZE_PATH(path) ;
- int pos_in_item ;
- int jbegin_count = JOURNAL_PER_BALANCE_CNT ;
- loff_t byte_offset = (block << inode->i_sb->s_blocksize_bits) + 1 ;
- int retval ;
- int use_get_block = 0 ;
- int bytes_copied = 0 ;
- int copy_size ;
- int trans_running = 0;
-
- /* catch places below that try to log something without starting a trans */
- th.t_trans_id = 0;
-
- if (!buffer_uptodate(bh_result)) {
- return -EIO;
- }
-
- kmap(bh_result->b_page) ;
-start_over:
- reiserfs_write_lock(inode->i_sb);
- make_cpu_key(&key, inode, byte_offset, TYPE_ANY, 3) ;
-
-research:
- retval = search_for_position_by_key(inode->i_sb, &key, &path) ;
- if (retval != POSITION_FOUND) {
- use_get_block = 1;
- goto out ;
- }
-
- bh = get_last_bh(&path) ;
- ih = get_ih(&path) ;
- item = get_item(&path) ;
- pos_in_item = path.pos_in_item ;
-
- /* we've found an unformatted node */
- if (indirect_item_found(retval, ih)) {
- if (bytes_copied > 0) {
- reiserfs_warning (inode->i_sb, "clm-6002: bytes_copied %d",
- bytes_copied) ;
- }
- if (!get_block_num(item, pos_in_item)) {
- /* crap, we are writing to a hole */
- use_get_block = 1;
- goto out ;
- }
- set_block_dev_mapped(bh_result, get_block_num(item,pos_in_item),inode);
- } else if (is_direct_le_ih(ih)) {
- char *p ;
- p = page_address(bh_result->b_page) ;
- p += (byte_offset -1) & (PAGE_CACHE_SIZE - 1) ;
- copy_size = ih_item_len(ih) - pos_in_item;
-
- fs_gen = get_generation(inode->i_sb) ;
- copy_item_head(&tmp_ih, ih) ;
-
- if (!trans_running) {
- /* vs-3050 is gone, no need to drop the path */
- retval = journal_begin(&th, inode->i_sb, jbegin_count) ;
- if (retval)
- goto out;
- reiserfs_update_inode_transaction(inode) ;
- trans_running = 1;
- if (fs_changed(fs_gen, inode->i_sb) && item_moved(&tmp_ih, &path)) {
- reiserfs_restore_prepared_buffer(inode->i_sb, bh) ;
- goto research;
- }
- }
-
- reiserfs_prepare_for_journal(inode->i_sb, bh, 1) ;
-
- if (fs_changed (fs_gen, inode->i_sb) && item_moved (&tmp_ih, &path)) {
- reiserfs_restore_prepared_buffer(inode->i_sb, bh) ;
- goto research;
- }
-
- memcpy( B_I_PITEM(bh, ih) + pos_in_item, p + bytes_copied, copy_size) ;
-
- journal_mark_dirty(&th, inode->i_sb, bh) ;
- bytes_copied += copy_size ;
- set_block_dev_mapped(bh_result, 0, inode);
-
- /* are there still bytes left? */
- if (bytes_copied < bh_result->b_size &&
- (byte_offset + bytes_copied) < inode->i_size) {
- set_cpu_key_k_offset(&key, cpu_key_k_offset(&key) + copy_size) ;
- goto research ;
- }
- } else {
- reiserfs_warning (inode->i_sb,
- "clm-6003: bad item inode %lu, device %s",
- inode->i_ino, reiserfs_bdevname (inode->i_sb)) ;
- retval = -EIO ;
- goto out ;
- }
- retval = 0 ;
-
-out:
- pathrelse(&path) ;
- if (trans_running) {
- int err = journal_end(&th, inode->i_sb, jbegin_count) ;
- if (err)
- retval = err;
- trans_running = 0;
- }
- reiserfs_write_unlock(inode->i_sb);
-
- /* this is where we fill in holes in the file. */
- if (use_get_block) {
- retval = reiserfs_get_block(inode, block, bh_result,
- GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM |
- GET_BLOCK_NO_DANGLE);
- if (!retval) {
- if (!buffer_mapped(bh_result) || bh_result->b_blocknr == 0) {
- /* get_block failed to find a mapped unformatted node. */
- use_get_block = 0 ;
- goto start_over ;
- }
- }
- }
- kunmap(bh_result->b_page) ;
-
- if (!retval && buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
- /* we've copied data from the page into the direct item, so the
- * buffer in the page is now clean, mark it to reflect that.
+ /* so, if page != NULL, we have a buffer head for the offset at
+ ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0,
+ ** then we have an unformatted node. Otherwise, we have a direct item,
+ ** and no zeroing is required on disk. We zero after the truncate,
+ ** because the truncate might pack the item anyway
+ ** (it will unmap bh if it packs).
*/
- lock_buffer(bh_result);
- clear_buffer_dirty(bh_result);
- unlock_buffer(bh_result);
- }
- return retval ;
+ /* it is enough to reserve space in transaction for 2 balancings:
+ one for "save" link adding and another for the first
+ cut_from_item. 1 is for update_sd */
+ error = journal_begin(&th, p_s_inode->i_sb,
+ JOURNAL_PER_BALANCE_CNT * 2 + 1);
+ if (error)
+ goto out;
+ reiserfs_update_inode_transaction(p_s_inode);
+ if (update_timestamps)
+ /* we are doing real truncate: if the system crashes before the last
+ transaction of truncating gets committed - on reboot the file
+ either appears truncated properly or not truncated at all */
+ add_save_link(&th, p_s_inode, 1);
+ error = reiserfs_do_truncate(&th, p_s_inode, page, update_timestamps);
+ if (error)
+ goto out;
+ error =
+ journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
+ if (error)
+ goto out;
+
+ if (update_timestamps) {
+ error = remove_save_link(p_s_inode, 1 /* truncate */ );
+ if (error)
+ goto out;
+ }
+
+ if (page) {
+ length = offset & (blocksize - 1);
+ /* if we are not on a block boundary */
+ if (length) {
+ char *kaddr;
+
+ length = blocksize - length;
+ kaddr = kmap_atomic(page, KM_USER0);
+ memset(kaddr + offset, 0, length);
+ flush_dcache_page(page);
+ kunmap_atomic(kaddr, KM_USER0);
+ if (buffer_mapped(bh) && bh->b_blocknr != 0) {
+ mark_buffer_dirty(bh);
+ }
+ }
+ unlock_page(page);
+ page_cache_release(page);
+ }
+
+ reiserfs_write_unlock(p_s_inode->i_sb);
+ return 0;
+ out:
+ if (page) {
+ unlock_page(page);
+ page_cache_release(page);
+ }
+ reiserfs_write_unlock(p_s_inode->i_sb);
+ return error;
+}
+
+static int map_block_for_writepage(struct inode *inode,
+ struct buffer_head *bh_result,
+ unsigned long block)
+{
+ struct reiserfs_transaction_handle th;
+ int fs_gen;
+ struct item_head tmp_ih;
+ struct item_head *ih;
+ struct buffer_head *bh;
+ __le32 *item;
+ struct cpu_key key;
+ INITIALIZE_PATH(path);
+ int pos_in_item;
+ int jbegin_count = JOURNAL_PER_BALANCE_CNT;
+ loff_t byte_offset = (block << inode->i_sb->s_blocksize_bits) + 1;
+ int retval;
+ int use_get_block = 0;
+ int bytes_copied = 0;
+ int copy_size;
+ int trans_running = 0;
+
+ /* catch places below that try to log something without starting a trans */
+ th.t_trans_id = 0;
+
+ if (!buffer_uptodate(bh_result)) {
+ return -EIO;
+ }
+
+ kmap(bh_result->b_page);
+ start_over:
+ reiserfs_write_lock(inode->i_sb);
+ make_cpu_key(&key, inode, byte_offset, TYPE_ANY, 3);
+
+ research:
+ retval = search_for_position_by_key(inode->i_sb, &key, &path);
+ if (retval != POSITION_FOUND) {
+ use_get_block = 1;
+ goto out;
+ }
+
+ bh = get_last_bh(&path);
+ ih = get_ih(&path);
+ item = get_item(&path);
+ pos_in_item = path.pos_in_item;
+
+ /* we've found an unformatted node */
+ if (indirect_item_found(retval, ih)) {
+ if (bytes_copied > 0) {
+ reiserfs_warning(inode->i_sb,
+ "clm-6002: bytes_copied %d",
+ bytes_copied);
+ }
+ if (!get_block_num(item, pos_in_item)) {
+ /* crap, we are writing to a hole */
+ use_get_block = 1;
+ goto out;
+ }
+ set_block_dev_mapped(bh_result,
+ get_block_num(item, pos_in_item), inode);
+ } else if (is_direct_le_ih(ih)) {
+ char *p;
+ p = page_address(bh_result->b_page);
+ p += (byte_offset - 1) & (PAGE_CACHE_SIZE - 1);
+ copy_size = ih_item_len(ih) - pos_in_item;
+
+ fs_gen = get_generation(inode->i_sb);
+ copy_item_head(&tmp_ih, ih);
+
+ if (!trans_running) {
+ /* vs-3050 is gone, no need to drop the path */
+ retval = journal_begin(&th, inode->i_sb, jbegin_count);
+ if (retval)
+ goto out;
+ reiserfs_update_inode_transaction(inode);
+ trans_running = 1;
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ reiserfs_restore_prepared_buffer(inode->i_sb,
+ bh);
+ goto research;
+ }
+ }
+
+ reiserfs_prepare_for_journal(inode->i_sb, bh, 1);
+
+ if (fs_changed(fs_gen, inode->i_sb)
+ && item_moved(&tmp_ih, &path)) {
+ reiserfs_restore_prepared_buffer(inode->i_sb, bh);
+ goto research;
+ }
+
+ memcpy(B_I_PITEM(bh, ih) + pos_in_item, p + bytes_copied,
+ copy_size);
+
+ journal_mark_dirty(&th, inode->i_sb, bh);
+ bytes_copied += copy_size;
+ set_block_dev_mapped(bh_result, 0, inode);
+
+ /* are there still bytes left? */
+ if (bytes_copied < bh_result->b_size &&
+ (byte_offset + bytes_copied) < inode->i_size) {
+ set_cpu_key_k_offset(&key,
+ cpu_key_k_offset(&key) +
+ copy_size);
+ goto research;
+ }
+ } else {
+ reiserfs_warning(inode->i_sb,
+ "clm-6003: bad item inode %lu, device %s",
+ inode->i_ino, reiserfs_bdevname(inode->i_sb));
+ retval = -EIO;
+ goto out;
+ }
+ retval = 0;
+
+ out:
+ pathrelse(&path);
+ if (trans_running) {
+ int err = journal_end(&th, inode->i_sb, jbegin_count);
+ if (err)
+ retval = err;
+ trans_running = 0;
+ }
+ reiserfs_write_unlock(inode->i_sb);
+
+ /* this is where we fill in holes in the file. */
+ if (use_get_block) {
+ retval = reiserfs_get_block(inode, block, bh_result,
+ GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM
+ | GET_BLOCK_NO_DANGLE);
+ if (!retval) {
+ if (!buffer_mapped(bh_result)
+ || bh_result->b_blocknr == 0) {
+ /* get_block failed to find a mapped unformatted node. */
+ use_get_block = 0;
+ goto start_over;
+ }
+ }
+ }
+ kunmap(bh_result->b_page);
+
+ if (!retval && buffer_mapped(bh_result) && bh_result->b_blocknr == 0) {
+ /* we've copied data from the page into the direct item, so the
+ * buffer in the page is now clean, mark it to reflect that.
+ */
+ lock_buffer(bh_result);
+ clear_buffer_dirty(bh_result);
+ unlock_buffer(bh_result);
+ }
+ return retval;
}
/*
@@ -2215,383 +2325,390 @@ out:
* start/recovery path as __block_write_full_page, along with special
* code to handle reiserfs tails.
*/
-static int reiserfs_write_full_page(struct page *page, struct writeback_control *wbc) {
- struct inode *inode = page->mapping->host ;
- unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT ;
- int error = 0;
- unsigned long block ;
- struct buffer_head *head, *bh;
- int partial = 0 ;
- int nr = 0;
- int checked = PageChecked(page);
- struct reiserfs_transaction_handle th;
- struct super_block *s = inode->i_sb;
- int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
- th.t_trans_id = 0;
-
- /* The page dirty bit is cleared before writepage is called, which
- * means we have to tell create_empty_buffers to make dirty buffers
- * The page really should be up to date at this point, so tossing
- * in the BH_Uptodate is just a sanity check.
- */
- if (!page_has_buffers(page)) {
- create_empty_buffers(page, s->s_blocksize,
- (1 << BH_Dirty) | (1 << BH_Uptodate));
- }
- head = page_buffers(page) ;
-
- /* last page in the file, zero out any contents past the
- ** last byte in the file
- */
- if (page->index >= end_index) {
- char *kaddr;
- unsigned last_offset;
-
- last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1) ;
- /* no file contents in this page */
- if (page->index >= end_index + 1 || !last_offset) {
- unlock_page(page);
- return 0;
- }
- kaddr = kmap_atomic(page, KM_USER0);
- memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE-last_offset) ;
- flush_dcache_page(page) ;
- kunmap_atomic(kaddr, KM_USER0) ;
- }
- bh = head ;
- block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits) ;
- /* first map all the buffers, logging any direct items we find */
- do {
- if ((checked || buffer_dirty(bh)) && (!buffer_mapped(bh) ||
- (buffer_mapped(bh) && bh->b_blocknr == 0))) {
- /* not mapped yet, or it points to a direct item, search
- * the btree for the mapping info, and log any direct
- * items found
- */
- if ((error = map_block_for_writepage(inode, bh, block))) {
- goto fail ;
- }
- }
- bh = bh->b_this_page;
- block++;
- } while(bh != head) ;
-
- /*
- * we start the transaction after map_block_for_writepage,
- * because it can create holes in the file (an unbounded operation).
- * starting it here, we can make a reliable estimate for how many
- * blocks we're going to log
- */
- if (checked) {
- ClearPageChecked(page);
- reiserfs_write_lock(s);
- error = journal_begin(&th, s, bh_per_page + 1);
- if (error) {
- reiserfs_write_unlock(s);
- goto fail;
- }
- reiserfs_update_inode_transaction(inode);
- }
- /* now go through and lock any dirty buffers on the page */
- do {
- get_bh(bh);
- if (!buffer_mapped(bh))
- continue;
- if (buffer_mapped(bh) && bh->b_blocknr == 0)
- continue;
+static int reiserfs_write_full_page(struct page *page,
+ struct writeback_control *wbc)
+{
+ struct inode *inode = page->mapping->host;
+ unsigned long end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ int error = 0;
+ unsigned long block;
+ struct buffer_head *head, *bh;
+ int partial = 0;
+ int nr = 0;
+ int checked = PageChecked(page);
+ struct reiserfs_transaction_handle th;
+ struct super_block *s = inode->i_sb;
+ int bh_per_page = PAGE_CACHE_SIZE / s->s_blocksize;
+ th.t_trans_id = 0;
+
+ /* The page dirty bit is cleared before writepage is called, which
+ * means we have to tell create_empty_buffers to make dirty buffers
+ * The page really should be up to date at this point, so tossing
+ * in the BH_Uptodate is just a sanity check.
+ */
+ if (!page_has_buffers(page)) {
+ create_empty_buffers(page, s->s_blocksize,
+ (1 << BH_Dirty) | (1 << BH_Uptodate));
+ }
+ head = page_buffers(page);
- if (checked) {
- reiserfs_prepare_for_journal(s, bh, 1);
- journal_mark_dirty(&th, s, bh);
- continue;
+ /* last page in the file, zero out any contents past the
+ ** last byte in the file
+ */
+ if (page->index >= end_index) {
+ char *kaddr;
+ unsigned last_offset;
+
+ last_offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+ /* no file contents in this page */
+ if (page->index >= end_index + 1 || !last_offset) {
+ unlock_page(page);
+ return 0;
+ }
+ kaddr = kmap_atomic(page, KM_USER0);
+ memset(kaddr + last_offset, 0, PAGE_CACHE_SIZE - last_offset);
+ flush_dcache_page(page);
+ kunmap_atomic(kaddr, KM_USER0);
}
- /* from this point on, we know the buffer is mapped to a
- * real block and not a direct item
+ bh = head;
+ block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);
+ /* first map all the buffers, logging any direct items we find */
+ do {
+ if ((checked || buffer_dirty(bh)) && (!buffer_mapped(bh) ||
+ (buffer_mapped(bh)
+ && bh->b_blocknr ==
+ 0))) {
+ /* not mapped yet, or it points to a direct item, search
+ * the btree for the mapping info, and log any direct
+ * items found
+ */
+ if ((error = map_block_for_writepage(inode, bh, block))) {
+ goto fail;
+ }
+ }
+ bh = bh->b_this_page;
+ block++;
+ } while (bh != head);
+
+ /*
+ * we start the transaction after map_block_for_writepage,
+ * because it can create holes in the file (an unbounded operation).
+ * starting it here, we can make a reliable estimate for how many
+ * blocks we're going to log
*/
- if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) {
- lock_buffer(bh);
- } else {
- if (test_set_buffer_locked(bh)) {
- redirty_page_for_writepage(wbc, page);
- continue;
- }
+ if (checked) {
+ ClearPageChecked(page);
+ reiserfs_write_lock(s);
+ error = journal_begin(&th, s, bh_per_page + 1);
+ if (error) {
+ reiserfs_write_unlock(s);
+ goto fail;
+ }
+ reiserfs_update_inode_transaction(inode);
}
- if (test_clear_buffer_dirty(bh)) {
- mark_buffer_async_write(bh);
- } else {
- unlock_buffer(bh);
+ /* now go through and lock any dirty buffers on the page */
+ do {
+ get_bh(bh);
+ if (!buffer_mapped(bh))
+ continue;
+ if (buffer_mapped(bh) && bh->b_blocknr == 0)
+ continue;
+
+ if (checked) {
+ reiserfs_prepare_for_journal(s, bh, 1);
+ journal_mark_dirty(&th, s, bh);
+ continue;
+ }
+ /* from this point on, we know the buffer is mapped to a
+ * real block and not a direct item
+ */
+ if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) {
+ lock_buffer(bh);
+ } else {
+ if (test_set_buffer_locked(bh)) {
+ redirty_page_for_writepage(wbc, page);
+ continue;
+ }
+ }
+ if (test_clear_buffer_dirty(bh)) {
+ mark_buffer_async_write(bh);
+ } else {
+ unlock_buffer(bh);
+ }
+ } while ((bh = bh->b_this_page) != head);
+
+ if (checked) {
+ error = journal_end(&th, s, bh_per_page + 1);
+ reiserfs_write_unlock(s);
+ if (error)
+ goto fail;
}
- } while((bh = bh->b_this_page) != head);
+ BUG_ON(PageWriteback(page));
+ set_page_writeback(page);
+ unlock_page(page);
- if (checked) {
- error = journal_end(&th, s, bh_per_page + 1);
- reiserfs_write_unlock(s);
- if (error)
- goto fail;
- }
- BUG_ON(PageWriteback(page));
- set_page_writeback(page);
- unlock_page(page);
-
- /*
- * since any buffer might be the only dirty buffer on the page,
- * the first submit_bh can bring the page out of writeback.
- * be careful with the buffers.
- */
- do {
- struct buffer_head *next = bh->b_this_page;
- if (buffer_async_write(bh)) {
- submit_bh(WRITE, bh);
- nr++;
- }
- put_bh(bh);
- bh = next;
- } while(bh != head);
-
- error = 0;
-done:
- if (nr == 0) {
- /*
- * if this page only had a direct item, it is very possible for
- * no io to be required without there being an error. Or,
- * someone else could have locked them and sent them down the
- * pipe without locking the page
+ /*
+ * since any buffer might be the only dirty buffer on the page,
+ * the first submit_bh can bring the page out of writeback.
+ * be careful with the buffers.
*/
- bh = head ;
do {
- if (!buffer_uptodate(bh)) {
- partial = 1;
- break;
- }
- bh = bh->b_this_page;
- } while(bh != head);
- if (!partial)
- SetPageUptodate(page);
- end_page_writeback(page);
- }
- return error;
-
-fail:
- /* catches various errors, we need to make sure any valid dirty blocks
- * get to the media. The page is currently locked and not marked for
- * writeback
- */
- ClearPageUptodate(page);
- bh = head;
- do {
- get_bh(bh);
- if (buffer_mapped(bh) && buffer_dirty(bh) && bh->b_blocknr) {
- lock_buffer(bh);
- mark_buffer_async_write(bh);
- } else {
- /*
- * clear any dirty bits that might have come from getting
- * attached to a dirty page
- */
- clear_buffer_dirty(bh);
- }
- bh = bh->b_this_page;
- } while(bh != head);
- SetPageError(page);
- BUG_ON(PageWriteback(page));
- set_page_writeback(page);
- unlock_page(page);
- do {
- struct buffer_head *next = bh->b_this_page;
- if (buffer_async_write(bh)) {
- clear_buffer_dirty(bh);
- submit_bh(WRITE, bh);
- nr++;
- }
- put_bh(bh);
- bh = next;
- } while(bh != head);
- goto done;
-}
+ struct buffer_head *next = bh->b_this_page;
+ if (buffer_async_write(bh)) {
+ submit_bh(WRITE, bh);
+ nr++;
+ }
+ put_bh(bh);
+ bh = next;
+ } while (bh != head);
+ error = 0;
+ done:
+ if (nr == 0) {
+ /*
+ * if this page only had a direct item, it is very possible for
+ * no io to be required without there being an error. Or,
+ * someone else could have locked them and sent them down the
+ * pipe without locking the page
+ */
+ bh = head;
+ do {
+ if (!buffer_uptodate(bh)) {
+ partial = 1;
+ break;
+ }
+ bh = bh->b_this_page;
+ } while (bh != head);
+ if (!partial)
+ SetPageUptodate(page);
+ end_page_writeback(page);
+ }
+ return error;
-static int reiserfs_readpage (struct file *f, struct page * page)
-{
- return block_read_full_page (page, reiserfs_get_block);
+ fail:
+ /* catches various errors, we need to make sure any valid dirty blocks
+ * get to the media. The page is currently locked and not marked for
+ * writeback
+ */
+ ClearPageUptodate(page);
+ bh = head;
+ do {
+ get_bh(bh);
+ if (buffer_mapped(bh) && buffer_dirty(bh) && bh->b_blocknr) {
+ lock_buffer(bh);
+ mark_buffer_async_write(bh);
+ } else {
+ /*
+ * clear any dirty bits that might have come from getting
+ * attached to a dirty page
+ */
+ clear_buffer_dirty(bh);
+ }
+ bh = bh->b_this_page;
+ } while (bh != head);
+ SetPageError(page);
+ BUG_ON(PageWriteback(page));
+ set_page_writeback(page);
+ unlock_page(page);
+ do {
+ struct buffer_head *next = bh->b_this_page;
+ if (buffer_async_write(bh)) {
+ clear_buffer_dirty(bh);
+ submit_bh(WRITE, bh);
+ nr++;
+ }
+ put_bh(bh);
+ bh = next;
+ } while (bh != head);
+ goto done;
}
+static int reiserfs_readpage(struct file *f, struct page *page)
+{
+ return block_read_full_page(page, reiserfs_get_block);
+}
-static int reiserfs_writepage (struct page * page, struct writeback_control *wbc)
+static int reiserfs_writepage(struct page *page, struct writeback_control *wbc)
{
- struct inode *inode = page->mapping->host ;
- reiserfs_wait_on_write_block(inode->i_sb) ;
- return reiserfs_write_full_page(page, wbc) ;
+ struct inode *inode = page->mapping->host;
+ reiserfs_wait_on_write_block(inode->i_sb);
+ return reiserfs_write_full_page(page, wbc);
}
static int reiserfs_prepare_write(struct file *f, struct page *page,
- unsigned from, unsigned to) {
- struct inode *inode = page->mapping->host ;
- int ret;
- int old_ref = 0;
-
- reiserfs_wait_on_write_block(inode->i_sb) ;
- fix_tail_page_for_writing(page) ;
- if (reiserfs_transaction_running(inode->i_sb)) {
- struct reiserfs_transaction_handle *th;
- th = (struct reiserfs_transaction_handle *)current->journal_info;
- BUG_ON (!th->t_refcount);
- BUG_ON (!th->t_trans_id);
- old_ref = th->t_refcount;
- th->t_refcount++;
- }
-
- ret = block_prepare_write(page, from, to, reiserfs_get_block) ;
- if (ret && reiserfs_transaction_running(inode->i_sb)) {
- struct reiserfs_transaction_handle *th = current->journal_info;
- /* this gets a little ugly. If reiserfs_get_block returned an
- * error and left a transacstion running, we've got to close it,
- * and we've got to free handle if it was a persistent transaction.
- *
- * But, if we had nested into an existing transaction, we need
- * to just drop the ref count on the handle.
- *
- * If old_ref == 0, the transaction is from reiserfs_get_block,
- * and it was a persistent trans. Otherwise, it was nested above.
- */
- if (th->t_refcount > old_ref) {
- if (old_ref)
- th->t_refcount--;
- else {
- int err;
- reiserfs_write_lock(inode->i_sb);
- err = reiserfs_end_persistent_transaction(th);
- reiserfs_write_unlock(inode->i_sb);
- if (err)
- ret = err;
- }
+ unsigned from, unsigned to)
+{
+ struct inode *inode = page->mapping->host;
+ int ret;
+ int old_ref = 0;
+
+ reiserfs_wait_on_write_block(inode->i_sb);
+ fix_tail_page_for_writing(page);
+ if (reiserfs_transaction_running(inode->i_sb)) {
+ struct reiserfs_transaction_handle *th;
+ th = (struct reiserfs_transaction_handle *)current->
+ journal_info;
+ BUG_ON(!th->t_refcount);
+ BUG_ON(!th->t_trans_id);
+ old_ref = th->t_refcount;
+ th->t_refcount++;
}
- }
- return ret;
-}
+ ret = block_prepare_write(page, from, to, reiserfs_get_block);
+ if (ret && reiserfs_transaction_running(inode->i_sb)) {
+ struct reiserfs_transaction_handle *th = current->journal_info;
+ /* this gets a little ugly. If reiserfs_get_block returned an
+ * error and left a transacstion running, we've got to close it,
+ * and we've got to free handle if it was a persistent transaction.
+ *
+ * But, if we had nested into an existing transaction, we need
+ * to just drop the ref count on the handle.
+ *
+ * If old_ref == 0, the transaction is from reiserfs_get_block,
+ * and it was a persistent trans. Otherwise, it was nested above.
+ */
+ if (th->t_refcount > old_ref) {
+ if (old_ref)
+ th->t_refcount--;
+ else {
+ int err;
+ reiserfs_write_lock(inode->i_sb);
+ err = reiserfs_end_persistent_transaction(th);
+ reiserfs_write_unlock(inode->i_sb);
+ if (err)
+ ret = err;
+ }
+ }
+ }
+ return ret;
+}
-static sector_t reiserfs_aop_bmap(struct address_space *as, sector_t block) {
- return generic_block_bmap(as, block, reiserfs_bmap) ;
+static sector_t reiserfs_aop_bmap(struct address_space *as, sector_t block)
+{
+ return generic_block_bmap(as, block, reiserfs_bmap);
}
-static int reiserfs_commit_write(struct file *f, struct page *page,
- unsigned from, unsigned to) {
- struct inode *inode = page->mapping->host ;
- loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
- int ret = 0;
- int update_sd = 0;
- struct reiserfs_transaction_handle *th = NULL;
-
- reiserfs_wait_on_write_block(inode->i_sb) ;
- if (reiserfs_transaction_running(inode->i_sb)) {
- th = current->journal_info;
- }
- reiserfs_commit_page(inode, page, from, to);
-
- /* generic_commit_write does this for us, but does not update the
- ** transaction tracking stuff when the size changes. So, we have
- ** to do the i_size updates here.
- */
- if (pos > inode->i_size) {
- struct reiserfs_transaction_handle myth ;
- reiserfs_write_lock(inode->i_sb);
- /* If the file have grown beyond the border where it
- can have a tail, unmark it as needing a tail
- packing */
- if ( (have_large_tails (inode->i_sb) && inode->i_size > i_block_size (inode)*4) ||
- (have_small_tails (inode->i_sb) && inode->i_size > i_block_size(inode)) )
- REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask ;
-
- ret = journal_begin(&myth, inode->i_sb, 1) ;
- if (ret) {
- reiserfs_write_unlock(inode->i_sb);
- goto journal_error;
- }
- reiserfs_update_inode_transaction(inode) ;
- inode->i_size = pos ;
- reiserfs_update_sd(&myth, inode) ;
- update_sd = 1;
- ret = journal_end(&myth, inode->i_sb, 1) ;
- reiserfs_write_unlock(inode->i_sb);
- if (ret)
- goto journal_error;
- }
- if (th) {
- reiserfs_write_lock(inode->i_sb);
- if (!update_sd)
- reiserfs_update_sd(th, inode) ;
- ret = reiserfs_end_persistent_transaction(th);
- reiserfs_write_unlock(inode->i_sb);
- if (ret)
- goto out;
- }
-
- /* we test for O_SYNC here so we can commit the transaction
- ** for any packed tails the file might have had
- */
- if (f && (f->f_flags & O_SYNC)) {
- reiserfs_write_lock(inode->i_sb);
- ret = reiserfs_commit_for_inode(inode) ;
- reiserfs_write_unlock(inode->i_sb);
- }
-out:
- return ret ;
+static int reiserfs_commit_write(struct file *f, struct page *page,
+ unsigned from, unsigned to)
+{
+ struct inode *inode = page->mapping->host;
+ loff_t pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + to;
+ int ret = 0;
+ int update_sd = 0;
+ struct reiserfs_transaction_handle *th = NULL;
+
+ reiserfs_wait_on_write_block(inode->i_sb);
+ if (reiserfs_transaction_running(inode->i_sb)) {
+ th = current->journal_info;
+ }
+ reiserfs_commit_page(inode, page, from, to);
-journal_error:
- if (th) {
- reiserfs_write_lock(inode->i_sb);
- if (!update_sd)
- reiserfs_update_sd(th, inode) ;
- ret = reiserfs_end_persistent_transaction(th);
- reiserfs_write_unlock(inode->i_sb);
- }
+ /* generic_commit_write does this for us, but does not update the
+ ** transaction tracking stuff when the size changes. So, we have
+ ** to do the i_size updates here.
+ */
+ if (pos > inode->i_size) {
+ struct reiserfs_transaction_handle myth;
+ reiserfs_write_lock(inode->i_sb);
+ /* If the file have grown beyond the border where it
+ can have a tail, unmark it as needing a tail
+ packing */
+ if ((have_large_tails(inode->i_sb)
+ && inode->i_size > i_block_size(inode) * 4)
+ || (have_small_tails(inode->i_sb)
+ && inode->i_size > i_block_size(inode)))
+ REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
+
+ ret = journal_begin(&myth, inode->i_sb, 1);
+ if (ret) {
+ reiserfs_write_unlock(inode->i_sb);
+ goto journal_error;
+ }
+ reiserfs_update_inode_transaction(inode);
+ inode->i_size = pos;
+ reiserfs_update_sd(&myth, inode);
+ update_sd = 1;
+ ret = journal_end(&myth, inode->i_sb, 1);
+ reiserfs_write_unlock(inode->i_sb);
+ if (ret)
+ goto journal_error;
+ }
+ if (th) {
+ reiserfs_write_lock(inode->i_sb);
+ if (!update_sd)
+ reiserfs_update_sd(th, inode);
+ ret = reiserfs_end_persistent_transaction(th);
+ reiserfs_write_unlock(inode->i_sb);
+ if (ret)
+ goto out;
+ }
+
+ /* we test for O_SYNC here so we can commit the transaction
+ ** for any packed tails the file might have had
+ */
+ if (f && (f->f_flags & O_SYNC)) {
+ reiserfs_write_lock(inode->i_sb);
+ ret = reiserfs_commit_for_inode(inode);
+ reiserfs_write_unlock(inode->i_sb);
+ }
+ out:
+ return ret;
- return ret;
+ journal_error:
+ if (th) {
+ reiserfs_write_lock(inode->i_sb);
+ if (!update_sd)
+ reiserfs_update_sd(th, inode);
+ ret = reiserfs_end_persistent_transaction(th);
+ reiserfs_write_unlock(inode->i_sb);
+ }
+
+ return ret;
}
-void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode )
+void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
{
- if( reiserfs_attrs( inode -> i_sb ) ) {
- if( sd_attrs & REISERFS_SYNC_FL )
- inode -> i_flags |= S_SYNC;
+ if (reiserfs_attrs(inode->i_sb)) {
+ if (sd_attrs & REISERFS_SYNC_FL)
+ inode->i_flags |= S_SYNC;
else
- inode -> i_flags &= ~S_SYNC;
- if( sd_attrs & REISERFS_IMMUTABLE_FL )
- inode -> i_flags |= S_IMMUTABLE;
+ inode->i_flags &= ~S_SYNC;
+ if (sd_attrs & REISERFS_IMMUTABLE_FL)
+ inode->i_flags |= S_IMMUTABLE;
else
- inode -> i_flags &= ~S_IMMUTABLE;
- if( sd_attrs & REISERFS_APPEND_FL )
- inode -> i_flags |= S_APPEND;
+ inode->i_flags &= ~S_IMMUTABLE;
+ if (sd_attrs & REISERFS_APPEND_FL)
+ inode->i_flags |= S_APPEND;
else
- inode -> i_flags &= ~S_APPEND;
- if( sd_attrs & REISERFS_NOATIME_FL )
- inode -> i_flags |= S_NOATIME;
+ inode->i_flags &= ~S_APPEND;
+ if (sd_attrs & REISERFS_NOATIME_FL)
+ inode->i_flags |= S_NOATIME;
else
- inode -> i_flags &= ~S_NOATIME;
- if( sd_attrs & REISERFS_NOTAIL_FL )
+ inode->i_flags &= ~S_NOATIME;
+ if (sd_attrs & REISERFS_NOTAIL_FL)
REISERFS_I(inode)->i_flags |= i_nopack_mask;
else
REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
}
}
-void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs )
+void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs)
{
- if( reiserfs_attrs( inode -> i_sb ) ) {
- if( inode -> i_flags & S_IMMUTABLE )
+ if (reiserfs_attrs(inode->i_sb)) {
+ if (inode->i_flags & S_IMMUTABLE)
*sd_attrs |= REISERFS_IMMUTABLE_FL;
else
*sd_attrs &= ~REISERFS_IMMUTABLE_FL;
- if( inode -> i_flags & S_SYNC )
+ if (inode->i_flags & S_SYNC)
*sd_attrs |= REISERFS_SYNC_FL;
else
*sd_attrs &= ~REISERFS_SYNC_FL;
- if( inode -> i_flags & S_NOATIME )
+ if (inode->i_flags & S_NOATIME)
*sd_attrs |= REISERFS_NOATIME_FL;
else
*sd_attrs &= ~REISERFS_NOATIME_FL;
- if( REISERFS_I(inode)->i_flags & i_nopack_mask )
+ if (REISERFS_I(inode)->i_flags & i_nopack_mask)
*sd_attrs |= REISERFS_NOTAIL_FL;
else
*sd_attrs &= ~REISERFS_NOTAIL_FL;
@@ -2603,106 +2720,107 @@ void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs )
*/
static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh)
{
- int ret = 1 ;
- struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb) ;
-
- spin_lock(&j->j_dirty_buffers_lock) ;
- if (!buffer_mapped(bh)) {
- goto free_jh;
- }
- /* the page is locked, and the only places that log a data buffer
- * also lock the page.
- */
- if (reiserfs_file_data_log(inode)) {
- /*
- * very conservative, leave the buffer pinned if
- * anyone might need it.
- */
- if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
- ret = 0 ;
- }
- } else
- if (buffer_dirty(bh) || buffer_locked(bh)) {
- struct reiserfs_journal_list *jl;
- struct reiserfs_jh *jh = bh->b_private;
-
- /* why is this safe?
- * reiserfs_setattr updates i_size in the on disk
- * stat data before allowing vmtruncate to be called.
- *
- * If buffer was put onto the ordered list for this
- * transaction, we know for sure either this transaction
- * or an older one already has updated i_size on disk,
- * and this ordered data won't be referenced in the file
- * if we crash.
- *
- * if the buffer was put onto the ordered list for an older
- * transaction, we need to leave it around
+ int ret = 1;
+ struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
+
+ spin_lock(&j->j_dirty_buffers_lock);
+ if (!buffer_mapped(bh)) {
+ goto free_jh;
+ }
+ /* the page is locked, and the only places that log a data buffer
+ * also lock the page.
*/
- if (jh && (jl = jh->jl) && jl != SB_JOURNAL(inode->i_sb)->j_current_jl)
- ret = 0;
- }
-free_jh:
- if (ret && bh->b_private) {
- reiserfs_free_jh(bh);
- }
- spin_unlock(&j->j_dirty_buffers_lock) ;
- return ret ;
+ if (reiserfs_file_data_log(inode)) {
+ /*
+ * very conservative, leave the buffer pinned if
+ * anyone might need it.
+ */
+ if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
+ ret = 0;
+ }
+ } else if (buffer_dirty(bh) || buffer_locked(bh)) {
+ struct reiserfs_journal_list *jl;
+ struct reiserfs_jh *jh = bh->b_private;
+
+ /* why is this safe?
+ * reiserfs_setattr updates i_size in the on disk
+ * stat data before allowing vmtruncate to be called.
+ *
+ * If buffer was put onto the ordered list for this
+ * transaction, we know for sure either this transaction
+ * or an older one already has updated i_size on disk,
+ * and this ordered data won't be referenced in the file
+ * if we crash.
+ *
+ * if the buffer was put onto the ordered list for an older
+ * transaction, we need to leave it around
+ */
+ if (jh && (jl = jh->jl)
+ && jl != SB_JOURNAL(inode->i_sb)->j_current_jl)
+ ret = 0;
+ }
+ free_jh:
+ if (ret && bh->b_private) {
+ reiserfs_free_jh(bh);
+ }
+ spin_unlock(&j->j_dirty_buffers_lock);
+ return ret;
}
/* clm -- taken from fs/buffer.c:block_invalidate_page */
static int reiserfs_invalidatepage(struct page *page, unsigned long offset)
{
- struct buffer_head *head, *bh, *next;
- struct inode *inode = page->mapping->host;
- unsigned int curr_off = 0;
- int ret = 1;
+ struct buffer_head *head, *bh, *next;
+ struct inode *inode = page->mapping->host;
+ unsigned int curr_off = 0;
+ int ret = 1;
- BUG_ON(!PageLocked(page));
+ BUG_ON(!PageLocked(page));
- if (offset == 0)
- ClearPageChecked(page);
+ if (offset == 0)
+ ClearPageChecked(page);
- if (!page_has_buffers(page))
- goto out;
+ if (!page_has_buffers(page))
+ goto out;
+
+ head = page_buffers(page);
+ bh = head;
+ do {
+ unsigned int next_off = curr_off + bh->b_size;
+ next = bh->b_this_page;
- head = page_buffers(page);
- bh = head;
- do {
- unsigned int next_off = curr_off + bh->b_size;
- next = bh->b_this_page;
+ /*
+ * is this block fully invalidated?
+ */
+ if (offset <= curr_off) {
+ if (invalidatepage_can_drop(inode, bh))
+ reiserfs_unmap_buffer(bh);
+ else
+ ret = 0;
+ }
+ curr_off = next_off;
+ bh = next;
+ } while (bh != head);
/*
- * is this block fully invalidated?
+ * We release buffers only if the entire page is being invalidated.
+ * The get_block cached value has been unconditionally invalidated,
+ * so real IO is not possible anymore.
*/
- if (offset <= curr_off) {
- if (invalidatepage_can_drop(inode, bh))
- reiserfs_unmap_buffer(bh);
- else
- ret = 0;
- }
- curr_off = next_off;
- bh = next;
- } while (bh != head);
-
- /*
- * We release buffers only if the entire page is being invalidated.
- * The get_block cached value has been unconditionally invalidated,
- * so real IO is not possible anymore.
- */
- if (!offset && ret)
- ret = try_to_release_page(page, 0);
-out:
- return ret;
+ if (!offset && ret)
+ ret = try_to_release_page(page, 0);
+ out:
+ return ret;
}
-static int reiserfs_set_page_dirty(struct page *page) {
- struct inode *inode = page->mapping->host;
- if (reiserfs_file_data_log(inode)) {
- SetPageChecked(page);
- return __set_page_dirty_nobuffers(page);
- }
- return __set_page_dirty_buffers(page);
+static int reiserfs_set_page_dirty(struct page *page)
+{
+ struct inode *inode = page->mapping->host;
+ if (reiserfs_file_data_log(inode)) {
+ SetPageChecked(page);
+ return __set_page_dirty_nobuffers(page);
+ }
+ return __set_page_dirty_buffers(page);
}
/*
@@ -2716,143 +2834,152 @@ static int reiserfs_set_page_dirty(struct page *page) {
*/
static int reiserfs_releasepage(struct page *page, int unused_gfp_flags)
{
- struct inode *inode = page->mapping->host ;
- struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb) ;
- struct buffer_head *head ;
- struct buffer_head *bh ;
- int ret = 1 ;
-
- WARN_ON(PageChecked(page));
- spin_lock(&j->j_dirty_buffers_lock) ;
- head = page_buffers(page) ;
- bh = head ;
- do {
- if (bh->b_private) {
- if (!buffer_dirty(bh) && !buffer_locked(bh)) {
- reiserfs_free_jh(bh);
- } else {
- ret = 0 ;
- break ;
- }
- }
- bh = bh->b_this_page ;
- } while (bh != head) ;
- if (ret)
- ret = try_to_free_buffers(page) ;
- spin_unlock(&j->j_dirty_buffers_lock) ;
- return ret ;
+ struct inode *inode = page->mapping->host;
+ struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
+ struct buffer_head *head;
+ struct buffer_head *bh;
+ int ret = 1;
+
+ WARN_ON(PageChecked(page));
+ spin_lock(&j->j_dirty_buffers_lock);
+ head = page_buffers(page);
+ bh = head;
+ do {
+ if (bh->b_private) {
+ if (!buffer_dirty(bh) && !buffer_locked(bh)) {
+ reiserfs_free_jh(bh);
+ } else {
+ ret = 0;
+ break;
+ }
+ }
+ bh = bh->b_this_page;
+ } while (bh != head);
+ if (ret)
+ ret = try_to_free_buffers(page);
+ spin_unlock(&j->j_dirty_buffers_lock);
+ return ret;
}
/* We thank Mingming Cao for helping us understand in great detail what
to do in this section of the code. */
static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
- const struct iovec *iov, loff_t offset, unsigned long nr_segs)
+ const struct iovec *iov, loff_t offset,
+ unsigned long nr_segs)
{
- struct file *file = iocb->ki_filp;
- struct inode *inode = file->f_mapping->host;
+ struct file *file = iocb->ki_filp;
+ struct inode *inode = file->f_mapping->host;
- return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
- offset, nr_segs, reiserfs_get_blocks_direct_io, NULL);
+ return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
+ offset, nr_segs,
+ reiserfs_get_blocks_direct_io, NULL);
}
-int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) {
- struct inode *inode = dentry->d_inode ;
- int error ;
- unsigned int ia_valid = attr->ia_valid;
- reiserfs_write_lock(inode->i_sb);
- if (attr->ia_valid & ATTR_SIZE) {
- /* version 2 items will be caught by the s_maxbytes check
- ** done for us in vmtruncate
- */
- if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5 &&
- attr->ia_size > MAX_NON_LFS) {
- error = -EFBIG ;
- goto out;
- }
- /* fill in hole pointers in the expanding truncate case. */
- if (attr->ia_size > inode->i_size) {
- error = generic_cont_expand(inode, attr->ia_size) ;
- if (REISERFS_I(inode)->i_prealloc_count > 0) {
- int err;
- struct reiserfs_transaction_handle th ;
- /* we're changing at most 2 bitmaps, inode + super */
- err = journal_begin(&th, inode->i_sb, 4) ;
- if (!err) {
- reiserfs_discard_prealloc (&th, inode);
- err = journal_end(&th, inode->i_sb, 4) ;
+int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
+{
+ struct inode *inode = dentry->d_inode;
+ int error;
+ unsigned int ia_valid = attr->ia_valid;
+ reiserfs_write_lock(inode->i_sb);
+ if (attr->ia_valid & ATTR_SIZE) {
+ /* version 2 items will be caught by the s_maxbytes check
+ ** done for us in vmtruncate
+ */
+ if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5 &&
+ attr->ia_size > MAX_NON_LFS) {
+ error = -EFBIG;
+ goto out;
+ }
+ /* fill in hole pointers in the expanding truncate case. */
+ if (attr->ia_size > inode->i_size) {
+ error = generic_cont_expand(inode, attr->ia_size);
+ if (REISERFS_I(inode)->i_prealloc_count > 0) {
+ int err;
+ struct reiserfs_transaction_handle th;
+ /* we're changing at most 2 bitmaps, inode + super */
+ err = journal_begin(&th, inode->i_sb, 4);
+ if (!err) {
+ reiserfs_discard_prealloc(&th, inode);
+ err = journal_end(&th, inode->i_sb, 4);
+ }
+ if (err)
+ error = err;
+ }
+ if (error)
+ goto out;
}
- if (err)
- error = err;
- }
- if (error)
- goto out;
}
- }
- if ((((attr->ia_valid & ATTR_UID) && (attr->ia_uid & ~0xffff)) ||
- ((attr->ia_valid & ATTR_GID) && (attr->ia_gid & ~0xffff))) &&
- (get_inode_sd_version (inode) == STAT_DATA_V1)) {
+ if ((((attr->ia_valid & ATTR_UID) && (attr->ia_uid & ~0xffff)) ||
+ ((attr->ia_valid & ATTR_GID) && (attr->ia_gid & ~0xffff))) &&
+ (get_inode_sd_version(inode) == STAT_DATA_V1)) {
/* stat data of format v3.5 has 16 bit uid and gid */
- error = -EINVAL;
- goto out;
- }
-
- error = inode_change_ok(inode, attr) ;
- if (!error) {
- if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
- (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
- error = reiserfs_chown_xattrs (inode, attr);
-
- if (!error) {
- struct reiserfs_transaction_handle th;
- int jbegin_count = 2*(REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb)+REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb))+2;
-
- /* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
- error = journal_begin(&th, inode->i_sb, jbegin_count);
- if (error)
- goto out;
- error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
- if (error) {
- journal_end(&th, inode->i_sb, jbegin_count);
- goto out;
- }
- /* Update corresponding info in inode so that everything is in
- * one transaction */
- if (attr->ia_valid & ATTR_UID)
- inode->i_uid = attr->ia_uid;
- if (attr->ia_valid & ATTR_GID)
- inode->i_gid = attr->ia_gid;
- mark_inode_dirty(inode);
- error = journal_end(&th, inode->i_sb, jbegin_count);
- }
- }
- if (!error)
- error = inode_setattr(inode, attr) ;
- }
+ error = -EINVAL;
+ goto out;
+ }
+ error = inode_change_ok(inode, attr);
+ if (!error) {
+ if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
+ (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
+ error = reiserfs_chown_xattrs(inode, attr);
+
+ if (!error) {
+ struct reiserfs_transaction_handle th;
+ int jbegin_count =
+ 2 *
+ (REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb) +
+ REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb)) +
+ 2;
+
+ /* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
+ error =
+ journal_begin(&th, inode->i_sb,
+ jbegin_count);
+ if (error)
+ goto out;
+ error =
+ DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0;
+ if (error) {
+ journal_end(&th, inode->i_sb,
+ jbegin_count);
+ goto out;
+ }
+ /* Update corresponding info in inode so that everything is in
+ * one transaction */
+ if (attr->ia_valid & ATTR_UID)
+ inode->i_uid = attr->ia_uid;
+ if (attr->ia_valid & ATTR_GID)
+ inode->i_gid = attr->ia_gid;
+ mark_inode_dirty(inode);
+ error =
+ journal_end(&th, inode->i_sb, jbegin_count);
+ }
+ }
+ if (!error)
+ error = inode_setattr(inode, attr);
+ }
- if (!error && reiserfs_posixacl (inode->i_sb)) {
- if (attr->ia_valid & ATTR_MODE)
- error = reiserfs_acl_chmod (inode);
- }
+ if (!error && reiserfs_posixacl(inode->i_sb)) {
+ if (attr->ia_valid & ATTR_MODE)
+ error = reiserfs_acl_chmod(inode);
+ }
-out:
- reiserfs_write_unlock(inode->i_sb);
- return error ;
+ out:
+ reiserfs_write_unlock(inode->i_sb);
+ return error;
}
-
-
struct address_space_operations reiserfs_address_space_operations = {
- .writepage = reiserfs_writepage,
- .readpage = reiserfs_readpage,
- .readpages = reiserfs_readpages,
- .releasepage = reiserfs_releasepage,
- .invalidatepage = reiserfs_invalidatepage,
- .sync_page = block_sync_page,
- .prepare_write = reiserfs_prepare_write,
- .commit_write = reiserfs_commit_write,
- .bmap = reiserfs_aop_bmap,
- .direct_IO = reiserfs_direct_IO,
- .set_page_dirty = reiserfs_set_page_dirty,
-} ;
+ .writepage = reiserfs_writepage,
+ .readpage = reiserfs_readpage,
+ .readpages = reiserfs_readpages,
+ .releasepage = reiserfs_releasepage,
+ .invalidatepage = reiserfs_invalidatepage,
+ .sync_page = block_sync_page,
+ .prepare_write = reiserfs_prepare_write,
+ .commit_write = reiserfs_commit_write,
+ .bmap = reiserfs_aop_bmap,
+ .direct_IO = reiserfs_direct_IO,
+ .set_page_dirty = reiserfs_set_page_dirty,
+};
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 76caedf737f..81fc00285f6 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -9,7 +9,7 @@
#include <linux/pagemap.h>
#include <linux/smp_lock.h>
-static int reiserfs_unpack (struct inode * inode, struct file * filp);
+static int reiserfs_unpack(struct inode *inode, struct file *filp);
/*
** reiserfs_ioctl - handler for ioctl for inode
@@ -19,69 +19,72 @@ static int reiserfs_unpack (struct inode * inode, struct file * filp);
** 2) REISERFS_IOC_[GS]ETFLAGS, REISERFS_IOC_[GS]ETVERSION
** 3) That's all for a while ...
*/
-int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
- unsigned long arg)
+int reiserfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
{
unsigned int flags;
switch (cmd) {
- case REISERFS_IOC_UNPACK:
- if( S_ISREG( inode -> i_mode ) ) {
- if (arg)
- return reiserfs_unpack (inode, filp);
+ case REISERFS_IOC_UNPACK:
+ if (S_ISREG(inode->i_mode)) {
+ if (arg)
+ return reiserfs_unpack(inode, filp);
else
return 0;
} else
return -ENOTTY;
- /* following two cases are taken from fs/ext2/ioctl.c by Remy
- Card (card@masi.ibp.fr) */
+ /* following two cases are taken from fs/ext2/ioctl.c by Remy
+ Card (card@masi.ibp.fr) */
case REISERFS_IOC_GETFLAGS:
- if (!reiserfs_attrs (inode->i_sb))
+ if (!reiserfs_attrs(inode->i_sb))
return -ENOTTY;
- flags = REISERFS_I(inode) -> i_attrs;
- i_attrs_to_sd_attrs( inode, ( __u16 * ) &flags );
- return put_user(flags, (int __user *) arg);
- case REISERFS_IOC_SETFLAGS: {
- if (!reiserfs_attrs (inode->i_sb))
- return -ENOTTY;
+ flags = REISERFS_I(inode)->i_attrs;
+ i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
+ return put_user(flags, (int __user *)arg);
+ case REISERFS_IOC_SETFLAGS:{
+ if (!reiserfs_attrs(inode->i_sb))
+ return -ENOTTY;
- if (IS_RDONLY(inode))
- return -EROFS;
+ if (IS_RDONLY(inode))
+ return -EROFS;
- if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
- return -EPERM;
+ if ((current->fsuid != inode->i_uid)
+ && !capable(CAP_FOWNER))
+ return -EPERM;
- if (get_user(flags, (int __user *) arg))
- return -EFAULT;
+ if (get_user(flags, (int __user *)arg))
+ return -EFAULT;
- if ( ( ( flags ^ REISERFS_I(inode) -> i_attrs) & ( REISERFS_IMMUTABLE_FL | REISERFS_APPEND_FL)) &&
- !capable( CAP_LINUX_IMMUTABLE ) )
- return -EPERM;
-
- if( ( flags & REISERFS_NOTAIL_FL ) &&
- S_ISREG( inode -> i_mode ) ) {
+ if (((flags ^ REISERFS_I(inode)->
+ i_attrs) & (REISERFS_IMMUTABLE_FL |
+ REISERFS_APPEND_FL))
+ && !capable(CAP_LINUX_IMMUTABLE))
+ return -EPERM;
+
+ if ((flags & REISERFS_NOTAIL_FL) &&
+ S_ISREG(inode->i_mode)) {
int result;
- result = reiserfs_unpack( inode, filp );
- if( result )
+ result = reiserfs_unpack(inode, filp);
+ if (result)
return result;
+ }
+ sd_attrs_to_i_attrs(flags, inode);
+ REISERFS_I(inode)->i_attrs = flags;
+ inode->i_ctime = CURRENT_TIME_SEC;
+ mark_inode_dirty(inode);
+ return 0;
}
- sd_attrs_to_i_attrs( flags, inode );
- REISERFS_I(inode) -> i_attrs = flags;
- inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty(inode);
- return 0;
- }
case REISERFS_IOC_GETVERSION:
- return put_user(inode->i_generation, (int __user *) arg);
+ return put_user(inode->i_generation, (int __user *)arg);
case REISERFS_IOC_SETVERSION:
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
return -EPERM;
if (IS_RDONLY(inode))
return -EROFS;
- if (get_user(inode->i_generation, (int __user *) arg))
- return -EFAULT;
+ if (get_user(inode->i_generation, (int __user *)arg))
+ return -EFAULT;
inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
return 0;
@@ -95,63 +98,65 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
** Function try to convert tail from direct item into indirect.
** It set up nopack attribute in the REISERFS_I(inode)->nopack
*/
-static int reiserfs_unpack (struct inode * inode, struct file * filp)
+static int reiserfs_unpack(struct inode *inode, struct file *filp)
{
- int retval = 0;
- int index ;
- struct page *page ;
- struct address_space *mapping ;
- unsigned long write_from ;
- unsigned long blocksize = inode->i_sb->s_blocksize ;
-
- if (inode->i_size == 0) {
- REISERFS_I(inode)->i_flags |= i_nopack_mask;
- return 0 ;
- }
- /* ioctl already done */
- if (REISERFS_I(inode)->i_flags & i_nopack_mask) {
- return 0 ;
- }
- reiserfs_write_lock(inode->i_sb);
-
- /* we need to make sure nobody is changing the file size beneath
- ** us
- */
- down(&inode->i_sem) ;
-
- write_from = inode->i_size & (blocksize - 1) ;
- /* if we are on a block boundary, we are already unpacked. */
- if ( write_from == 0) {
+ int retval = 0;
+ int index;
+ struct page *page;
+ struct address_space *mapping;
+ unsigned long write_from;
+ unsigned long blocksize = inode->i_sb->s_blocksize;
+
+ if (inode->i_size == 0) {
+ REISERFS_I(inode)->i_flags |= i_nopack_mask;
+ return 0;
+ }
+ /* ioctl already done */
+ if (REISERFS_I(inode)->i_flags & i_nopack_mask) {
+ return 0;
+ }
+ reiserfs_write_lock(inode->i_sb);
+
+ /* we need to make sure nobody is changing the file size beneath
+ ** us
+ */
+ down(&inode->i_sem);
+
+ write_from = inode->i_size & (blocksize - 1);
+ /* if we are on a block boundary, we are already unpacked. */
+ if (write_from == 0) {
+ REISERFS_I(inode)->i_flags |= i_nopack_mask;
+ goto out;
+ }
+
+ /* we unpack by finding the page with the tail, and calling
+ ** reiserfs_prepare_write on that page. This will force a
+ ** reiserfs_get_block to unpack the tail for us.
+ */
+ index = inode->i_size >> PAGE_CACHE_SHIFT;
+ mapping = inode->i_mapping;
+ page = grab_cache_page(mapping, index);
+ retval = -ENOMEM;
+ if (!page) {
+ goto out;
+ }
+ retval =
+ mapping->a_ops->prepare_write(NULL, page, write_from, write_from);
+ if (retval)
+ goto out_unlock;
+
+ /* conversion can change page contents, must flush */
+ flush_dcache_page(page);
+ retval =
+ mapping->a_ops->commit_write(NULL, page, write_from, write_from);
REISERFS_I(inode)->i_flags |= i_nopack_mask;
- goto out ;
- }
-
- /* we unpack by finding the page with the tail, and calling
- ** reiserfs_prepare_write on that page. This will force a
- ** reiserfs_get_block to unpack the tail for us.
- */
- index = inode->i_size >> PAGE_CACHE_SHIFT ;
- mapping = inode->i_mapping ;
- page = grab_cache_page(mapping, index) ;
- retval = -ENOMEM;
- if (!page) {
- goto out ;
- }
- retval = mapping->a_ops->prepare_write(NULL, page, write_from, write_from) ;
- if (retval)
- goto out_unlock ;
-
- /* conversion can change page contents, must flush */
- flush_dcache_page(page) ;
- retval = mapping->a_ops->commit_write(NULL, page, write_from, write_from) ;
- REISERFS_I(inode)->i_flags |= i_nopack_mask;
-
-out_unlock:
- unlock_page(page) ;
- page_cache_release(page) ;
-
-out:
- up(&inode->i_sem) ;
- reiserfs_write_unlock(inode->i_sb);
- return retval;
+
+ out_unlock:
+ unlock_page(page);
+ page_cache_release(page);
+
+ out:
+ up(&inode->i_sem);
+ reiserfs_write_unlock(inode->i_sb);
+ return retval;
}
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index 0ce33db1acd..e237cd668e5 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -14,776 +14,741 @@
//////////////////////////////////////////////////////////////////////////////
// stat data functions
//
-static int sd_bytes_number (struct item_head * ih, int block_size)
+static int sd_bytes_number(struct item_head *ih, int block_size)
{
- return 0;
+ return 0;
}
-static void sd_decrement_key (struct cpu_key * key)
+static void sd_decrement_key(struct cpu_key *key)
{
- key->on_disk_key.k_objectid --;
- set_cpu_key_k_type (key, TYPE_ANY);
- set_cpu_key_k_offset(key, (loff_t)(-1));
+ key->on_disk_key.k_objectid--;
+ set_cpu_key_k_type(key, TYPE_ANY);
+ set_cpu_key_k_offset(key, (loff_t) (-1));
}
-static int sd_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
+static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)
{
- return 0;
+ return 0;
}
-
-
-static char * print_time (time_t t)
+static char *print_time(time_t t)
{
- static char timebuf[256];
+ static char timebuf[256];
- sprintf (timebuf, "%ld", t);
- return timebuf;
+ sprintf(timebuf, "%ld", t);
+ return timebuf;
}
-
-static void sd_print_item (struct item_head * ih, char * item)
+static void sd_print_item(struct item_head *ih, char *item)
{
- printk ("\tmode | size | nlinks | first direct | mtime\n");
- if (stat_data_v1 (ih)) {
- struct stat_data_v1 * sd = (struct stat_data_v1 *)item;
+ printk("\tmode | size | nlinks | first direct | mtime\n");
+ if (stat_data_v1(ih)) {
+ struct stat_data_v1 *sd = (struct stat_data_v1 *)item;
- printk ("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
- sd_v1_size(sd), sd_v1_nlink(sd), sd_v1_first_direct_byte(sd),
- print_time( sd_v1_mtime(sd) ) );
- } else {
- struct stat_data * sd = (struct stat_data *)item;
+ printk("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
+ sd_v1_size(sd), sd_v1_nlink(sd),
+ sd_v1_first_direct_byte(sd),
+ print_time(sd_v1_mtime(sd)));
+ } else {
+ struct stat_data *sd = (struct stat_data *)item;
- printk ("\t0%-6o | %6Lu | %2u | %d | %s\n", sd_v2_mode(sd),
- (unsigned long long)sd_v2_size(sd), sd_v2_nlink(sd),
- sd_v2_rdev(sd), print_time(sd_v2_mtime(sd)));
- }
+ printk("\t0%-6o | %6Lu | %2u | %d | %s\n", sd_v2_mode(sd),
+ (unsigned long long)sd_v2_size(sd), sd_v2_nlink(sd),
+ sd_v2_rdev(sd), print_time(sd_v2_mtime(sd)));
+ }
}
-static void sd_check_item (struct item_head * ih, char * item)
+static void sd_check_item(struct item_head *ih, char *item)
{
- // FIXME: type something here!
+ // FIXME: type something here!
}
-
-static int sd_create_vi (struct virtual_node * vn,
- struct virtual_item * vi,
- int is_affected,
- int insert_size)
+static int sd_create_vi(struct virtual_node *vn,
+ struct virtual_item *vi,
+ int is_affected, int insert_size)
{
- vi->vi_index = TYPE_STAT_DATA;
- //vi->vi_type |= VI_TYPE_STAT_DATA;// not needed?
- return 0;
+ vi->vi_index = TYPE_STAT_DATA;
+ //vi->vi_type |= VI_TYPE_STAT_DATA;// not needed?
+ return 0;
}
-
-static int sd_check_left (struct virtual_item * vi, int free,
- int start_skip, int end_skip)
+static int sd_check_left(struct virtual_item *vi, int free,
+ int start_skip, int end_skip)
{
- if (start_skip || end_skip)
- BUG ();
- return -1;
+ if (start_skip || end_skip)
+ BUG();
+ return -1;
}
-
-static int sd_check_right (struct virtual_item * vi, int free)
+static int sd_check_right(struct virtual_item *vi, int free)
{
- return -1;
+ return -1;
}
-static int sd_part_size (struct virtual_item * vi, int first, int count)
+static int sd_part_size(struct virtual_item *vi, int first, int count)
{
- if (count)
- BUG ();
- return 0;
+ if (count)
+ BUG();
+ return 0;
}
-static int sd_unit_num (struct virtual_item * vi)
+static int sd_unit_num(struct virtual_item *vi)
{
- return vi->vi_item_len - IH_SIZE;
+ return vi->vi_item_len - IH_SIZE;
}
-
-static void sd_print_vi (struct virtual_item * vi)
+static void sd_print_vi(struct virtual_item *vi)
{
- reiserfs_warning (NULL, "STATDATA, index %d, type 0x%x, %h",
- vi->vi_index, vi->vi_type, vi->vi_ih);
+ reiserfs_warning(NULL, "STATDATA, index %d, type 0x%x, %h",
+ vi->vi_index, vi->vi_type, vi->vi_ih);
}
static struct item_operations stat_data_ops = {
- .bytes_number = sd_bytes_number,
- .decrement_key = sd_decrement_key,
- .is_left_mergeable = sd_is_left_mergeable,
- .print_item = sd_print_item,
- .check_item = sd_check_item,
-
- .create_vi = sd_create_vi,
- .check_left = sd_check_left,
- .check_right = sd_check_right,
- .part_size = sd_part_size,
- .unit_num = sd_unit_num,
- .print_vi = sd_print_vi
+ .bytes_number = sd_bytes_number,
+ .decrement_key = sd_decrement_key,
+ .is_left_mergeable = sd_is_left_mergeable,
+ .print_item = sd_print_item,
+ .check_item = sd_check_item,
+
+ .create_vi = sd_create_vi,
+ .check_left = sd_check_left,
+ .check_right = sd_check_right,
+ .part_size = sd_part_size,
+ .unit_num = sd_unit_num,
+ .print_vi = sd_print_vi
};
-
-
//////////////////////////////////////////////////////////////////////////////
// direct item functions
//
-static int direct_bytes_number (struct item_head * ih, int block_size)
+static int direct_bytes_number(struct item_head *ih, int block_size)
{
- return ih_item_len(ih);
+ return ih_item_len(ih);
}
-
// FIXME: this should probably switch to indirect as well
-static void direct_decrement_key (struct cpu_key * key)
+static void direct_decrement_key(struct cpu_key *key)
{
- cpu_key_k_offset_dec (key);
- if (cpu_key_k_offset (key) == 0)
- set_cpu_key_k_type (key, TYPE_STAT_DATA);
+ cpu_key_k_offset_dec(key);
+ if (cpu_key_k_offset(key) == 0)
+ set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
-
-static int direct_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
+static int direct_is_left_mergeable(struct reiserfs_key *key,
+ unsigned long bsize)
{
- int version = le_key_version (key);
- return ((le_key_k_offset (version, key) & (bsize - 1)) != 1);
+ int version = le_key_version(key);
+ return ((le_key_k_offset(version, key) & (bsize - 1)) != 1);
}
-
-static void direct_print_item (struct item_head * ih, char * item)
+static void direct_print_item(struct item_head *ih, char *item)
{
- int j = 0;
+ int j = 0;
// return;
- printk ("\"");
- while (j < ih_item_len(ih))
- printk ("%c", item[j++]);
- printk ("\"\n");
+ printk("\"");
+ while (j < ih_item_len(ih))
+ printk("%c", item[j++]);
+ printk("\"\n");
}
-
-static void direct_check_item (struct item_head * ih, char * item)
+static void direct_check_item(struct item_head *ih, char *item)
{
- // FIXME: type something here!
+ // FIXME: type something here!
}
-
-static int direct_create_vi (struct virtual_node * vn,
- struct virtual_item * vi,
- int is_affected,
- int insert_size)
+static int direct_create_vi(struct virtual_node *vn,
+ struct virtual_item *vi,
+ int is_affected, int insert_size)
{
- vi->vi_index = TYPE_DIRECT;
- //vi->vi_type |= VI_TYPE_DIRECT;
- return 0;
+ vi->vi_index = TYPE_DIRECT;
+ //vi->vi_type |= VI_TYPE_DIRECT;
+ return 0;
}
-static int direct_check_left (struct virtual_item * vi, int free,
- int start_skip, int end_skip)
+static int direct_check_left(struct virtual_item *vi, int free,
+ int start_skip, int end_skip)
{
- int bytes;
+ int bytes;
- bytes = free - free % 8;
- return bytes ?: -1;
+ bytes = free - free % 8;
+ return bytes ? : -1;
}
-
-static int direct_check_right (struct virtual_item * vi, int free)
+static int direct_check_right(struct virtual_item *vi, int free)
{
- return direct_check_left (vi, free, 0, 0);
+ return direct_check_left(vi, free, 0, 0);
}
-static int direct_part_size (struct virtual_item * vi, int first, int count)
+static int direct_part_size(struct virtual_item *vi, int first, int count)
{
- return count;
+ return count;
}
-
-static int direct_unit_num (struct virtual_item * vi)
+static int direct_unit_num(struct virtual_item *vi)
{
- return vi->vi_item_len - IH_SIZE;
+ return vi->vi_item_len - IH_SIZE;
}
-
-static void direct_print_vi (struct virtual_item * vi)
+static void direct_print_vi(struct virtual_item *vi)
{
- reiserfs_warning (NULL, "DIRECT, index %d, type 0x%x, %h",
- vi->vi_index, vi->vi_type, vi->vi_ih);
+ reiserfs_warning(NULL, "DIRECT, index %d, type 0x%x, %h",
+ vi->vi_index, vi->vi_type, vi->vi_ih);
}
static struct item_operations direct_ops = {
- .bytes_number = direct_bytes_number,
- .decrement_key = direct_decrement_key,
- .is_left_mergeable = direct_is_left_mergeable,
- .print_item = direct_print_item,
- .check_item = direct_check_item,
-
- .create_vi = direct_create_vi,
- .check_left = direct_check_left,
- .check_right = direct_check_right,
- .part_size = direct_part_size,
- .unit_num = direct_unit_num,
- .print_vi = direct_print_vi
+ .bytes_number = direct_bytes_number,
+ .decrement_key = direct_decrement_key,
+ .is_left_mergeable = direct_is_left_mergeable,
+ .print_item = direct_print_item,
+ .check_item = direct_check_item,
+
+ .create_vi = direct_create_vi,
+ .check_left = direct_check_left,
+ .check_right = direct_check_right,
+ .part_size = direct_part_size,
+ .unit_num = direct_unit_num,
+ .print_vi = direct_print_vi
};
-
-
//////////////////////////////////////////////////////////////////////////////
// indirect item functions
//
-static int indirect_bytes_number (struct item_head * ih, int block_size)
+static int indirect_bytes_number(struct item_head *ih, int block_size)
{
- return ih_item_len(ih) / UNFM_P_SIZE * block_size; //- get_ih_free_space (ih);
+ return ih_item_len(ih) / UNFM_P_SIZE * block_size; //- get_ih_free_space (ih);
}
-
// decrease offset, if it becomes 0, change type to stat data
-static void indirect_decrement_key (struct cpu_key * key)
+static void indirect_decrement_key(struct cpu_key *key)
{
- cpu_key_k_offset_dec (key);
- if (cpu_key_k_offset (key) == 0)
- set_cpu_key_k_type (key, TYPE_STAT_DATA);
+ cpu_key_k_offset_dec(key);
+ if (cpu_key_k_offset(key) == 0)
+ set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
-
// if it is not first item of the body, then it is mergeable
-static int indirect_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
+static int indirect_is_left_mergeable(struct reiserfs_key *key,
+ unsigned long bsize)
{
- int version = le_key_version (key);
- return (le_key_k_offset (version, key) != 1);
+ int version = le_key_version(key);
+ return (le_key_k_offset(version, key) != 1);
}
-
// printing of indirect item
-static void start_new_sequence (__u32 * start, int * len, __u32 new)
+static void start_new_sequence(__u32 * start, int *len, __u32 new)
{
- *start = new;
- *len = 1;
+ *start = new;
+ *len = 1;
}
-
-static int sequence_finished (__u32 start, int * len, __u32 new)
+static int sequence_finished(__u32 start, int *len, __u32 new)
{
- if (start == INT_MAX)
- return 1;
+ if (start == INT_MAX)
+ return 1;
- if (start == 0 && new == 0) {
- (*len) ++;
- return 0;
- }
- if (start != 0 && (start + *len) == new) {
- (*len) ++;
- return 0;
- }
- return 1;
+ if (start == 0 && new == 0) {
+ (*len)++;
+ return 0;
+ }
+ if (start != 0 && (start + *len) == new) {
+ (*len)++;
+ return 0;
+ }
+ return 1;
}
-static void print_sequence (__u32 start, int len)
+static void print_sequence(__u32 start, int len)
{
- if (start == INT_MAX)
- return;
+ if (start == INT_MAX)
+ return;
- if (len == 1)
- printk (" %d", start);
- else
- printk (" %d(%d)", start, len);
+ if (len == 1)
+ printk(" %d", start);
+ else
+ printk(" %d(%d)", start, len);
}
-
-static void indirect_print_item (struct item_head * ih, char * item)
+static void indirect_print_item(struct item_head *ih, char *item)
{
- int j;
- __le32 * unp;
- __u32 prev = INT_MAX;
- int num;
+ int j;
+ __le32 *unp;
+ __u32 prev = INT_MAX;
+ int num;
- unp = (__le32 *)item;
+ unp = (__le32 *) item;
- if (ih_item_len(ih) % UNFM_P_SIZE)
- reiserfs_warning (NULL, "indirect_print_item: invalid item len");
+ if (ih_item_len(ih) % UNFM_P_SIZE)
+ reiserfs_warning(NULL, "indirect_print_item: invalid item len");
- printk ("%d pointers\n[ ", (int)I_UNFM_NUM (ih));
- for (j = 0; j < I_UNFM_NUM (ih); j ++) {
- if (sequence_finished (prev, &num, get_block_num(unp, j))) {
- print_sequence (prev, num);
- start_new_sequence (&prev, &num, get_block_num(unp, j));
+ printk("%d pointers\n[ ", (int)I_UNFM_NUM(ih));
+ for (j = 0; j < I_UNFM_NUM(ih); j++) {
+ if (sequence_finished(prev, &num, get_block_num(unp, j))) {
+ print_sequence(prev, num);
+ start_new_sequence(&prev, &num, get_block_num(unp, j));
+ }
}
- }
- print_sequence (prev, num);
- printk ("]\n");
+ print_sequence(prev, num);
+ printk("]\n");
}
-static void indirect_check_item (struct item_head * ih, char * item)
+static void indirect_check_item(struct item_head *ih, char *item)
{
- // FIXME: type something here!
+ // FIXME: type something here!
}
-
-static int indirect_create_vi (struct virtual_node * vn,
- struct virtual_item * vi,
- int is_affected,
- int insert_size)
+static int indirect_create_vi(struct virtual_node *vn,
+ struct virtual_item *vi,
+ int is_affected, int insert_size)
{
- vi->vi_index = TYPE_INDIRECT;
- //vi->vi_type |= VI_TYPE_INDIRECT;
- return 0;
+ vi->vi_index = TYPE_INDIRECT;
+ //vi->vi_type |= VI_TYPE_INDIRECT;
+ return 0;
}
-static int indirect_check_left (struct virtual_item * vi, int free,
- int start_skip, int end_skip)
+static int indirect_check_left(struct virtual_item *vi, int free,
+ int start_skip, int end_skip)
{
- int bytes;
+ int bytes;
- bytes = free - free % UNFM_P_SIZE;
- return bytes ?: -1;
+ bytes = free - free % UNFM_P_SIZE;
+ return bytes ? : -1;
}
-
-static int indirect_check_right (struct virtual_item * vi, int free)
+static int indirect_check_right(struct virtual_item *vi, int free)
{
- return indirect_check_left (vi, free, 0, 0);
+ return indirect_check_left(vi, free, 0, 0);
}
-
-
// return size in bytes of 'units' units. If first == 0 - calculate from the head (left), otherwise - from tail (right)
-static int indirect_part_size (struct virtual_item * vi, int first, int units)
+static int indirect_part_size(struct virtual_item *vi, int first, int units)
{
- // unit of indirect item is byte (yet)
- return units;
+ // unit of indirect item is byte (yet)
+ return units;
}
-static int indirect_unit_num (struct virtual_item * vi)
+static int indirect_unit_num(struct virtual_item *vi)
{
- // unit of indirect item is byte (yet)
- return vi->vi_item_len - IH_SIZE;
+ // unit of indirect item is byte (yet)
+ return vi->vi_item_len - IH_SIZE;
}
-static void indirect_print_vi (struct virtual_item * vi)
+static void indirect_print_vi(struct virtual_item *vi)
{
- reiserfs_warning (NULL, "INDIRECT, index %d, type 0x%x, %h",
- vi->vi_index, vi->vi_type, vi->vi_ih);
+ reiserfs_warning(NULL, "INDIRECT, index %d, type 0x%x, %h",
+ vi->vi_index, vi->vi_type, vi->vi_ih);
}
static struct item_operations indirect_ops = {
- .bytes_number = indirect_bytes_number,
- .decrement_key = indirect_decrement_key,
- .is_left_mergeable = indirect_is_left_mergeable,
- .print_item = indirect_print_item,
- .check_item = indirect_check_item,
-
- .create_vi = indirect_create_vi,
- .check_left = indirect_check_left,
- .check_right = indirect_check_right,
- .part_size = indirect_part_size,
- .unit_num = indirect_unit_num,
- .print_vi = indirect_print_vi
+ .bytes_number = indirect_bytes_number,
+ .decrement_key = indirect_decrement_key,
+ .is_left_mergeable = indirect_is_left_mergeable,
+ .print_item = indirect_print_item,
+ .check_item = indirect_check_item,
+
+ .create_vi = indirect_create_vi,
+ .check_left = indirect_check_left,
+ .check_right = indirect_check_right,
+ .part_size = indirect_part_size,
+ .unit_num = indirect_unit_num,
+ .print_vi = indirect_print_vi
};
-
//////////////////////////////////////////////////////////////////////////////
// direntry functions
//
-
-static int direntry_bytes_number (struct item_head * ih, int block_size)
+static int direntry_bytes_number(struct item_head *ih, int block_size)
{
- reiserfs_warning (NULL, "vs-16090: direntry_bytes_number: "
- "bytes number is asked for direntry");
- return 0;
-}
-
-static void direntry_decrement_key (struct cpu_key * key)
-{
- cpu_key_k_offset_dec (key);
- if (cpu_key_k_offset (key) == 0)
- set_cpu_key_k_type (key, TYPE_STAT_DATA);
+ reiserfs_warning(NULL, "vs-16090: direntry_bytes_number: "
+ "bytes number is asked for direntry");
+ return 0;
}
-
-static int direntry_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
+static void direntry_decrement_key(struct cpu_key *key)
{
- if (le32_to_cpu (key->u.k_offset_v1.k_offset) == DOT_OFFSET)
- return 0;
- return 1;
-
+ cpu_key_k_offset_dec(key);
+ if (cpu_key_k_offset(key) == 0)
+ set_cpu_key_k_type(key, TYPE_STAT_DATA);
}
-
-static void direntry_print_item (struct item_head * ih, char * item)
+static int direntry_is_left_mergeable(struct reiserfs_key *key,
+ unsigned long bsize)
{
- int i;
- int namelen;
- struct reiserfs_de_head * deh;
- char * name;
- static char namebuf [80];
-
-
- printk ("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name", "Key of pointed object", "Hash", "Gen number", "Status");
+ if (le32_to_cpu(key->u.k_offset_v1.k_offset) == DOT_OFFSET)
+ return 0;
+ return 1;
- deh = (struct reiserfs_de_head *)item;
+}
- for (i = 0; i < I_ENTRY_COUNT (ih); i ++, deh ++) {
- namelen = (i ? (deh_location(deh - 1)) : ih_item_len(ih)) - deh_location(deh);
- name = item + deh_location(deh);
- if (name[namelen-1] == 0)
- namelen = strlen (name);
- namebuf[0] = '"';
- if (namelen > sizeof (namebuf) - 3) {
- strncpy (namebuf + 1, name, sizeof (namebuf) - 3);
- namebuf[sizeof (namebuf) - 2] = '"';
- namebuf[sizeof (namebuf) - 1] = 0;
- } else {
- memcpy (namebuf + 1, name, namelen);
- namebuf[namelen + 1] = '"';
- namebuf[namelen + 2] = 0;
+static void direntry_print_item(struct item_head *ih, char *item)
+{
+ int i;
+ int namelen;
+ struct reiserfs_de_head *deh;
+ char *name;
+ static char namebuf[80];
+
+ printk("\n # %-15s%-30s%-15s%-15s%-15s\n", "Name",
+ "Key of pointed object", "Hash", "Gen number", "Status");
+
+ deh = (struct reiserfs_de_head *)item;
+
+ for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) {
+ namelen =
+ (i ? (deh_location(deh - 1)) : ih_item_len(ih)) -
+ deh_location(deh);
+ name = item + deh_location(deh);
+ if (name[namelen - 1] == 0)
+ namelen = strlen(name);
+ namebuf[0] = '"';
+ if (namelen > sizeof(namebuf) - 3) {
+ strncpy(namebuf + 1, name, sizeof(namebuf) - 3);
+ namebuf[sizeof(namebuf) - 2] = '"';
+ namebuf[sizeof(namebuf) - 1] = 0;
+ } else {
+ memcpy(namebuf + 1, name, namelen);
+ namebuf[namelen + 1] = '"';
+ namebuf[namelen + 2] = 0;
+ }
+
+ printk("%d: %-15s%-15d%-15d%-15Ld%-15Ld(%s)\n",
+ i, namebuf,
+ deh_dir_id(deh), deh_objectid(deh),
+ GET_HASH_VALUE(deh_offset(deh)),
+ GET_GENERATION_NUMBER((deh_offset(deh))),
+ (de_hidden(deh)) ? "HIDDEN" : "VISIBLE");
}
-
- printk ("%d: %-15s%-15d%-15d%-15Ld%-15Ld(%s)\n",
- i, namebuf,
- deh_dir_id(deh), deh_objectid(deh),
- GET_HASH_VALUE (deh_offset (deh)), GET_GENERATION_NUMBER ((deh_offset (deh))),
- (de_hidden (deh)) ? "HIDDEN" : "VISIBLE");
- }
}
-
-static void direntry_check_item (struct item_head * ih, char * item)
+static void direntry_check_item(struct item_head *ih, char *item)
{
- int i;
- struct reiserfs_de_head * deh;
+ int i;
+ struct reiserfs_de_head *deh;
- // FIXME: type something here!
- deh = (struct reiserfs_de_head *)item;
- for (i = 0; i < I_ENTRY_COUNT (ih); i ++, deh ++) {
- ;
- }
+ // FIXME: type something here!
+ deh = (struct reiserfs_de_head *)item;
+ for (i = 0; i < I_ENTRY_COUNT(ih); i++, deh++) {
+ ;
+ }
}
-
-
#define DIRENTRY_VI_FIRST_DIRENTRY_ITEM 1
/*
* function returns old entry number in directory item in real node
* using new entry number in virtual item in virtual node */
-static inline int old_entry_num (int is_affected, int virtual_entry_num, int pos_in_item, int mode)
+static inline int old_entry_num(int is_affected, int virtual_entry_num,
+ int pos_in_item, int mode)
{
- if ( mode == M_INSERT || mode == M_DELETE)
- return virtual_entry_num;
-
- if (!is_affected)
- /* cut or paste is applied to another item */
- return virtual_entry_num;
-
- if (virtual_entry_num < pos_in_item)
- return virtual_entry_num;
+ if (mode == M_INSERT || mode == M_DELETE)
+ return virtual_entry_num;
- if (mode == M_CUT)
- return virtual_entry_num + 1;
+ if (!is_affected)
+ /* cut or paste is applied to another item */
+ return virtual_entry_num;
- RFALSE( mode != M_PASTE || virtual_entry_num == 0,
- "vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'", mode);
-
- return virtual_entry_num - 1;
-}
+ if (virtual_entry_num < pos_in_item)
+ return virtual_entry_num;
+ if (mode == M_CUT)
+ return virtual_entry_num + 1;
+ RFALSE(mode != M_PASTE || virtual_entry_num == 0,
+ "vs-8015: old_entry_num: mode must be M_PASTE (mode = \'%c\'",
+ mode);
+ return virtual_entry_num - 1;
+}
/* Create an array of sizes of directory entries for virtual
item. Return space used by an item. FIXME: no control over
consuming of space used by this item handler */
-static int direntry_create_vi (struct virtual_node * vn,
- struct virtual_item * vi,
- int is_affected,
- int insert_size)
-{
- struct direntry_uarea * dir_u = vi->vi_uarea;
- int i, j;
- int size = sizeof (struct direntry_uarea);
- struct reiserfs_de_head * deh;
-
- vi->vi_index = TYPE_DIRENTRY;
-
- if (!(vi->vi_ih) || !vi->vi_item)
- BUG ();
-
-
- dir_u->flags = 0;
- if (le_ih_k_offset (vi->vi_ih) == DOT_OFFSET)
- dir_u->flags |= DIRENTRY_VI_FIRST_DIRENTRY_ITEM;
-
- deh = (struct reiserfs_de_head *)(vi->vi_item);
-
-
- /* virtual directory item have this amount of entry after */
- dir_u->entry_count = ih_entry_count (vi->vi_ih) +
- ((is_affected) ? ((vn->vn_mode == M_CUT) ? -1 :
- (vn->vn_mode == M_PASTE ? 1 : 0)) : 0);
-
- for (i = 0; i < dir_u->entry_count; i ++) {
- j = old_entry_num (is_affected, i, vn->vn_pos_in_item, vn->vn_mode);
- dir_u->entry_sizes[i] = (j ? deh_location( &(deh[j - 1]) ) :
- ih_item_len (vi->vi_ih)) -
- deh_location( &(deh[j])) + DEH_SIZE;
- }
-
- size += (dir_u->entry_count * sizeof (short));
-
- /* set size of pasted entry */
- if (is_affected && vn->vn_mode == M_PASTE)
- dir_u->entry_sizes[vn->vn_pos_in_item] = insert_size;
+static int direntry_create_vi(struct virtual_node *vn,
+ struct virtual_item *vi,
+ int is_affected, int insert_size)
+{
+ struct direntry_uarea *dir_u = vi->vi_uarea;
+ int i, j;
+ int size = sizeof(struct direntry_uarea);
+ struct reiserfs_de_head *deh;
+ vi->vi_index = TYPE_DIRENTRY;
+
+ if (!(vi->vi_ih) || !vi->vi_item)
+ BUG();
+
+ dir_u->flags = 0;
+ if (le_ih_k_offset(vi->vi_ih) == DOT_OFFSET)
+ dir_u->flags |= DIRENTRY_VI_FIRST_DIRENTRY_ITEM;
+
+ deh = (struct reiserfs_de_head *)(vi->vi_item);
+
+ /* virtual directory item have this amount of entry after */
+ dir_u->entry_count = ih_entry_count(vi->vi_ih) +
+ ((is_affected) ? ((vn->vn_mode == M_CUT) ? -1 :
+ (vn->vn_mode == M_PASTE ? 1 : 0)) : 0);
+
+ for (i = 0; i < dir_u->entry_count; i++) {
+ j = old_entry_num(is_affected, i, vn->vn_pos_in_item,
+ vn->vn_mode);
+ dir_u->entry_sizes[i] =
+ (j ? deh_location(&(deh[j - 1])) : ih_item_len(vi->vi_ih)) -
+ deh_location(&(deh[j])) + DEH_SIZE;
+ }
+
+ size += (dir_u->entry_count * sizeof(short));
+
+ /* set size of pasted entry */
+ if (is_affected && vn->vn_mode == M_PASTE)
+ dir_u->entry_sizes[vn->vn_pos_in_item] = insert_size;
#ifdef CONFIG_REISERFS_CHECK
- /* compare total size of entries with item length */
- {
- int k, l;
-
- l = 0;
- for (k = 0; k < dir_u->entry_count; k ++)
- l += dir_u->entry_sizes[k];
-
- if (l + IH_SIZE != vi->vi_item_len +
- ((is_affected && (vn->vn_mode == M_PASTE || vn->vn_mode == M_CUT)) ? insert_size : 0) ) {
- reiserfs_panic (NULL, "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
- vn->vn_mode, insert_size);
+ /* compare total size of entries with item length */
+ {
+ int k, l;
+
+ l = 0;
+ for (k = 0; k < dir_u->entry_count; k++)
+ l += dir_u->entry_sizes[k];
+
+ if (l + IH_SIZE != vi->vi_item_len +
+ ((is_affected
+ && (vn->vn_mode == M_PASTE
+ || vn->vn_mode == M_CUT)) ? insert_size : 0)) {
+ reiserfs_panic(NULL,
+ "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
+ vn->vn_mode, insert_size);
+ }
}
- }
#endif
- return size;
-
+ return size;
}
-
//
// return number of entries which may fit into specified amount of
// free space, or -1 if free space is not enough even for 1 entry
//
-static int direntry_check_left (struct virtual_item * vi, int free,
- int start_skip, int end_skip)
+static int direntry_check_left(struct virtual_item *vi, int free,
+ int start_skip, int end_skip)
{
- int i;
- int entries = 0;
- struct direntry_uarea * dir_u = vi->vi_uarea;
+ int i;
+ int entries = 0;
+ struct direntry_uarea *dir_u = vi->vi_uarea;
- for (i = start_skip; i < dir_u->entry_count - end_skip; i ++) {
- if (dir_u->entry_sizes[i] > free)
- /* i-th entry doesn't fit into the remaining free space */
- break;
-
- free -= dir_u->entry_sizes[i];
- entries ++;
- }
+ for (i = start_skip; i < dir_u->entry_count - end_skip; i++) {
+ if (dir_u->entry_sizes[i] > free)
+ /* i-th entry doesn't fit into the remaining free space */
+ break;
- if (entries == dir_u->entry_count) {
- reiserfs_panic (NULL, "free space %d, entry_count %d\n", free, dir_u->entry_count);
- }
+ free -= dir_u->entry_sizes[i];
+ entries++;
+ }
- /* "." and ".." can not be separated from each other */
- if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) && entries < 2)
- entries = 0;
-
- return entries ?: -1;
-}
+ if (entries == dir_u->entry_count) {
+ reiserfs_panic(NULL, "free space %d, entry_count %d\n", free,
+ dir_u->entry_count);
+ }
+ /* "." and ".." can not be separated from each other */
+ if (start_skip == 0 && (dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
+ && entries < 2)
+ entries = 0;
-static int direntry_check_right (struct virtual_item * vi, int free)
+ return entries ? : -1;
+}
+
+static int direntry_check_right(struct virtual_item *vi, int free)
{
- int i;
- int entries = 0;
- struct direntry_uarea * dir_u = vi->vi_uarea;
-
- for (i = dir_u->entry_count - 1; i >= 0; i --) {
- if (dir_u->entry_sizes[i] > free)
- /* i-th entry doesn't fit into the remaining free space */
- break;
-
- free -= dir_u->entry_sizes[i];
- entries ++;
- }
- if (entries == dir_u->entry_count)
- BUG ();
+ int i;
+ int entries = 0;
+ struct direntry_uarea *dir_u = vi->vi_uarea;
- /* "." and ".." can not be separated from each other */
- if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM) && entries > dir_u->entry_count - 2)
- entries = dir_u->entry_count - 2;
+ for (i = dir_u->entry_count - 1; i >= 0; i--) {
+ if (dir_u->entry_sizes[i] > free)
+ /* i-th entry doesn't fit into the remaining free space */
+ break;
- return entries ?: -1;
-}
+ free -= dir_u->entry_sizes[i];
+ entries++;
+ }
+ if (entries == dir_u->entry_count)
+ BUG();
+ /* "." and ".." can not be separated from each other */
+ if ((dir_u->flags & DIRENTRY_VI_FIRST_DIRENTRY_ITEM)
+ && entries > dir_u->entry_count - 2)
+ entries = dir_u->entry_count - 2;
+
+ return entries ? : -1;
+}
/* sum of entry sizes between from-th and to-th entries including both edges */
-static int direntry_part_size (struct virtual_item * vi, int first, int count)
+static int direntry_part_size(struct virtual_item *vi, int first, int count)
{
- int i, retval;
- int from, to;
- struct direntry_uarea * dir_u = vi->vi_uarea;
-
- retval = 0;
- if (first == 0)
- from = 0;
- else
- from = dir_u->entry_count - count;
- to = from + count - 1;
+ int i, retval;
+ int from, to;
+ struct direntry_uarea *dir_u = vi->vi_uarea;
- for (i = from; i <= to; i ++)
- retval += dir_u->entry_sizes[i];
+ retval = 0;
+ if (first == 0)
+ from = 0;
+ else
+ from = dir_u->entry_count - count;
+ to = from + count - 1;
- return retval;
-}
+ for (i = from; i <= to; i++)
+ retval += dir_u->entry_sizes[i];
-static int direntry_unit_num (struct virtual_item * vi)
-{
- struct direntry_uarea * dir_u = vi->vi_uarea;
-
- return dir_u->entry_count;
+ return retval;
}
+static int direntry_unit_num(struct virtual_item *vi)
+{
+ struct direntry_uarea *dir_u = vi->vi_uarea;
+ return dir_u->entry_count;
+}
-static void direntry_print_vi (struct virtual_item * vi)
+static void direntry_print_vi(struct virtual_item *vi)
{
- int i;
- struct direntry_uarea * dir_u = vi->vi_uarea;
+ int i;
+ struct direntry_uarea *dir_u = vi->vi_uarea;
- reiserfs_warning (NULL, "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
- vi->vi_index, vi->vi_type, vi->vi_ih, dir_u->flags);
- printk ("%d entries: ", dir_u->entry_count);
- for (i = 0; i < dir_u->entry_count; i ++)
- printk ("%d ", dir_u->entry_sizes[i]);
- printk ("\n");
+ reiserfs_warning(NULL, "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
+ vi->vi_index, vi->vi_type, vi->vi_ih, dir_u->flags);
+ printk("%d entries: ", dir_u->entry_count);
+ for (i = 0; i < dir_u->entry_count; i++)
+ printk("%d ", dir_u->entry_sizes[i]);
+ printk("\n");
}
static struct item_operations direntry_ops = {
- .bytes_number = direntry_bytes_number,
- .decrement_key = direntry_decrement_key,
- .is_left_mergeable = direntry_is_left_mergeable,
- .print_item = direntry_print_item,
- .check_item = direntry_check_item,
-
- .create_vi = direntry_create_vi,
- .check_left = direntry_check_left,
- .check_right = direntry_check_right,
- .part_size = direntry_part_size,
- .unit_num = direntry_unit_num,
- .print_vi = direntry_print_vi
+ .bytes_number = direntry_bytes_number,
+ .decrement_key = direntry_decrement_key,
+ .is_left_mergeable = direntry_is_left_mergeable,
+ .print_item = direntry_print_item,
+ .check_item = direntry_check_item,
+
+ .create_vi = direntry_create_vi,
+ .check_left = direntry_check_left,
+ .check_right = direntry_check_right,
+ .part_size = direntry_part_size,
+ .unit_num = direntry_unit_num,
+ .print_vi = direntry_print_vi
};
-
//////////////////////////////////////////////////////////////////////////////
// Error catching functions to catch errors caused by incorrect item types.
//
-static int errcatch_bytes_number (struct item_head * ih, int block_size)
+static int errcatch_bytes_number(struct item_head *ih, int block_size)
{
- reiserfs_warning (NULL, "green-16001: Invalid item type observed, run fsck ASAP");
- return 0;
+ reiserfs_warning(NULL,
+ "green-16001: Invalid item type observed, run fsck ASAP");
+ return 0;
}
-static void errcatch_decrement_key (struct cpu_key * key)
+static void errcatch_decrement_key(struct cpu_key *key)
{
- reiserfs_warning (NULL, "green-16002: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL,
+ "green-16002: Invalid item type observed, run fsck ASAP");
}
-
-static int errcatch_is_left_mergeable (struct reiserfs_key * key, unsigned long bsize)
+static int errcatch_is_left_mergeable(struct reiserfs_key *key,
+ unsigned long bsize)
{
- reiserfs_warning (NULL, "green-16003: Invalid item type observed, run fsck ASAP");
- return 0;
+ reiserfs_warning(NULL,
+ "green-16003: Invalid item type observed, run fsck ASAP");
+ return 0;
}
-
-static void errcatch_print_item (struct item_head * ih, char * item)
+static void errcatch_print_item(struct item_head *ih, char *item)
{
- reiserfs_warning (NULL, "green-16004: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL,
+ "green-16004: Invalid item type observed, run fsck ASAP");
}
-
-static void errcatch_check_item (struct item_head * ih, char * item)
+static void errcatch_check_item(struct item_head *ih, char *item)
{
- reiserfs_warning (NULL, "green-16005: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL,
+ "green-16005: Invalid item type observed, run fsck ASAP");
}
-static int errcatch_create_vi (struct virtual_node * vn,
- struct virtual_item * vi,
- int is_affected,
- int insert_size)
+static int errcatch_create_vi(struct virtual_node *vn,
+ struct virtual_item *vi,
+ int is_affected, int insert_size)
{
- reiserfs_warning (NULL, "green-16006: Invalid item type observed, run fsck ASAP");
- return 0; // We might return -1 here as well, but it won't help as create_virtual_node() from where
- // this operation is called from is of return type void.
+ reiserfs_warning(NULL,
+ "green-16006: Invalid item type observed, run fsck ASAP");
+ return 0; // We might return -1 here as well, but it won't help as create_virtual_node() from where
+ // this operation is called from is of return type void.
}
-static int errcatch_check_left (struct virtual_item * vi, int free,
- int start_skip, int end_skip)
+static int errcatch_check_left(struct virtual_item *vi, int free,
+ int start_skip, int end_skip)
{
- reiserfs_warning (NULL, "green-16007: Invalid item type observed, run fsck ASAP");
- return -1;
+ reiserfs_warning(NULL,
+ "green-16007: Invalid item type observed, run fsck ASAP");
+ return -1;
}
-
-static int errcatch_check_right (struct virtual_item * vi, int free)
+static int errcatch_check_right(struct virtual_item *vi, int free)
{
- reiserfs_warning (NULL, "green-16008: Invalid item type observed, run fsck ASAP");
- return -1;
+ reiserfs_warning(NULL,
+ "green-16008: Invalid item type observed, run fsck ASAP");
+ return -1;
}
-static int errcatch_part_size (struct virtual_item * vi, int first, int count)
+static int errcatch_part_size(struct virtual_item *vi, int first, int count)
{
- reiserfs_warning (NULL, "green-16009: Invalid item type observed, run fsck ASAP");
- return 0;
+ reiserfs_warning(NULL,
+ "green-16009: Invalid item type observed, run fsck ASAP");
+ return 0;
}
-static int errcatch_unit_num (struct virtual_item * vi)
+static int errcatch_unit_num(struct virtual_item *vi)
{
- reiserfs_warning (NULL, "green-16010: Invalid item type observed, run fsck ASAP");
- return 0;
+ reiserfs_warning(NULL,
+ "green-16010: Invalid item type observed, run fsck ASAP");
+ return 0;
}
-static void errcatch_print_vi (struct virtual_item * vi)
+static void errcatch_print_vi(struct virtual_item *vi)
{
- reiserfs_warning (NULL, "green-16011: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL,
+ "green-16011: Invalid item type observed, run fsck ASAP");
}
static struct item_operations errcatch_ops = {
- errcatch_bytes_number,
- errcatch_decrement_key,
- errcatch_is_left_mergeable,
- errcatch_print_item,
- errcatch_check_item,
-
- errcatch_create_vi,
- errcatch_check_left,
- errcatch_check_right,
- errcatch_part_size,
- errcatch_unit_num,
- errcatch_print_vi
+ errcatch_bytes_number,
+ errcatch_decrement_key,
+ errcatch_is_left_mergeable,
+ errcatch_print_item,
+ errcatch_check_item,
+
+ errcatch_create_vi,
+ errcatch_check_left,
+ errcatch_check_right,
+ errcatch_part_size,
+ errcatch_unit_num,
+ errcatch_print_vi
};
-
-
//////////////////////////////////////////////////////////////////////////////
//
//
#if ! (TYPE_STAT_DATA == 0 && TYPE_INDIRECT == 1 && TYPE_DIRECT == 2 && TYPE_DIRENTRY == 3)
- do not compile
+#error Item types must use disk-format assigned values.
#endif
-struct item_operations * item_ops [TYPE_ANY + 1] = {
- &stat_data_ops,
- &indirect_ops,
- &direct_ops,
- &direntry_ops,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &errcatch_ops /* This is to catch errors with invalid type (15th entry for TYPE_ANY) */
+struct item_operations *item_ops[TYPE_ANY + 1] = {
+ &stat_data_ops,
+ &indirect_ops,
+ &direct_ops,
+ &direntry_ops,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &errcatch_ops /* This is to catch errors with invalid type (15th entry for TYPE_ANY) */
};
-
-
-
-
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index d1bcf0da672..c66c27ec410 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -55,7 +55,6 @@
#include <linux/writeback.h>
#include <linux/blkdev.h>
-
/* gets a struct reiserfs_journal_list * from a list head */
#define JOURNAL_LIST_ENTRY(h) (list_entry((h), struct reiserfs_journal_list, \
j_list))
@@ -69,55 +68,61 @@ static int reiserfs_mounted_fs_count;
static struct workqueue_struct *commit_wq;
-#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit
- structs at 4k */
-#define BUFNR 64 /*read ahead */
+#define JOURNAL_TRANS_HALF 1018 /* must be correct to keep the desc and commit
+ structs at 4k */
+#define BUFNR 64 /*read ahead */
/* cnode stat bits. Move these into reiserfs_fs.h */
#define BLOCK_FREED 2 /* this block was freed, and can't be written. */
-#define BLOCK_FREED_HOLDER 3 /* this block was freed during this transaction, and can't be written */
+#define BLOCK_FREED_HOLDER 3 /* this block was freed during this transaction, and can't be written */
#define BLOCK_NEEDS_FLUSH 4 /* used in flush_journal_list */
#define BLOCK_DIRTIED 5
-
/* journal list state bits */
#define LIST_TOUCHED 1
#define LIST_DIRTY 2
-#define LIST_COMMIT_PENDING 4 /* someone will commit this list */
+#define LIST_COMMIT_PENDING 4 /* someone will commit this list */
/* flags for do_journal_end */
#define FLUSH_ALL 1 /* flush commit and real blocks */
#define COMMIT_NOW 2 /* end and commit this transaction */
-#define WAIT 4 /* wait for the log blocks to hit the disk*/
-
-static int do_journal_end(struct reiserfs_transaction_handle *,struct super_block *,unsigned long nblocks,int flags) ;
-static int flush_journal_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ;
-static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) ;
-static int can_dirty(struct reiserfs_journal_cnode *cn) ;
-static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks);
-static int release_journal_dev( struct super_block *super,
- struct reiserfs_journal *journal );
+#define WAIT 4 /* wait for the log blocks to hit the disk */
+
+static int do_journal_end(struct reiserfs_transaction_handle *,
+ struct super_block *, unsigned long nblocks,
+ int flags);
+static int flush_journal_list(struct super_block *s,
+ struct reiserfs_journal_list *jl, int flushall);
+static int flush_commit_list(struct super_block *s,
+ struct reiserfs_journal_list *jl, int flushall);
+static int can_dirty(struct reiserfs_journal_cnode *cn);
+static int journal_join(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks);
+static int release_journal_dev(struct super_block *super,
+ struct reiserfs_journal *journal);
static int dirty_one_transaction(struct super_block *s,
- struct reiserfs_journal_list *jl);
+ struct reiserfs_journal_list *jl);
static void flush_async_commits(void *p);
static void queue_log_writer(struct super_block *s);
/* values for join in do_journal_begin_r */
enum {
- JBEGIN_REG = 0, /* regular journal begin */
- JBEGIN_JOIN = 1, /* join the running transaction if at all possible */
- JBEGIN_ABORT = 2, /* called from cleanup code, ignores aborted flag */
+ JBEGIN_REG = 0, /* regular journal begin */
+ JBEGIN_JOIN = 1, /* join the running transaction if at all possible */
+ JBEGIN_ABORT = 2, /* called from cleanup code, ignores aborted flag */
};
static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
- struct super_block * p_s_sb,
- unsigned long nblocks,int join);
+ struct super_block *p_s_sb,
+ unsigned long nblocks, int join);
-static void init_journal_hash(struct super_block *p_s_sb) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- memset(journal->j_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
+static void init_journal_hash(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ memset(journal->j_hash_table, 0,
+ JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *));
}
/*
@@ -125,149 +130,159 @@ static void init_journal_hash(struct super_block *p_s_sb) {
** make schedule happen after I've freed a block. Look at remove_from_transaction and journal_mark_freed for
** more details.
*/
-static int reiserfs_clean_and_file_buffer(struct buffer_head *bh) {
- if (bh) {
- clear_buffer_dirty(bh);
- clear_buffer_journal_test(bh);
- }
- return 0 ;
+static int reiserfs_clean_and_file_buffer(struct buffer_head *bh)
+{
+ if (bh) {
+ clear_buffer_dirty(bh);
+ clear_buffer_journal_test(bh);
+ }
+ return 0;
}
static void disable_barrier(struct super_block *s)
{
- REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_BARRIER_FLUSH);
- printk("reiserfs: disabling flush barriers on %s\n", reiserfs_bdevname(s));
-}
-
-static struct reiserfs_bitmap_node *
-allocate_bitmap_node(struct super_block *p_s_sb) {
- struct reiserfs_bitmap_node *bn ;
- static int id;
-
- bn = reiserfs_kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS, p_s_sb) ;
- if (!bn) {
- return NULL ;
- }
- bn->data = reiserfs_kmalloc(p_s_sb->s_blocksize, GFP_NOFS, p_s_sb) ;
- if (!bn->data) {
- reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
- return NULL ;
- }
- bn->id = id++ ;
- memset(bn->data, 0, p_s_sb->s_blocksize) ;
- INIT_LIST_HEAD(&bn->list) ;
- return bn ;
-}
-
-static struct reiserfs_bitmap_node *
-get_bitmap_node(struct super_block *p_s_sb) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_bitmap_node *bn = NULL;
- struct list_head *entry = journal->j_bitmap_nodes.next ;
-
- journal->j_used_bitmap_nodes++ ;
-repeat:
-
- if(entry != &journal->j_bitmap_nodes) {
- bn = list_entry(entry, struct reiserfs_bitmap_node, list) ;
- list_del(entry) ;
- memset(bn->data, 0, p_s_sb->s_blocksize) ;
- journal->j_free_bitmap_nodes-- ;
- return bn ;
- }
- bn = allocate_bitmap_node(p_s_sb) ;
- if (!bn) {
- yield();
- goto repeat ;
- }
- return bn ;
+ REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_BARRIER_FLUSH);
+ printk("reiserfs: disabling flush barriers on %s\n",
+ reiserfs_bdevname(s));
+}
+
+static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
+ *p_s_sb)
+{
+ struct reiserfs_bitmap_node *bn;
+ static int id;
+
+ bn = reiserfs_kmalloc(sizeof(struct reiserfs_bitmap_node), GFP_NOFS,
+ p_s_sb);
+ if (!bn) {
+ return NULL;
+ }
+ bn->data = reiserfs_kmalloc(p_s_sb->s_blocksize, GFP_NOFS, p_s_sb);
+ if (!bn->data) {
+ reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb);
+ return NULL;
+ }
+ bn->id = id++;
+ memset(bn->data, 0, p_s_sb->s_blocksize);
+ INIT_LIST_HEAD(&bn->list);
+ return bn;
+}
+
+static struct reiserfs_bitmap_node *get_bitmap_node(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_bitmap_node *bn = NULL;
+ struct list_head *entry = journal->j_bitmap_nodes.next;
+
+ journal->j_used_bitmap_nodes++;
+ repeat:
+
+ if (entry != &journal->j_bitmap_nodes) {
+ bn = list_entry(entry, struct reiserfs_bitmap_node, list);
+ list_del(entry);
+ memset(bn->data, 0, p_s_sb->s_blocksize);
+ journal->j_free_bitmap_nodes--;
+ return bn;
+ }
+ bn = allocate_bitmap_node(p_s_sb);
+ if (!bn) {
+ yield();
+ goto repeat;
+ }
+ return bn;
}
static inline void free_bitmap_node(struct super_block *p_s_sb,
- struct reiserfs_bitmap_node *bn) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- journal->j_used_bitmap_nodes-- ;
- if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
- reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
- reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
- } else {
- list_add(&bn->list, &journal->j_bitmap_nodes) ;
- journal->j_free_bitmap_nodes++ ;
- }
-}
-
-static void allocate_bitmap_nodes(struct super_block *p_s_sb) {
- int i ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_bitmap_node *bn = NULL ;
- for (i = 0 ; i < REISERFS_MIN_BITMAP_NODES ; i++) {
- bn = allocate_bitmap_node(p_s_sb) ;
- if (bn) {
- list_add(&bn->list, &journal->j_bitmap_nodes) ;
- journal->j_free_bitmap_nodes++ ;
- } else {
- break ; // this is ok, we'll try again when more are needed
- }
- }
+ struct reiserfs_bitmap_node *bn)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ journal->j_used_bitmap_nodes--;
+ if (journal->j_free_bitmap_nodes > REISERFS_MAX_BITMAP_NODES) {
+ reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb);
+ reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb);
+ } else {
+ list_add(&bn->list, &journal->j_bitmap_nodes);
+ journal->j_free_bitmap_nodes++;
+ }
+}
+
+static void allocate_bitmap_nodes(struct super_block *p_s_sb)
+{
+ int i;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_bitmap_node *bn = NULL;
+ for (i = 0; i < REISERFS_MIN_BITMAP_NODES; i++) {
+ bn = allocate_bitmap_node(p_s_sb);
+ if (bn) {
+ list_add(&bn->list, &journal->j_bitmap_nodes);
+ journal->j_free_bitmap_nodes++;
+ } else {
+ break; // this is ok, we'll try again when more are needed
+ }
+ }
}
static int set_bit_in_list_bitmap(struct super_block *p_s_sb, int block,
- struct reiserfs_list_bitmap *jb) {
- int bmap_nr = block / (p_s_sb->s_blocksize << 3) ;
- int bit_nr = block % (p_s_sb->s_blocksize << 3) ;
+ struct reiserfs_list_bitmap *jb)
+{
+ int bmap_nr = block / (p_s_sb->s_blocksize << 3);
+ int bit_nr = block % (p_s_sb->s_blocksize << 3);
- if (!jb->bitmaps[bmap_nr]) {
- jb->bitmaps[bmap_nr] = get_bitmap_node(p_s_sb) ;
- }
- set_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data) ;
- return 0 ;
+ if (!jb->bitmaps[bmap_nr]) {
+ jb->bitmaps[bmap_nr] = get_bitmap_node(p_s_sb);
+ }
+ set_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data);
+ return 0;
}
static void cleanup_bitmap_list(struct super_block *p_s_sb,
- struct reiserfs_list_bitmap *jb) {
- int i;
- if (jb->bitmaps == NULL)
- return;
-
- for (i = 0 ; i < SB_BMAP_NR(p_s_sb) ; i++) {
- if (jb->bitmaps[i]) {
- free_bitmap_node(p_s_sb, jb->bitmaps[i]) ;
- jb->bitmaps[i] = NULL ;
- }
- }
+ struct reiserfs_list_bitmap *jb)
+{
+ int i;
+ if (jb->bitmaps == NULL)
+ return;
+
+ for (i = 0; i < SB_BMAP_NR(p_s_sb); i++) {
+ if (jb->bitmaps[i]) {
+ free_bitmap_node(p_s_sb, jb->bitmaps[i]);
+ jb->bitmaps[i] = NULL;
+ }
+ }
}
/*
** only call this on FS unmount.
*/
static int free_list_bitmaps(struct super_block *p_s_sb,
- struct reiserfs_list_bitmap *jb_array) {
- int i ;
- struct reiserfs_list_bitmap *jb ;
- for (i = 0 ; i < JOURNAL_NUM_BITMAPS ; i++) {
- jb = jb_array + i ;
- jb->journal_list = NULL ;
- cleanup_bitmap_list(p_s_sb, jb) ;
- vfree(jb->bitmaps) ;
- jb->bitmaps = NULL ;
- }
- return 0;
-}
-
-static int free_bitmap_nodes(struct super_block *p_s_sb) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct list_head *next = journal->j_bitmap_nodes.next ;
- struct reiserfs_bitmap_node *bn ;
-
- while(next != &journal->j_bitmap_nodes) {
- bn = list_entry(next, struct reiserfs_bitmap_node, list) ;
- list_del(next) ;
- reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb) ;
- reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb) ;
- next = journal->j_bitmap_nodes.next ;
- journal->j_free_bitmap_nodes-- ;
- }
-
- return 0 ;
+ struct reiserfs_list_bitmap *jb_array)
+{
+ int i;
+ struct reiserfs_list_bitmap *jb;
+ for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
+ jb = jb_array + i;
+ jb->journal_list = NULL;
+ cleanup_bitmap_list(p_s_sb, jb);
+ vfree(jb->bitmaps);
+ jb->bitmaps = NULL;
+ }
+ return 0;
+}
+
+static int free_bitmap_nodes(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct list_head *next = journal->j_bitmap_nodes.next;
+ struct reiserfs_bitmap_node *bn;
+
+ while (next != &journal->j_bitmap_nodes) {
+ bn = list_entry(next, struct reiserfs_bitmap_node, list);
+ list_del(next);
+ reiserfs_kfree(bn->data, p_s_sb->s_blocksize, p_s_sb);
+ reiserfs_kfree(bn, sizeof(struct reiserfs_bitmap_node), p_s_sb);
+ next = journal->j_bitmap_nodes.next;
+ journal->j_free_bitmap_nodes--;
+ }
+
+ return 0;
}
/*
@@ -275,59 +290,65 @@ static int free_bitmap_nodes(struct super_block *p_s_sb) {
** jb_array is the array to be filled in.
*/
int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
- struct reiserfs_list_bitmap *jb_array,
- int bmap_nr) {
- int i ;
- int failed = 0 ;
- struct reiserfs_list_bitmap *jb ;
- int mem = bmap_nr * sizeof(struct reiserfs_bitmap_node *) ;
-
- for (i = 0 ; i < JOURNAL_NUM_BITMAPS ; i++) {
- jb = jb_array + i ;
- jb->journal_list = NULL ;
- jb->bitmaps = vmalloc( mem ) ;
- if (!jb->bitmaps) {
- reiserfs_warning(p_s_sb, "clm-2000, unable to allocate bitmaps for journal lists") ;
- failed = 1;
- break ;
- }
- memset(jb->bitmaps, 0, mem) ;
- }
- if (failed) {
- free_list_bitmaps(p_s_sb, jb_array) ;
- return -1 ;
- }
- return 0 ;
+ struct reiserfs_list_bitmap *jb_array,
+ int bmap_nr)
+{
+ int i;
+ int failed = 0;
+ struct reiserfs_list_bitmap *jb;
+ int mem = bmap_nr * sizeof(struct reiserfs_bitmap_node *);
+
+ for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
+ jb = jb_array + i;
+ jb->journal_list = NULL;
+ jb->bitmaps = vmalloc(mem);
+ if (!jb->bitmaps) {
+ reiserfs_warning(p_s_sb,
+ "clm-2000, unable to allocate bitmaps for journal lists");
+ failed = 1;
+ break;
+ }
+ memset(jb->bitmaps, 0, mem);
+ }
+ if (failed) {
+ free_list_bitmaps(p_s_sb, jb_array);
+ return -1;
+ }
+ return 0;
}
/*
** find an available list bitmap. If you can't find one, flush a commit list
** and try again
*/
-static struct reiserfs_list_bitmap *
-get_list_bitmap(struct super_block *p_s_sb, struct reiserfs_journal_list *jl) {
- int i,j ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_list_bitmap *jb = NULL ;
-
- for (j = 0 ; j < (JOURNAL_NUM_BITMAPS * 3) ; j++) {
- i = journal->j_list_bitmap_index ;
- journal->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS ;
- jb = journal->j_list_bitmap + i ;
- if (journal->j_list_bitmap[i].journal_list) {
- flush_commit_list(p_s_sb, journal->j_list_bitmap[i].journal_list, 1) ;
- if (!journal->j_list_bitmap[i].journal_list) {
- break ;
- }
- } else {
- break ;
- }
- }
- if (jb->journal_list) { /* double check to make sure if flushed correctly */
- return NULL ;
- }
- jb->journal_list = jl ;
- return jb ;
+static struct reiserfs_list_bitmap *get_list_bitmap(struct super_block *p_s_sb,
+ struct reiserfs_journal_list
+ *jl)
+{
+ int i, j;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_list_bitmap *jb = NULL;
+
+ for (j = 0; j < (JOURNAL_NUM_BITMAPS * 3); j++) {
+ i = journal->j_list_bitmap_index;
+ journal->j_list_bitmap_index = (i + 1) % JOURNAL_NUM_BITMAPS;
+ jb = journal->j_list_bitmap + i;
+ if (journal->j_list_bitmap[i].journal_list) {
+ flush_commit_list(p_s_sb,
+ journal->j_list_bitmap[i].
+ journal_list, 1);
+ if (!journal->j_list_bitmap[i].journal_list) {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ if (jb->journal_list) { /* double check to make sure if flushed correctly */
+ return NULL;
+ }
+ jb->journal_list = jl;
+ return jb;
}
/*
@@ -335,104 +356,114 @@ get_list_bitmap(struct super_block *p_s_sb, struct reiserfs_journal_list *jl) {
** Uses the cnode->next and cnode->prev pointers
** returns NULL on failure
*/
-static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes) {
- struct reiserfs_journal_cnode *head ;
- int i ;
- if (num_cnodes <= 0) {
- return NULL ;
- }
- head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode)) ;
- if (!head) {
- return NULL ;
- }
- memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode)) ;
- head[0].prev = NULL ;
- head[0].next = head + 1 ;
- for (i = 1 ; i < num_cnodes; i++) {
- head[i].prev = head + (i - 1) ;
- head[i].next = head + (i + 1) ; /* if last one, overwrite it after the if */
- }
- head[num_cnodes -1].next = NULL ;
- return head ;
+static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
+{
+ struct reiserfs_journal_cnode *head;
+ int i;
+ if (num_cnodes <= 0) {
+ return NULL;
+ }
+ head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
+ if (!head) {
+ return NULL;
+ }
+ memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode));
+ head[0].prev = NULL;
+ head[0].next = head + 1;
+ for (i = 1; i < num_cnodes; i++) {
+ head[i].prev = head + (i - 1);
+ head[i].next = head + (i + 1); /* if last one, overwrite it after the if */
+ }
+ head[num_cnodes - 1].next = NULL;
+ return head;
}
/*
** pulls a cnode off the free list, or returns NULL on failure
*/
-static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb) {
- struct reiserfs_journal_cnode *cn ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
-
- reiserfs_check_lock_depth(p_s_sb, "get_cnode") ;
-
- if (journal->j_cnode_free <= 0) {
- return NULL ;
- }
- journal->j_cnode_used++ ;
- journal->j_cnode_free-- ;
- cn = journal->j_cnode_free_list ;
- if (!cn) {
- return cn ;
- }
- if (cn->next) {
- cn->next->prev = NULL ;
- }
- journal->j_cnode_free_list = cn->next ;
- memset(cn, 0, sizeof(struct reiserfs_journal_cnode)) ;
- return cn ;
+static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal_cnode *cn;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+
+ reiserfs_check_lock_depth(p_s_sb, "get_cnode");
+
+ if (journal->j_cnode_free <= 0) {
+ return NULL;
+ }
+ journal->j_cnode_used++;
+ journal->j_cnode_free--;
+ cn = journal->j_cnode_free_list;
+ if (!cn) {
+ return cn;
+ }
+ if (cn->next) {
+ cn->next->prev = NULL;
+ }
+ journal->j_cnode_free_list = cn->next;
+ memset(cn, 0, sizeof(struct reiserfs_journal_cnode));
+ return cn;
}
/*
** returns a cnode to the free list
*/
-static void free_cnode(struct super_block *p_s_sb, struct reiserfs_journal_cnode *cn) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+static void free_cnode(struct super_block *p_s_sb,
+ struct reiserfs_journal_cnode *cn)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
- reiserfs_check_lock_depth(p_s_sb, "free_cnode") ;
+ reiserfs_check_lock_depth(p_s_sb, "free_cnode");
- journal->j_cnode_used-- ;
- journal->j_cnode_free++ ;
- /* memset(cn, 0, sizeof(struct reiserfs_journal_cnode)) ; */
- cn->next = journal->j_cnode_free_list ;
- if (journal->j_cnode_free_list) {
- journal->j_cnode_free_list->prev = cn ;
- }
- cn->prev = NULL ; /* not needed with the memset, but I might kill the memset, and forget to do this */
- journal->j_cnode_free_list = cn ;
+ journal->j_cnode_used--;
+ journal->j_cnode_free++;
+ /* memset(cn, 0, sizeof(struct reiserfs_journal_cnode)) ; */
+ cn->next = journal->j_cnode_free_list;
+ if (journal->j_cnode_free_list) {
+ journal->j_cnode_free_list->prev = cn;
+ }
+ cn->prev = NULL; /* not needed with the memset, but I might kill the memset, and forget to do this */
+ journal->j_cnode_free_list = cn;
}
-static void clear_prepared_bits(struct buffer_head *bh) {
- clear_buffer_journal_prepared (bh);
- clear_buffer_journal_restore_dirty (bh);
+static void clear_prepared_bits(struct buffer_head *bh)
+{
+ clear_buffer_journal_prepared(bh);
+ clear_buffer_journal_restore_dirty(bh);
}
/* utility function to force a BUG if it is called without the big
** kernel lock held. caller is the string printed just before calling BUG()
*/
-void reiserfs_check_lock_depth(struct super_block *sb, char *caller) {
+void reiserfs_check_lock_depth(struct super_block *sb, char *caller)
+{
#ifdef CONFIG_SMP
- if (current->lock_depth < 0) {
- reiserfs_panic (sb, "%s called without kernel lock held", caller) ;
- }
+ if (current->lock_depth < 0) {
+ reiserfs_panic(sb, "%s called without kernel lock held",
+ caller);
+ }
#else
- ;
+ ;
#endif
}
/* return a cnode with same dev, block number and size in table, or null if not found */
-static inline struct reiserfs_journal_cnode *
-get_journal_hash_dev(struct super_block *sb,
- struct reiserfs_journal_cnode **table,
- long bl)
+static inline struct reiserfs_journal_cnode *get_journal_hash_dev(struct
+ super_block
+ *sb,
+ struct
+ reiserfs_journal_cnode
+ **table,
+ long bl)
{
- struct reiserfs_journal_cnode *cn ;
- cn = journal_hash(table, sb, bl) ;
- while(cn) {
- if (cn->blocknr == bl && cn->sb == sb)
- return cn ;
- cn = cn->hnext ;
- }
- return (struct reiserfs_journal_cnode *)0 ;
+ struct reiserfs_journal_cnode *cn;
+ cn = journal_hash(table, sb, bl);
+ while (cn) {
+ if (cn->blocknr == bl && cn->sb == sb)
+ return cn;
+ cn = cn->hnext;
+ }
+ return (struct reiserfs_journal_cnode *)0;
}
/*
@@ -454,91 +485,103 @@ get_journal_hash_dev(struct super_block *sb,
**
*/
int reiserfs_in_journal(struct super_block *p_s_sb,
- int bmap_nr, int bit_nr, int search_all,
- b_blocknr_t *next_zero_bit) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_cnode *cn ;
- struct reiserfs_list_bitmap *jb ;
- int i ;
- unsigned long bl;
-
- *next_zero_bit = 0 ; /* always start this at zero. */
-
- PROC_INFO_INC( p_s_sb, journal.in_journal );
- /* If we aren't doing a search_all, this is a metablock, and it will be logged before use.
- ** if we crash before the transaction that freed it commits, this transaction won't
- ** have committed either, and the block will never be written
- */
- if (search_all) {
- for (i = 0 ; i < JOURNAL_NUM_BITMAPS ; i++) {
- PROC_INFO_INC( p_s_sb, journal.in_journal_bitmap );
- jb = journal->j_list_bitmap + i ;
- if (jb->journal_list && jb->bitmaps[bmap_nr] &&
- test_bit(bit_nr, (unsigned long *)jb->bitmaps[bmap_nr]->data)) {
- *next_zero_bit = find_next_zero_bit((unsigned long *)
- (jb->bitmaps[bmap_nr]->data),
- p_s_sb->s_blocksize << 3, bit_nr+1) ;
- return 1 ;
- }
- }
- }
-
- bl = bmap_nr * (p_s_sb->s_blocksize << 3) + bit_nr;
- /* is it in any old transactions? */
- if (search_all && (cn = get_journal_hash_dev(p_s_sb, journal->j_list_hash_table, bl))) {
- return 1;
- }
-
- /* is it in the current transaction. This should never happen */
- if ((cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, bl))) {
- BUG();
- return 1;
- }
-
- PROC_INFO_INC( p_s_sb, journal.in_journal_reusable );
- /* safe for reuse */
- return 0 ;
+ int bmap_nr, int bit_nr, int search_all,
+ b_blocknr_t * next_zero_bit)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_cnode *cn;
+ struct reiserfs_list_bitmap *jb;
+ int i;
+ unsigned long bl;
+
+ *next_zero_bit = 0; /* always start this at zero. */
+
+ PROC_INFO_INC(p_s_sb, journal.in_journal);
+ /* If we aren't doing a search_all, this is a metablock, and it will be logged before use.
+ ** if we crash before the transaction that freed it commits, this transaction won't
+ ** have committed either, and the block will never be written
+ */
+ if (search_all) {
+ for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
+ PROC_INFO_INC(p_s_sb, journal.in_journal_bitmap);
+ jb = journal->j_list_bitmap + i;
+ if (jb->journal_list && jb->bitmaps[bmap_nr] &&
+ test_bit(bit_nr,
+ (unsigned long *)jb->bitmaps[bmap_nr]->
+ data)) {
+ *next_zero_bit =
+ find_next_zero_bit((unsigned long *)
+ (jb->bitmaps[bmap_nr]->
+ data),
+ p_s_sb->s_blocksize << 3,
+ bit_nr + 1);
+ return 1;
+ }
+ }
+ }
+
+ bl = bmap_nr * (p_s_sb->s_blocksize << 3) + bit_nr;
+ /* is it in any old transactions? */
+ if (search_all
+ && (cn =
+ get_journal_hash_dev(p_s_sb, journal->j_list_hash_table, bl))) {
+ return 1;
+ }
+
+ /* is it in the current transaction. This should never happen */
+ if ((cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, bl))) {
+ BUG();
+ return 1;
+ }
+
+ PROC_INFO_INC(p_s_sb, journal.in_journal_reusable);
+ /* safe for reuse */
+ return 0;
}
/* insert cn into table
*/
-static inline void insert_journal_hash(struct reiserfs_journal_cnode **table, struct reiserfs_journal_cnode *cn) {
- struct reiserfs_journal_cnode *cn_orig ;
+static inline void insert_journal_hash(struct reiserfs_journal_cnode **table,
+ struct reiserfs_journal_cnode *cn)
+{
+ struct reiserfs_journal_cnode *cn_orig;
- cn_orig = journal_hash(table, cn->sb, cn->blocknr) ;
- cn->hnext = cn_orig ;
- cn->hprev = NULL ;
- if (cn_orig) {
- cn_orig->hprev = cn ;
- }
- journal_hash(table, cn->sb, cn->blocknr) = cn ;
+ cn_orig = journal_hash(table, cn->sb, cn->blocknr);
+ cn->hnext = cn_orig;
+ cn->hprev = NULL;
+ if (cn_orig) {
+ cn_orig->hprev = cn;
+ }
+ journal_hash(table, cn->sb, cn->blocknr) = cn;
}
/* lock the current transaction */
-inline static void lock_journal(struct super_block *p_s_sb) {
- PROC_INFO_INC( p_s_sb, journal.lock_journal );
- down(&SB_JOURNAL(p_s_sb)->j_lock);
+inline static void lock_journal(struct super_block *p_s_sb)
+{
+ PROC_INFO_INC(p_s_sb, journal.lock_journal);
+ down(&SB_JOURNAL(p_s_sb)->j_lock);
}
/* unlock the current transaction */
-inline static void unlock_journal(struct super_block *p_s_sb) {
- up(&SB_JOURNAL(p_s_sb)->j_lock);
+inline static void unlock_journal(struct super_block *p_s_sb)
+{
+ up(&SB_JOURNAL(p_s_sb)->j_lock);
}
static inline void get_journal_list(struct reiserfs_journal_list *jl)
{
- jl->j_refcount++;
+ jl->j_refcount++;
}
static inline void put_journal_list(struct super_block *s,
- struct reiserfs_journal_list *jl)
+ struct reiserfs_journal_list *jl)
{
- if (jl->j_refcount < 1) {
- reiserfs_panic (s, "trans id %lu, refcount at %d", jl->j_trans_id,
- jl->j_refcount);
- }
- if (--jl->j_refcount == 0)
- reiserfs_kfree(jl, sizeof(struct reiserfs_journal_list), s);
+ if (jl->j_refcount < 1) {
+ reiserfs_panic(s, "trans id %lu, refcount at %d",
+ jl->j_trans_id, jl->j_refcount);
+ }
+ if (--jl->j_refcount == 0)
+ reiserfs_kfree(jl, sizeof(struct reiserfs_journal_list), s);
}
/*
@@ -546,358 +589,375 @@ static inline void put_journal_list(struct super_block *s,
** it gets called by flush_commit_list, and cleans up any data stored about blocks freed during a
** transaction.
*/
-static void cleanup_freed_for_journal_list(struct super_block *p_s_sb, struct reiserfs_journal_list *jl) {
+static void cleanup_freed_for_journal_list(struct super_block *p_s_sb,
+ struct reiserfs_journal_list *jl)
+{
- struct reiserfs_list_bitmap *jb = jl->j_list_bitmap ;
- if (jb) {
- cleanup_bitmap_list(p_s_sb, jb) ;
- }
- jl->j_list_bitmap->journal_list = NULL ;
- jl->j_list_bitmap = NULL ;
+ struct reiserfs_list_bitmap *jb = jl->j_list_bitmap;
+ if (jb) {
+ cleanup_bitmap_list(p_s_sb, jb);
+ }
+ jl->j_list_bitmap->journal_list = NULL;
+ jl->j_list_bitmap = NULL;
}
static int journal_list_still_alive(struct super_block *s,
- unsigned long trans_id)
-{
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- struct list_head *entry = &journal->j_journal_list;
- struct reiserfs_journal_list *jl;
-
- if (!list_empty(entry)) {
- jl = JOURNAL_LIST_ENTRY(entry->next);
- if (jl->j_trans_id <= trans_id) {
- return 1;
- }
- }
- return 0;
-}
-
-static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate) {
- char b[BDEVNAME_SIZE];
-
- if (buffer_journaled(bh)) {
- reiserfs_warning(NULL, "clm-2084: pinned buffer %lu:%s sent to disk",
- bh->b_blocknr, bdevname(bh->b_bdev, b)) ;
- }
- if (uptodate)
- set_buffer_uptodate(bh) ;
- else
- clear_buffer_uptodate(bh) ;
- unlock_buffer(bh) ;
- put_bh(bh) ;
-}
-
-static void reiserfs_end_ordered_io(struct buffer_head *bh, int uptodate) {
- if (uptodate)
- set_buffer_uptodate(bh) ;
- else
- clear_buffer_uptodate(bh) ;
- unlock_buffer(bh) ;
- put_bh(bh) ;
-}
-
-static void submit_logged_buffer(struct buffer_head *bh) {
- get_bh(bh) ;
- bh->b_end_io = reiserfs_end_buffer_io_sync ;
- clear_buffer_journal_new (bh);
- clear_buffer_dirty(bh) ;
- if (!test_clear_buffer_journal_test (bh))
- BUG();
- if (!buffer_uptodate(bh))
- BUG();
- submit_bh(WRITE, bh) ;
-}
-
-static void submit_ordered_buffer(struct buffer_head *bh) {
- get_bh(bh) ;
- bh->b_end_io = reiserfs_end_ordered_io;
- clear_buffer_dirty(bh) ;
- if (!buffer_uptodate(bh))
- BUG();
- submit_bh(WRITE, bh) ;
-}
-
-static int submit_barrier_buffer(struct buffer_head *bh) {
- get_bh(bh) ;
- bh->b_end_io = reiserfs_end_ordered_io;
- clear_buffer_dirty(bh) ;
- if (!buffer_uptodate(bh))
- BUG();
- return submit_bh(WRITE_BARRIER, bh) ;
+ unsigned long trans_id)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ struct list_head *entry = &journal->j_journal_list;
+ struct reiserfs_journal_list *jl;
+
+ if (!list_empty(entry)) {
+ jl = JOURNAL_LIST_ENTRY(entry->next);
+ if (jl->j_trans_id <= trans_id) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void reiserfs_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
+{
+ char b[BDEVNAME_SIZE];
+
+ if (buffer_journaled(bh)) {
+ reiserfs_warning(NULL,
+ "clm-2084: pinned buffer %lu:%s sent to disk",
+ bh->b_blocknr, bdevname(bh->b_bdev, b));
+ }
+ if (uptodate)
+ set_buffer_uptodate(bh);
+ else
+ clear_buffer_uptodate(bh);
+ unlock_buffer(bh);
+ put_bh(bh);
+}
+
+static void reiserfs_end_ordered_io(struct buffer_head *bh, int uptodate)
+{
+ if (uptodate)
+ set_buffer_uptodate(bh);
+ else
+ clear_buffer_uptodate(bh);
+ unlock_buffer(bh);
+ put_bh(bh);
+}
+
+static void submit_logged_buffer(struct buffer_head *bh)
+{
+ get_bh(bh);
+ bh->b_end_io = reiserfs_end_buffer_io_sync;
+ clear_buffer_journal_new(bh);
+ clear_buffer_dirty(bh);
+ if (!test_clear_buffer_journal_test(bh))
+ BUG();
+ if (!buffer_uptodate(bh))
+ BUG();
+ submit_bh(WRITE, bh);
+}
+
+static void submit_ordered_buffer(struct buffer_head *bh)
+{
+ get_bh(bh);
+ bh->b_end_io = reiserfs_end_ordered_io;
+ clear_buffer_dirty(bh);
+ if (!buffer_uptodate(bh))
+ BUG();
+ submit_bh(WRITE, bh);
+}
+
+static int submit_barrier_buffer(struct buffer_head *bh)
+{
+ get_bh(bh);
+ bh->b_end_io = reiserfs_end_ordered_io;
+ clear_buffer_dirty(bh);
+ if (!buffer_uptodate(bh))
+ BUG();
+ return submit_bh(WRITE_BARRIER, bh);
}
static void check_barrier_completion(struct super_block *s,
- struct buffer_head *bh) {
- if (buffer_eopnotsupp(bh)) {
- clear_buffer_eopnotsupp(bh);
- disable_barrier(s);
- set_buffer_uptodate(bh);
- set_buffer_dirty(bh);
- sync_dirty_buffer(bh);
- }
+ struct buffer_head *bh)
+{
+ if (buffer_eopnotsupp(bh)) {
+ clear_buffer_eopnotsupp(bh);
+ disable_barrier(s);
+ set_buffer_uptodate(bh);
+ set_buffer_dirty(bh);
+ sync_dirty_buffer(bh);
+ }
}
#define CHUNK_SIZE 32
struct buffer_chunk {
- struct buffer_head *bh[CHUNK_SIZE];
- int nr;
+ struct buffer_head *bh[CHUNK_SIZE];
+ int nr;
};
-static void write_chunk(struct buffer_chunk *chunk) {
- int i;
- get_fs_excl();
- for (i = 0; i < chunk->nr ; i++) {
- submit_logged_buffer(chunk->bh[i]) ;
- }
- chunk->nr = 0;
- put_fs_excl();
+static void write_chunk(struct buffer_chunk *chunk)
+{
+ int i;
+ get_fs_excl();
+ for (i = 0; i < chunk->nr; i++) {
+ submit_logged_buffer(chunk->bh[i]);
+ }
+ chunk->nr = 0;
+ put_fs_excl();
}
-static void write_ordered_chunk(struct buffer_chunk *chunk) {
- int i;
- get_fs_excl();
- for (i = 0; i < chunk->nr ; i++) {
- submit_ordered_buffer(chunk->bh[i]) ;
- }
- chunk->nr = 0;
- put_fs_excl();
+static void write_ordered_chunk(struct buffer_chunk *chunk)
+{
+ int i;
+ get_fs_excl();
+ for (i = 0; i < chunk->nr; i++) {
+ submit_ordered_buffer(chunk->bh[i]);
+ }
+ chunk->nr = 0;
+ put_fs_excl();
}
static int add_to_chunk(struct buffer_chunk *chunk, struct buffer_head *bh,
- spinlock_t *lock,
- void (fn)(struct buffer_chunk *))
+ spinlock_t * lock, void (fn) (struct buffer_chunk *))
{
- int ret = 0;
- if (chunk->nr >= CHUNK_SIZE)
- BUG();
- chunk->bh[chunk->nr++] = bh;
- if (chunk->nr >= CHUNK_SIZE) {
- ret = 1;
- if (lock)
- spin_unlock(lock);
- fn(chunk);
- if (lock)
- spin_lock(lock);
- }
- return ret;
+ int ret = 0;
+ if (chunk->nr >= CHUNK_SIZE)
+ BUG();
+ chunk->bh[chunk->nr++] = bh;
+ if (chunk->nr >= CHUNK_SIZE) {
+ ret = 1;
+ if (lock)
+ spin_unlock(lock);
+ fn(chunk);
+ if (lock)
+ spin_lock(lock);
+ }
+ return ret;
}
-
static atomic_t nr_reiserfs_jh = ATOMIC_INIT(0);
-static struct reiserfs_jh *alloc_jh(void) {
- struct reiserfs_jh *jh;
- while(1) {
- jh = kmalloc(sizeof(*jh), GFP_NOFS);
- if (jh) {
- atomic_inc(&nr_reiserfs_jh);
- return jh;
+static struct reiserfs_jh *alloc_jh(void)
+{
+ struct reiserfs_jh *jh;
+ while (1) {
+ jh = kmalloc(sizeof(*jh), GFP_NOFS);
+ if (jh) {
+ atomic_inc(&nr_reiserfs_jh);
+ return jh;
+ }
+ yield();
}
- yield();
- }
}
/*
* we want to free the jh when the buffer has been written
* and waited on
*/
-void reiserfs_free_jh(struct buffer_head *bh) {
- struct reiserfs_jh *jh;
-
- jh = bh->b_private;
- if (jh) {
- bh->b_private = NULL;
- jh->bh = NULL;
- list_del_init(&jh->list);
- kfree(jh);
- if (atomic_read(&nr_reiserfs_jh) <= 0)
- BUG();
- atomic_dec(&nr_reiserfs_jh);
- put_bh(bh);
- }
+void reiserfs_free_jh(struct buffer_head *bh)
+{
+ struct reiserfs_jh *jh;
+
+ jh = bh->b_private;
+ if (jh) {
+ bh->b_private = NULL;
+ jh->bh = NULL;
+ list_del_init(&jh->list);
+ kfree(jh);
+ if (atomic_read(&nr_reiserfs_jh) <= 0)
+ BUG();
+ atomic_dec(&nr_reiserfs_jh);
+ put_bh(bh);
+ }
}
static inline int __add_jh(struct reiserfs_journal *j, struct buffer_head *bh,
- int tail)
+ int tail)
{
- struct reiserfs_jh *jh;
+ struct reiserfs_jh *jh;
- if (bh->b_private) {
- spin_lock(&j->j_dirty_buffers_lock);
- if (!bh->b_private) {
- spin_unlock(&j->j_dirty_buffers_lock);
- goto no_jh;
+ if (bh->b_private) {
+ spin_lock(&j->j_dirty_buffers_lock);
+ if (!bh->b_private) {
+ spin_unlock(&j->j_dirty_buffers_lock);
+ goto no_jh;
+ }
+ jh = bh->b_private;
+ list_del_init(&jh->list);
+ } else {
+ no_jh:
+ get_bh(bh);
+ jh = alloc_jh();
+ spin_lock(&j->j_dirty_buffers_lock);
+ /* buffer must be locked for __add_jh, should be able to have
+ * two adds at the same time
+ */
+ if (bh->b_private)
+ BUG();
+ jh->bh = bh;
+ bh->b_private = jh;
}
- jh = bh->b_private;
- list_del_init(&jh->list);
- } else {
-no_jh:
- get_bh(bh);
- jh = alloc_jh();
- spin_lock(&j->j_dirty_buffers_lock);
- /* buffer must be locked for __add_jh, should be able to have
- * two adds at the same time
- */
- if (bh->b_private)
- BUG();
- jh->bh = bh;
- bh->b_private = jh;
- }
- jh->jl = j->j_current_jl;
- if (tail)
- list_add_tail(&jh->list, &jh->jl->j_tail_bh_list);
- else {
- list_add_tail(&jh->list, &jh->jl->j_bh_list);
- }
- spin_unlock(&j->j_dirty_buffers_lock);
- return 0;
+ jh->jl = j->j_current_jl;
+ if (tail)
+ list_add_tail(&jh->list, &jh->jl->j_tail_bh_list);
+ else {
+ list_add_tail(&jh->list, &jh->jl->j_bh_list);
+ }
+ spin_unlock(&j->j_dirty_buffers_lock);
+ return 0;
}
-int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh) {
- return __add_jh(SB_JOURNAL(inode->i_sb), bh, 1);
+int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh)
+{
+ return __add_jh(SB_JOURNAL(inode->i_sb), bh, 1);
}
-int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh) {
- return __add_jh(SB_JOURNAL(inode->i_sb), bh, 0);
+int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh)
+{
+ return __add_jh(SB_JOURNAL(inode->i_sb), bh, 0);
}
#define JH_ENTRY(l) list_entry((l), struct reiserfs_jh, list)
-static int write_ordered_buffers(spinlock_t *lock,
+static int write_ordered_buffers(spinlock_t * lock,
struct reiserfs_journal *j,
- struct reiserfs_journal_list *jl,
+ struct reiserfs_journal_list *jl,
struct list_head *list)
{
- struct buffer_head *bh;
- struct reiserfs_jh *jh;
- int ret = j->j_errno;
- struct buffer_chunk chunk;
- struct list_head tmp;
- INIT_LIST_HEAD(&tmp);
-
- chunk.nr = 0;
- spin_lock(lock);
- while(!list_empty(list)) {
- jh = JH_ENTRY(list->next);
- bh = jh->bh;
- get_bh(bh);
- if (test_set_buffer_locked(bh)) {
- if (!buffer_dirty(bh)) {
- list_del_init(&jh->list);
- list_add(&jh->list, &tmp);
- goto loop_next;
- }
- spin_unlock(lock);
- if (chunk.nr)
+ struct buffer_head *bh;
+ struct reiserfs_jh *jh;
+ int ret = j->j_errno;
+ struct buffer_chunk chunk;
+ struct list_head tmp;
+ INIT_LIST_HEAD(&tmp);
+
+ chunk.nr = 0;
+ spin_lock(lock);
+ while (!list_empty(list)) {
+ jh = JH_ENTRY(list->next);
+ bh = jh->bh;
+ get_bh(bh);
+ if (test_set_buffer_locked(bh)) {
+ if (!buffer_dirty(bh)) {
+ list_del_init(&jh->list);
+ list_add(&jh->list, &tmp);
+ goto loop_next;
+ }
+ spin_unlock(lock);
+ if (chunk.nr)
+ write_ordered_chunk(&chunk);
+ wait_on_buffer(bh);
+ cond_resched();
+ spin_lock(lock);
+ goto loop_next;
+ }
+ if (buffer_dirty(bh)) {
+ list_del_init(&jh->list);
+ list_add(&jh->list, &tmp);
+ add_to_chunk(&chunk, bh, lock, write_ordered_chunk);
+ } else {
+ reiserfs_free_jh(bh);
+ unlock_buffer(bh);
+ }
+ loop_next:
+ put_bh(bh);
+ cond_resched_lock(lock);
+ }
+ if (chunk.nr) {
+ spin_unlock(lock);
write_ordered_chunk(&chunk);
- wait_on_buffer(bh);
- cond_resched();
- spin_lock(lock);
- goto loop_next;
- }
- if (buffer_dirty(bh)) {
- list_del_init(&jh->list);
- list_add(&jh->list, &tmp);
- add_to_chunk(&chunk, bh, lock, write_ordered_chunk);
- } else {
- reiserfs_free_jh(bh);
- unlock_buffer(bh);
+ spin_lock(lock);
}
-loop_next:
- put_bh(bh);
- cond_resched_lock(lock);
- }
- if (chunk.nr) {
- spin_unlock(lock);
- write_ordered_chunk(&chunk);
- spin_lock(lock);
- }
- while(!list_empty(&tmp)) {
- jh = JH_ENTRY(tmp.prev);
- bh = jh->bh;
- get_bh(bh);
- reiserfs_free_jh(bh);
-
- if (buffer_locked(bh)) {
- spin_unlock(lock);
- wait_on_buffer(bh);
- spin_lock(lock);
+ while (!list_empty(&tmp)) {
+ jh = JH_ENTRY(tmp.prev);
+ bh = jh->bh;
+ get_bh(bh);
+ reiserfs_free_jh(bh);
+
+ if (buffer_locked(bh)) {
+ spin_unlock(lock);
+ wait_on_buffer(bh);
+ spin_lock(lock);
+ }
+ if (!buffer_uptodate(bh)) {
+ ret = -EIO;
+ }
+ put_bh(bh);
+ cond_resched_lock(lock);
}
- if (!buffer_uptodate(bh)) {
- ret = -EIO;
- }
- put_bh(bh);
- cond_resched_lock(lock);
- }
- spin_unlock(lock);
- return ret;
-}
-
-static int flush_older_commits(struct super_block *s, struct reiserfs_journal_list *jl) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- struct reiserfs_journal_list *other_jl;
- struct reiserfs_journal_list *first_jl;
- struct list_head *entry;
- unsigned long trans_id = jl->j_trans_id;
- unsigned long other_trans_id;
- unsigned long first_trans_id;
-
-find_first:
- /*
- * first we walk backwards to find the oldest uncommitted transation
- */
- first_jl = jl;
- entry = jl->j_list.prev;
- while(1) {
- other_jl = JOURNAL_LIST_ENTRY(entry);
- if (entry == &journal->j_journal_list ||
- atomic_read(&other_jl->j_older_commits_done))
- break;
-
- first_jl = other_jl;
- entry = other_jl->j_list.prev;
- }
-
- /* if we didn't find any older uncommitted transactions, return now */
- if (first_jl == jl) {
- return 0;
- }
-
- first_trans_id = first_jl->j_trans_id;
+ spin_unlock(lock);
+ return ret;
+}
- entry = &first_jl->j_list;
- while(1) {
- other_jl = JOURNAL_LIST_ENTRY(entry);
- other_trans_id = other_jl->j_trans_id;
+static int flush_older_commits(struct super_block *s,
+ struct reiserfs_journal_list *jl)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ struct reiserfs_journal_list *other_jl;
+ struct reiserfs_journal_list *first_jl;
+ struct list_head *entry;
+ unsigned long trans_id = jl->j_trans_id;
+ unsigned long other_trans_id;
+ unsigned long first_trans_id;
+
+ find_first:
+ /*
+ * first we walk backwards to find the oldest uncommitted transation
+ */
+ first_jl = jl;
+ entry = jl->j_list.prev;
+ while (1) {
+ other_jl = JOURNAL_LIST_ENTRY(entry);
+ if (entry == &journal->j_journal_list ||
+ atomic_read(&other_jl->j_older_commits_done))
+ break;
- if (other_trans_id < trans_id) {
- if (atomic_read(&other_jl->j_commit_left) != 0) {
- flush_commit_list(s, other_jl, 0);
+ first_jl = other_jl;
+ entry = other_jl->j_list.prev;
+ }
- /* list we were called with is gone, return */
- if (!journal_list_still_alive(s, trans_id))
- return 1;
+ /* if we didn't find any older uncommitted transactions, return now */
+ if (first_jl == jl) {
+ return 0;
+ }
- /* the one we just flushed is gone, this means all
- * older lists are also gone, so first_jl is no longer
- * valid either. Go back to the beginning.
- */
- if (!journal_list_still_alive(s, other_trans_id)) {
- goto find_first;
+ first_trans_id = first_jl->j_trans_id;
+
+ entry = &first_jl->j_list;
+ while (1) {
+ other_jl = JOURNAL_LIST_ENTRY(entry);
+ other_trans_id = other_jl->j_trans_id;
+
+ if (other_trans_id < trans_id) {
+ if (atomic_read(&other_jl->j_commit_left) != 0) {
+ flush_commit_list(s, other_jl, 0);
+
+ /* list we were called with is gone, return */
+ if (!journal_list_still_alive(s, trans_id))
+ return 1;
+
+ /* the one we just flushed is gone, this means all
+ * older lists are also gone, so first_jl is no longer
+ * valid either. Go back to the beginning.
+ */
+ if (!journal_list_still_alive
+ (s, other_trans_id)) {
+ goto find_first;
+ }
+ }
+ entry = entry->next;
+ if (entry == &journal->j_journal_list)
+ return 0;
+ } else {
+ return 0;
}
- }
- entry = entry->next;
- if (entry == &journal->j_journal_list)
- return 0;
- } else {
- return 0;
}
- }
- return 0;
+ return 0;
}
-int reiserfs_async_progress_wait(struct super_block *s) {
- DEFINE_WAIT(wait);
- struct reiserfs_journal *j = SB_JOURNAL(s);
- if (atomic_read(&j->j_async_throttle))
- blk_congestion_wait(WRITE, HZ/10);
- return 0;
+int reiserfs_async_progress_wait(struct super_block *s)
+{
+ DEFINE_WAIT(wait);
+ struct reiserfs_journal *j = SB_JOURNAL(s);
+ if (atomic_read(&j->j_async_throttle))
+ blk_congestion_wait(WRITE, HZ / 10);
+ return 0;
}
/*
@@ -907,212 +967,225 @@ int reiserfs_async_progress_wait(struct super_block *s) {
** Before the commit block can by written, every other log block must be safely on disk
**
*/
-static int flush_commit_list(struct super_block *s, struct reiserfs_journal_list *jl, int flushall) {
- int i;
- int bn ;
- struct buffer_head *tbh = NULL ;
- unsigned long trans_id = jl->j_trans_id;
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- int barrier = 0;
- int retval = 0;
-
- reiserfs_check_lock_depth(s, "flush_commit_list") ;
-
- if (atomic_read(&jl->j_older_commits_done)) {
- return 0 ;
- }
-
- get_fs_excl();
-
- /* before we can put our commit blocks on disk, we have to make sure everyone older than
- ** us is on disk too
- */
- BUG_ON (jl->j_len <= 0);
- BUG_ON (trans_id == journal->j_trans_id);
-
- get_journal_list(jl);
- if (flushall) {
- if (flush_older_commits(s, jl) == 1) {
- /* list disappeared during flush_older_commits. return */
- goto put_jl;
- }
- }
-
- /* make sure nobody is trying to flush this one at the same time */
- down(&jl->j_commit_lock);
- if (!journal_list_still_alive(s, trans_id)) {
- up(&jl->j_commit_lock);
- goto put_jl;
- }
- BUG_ON (jl->j_trans_id == 0);
-
- /* this commit is done, exit */
- if (atomic_read(&(jl->j_commit_left)) <= 0) {
- if (flushall) {
- atomic_set(&(jl->j_older_commits_done), 1) ;
- }
- up(&jl->j_commit_lock);
- goto put_jl;
- }
-
- if (!list_empty(&jl->j_bh_list)) {
- unlock_kernel();
- write_ordered_buffers(&journal->j_dirty_buffers_lock,
- journal, jl, &jl->j_bh_list);
- lock_kernel();
- }
- BUG_ON (!list_empty(&jl->j_bh_list));
- /*
- * for the description block and all the log blocks, submit any buffers
- * that haven't already reached the disk
- */
- atomic_inc(&journal->j_async_throttle);
- for (i = 0 ; i < (jl->j_len + 1) ; i++) {
- bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start+i) %
- SB_ONDISK_JOURNAL_SIZE(s);
- tbh = journal_find_get_block(s, bn) ;
- if (buffer_dirty(tbh)) /* redundant, ll_rw_block() checks */
- ll_rw_block(WRITE, 1, &tbh) ;
- put_bh(tbh) ;
- }
- atomic_dec(&journal->j_async_throttle);
-
- /* wait on everything written so far before writing the commit
- * if we are in barrier mode, send the commit down now
- */
- barrier = reiserfs_barrier_flush(s);
- if (barrier) {
- int ret;
- lock_buffer(jl->j_commit_bh);
- ret = submit_barrier_buffer(jl->j_commit_bh);
- if (ret == -EOPNOTSUPP) {
- set_buffer_uptodate(jl->j_commit_bh);
- disable_barrier(s);
- barrier = 0;
- }
- }
- for (i = 0 ; i < (jl->j_len + 1) ; i++) {
- bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) +
- (jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s) ;
- tbh = journal_find_get_block(s, bn) ;
- wait_on_buffer(tbh) ;
- // since we're using ll_rw_blk above, it might have skipped over
- // a locked buffer. Double check here
- //
- if (buffer_dirty(tbh)) /* redundant, sync_dirty_buffer() checks */
- sync_dirty_buffer(tbh);
- if (unlikely (!buffer_uptodate(tbh))) {
+static int flush_commit_list(struct super_block *s,
+ struct reiserfs_journal_list *jl, int flushall)
+{
+ int i;
+ int bn;
+ struct buffer_head *tbh = NULL;
+ unsigned long trans_id = jl->j_trans_id;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ int barrier = 0;
+ int retval = 0;
+
+ reiserfs_check_lock_depth(s, "flush_commit_list");
+
+ if (atomic_read(&jl->j_older_commits_done)) {
+ return 0;
+ }
+
+ get_fs_excl();
+
+ /* before we can put our commit blocks on disk, we have to make sure everyone older than
+ ** us is on disk too
+ */
+ BUG_ON(jl->j_len <= 0);
+ BUG_ON(trans_id == journal->j_trans_id);
+
+ get_journal_list(jl);
+ if (flushall) {
+ if (flush_older_commits(s, jl) == 1) {
+ /* list disappeared during flush_older_commits. return */
+ goto put_jl;
+ }
+ }
+
+ /* make sure nobody is trying to flush this one at the same time */
+ down(&jl->j_commit_lock);
+ if (!journal_list_still_alive(s, trans_id)) {
+ up(&jl->j_commit_lock);
+ goto put_jl;
+ }
+ BUG_ON(jl->j_trans_id == 0);
+
+ /* this commit is done, exit */
+ if (atomic_read(&(jl->j_commit_left)) <= 0) {
+ if (flushall) {
+ atomic_set(&(jl->j_older_commits_done), 1);
+ }
+ up(&jl->j_commit_lock);
+ goto put_jl;
+ }
+
+ if (!list_empty(&jl->j_bh_list)) {
+ unlock_kernel();
+ write_ordered_buffers(&journal->j_dirty_buffers_lock,
+ journal, jl, &jl->j_bh_list);
+ lock_kernel();
+ }
+ BUG_ON(!list_empty(&jl->j_bh_list));
+ /*
+ * for the description block and all the log blocks, submit any buffers
+ * that haven't already reached the disk
+ */
+ atomic_inc(&journal->j_async_throttle);
+ for (i = 0; i < (jl->j_len + 1); i++) {
+ bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + (jl->j_start + i) %
+ SB_ONDISK_JOURNAL_SIZE(s);
+ tbh = journal_find_get_block(s, bn);
+ if (buffer_dirty(tbh)) /* redundant, ll_rw_block() checks */
+ ll_rw_block(WRITE, 1, &tbh);
+ put_bh(tbh);
+ }
+ atomic_dec(&journal->j_async_throttle);
+
+ /* wait on everything written so far before writing the commit
+ * if we are in barrier mode, send the commit down now
+ */
+ barrier = reiserfs_barrier_flush(s);
+ if (barrier) {
+ int ret;
+ lock_buffer(jl->j_commit_bh);
+ ret = submit_barrier_buffer(jl->j_commit_bh);
+ if (ret == -EOPNOTSUPP) {
+ set_buffer_uptodate(jl->j_commit_bh);
+ disable_barrier(s);
+ barrier = 0;
+ }
+ }
+ for (i = 0; i < (jl->j_len + 1); i++) {
+ bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) +
+ (jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s);
+ tbh = journal_find_get_block(s, bn);
+ wait_on_buffer(tbh);
+ // since we're using ll_rw_blk above, it might have skipped over
+ // a locked buffer. Double check here
+ //
+ if (buffer_dirty(tbh)) /* redundant, sync_dirty_buffer() checks */
+ sync_dirty_buffer(tbh);
+ if (unlikely(!buffer_uptodate(tbh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s, "journal-601, buffer write failed") ;
+ reiserfs_warning(s, "journal-601, buffer write failed");
#endif
- retval = -EIO;
- }
- put_bh(tbh) ; /* once for journal_find_get_block */
- put_bh(tbh) ; /* once due to original getblk in do_journal_end */
- atomic_dec(&(jl->j_commit_left)) ;
- }
-
- BUG_ON (atomic_read(&(jl->j_commit_left)) != 1);
-
- if (!barrier) {
- if (buffer_dirty(jl->j_commit_bh))
- BUG();
- mark_buffer_dirty(jl->j_commit_bh) ;
- sync_dirty_buffer(jl->j_commit_bh) ;
- } else
- wait_on_buffer(jl->j_commit_bh);
-
- check_barrier_completion(s, jl->j_commit_bh);
-
- /* If there was a write error in the journal - we can't commit this
- * transaction - it will be invalid and, if successful, will just end
- * up propogating the write error out to the filesystem. */
- if (unlikely (!buffer_uptodate(jl->j_commit_bh))) {
+ retval = -EIO;
+ }
+ put_bh(tbh); /* once for journal_find_get_block */
+ put_bh(tbh); /* once due to original getblk in do_journal_end */
+ atomic_dec(&(jl->j_commit_left));
+ }
+
+ BUG_ON(atomic_read(&(jl->j_commit_left)) != 1);
+
+ if (!barrier) {
+ if (buffer_dirty(jl->j_commit_bh))
+ BUG();
+ mark_buffer_dirty(jl->j_commit_bh);
+ sync_dirty_buffer(jl->j_commit_bh);
+ } else
+ wait_on_buffer(jl->j_commit_bh);
+
+ check_barrier_completion(s, jl->j_commit_bh);
+
+ /* If there was a write error in the journal - we can't commit this
+ * transaction - it will be invalid and, if successful, will just end
+ * up propogating the write error out to the filesystem. */
+ if (unlikely(!buffer_uptodate(jl->j_commit_bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s, "journal-615: buffer write failed") ;
+ reiserfs_warning(s, "journal-615: buffer write failed");
#endif
- retval = -EIO;
- }
- bforget(jl->j_commit_bh) ;
- if (journal->j_last_commit_id != 0 &&
- (jl->j_trans_id - journal->j_last_commit_id) != 1) {
- reiserfs_warning(s, "clm-2200: last commit %lu, current %lu",
- journal->j_last_commit_id,
- jl->j_trans_id);
- }
- journal->j_last_commit_id = jl->j_trans_id;
-
- /* now, every commit block is on the disk. It is safe to allow blocks freed during this transaction to be reallocated */
- cleanup_freed_for_journal_list(s, jl) ;
-
- retval = retval ? retval : journal->j_errno;
-
- /* mark the metadata dirty */
- if (!retval)
- dirty_one_transaction(s, jl);
- atomic_dec(&(jl->j_commit_left)) ;
-
- if (flushall) {
- atomic_set(&(jl->j_older_commits_done), 1) ;
- }
- up(&jl->j_commit_lock);
-put_jl:
- put_journal_list(s, jl);
-
- if (retval)
- reiserfs_abort (s, retval, "Journal write error in %s", __FUNCTION__);
- put_fs_excl();
- return retval;
+ retval = -EIO;
+ }
+ bforget(jl->j_commit_bh);
+ if (journal->j_last_commit_id != 0 &&
+ (jl->j_trans_id - journal->j_last_commit_id) != 1) {
+ reiserfs_warning(s, "clm-2200: last commit %lu, current %lu",
+ journal->j_last_commit_id, jl->j_trans_id);
+ }
+ journal->j_last_commit_id = jl->j_trans_id;
+
+ /* now, every commit block is on the disk. It is safe to allow blocks freed during this transaction to be reallocated */
+ cleanup_freed_for_journal_list(s, jl);
+
+ retval = retval ? retval : journal->j_errno;
+
+ /* mark the metadata dirty */
+ if (!retval)
+ dirty_one_transaction(s, jl);
+ atomic_dec(&(jl->j_commit_left));
+
+ if (flushall) {
+ atomic_set(&(jl->j_older_commits_done), 1);
+ }
+ up(&jl->j_commit_lock);
+ put_jl:
+ put_journal_list(s, jl);
+
+ if (retval)
+ reiserfs_abort(s, retval, "Journal write error in %s",
+ __FUNCTION__);
+ put_fs_excl();
+ return retval;
}
/*
** flush_journal_list frequently needs to find a newer transaction for a given block. This does that, or
** returns NULL if it can't find anything
*/
-static struct reiserfs_journal_list *find_newer_jl_for_cn(struct reiserfs_journal_cnode *cn) {
- struct super_block *sb = cn->sb;
- b_blocknr_t blocknr = cn->blocknr ;
+static struct reiserfs_journal_list *find_newer_jl_for_cn(struct
+ reiserfs_journal_cnode
+ *cn)
+{
+ struct super_block *sb = cn->sb;
+ b_blocknr_t blocknr = cn->blocknr;
- cn = cn->hprev ;
- while(cn) {
- if (cn->sb == sb && cn->blocknr == blocknr && cn->jlist) {
- return cn->jlist ;
- }
- cn = cn->hprev ;
- }
- return NULL ;
+ cn = cn->hprev;
+ while (cn) {
+ if (cn->sb == sb && cn->blocknr == blocknr && cn->jlist) {
+ return cn->jlist;
+ }
+ cn = cn->hprev;
+ }
+ return NULL;
}
-static void remove_journal_hash(struct super_block *, struct reiserfs_journal_cnode **,
-struct reiserfs_journal_list *, unsigned long, int);
+static void remove_journal_hash(struct super_block *,
+ struct reiserfs_journal_cnode **,
+ struct reiserfs_journal_list *, unsigned long,
+ int);
/*
** once all the real blocks have been flushed, it is safe to remove them from the
** journal list for this transaction. Aside from freeing the cnode, this also allows the
** block to be reallocated for data blocks if it had been deleted.
*/
-static void remove_all_from_journal_list(struct super_block *p_s_sb, struct reiserfs_journal_list *jl, int debug) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_cnode *cn, *last ;
- cn = jl->j_realblock ;
-
- /* which is better, to lock once around the whole loop, or
- ** to lock for each call to remove_journal_hash?
- */
- while(cn) {
- if (cn->blocknr != 0) {
- if (debug) {
- reiserfs_warning (p_s_sb, "block %u, bh is %d, state %ld", cn->blocknr,
- cn->bh ? 1: 0, cn->state) ;
- }
- cn->state = 0 ;
- remove_journal_hash(p_s_sb, journal->j_list_hash_table, jl, cn->blocknr, 1) ;
- }
- last = cn ;
- cn = cn->next ;
- free_cnode(p_s_sb, last) ;
- }
- jl->j_realblock = NULL ;
+static void remove_all_from_journal_list(struct super_block *p_s_sb,
+ struct reiserfs_journal_list *jl,
+ int debug)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_cnode *cn, *last;
+ cn = jl->j_realblock;
+
+ /* which is better, to lock once around the whole loop, or
+ ** to lock for each call to remove_journal_hash?
+ */
+ while (cn) {
+ if (cn->blocknr != 0) {
+ if (debug) {
+ reiserfs_warning(p_s_sb,
+ "block %u, bh is %d, state %ld",
+ cn->blocknr, cn->bh ? 1 : 0,
+ cn->state);
+ }
+ cn->state = 0;
+ remove_journal_hash(p_s_sb, journal->j_list_hash_table,
+ jl, cn->blocknr, 1);
+ }
+ last = cn;
+ cn = cn->next;
+ free_cnode(p_s_sb, last);
+ }
+ jl->j_realblock = NULL;
}
/*
@@ -1122,98 +1195,107 @@ static void remove_all_from_journal_list(struct super_block *p_s_sb, struct reis
** called by flush_journal_list, before it calls remove_all_from_journal_list
**
*/
-static int _update_journal_header_block(struct super_block *p_s_sb, unsigned long offset, unsigned long trans_id) {
- struct reiserfs_journal_header *jh ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+static int _update_journal_header_block(struct super_block *p_s_sb,
+ unsigned long offset,
+ unsigned long trans_id)
+{
+ struct reiserfs_journal_header *jh;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
- if (reiserfs_is_journal_aborted (journal))
- return -EIO;
+ if (reiserfs_is_journal_aborted(journal))
+ return -EIO;
- if (trans_id >= journal->j_last_flush_trans_id) {
- if (buffer_locked((journal->j_header_bh))) {
- wait_on_buffer((journal->j_header_bh)) ;
- if (unlikely (!buffer_uptodate(journal->j_header_bh))) {
+ if (trans_id >= journal->j_last_flush_trans_id) {
+ if (buffer_locked((journal->j_header_bh))) {
+ wait_on_buffer((journal->j_header_bh));
+ if (unlikely(!buffer_uptodate(journal->j_header_bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning (p_s_sb, "journal-699: buffer write failed") ;
+ reiserfs_warning(p_s_sb,
+ "journal-699: buffer write failed");
#endif
- return -EIO;
- }
- }
- journal->j_last_flush_trans_id = trans_id ;
- journal->j_first_unflushed_offset = offset ;
- jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data) ;
- jh->j_last_flush_trans_id = cpu_to_le32(trans_id) ;
- jh->j_first_unflushed_offset = cpu_to_le32(offset) ;
- jh->j_mount_id = cpu_to_le32(journal->j_mount_id) ;
-
- if (reiserfs_barrier_flush(p_s_sb)) {
- int ret;
- lock_buffer(journal->j_header_bh);
- ret = submit_barrier_buffer(journal->j_header_bh);
- if (ret == -EOPNOTSUPP) {
- set_buffer_uptodate(journal->j_header_bh);
- disable_barrier(p_s_sb);
- goto sync;
- }
- wait_on_buffer(journal->j_header_bh);
- check_barrier_completion(p_s_sb, journal->j_header_bh);
- } else {
-sync:
- set_buffer_dirty(journal->j_header_bh) ;
- sync_dirty_buffer(journal->j_header_bh) ;
- }
- if (!buffer_uptodate(journal->j_header_bh)) {
- reiserfs_warning (p_s_sb, "journal-837: IO error during journal replay");
- return -EIO ;
- }
- }
- return 0 ;
-}
-
-static int update_journal_header_block(struct super_block *p_s_sb,
- unsigned long offset,
- unsigned long trans_id) {
- return _update_journal_header_block(p_s_sb, offset, trans_id);
+ return -EIO;
+ }
+ }
+ journal->j_last_flush_trans_id = trans_id;
+ journal->j_first_unflushed_offset = offset;
+ jh = (struct reiserfs_journal_header *)(journal->j_header_bh->
+ b_data);
+ jh->j_last_flush_trans_id = cpu_to_le32(trans_id);
+ jh->j_first_unflushed_offset = cpu_to_le32(offset);
+ jh->j_mount_id = cpu_to_le32(journal->j_mount_id);
+
+ if (reiserfs_barrier_flush(p_s_sb)) {
+ int ret;
+ lock_buffer(journal->j_header_bh);
+ ret = submit_barrier_buffer(journal->j_header_bh);
+ if (ret == -EOPNOTSUPP) {
+ set_buffer_uptodate(journal->j_header_bh);
+ disable_barrier(p_s_sb);
+ goto sync;
+ }
+ wait_on_buffer(journal->j_header_bh);
+ check_barrier_completion(p_s_sb, journal->j_header_bh);
+ } else {
+ sync:
+ set_buffer_dirty(journal->j_header_bh);
+ sync_dirty_buffer(journal->j_header_bh);
+ }
+ if (!buffer_uptodate(journal->j_header_bh)) {
+ reiserfs_warning(p_s_sb,
+ "journal-837: IO error during journal replay");
+ return -EIO;
+ }
+ }
+ return 0;
}
+
+static int update_journal_header_block(struct super_block *p_s_sb,
+ unsigned long offset,
+ unsigned long trans_id)
+{
+ return _update_journal_header_block(p_s_sb, offset, trans_id);
+}
+
/*
** flush any and all journal lists older than you are
** can only be called from flush_journal_list
*/
static int flush_older_journal_lists(struct super_block *p_s_sb,
- struct reiserfs_journal_list *jl)
-{
- struct list_head *entry;
- struct reiserfs_journal_list *other_jl ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- unsigned long trans_id = jl->j_trans_id;
-
- /* we know we are the only ones flushing things, no extra race
- * protection is required.
- */
-restart:
- entry = journal->j_journal_list.next;
- /* Did we wrap? */
- if (entry == &journal->j_journal_list)
- return 0;
- other_jl = JOURNAL_LIST_ENTRY(entry);
- if (other_jl->j_trans_id < trans_id) {
- BUG_ON (other_jl->j_refcount <= 0);
- /* do not flush all */
- flush_journal_list(p_s_sb, other_jl, 0) ;
-
- /* other_jl is now deleted from the list */
- goto restart;
- }
- return 0 ;
+ struct reiserfs_journal_list *jl)
+{
+ struct list_head *entry;
+ struct reiserfs_journal_list *other_jl;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ unsigned long trans_id = jl->j_trans_id;
+
+ /* we know we are the only ones flushing things, no extra race
+ * protection is required.
+ */
+ restart:
+ entry = journal->j_journal_list.next;
+ /* Did we wrap? */
+ if (entry == &journal->j_journal_list)
+ return 0;
+ other_jl = JOURNAL_LIST_ENTRY(entry);
+ if (other_jl->j_trans_id < trans_id) {
+ BUG_ON(other_jl->j_refcount <= 0);
+ /* do not flush all */
+ flush_journal_list(p_s_sb, other_jl, 0);
+
+ /* other_jl is now deleted from the list */
+ goto restart;
+ }
+ return 0;
}
static void del_from_work_list(struct super_block *s,
- struct reiserfs_journal_list *jl) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- if (!list_empty(&jl->j_working_list)) {
- list_del_init(&jl->j_working_list);
- journal->j_num_work_lists--;
- }
+ struct reiserfs_journal_list *jl)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ if (!list_empty(&jl->j_working_list)) {
+ list_del_init(&jl->j_working_list);
+ journal->j_num_work_lists--;
+ }
}
/* flush a journal list, both commit and real blocks
@@ -1225,386 +1307,407 @@ static void del_from_work_list(struct super_block *s,
** and the journal is locked. That means it can only be called from
** do_journal_end, or by journal_release
*/
-static int flush_journal_list(struct super_block *s,
- struct reiserfs_journal_list *jl, int flushall) {
- struct reiserfs_journal_list *pjl ;
- struct reiserfs_journal_cnode *cn, *last ;
- int count ;
- int was_jwait = 0 ;
- int was_dirty = 0 ;
- struct buffer_head *saved_bh ;
- unsigned long j_len_saved = jl->j_len ;
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- int err = 0;
-
- BUG_ON (j_len_saved <= 0);
-
- if (atomic_read(&journal->j_wcount) != 0) {
- reiserfs_warning(s, "clm-2048: flush_journal_list called with wcount %d",
- atomic_read(&journal->j_wcount)) ;
- }
- BUG_ON (jl->j_trans_id == 0);
-
- /* if flushall == 0, the lock is already held */
- if (flushall) {
- down(&journal->j_flush_sem);
- } else if (!down_trylock(&journal->j_flush_sem)) {
- BUG();
- }
-
- count = 0 ;
- if (j_len_saved > journal->j_trans_max) {
- reiserfs_panic(s, "journal-715: flush_journal_list, length is %lu, trans id %lu\n", j_len_saved, jl->j_trans_id);
- return 0 ;
- }
-
- get_fs_excl();
-
- /* if all the work is already done, get out of here */
- if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
- atomic_read(&(jl->j_commit_left)) <= 0) {
- goto flush_older_and_return ;
- }
-
- /* start by putting the commit list on disk. This will also flush
- ** the commit lists of any olders transactions
- */
- flush_commit_list(s, jl, 1) ;
-
- if (!(jl->j_state & LIST_DIRTY) && !reiserfs_is_journal_aborted (journal))
- BUG();
-
- /* are we done now? */
- if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
- atomic_read(&(jl->j_commit_left)) <= 0) {
- goto flush_older_and_return ;
- }
-
- /* loop through each cnode, see if we need to write it,
- ** or wait on a more recent transaction, or just ignore it
- */
- if (atomic_read(&(journal->j_wcount)) != 0) {
- reiserfs_panic(s, "journal-844: panic journal list is flushing, wcount is not 0\n") ;
- }
- cn = jl->j_realblock ;
- while(cn) {
- was_jwait = 0 ;
- was_dirty = 0 ;
- saved_bh = NULL ;
- /* blocknr of 0 is no longer in the hash, ignore it */
- if (cn->blocknr == 0) {
- goto free_cnode ;
- }
-
- /* This transaction failed commit. Don't write out to the disk */
- if (!(jl->j_state & LIST_DIRTY))
- goto free_cnode;
-
- pjl = find_newer_jl_for_cn(cn) ;
- /* the order is important here. We check pjl to make sure we
- ** don't clear BH_JDirty_wait if we aren't the one writing this
- ** block to disk
- */
- if (!pjl && cn->bh) {
- saved_bh = cn->bh ;
-
- /* we do this to make sure nobody releases the buffer while
- ** we are working with it
- */
- get_bh(saved_bh) ;
-
- if (buffer_journal_dirty(saved_bh)) {
- BUG_ON (!can_dirty (cn));
- was_jwait = 1 ;
- was_dirty = 1 ;
- } else if (can_dirty(cn)) {
- /* everything with !pjl && jwait should be writable */
- BUG();
- }
- }
-
- /* if someone has this block in a newer transaction, just make
- ** sure they are commited, and don't try writing it to disk
- */
- if (pjl) {
- if (atomic_read(&pjl->j_commit_left))
- flush_commit_list(s, pjl, 1) ;
- goto free_cnode ;
- }
-
- /* bh == NULL when the block got to disk on its own, OR,
- ** the block got freed in a future transaction
- */
- if (saved_bh == NULL) {
- goto free_cnode ;
- }
-
- /* this should never happen. kupdate_one_transaction has this list
- ** locked while it works, so we should never see a buffer here that
- ** is not marked JDirty_wait
- */
- if ((!was_jwait) && !buffer_locked(saved_bh)) {
- reiserfs_warning (s, "journal-813: BAD! buffer %llu %cdirty %cjwait, "
- "not in a newer tranasction",
- (unsigned long long)saved_bh->b_blocknr,
- was_dirty ? ' ' : '!', was_jwait ? ' ' : '!') ;
- }
- if (was_dirty) {
- /* we inc again because saved_bh gets decremented at free_cnode */
- get_bh(saved_bh) ;
- set_bit(BLOCK_NEEDS_FLUSH, &cn->state) ;
- lock_buffer(saved_bh);
- BUG_ON (cn->blocknr != saved_bh->b_blocknr);
- if (buffer_dirty(saved_bh))
- submit_logged_buffer(saved_bh) ;
- else
- unlock_buffer(saved_bh);
- count++ ;
- } else {
- reiserfs_warning (s, "clm-2082: Unable to flush buffer %llu in %s",
- (unsigned long long)saved_bh->b_blocknr, __FUNCTION__);
- }
-free_cnode:
- last = cn ;
- cn = cn->next ;
- if (saved_bh) {
- /* we incremented this to keep others from taking the buffer head away */
- put_bh(saved_bh) ;
- if (atomic_read(&(saved_bh->b_count)) < 0) {
- reiserfs_warning (s, "journal-945: saved_bh->b_count < 0");
- }
- }
- }
- if (count > 0) {
- cn = jl->j_realblock ;
- while(cn) {
- if (test_bit(BLOCK_NEEDS_FLUSH, &cn->state)) {
- if (!cn->bh) {
- reiserfs_panic(s, "journal-1011: cn->bh is NULL\n") ;
- }
- wait_on_buffer(cn->bh) ;
- if (!cn->bh) {
- reiserfs_panic(s, "journal-1012: cn->bh is NULL\n") ;
- }
- if (unlikely (!buffer_uptodate(cn->bh))) {
+static int flush_journal_list(struct super_block *s,
+ struct reiserfs_journal_list *jl, int flushall)
+{
+ struct reiserfs_journal_list *pjl;
+ struct reiserfs_journal_cnode *cn, *last;
+ int count;
+ int was_jwait = 0;
+ int was_dirty = 0;
+ struct buffer_head *saved_bh;
+ unsigned long j_len_saved = jl->j_len;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ int err = 0;
+
+ BUG_ON(j_len_saved <= 0);
+
+ if (atomic_read(&journal->j_wcount) != 0) {
+ reiserfs_warning(s,
+ "clm-2048: flush_journal_list called with wcount %d",
+ atomic_read(&journal->j_wcount));
+ }
+ BUG_ON(jl->j_trans_id == 0);
+
+ /* if flushall == 0, the lock is already held */
+ if (flushall) {
+ down(&journal->j_flush_sem);
+ } else if (!down_trylock(&journal->j_flush_sem)) {
+ BUG();
+ }
+
+ count = 0;
+ if (j_len_saved > journal->j_trans_max) {
+ reiserfs_panic(s,
+ "journal-715: flush_journal_list, length is %lu, trans id %lu\n",
+ j_len_saved, jl->j_trans_id);
+ return 0;
+ }
+
+ get_fs_excl();
+
+ /* if all the work is already done, get out of here */
+ if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
+ atomic_read(&(jl->j_commit_left)) <= 0) {
+ goto flush_older_and_return;
+ }
+
+ /* start by putting the commit list on disk. This will also flush
+ ** the commit lists of any olders transactions
+ */
+ flush_commit_list(s, jl, 1);
+
+ if (!(jl->j_state & LIST_DIRTY)
+ && !reiserfs_is_journal_aborted(journal))
+ BUG();
+
+ /* are we done now? */
+ if (atomic_read(&(jl->j_nonzerolen)) <= 0 &&
+ atomic_read(&(jl->j_commit_left)) <= 0) {
+ goto flush_older_and_return;
+ }
+
+ /* loop through each cnode, see if we need to write it,
+ ** or wait on a more recent transaction, or just ignore it
+ */
+ if (atomic_read(&(journal->j_wcount)) != 0) {
+ reiserfs_panic(s,
+ "journal-844: panic journal list is flushing, wcount is not 0\n");
+ }
+ cn = jl->j_realblock;
+ while (cn) {
+ was_jwait = 0;
+ was_dirty = 0;
+ saved_bh = NULL;
+ /* blocknr of 0 is no longer in the hash, ignore it */
+ if (cn->blocknr == 0) {
+ goto free_cnode;
+ }
+
+ /* This transaction failed commit. Don't write out to the disk */
+ if (!(jl->j_state & LIST_DIRTY))
+ goto free_cnode;
+
+ pjl = find_newer_jl_for_cn(cn);
+ /* the order is important here. We check pjl to make sure we
+ ** don't clear BH_JDirty_wait if we aren't the one writing this
+ ** block to disk
+ */
+ if (!pjl && cn->bh) {
+ saved_bh = cn->bh;
+
+ /* we do this to make sure nobody releases the buffer while
+ ** we are working with it
+ */
+ get_bh(saved_bh);
+
+ if (buffer_journal_dirty(saved_bh)) {
+ BUG_ON(!can_dirty(cn));
+ was_jwait = 1;
+ was_dirty = 1;
+ } else if (can_dirty(cn)) {
+ /* everything with !pjl && jwait should be writable */
+ BUG();
+ }
+ }
+
+ /* if someone has this block in a newer transaction, just make
+ ** sure they are commited, and don't try writing it to disk
+ */
+ if (pjl) {
+ if (atomic_read(&pjl->j_commit_left))
+ flush_commit_list(s, pjl, 1);
+ goto free_cnode;
+ }
+
+ /* bh == NULL when the block got to disk on its own, OR,
+ ** the block got freed in a future transaction
+ */
+ if (saved_bh == NULL) {
+ goto free_cnode;
+ }
+
+ /* this should never happen. kupdate_one_transaction has this list
+ ** locked while it works, so we should never see a buffer here that
+ ** is not marked JDirty_wait
+ */
+ if ((!was_jwait) && !buffer_locked(saved_bh)) {
+ reiserfs_warning(s,
+ "journal-813: BAD! buffer %llu %cdirty %cjwait, "
+ "not in a newer tranasction",
+ (unsigned long long)saved_bh->
+ b_blocknr, was_dirty ? ' ' : '!',
+ was_jwait ? ' ' : '!');
+ }
+ if (was_dirty) {
+ /* we inc again because saved_bh gets decremented at free_cnode */
+ get_bh(saved_bh);
+ set_bit(BLOCK_NEEDS_FLUSH, &cn->state);
+ lock_buffer(saved_bh);
+ BUG_ON(cn->blocknr != saved_bh->b_blocknr);
+ if (buffer_dirty(saved_bh))
+ submit_logged_buffer(saved_bh);
+ else
+ unlock_buffer(saved_bh);
+ count++;
+ } else {
+ reiserfs_warning(s,
+ "clm-2082: Unable to flush buffer %llu in %s",
+ (unsigned long long)saved_bh->
+ b_blocknr, __FUNCTION__);
+ }
+ free_cnode:
+ last = cn;
+ cn = cn->next;
+ if (saved_bh) {
+ /* we incremented this to keep others from taking the buffer head away */
+ put_bh(saved_bh);
+ if (atomic_read(&(saved_bh->b_count)) < 0) {
+ reiserfs_warning(s,
+ "journal-945: saved_bh->b_count < 0");
+ }
+ }
+ }
+ if (count > 0) {
+ cn = jl->j_realblock;
+ while (cn) {
+ if (test_bit(BLOCK_NEEDS_FLUSH, &cn->state)) {
+ if (!cn->bh) {
+ reiserfs_panic(s,
+ "journal-1011: cn->bh is NULL\n");
+ }
+ wait_on_buffer(cn->bh);
+ if (!cn->bh) {
+ reiserfs_panic(s,
+ "journal-1012: cn->bh is NULL\n");
+ }
+ if (unlikely(!buffer_uptodate(cn->bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s, "journal-949: buffer write failed\n") ;
+ reiserfs_warning(s,
+ "journal-949: buffer write failed\n");
#endif
- err = -EIO;
- }
- /* note, we must clear the JDirty_wait bit after the up to date
- ** check, otherwise we race against our flushpage routine
- */
- BUG_ON (!test_clear_buffer_journal_dirty (cn->bh));
-
- /* undo the inc from journal_mark_dirty */
- put_bh(cn->bh) ;
- brelse(cn->bh) ;
- }
- cn = cn->next ;
- }
- }
-
- if (err)
- reiserfs_abort (s, -EIO, "Write error while pushing transaction to disk in %s", __FUNCTION__);
-flush_older_and_return:
-
-
- /* before we can update the journal header block, we _must_ flush all
- ** real blocks from all older transactions to disk. This is because
- ** once the header block is updated, this transaction will not be
- ** replayed after a crash
- */
- if (flushall) {
- flush_older_journal_lists(s, jl);
- }
-
- err = journal->j_errno;
- /* before we can remove everything from the hash tables for this
- ** transaction, we must make sure it can never be replayed
- **
- ** since we are only called from do_journal_end, we know for sure there
- ** are no allocations going on while we are flushing journal lists. So,
- ** we only need to update the journal header block for the last list
- ** being flushed
- */
- if (!err && flushall) {
- err = update_journal_header_block(s, (jl->j_start + jl->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(s), jl->j_trans_id) ;
- if (err)
- reiserfs_abort (s, -EIO, "Write error while updating journal header in %s", __FUNCTION__);
- }
- remove_all_from_journal_list(s, jl, 0) ;
- list_del_init(&jl->j_list);
- journal->j_num_lists--;
- del_from_work_list(s, jl);
-
- if (journal->j_last_flush_id != 0 &&
- (jl->j_trans_id - journal->j_last_flush_id) != 1) {
- reiserfs_warning(s, "clm-2201: last flush %lu, current %lu",
- journal->j_last_flush_id,
- jl->j_trans_id);
- }
- journal->j_last_flush_id = jl->j_trans_id;
-
- /* not strictly required since we are freeing the list, but it should
- * help find code using dead lists later on
- */
- jl->j_len = 0 ;
- atomic_set(&(jl->j_nonzerolen), 0) ;
- jl->j_start = 0 ;
- jl->j_realblock = NULL ;
- jl->j_commit_bh = NULL ;
- jl->j_trans_id = 0 ;
- jl->j_state = 0;
- put_journal_list(s, jl);
- if (flushall)
- up(&journal->j_flush_sem);
- put_fs_excl();
- return err ;
-}
+ err = -EIO;
+ }
+ /* note, we must clear the JDirty_wait bit after the up to date
+ ** check, otherwise we race against our flushpage routine
+ */
+ BUG_ON(!test_clear_buffer_journal_dirty
+ (cn->bh));
+
+ /* undo the inc from journal_mark_dirty */
+ put_bh(cn->bh);
+ brelse(cn->bh);
+ }
+ cn = cn->next;
+ }
+ }
+
+ if (err)
+ reiserfs_abort(s, -EIO,
+ "Write error while pushing transaction to disk in %s",
+ __FUNCTION__);
+ flush_older_and_return:
+
+ /* before we can update the journal header block, we _must_ flush all
+ ** real blocks from all older transactions to disk. This is because
+ ** once the header block is updated, this transaction will not be
+ ** replayed after a crash
+ */
+ if (flushall) {
+ flush_older_journal_lists(s, jl);
+ }
+
+ err = journal->j_errno;
+ /* before we can remove everything from the hash tables for this
+ ** transaction, we must make sure it can never be replayed
+ **
+ ** since we are only called from do_journal_end, we know for sure there
+ ** are no allocations going on while we are flushing journal lists. So,
+ ** we only need to update the journal header block for the last list
+ ** being flushed
+ */
+ if (!err && flushall) {
+ err =
+ update_journal_header_block(s,
+ (jl->j_start + jl->j_len +
+ 2) % SB_ONDISK_JOURNAL_SIZE(s),
+ jl->j_trans_id);
+ if (err)
+ reiserfs_abort(s, -EIO,
+ "Write error while updating journal header in %s",
+ __FUNCTION__);
+ }
+ remove_all_from_journal_list(s, jl, 0);
+ list_del_init(&jl->j_list);
+ journal->j_num_lists--;
+ del_from_work_list(s, jl);
+
+ if (journal->j_last_flush_id != 0 &&
+ (jl->j_trans_id - journal->j_last_flush_id) != 1) {
+ reiserfs_warning(s, "clm-2201: last flush %lu, current %lu",
+ journal->j_last_flush_id, jl->j_trans_id);
+ }
+ journal->j_last_flush_id = jl->j_trans_id;
+
+ /* not strictly required since we are freeing the list, but it should
+ * help find code using dead lists later on
+ */
+ jl->j_len = 0;
+ atomic_set(&(jl->j_nonzerolen), 0);
+ jl->j_start = 0;
+ jl->j_realblock = NULL;
+ jl->j_commit_bh = NULL;
+ jl->j_trans_id = 0;
+ jl->j_state = 0;
+ put_journal_list(s, jl);
+ if (flushall)
+ up(&journal->j_flush_sem);
+ put_fs_excl();
+ return err;
+}
static int write_one_transaction(struct super_block *s,
- struct reiserfs_journal_list *jl,
+ struct reiserfs_journal_list *jl,
struct buffer_chunk *chunk)
{
- struct reiserfs_journal_cnode *cn;
- int ret = 0 ;
-
- jl->j_state |= LIST_TOUCHED;
- del_from_work_list(s, jl);
- if (jl->j_len == 0 || atomic_read(&jl->j_nonzerolen) == 0) {
- return 0;
- }
-
- cn = jl->j_realblock ;
- while(cn) {
- /* if the blocknr == 0, this has been cleared from the hash,
- ** skip it
- */
- if (cn->blocknr == 0) {
- goto next ;
- }
- if (cn->bh && can_dirty(cn) && buffer_dirty(cn->bh)) {
- struct buffer_head *tmp_bh;
- /* we can race against journal_mark_freed when we try
- * to lock_buffer(cn->bh), so we have to inc the buffer
- * count, and recheck things after locking
- */
- tmp_bh = cn->bh;
- get_bh(tmp_bh);
- lock_buffer(tmp_bh);
- if (cn->bh && can_dirty(cn) && buffer_dirty(tmp_bh)) {
- if (!buffer_journal_dirty(tmp_bh) ||
- buffer_journal_prepared(tmp_bh))
- BUG();
- add_to_chunk(chunk, tmp_bh, NULL, write_chunk);
- ret++;
- } else {
- /* note, cn->bh might be null now */
- unlock_buffer(tmp_bh);
- }
- put_bh(tmp_bh);
- }
-next:
- cn = cn->next ;
- cond_resched();
- }
- return ret ;
+ struct reiserfs_journal_cnode *cn;
+ int ret = 0;
+
+ jl->j_state |= LIST_TOUCHED;
+ del_from_work_list(s, jl);
+ if (jl->j_len == 0 || atomic_read(&jl->j_nonzerolen) == 0) {
+ return 0;
+ }
+
+ cn = jl->j_realblock;
+ while (cn) {
+ /* if the blocknr == 0, this has been cleared from the hash,
+ ** skip it
+ */
+ if (cn->blocknr == 0) {
+ goto next;
+ }
+ if (cn->bh && can_dirty(cn) && buffer_dirty(cn->bh)) {
+ struct buffer_head *tmp_bh;
+ /* we can race against journal_mark_freed when we try
+ * to lock_buffer(cn->bh), so we have to inc the buffer
+ * count, and recheck things after locking
+ */
+ tmp_bh = cn->bh;
+ get_bh(tmp_bh);
+ lock_buffer(tmp_bh);
+ if (cn->bh && can_dirty(cn) && buffer_dirty(tmp_bh)) {
+ if (!buffer_journal_dirty(tmp_bh) ||
+ buffer_journal_prepared(tmp_bh))
+ BUG();
+ add_to_chunk(chunk, tmp_bh, NULL, write_chunk);
+ ret++;
+ } else {
+ /* note, cn->bh might be null now */
+ unlock_buffer(tmp_bh);
+ }
+ put_bh(tmp_bh);
+ }
+ next:
+ cn = cn->next;
+ cond_resched();
+ }
+ return ret;
}
/* used by flush_commit_list */
static int dirty_one_transaction(struct super_block *s,
- struct reiserfs_journal_list *jl)
-{
- struct reiserfs_journal_cnode *cn;
- struct reiserfs_journal_list *pjl;
- int ret = 0 ;
-
- jl->j_state |= LIST_DIRTY;
- cn = jl->j_realblock ;
- while(cn) {
- /* look for a more recent transaction that logged this
- ** buffer. Only the most recent transaction with a buffer in
- ** it is allowed to send that buffer to disk
- */
- pjl = find_newer_jl_for_cn(cn) ;
- if (!pjl && cn->blocknr && cn->bh && buffer_journal_dirty(cn->bh))
- {
- BUG_ON (!can_dirty(cn));
- /* if the buffer is prepared, it will either be logged
- * or restored. If restored, we need to make sure
- * it actually gets marked dirty
- */
- clear_buffer_journal_new (cn->bh);
- if (buffer_journal_prepared (cn->bh)) {
- set_buffer_journal_restore_dirty (cn->bh);
- } else {
- set_buffer_journal_test (cn->bh);
- mark_buffer_dirty(cn->bh);
- }
- }
- cn = cn->next ;
- }
- return ret ;
+ struct reiserfs_journal_list *jl)
+{
+ struct reiserfs_journal_cnode *cn;
+ struct reiserfs_journal_list *pjl;
+ int ret = 0;
+
+ jl->j_state |= LIST_DIRTY;
+ cn = jl->j_realblock;
+ while (cn) {
+ /* look for a more recent transaction that logged this
+ ** buffer. Only the most recent transaction with a buffer in
+ ** it is allowed to send that buffer to disk
+ */
+ pjl = find_newer_jl_for_cn(cn);
+ if (!pjl && cn->blocknr && cn->bh
+ && buffer_journal_dirty(cn->bh)) {
+ BUG_ON(!can_dirty(cn));
+ /* if the buffer is prepared, it will either be logged
+ * or restored. If restored, we need to make sure
+ * it actually gets marked dirty
+ */
+ clear_buffer_journal_new(cn->bh);
+ if (buffer_journal_prepared(cn->bh)) {
+ set_buffer_journal_restore_dirty(cn->bh);
+ } else {
+ set_buffer_journal_test(cn->bh);
+ mark_buffer_dirty(cn->bh);
+ }
+ }
+ cn = cn->next;
+ }
+ return ret;
}
static int kupdate_transactions(struct super_block *s,
- struct reiserfs_journal_list *jl,
- struct reiserfs_journal_list **next_jl,
- unsigned long *next_trans_id,
- int num_blocks,
- int num_trans) {
- int ret = 0;
- int written = 0 ;
- int transactions_flushed = 0;
- unsigned long orig_trans_id = jl->j_trans_id;
- struct buffer_chunk chunk;
- struct list_head *entry;
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- chunk.nr = 0;
-
- down(&journal->j_flush_sem);
- if (!journal_list_still_alive(s, orig_trans_id)) {
- goto done;
- }
-
- /* we've got j_flush_sem held, nobody is going to delete any
- * of these lists out from underneath us
- */
- while((num_trans && transactions_flushed < num_trans) ||
- (!num_trans && written < num_blocks)) {
-
- if (jl->j_len == 0 || (jl->j_state & LIST_TOUCHED) ||
- atomic_read(&jl->j_commit_left) || !(jl->j_state & LIST_DIRTY))
- {
- del_from_work_list(s, jl);
- break;
- }
- ret = write_one_transaction(s, jl, &chunk);
-
- if (ret < 0)
- goto done;
- transactions_flushed++;
- written += ret;
- entry = jl->j_list.next;
-
- /* did we wrap? */
- if (entry == &journal->j_journal_list) {
- break;
- }
- jl = JOURNAL_LIST_ENTRY(entry);
-
- /* don't bother with older transactions */
- if (jl->j_trans_id <= orig_trans_id)
- break;
- }
- if (chunk.nr) {
- write_chunk(&chunk);
- }
-
-done:
- up(&journal->j_flush_sem);
- return ret;
+ struct reiserfs_journal_list *jl,
+ struct reiserfs_journal_list **next_jl,
+ unsigned long *next_trans_id,
+ int num_blocks, int num_trans)
+{
+ int ret = 0;
+ int written = 0;
+ int transactions_flushed = 0;
+ unsigned long orig_trans_id = jl->j_trans_id;
+ struct buffer_chunk chunk;
+ struct list_head *entry;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ chunk.nr = 0;
+
+ down(&journal->j_flush_sem);
+ if (!journal_list_still_alive(s, orig_trans_id)) {
+ goto done;
+ }
+
+ /* we've got j_flush_sem held, nobody is going to delete any
+ * of these lists out from underneath us
+ */
+ while ((num_trans && transactions_flushed < num_trans) ||
+ (!num_trans && written < num_blocks)) {
+
+ if (jl->j_len == 0 || (jl->j_state & LIST_TOUCHED) ||
+ atomic_read(&jl->j_commit_left)
+ || !(jl->j_state & LIST_DIRTY)) {
+ del_from_work_list(s, jl);
+ break;
+ }
+ ret = write_one_transaction(s, jl, &chunk);
+
+ if (ret < 0)
+ goto done;
+ transactions_flushed++;
+ written += ret;
+ entry = jl->j_list.next;
+
+ /* did we wrap? */
+ if (entry == &journal->j_journal_list) {
+ break;
+ }
+ jl = JOURNAL_LIST_ENTRY(entry);
+
+ /* don't bother with older transactions */
+ if (jl->j_trans_id <= orig_trans_id)
+ break;
+ }
+ if (chunk.nr) {
+ write_chunk(&chunk);
+ }
+
+ done:
+ up(&journal->j_flush_sem);
+ return ret;
}
/* for o_sync and fsync heavy applications, they tend to use
@@ -1617,47 +1720,48 @@ done:
** list updates the header block
*/
static int flush_used_journal_lists(struct super_block *s,
- struct reiserfs_journal_list *jl) {
- unsigned long len = 0;
- unsigned long cur_len;
- int ret;
- int i;
- int limit = 256;
- struct reiserfs_journal_list *tjl;
- struct reiserfs_journal_list *flush_jl;
- unsigned long trans_id;
- struct reiserfs_journal *journal = SB_JOURNAL (s);
-
- flush_jl = tjl = jl;
-
- /* in data logging mode, try harder to flush a lot of blocks */
- if (reiserfs_data_log(s))
- limit = 1024;
- /* flush for 256 transactions or limit blocks, whichever comes first */
- for(i = 0 ; i < 256 && len < limit ; i++) {
- if (atomic_read(&tjl->j_commit_left) ||
- tjl->j_trans_id < jl->j_trans_id) {
- break;
- }
- cur_len = atomic_read(&tjl->j_nonzerolen);
- if (cur_len > 0) {
- tjl->j_state &= ~LIST_TOUCHED;
- }
- len += cur_len;
- flush_jl = tjl;
- if (tjl->j_list.next == &journal->j_journal_list)
- break;
- tjl = JOURNAL_LIST_ENTRY(tjl->j_list.next);
- }
- /* try to find a group of blocks we can flush across all the
- ** transactions, but only bother if we've actually spanned
- ** across multiple lists
- */
- if (flush_jl != jl) {
- ret = kupdate_transactions(s, jl, &tjl, &trans_id, len, i);
- }
- flush_journal_list(s, flush_jl, 1);
- return 0;
+ struct reiserfs_journal_list *jl)
+{
+ unsigned long len = 0;
+ unsigned long cur_len;
+ int ret;
+ int i;
+ int limit = 256;
+ struct reiserfs_journal_list *tjl;
+ struct reiserfs_journal_list *flush_jl;
+ unsigned long trans_id;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+
+ flush_jl = tjl = jl;
+
+ /* in data logging mode, try harder to flush a lot of blocks */
+ if (reiserfs_data_log(s))
+ limit = 1024;
+ /* flush for 256 transactions or limit blocks, whichever comes first */
+ for (i = 0; i < 256 && len < limit; i++) {
+ if (atomic_read(&tjl->j_commit_left) ||
+ tjl->j_trans_id < jl->j_trans_id) {
+ break;
+ }
+ cur_len = atomic_read(&tjl->j_nonzerolen);
+ if (cur_len > 0) {
+ tjl->j_state &= ~LIST_TOUCHED;
+ }
+ len += cur_len;
+ flush_jl = tjl;
+ if (tjl->j_list.next == &journal->j_journal_list)
+ break;
+ tjl = JOURNAL_LIST_ENTRY(tjl->j_list.next);
+ }
+ /* try to find a group of blocks we can flush across all the
+ ** transactions, but only bother if we've actually spanned
+ ** across multiple lists
+ */
+ if (flush_jl != jl) {
+ ret = kupdate_transactions(s, jl, &tjl, &trans_id, len, i);
+ }
+ flush_journal_list(s, flush_jl, 1);
+ return 0;
}
/*
@@ -1665,207 +1769,248 @@ static int flush_used_journal_lists(struct super_block *s,
** only touchs the hnext and hprev pointers.
*/
void remove_journal_hash(struct super_block *sb,
- struct reiserfs_journal_cnode **table,
- struct reiserfs_journal_list *jl,
- unsigned long block, int remove_freed)
-{
- struct reiserfs_journal_cnode *cur ;
- struct reiserfs_journal_cnode **head ;
-
- head= &(journal_hash(table, sb, block)) ;
- if (!head) {
- return ;
- }
- cur = *head ;
- while(cur) {
- if (cur->blocknr == block && cur->sb == sb && (jl == NULL || jl == cur->jlist) &&
- (!test_bit(BLOCK_FREED, &cur->state) || remove_freed)) {
- if (cur->hnext) {
- cur->hnext->hprev = cur->hprev ;
- }
- if (cur->hprev) {
- cur->hprev->hnext = cur->hnext ;
- } else {
- *head = cur->hnext ;
- }
- cur->blocknr = 0 ;
- cur->sb = NULL ;
- cur->state = 0 ;
- if (cur->bh && cur->jlist) /* anybody who clears the cur->bh will also dec the nonzerolen */
- atomic_dec(&(cur->jlist->j_nonzerolen)) ;
- cur->bh = NULL ;
- cur->jlist = NULL ;
- }
- cur = cur->hnext ;
- }
-}
-
-static void free_journal_ram(struct super_block *p_s_sb) {
- struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
- reiserfs_kfree(journal->j_current_jl,
- sizeof(struct reiserfs_journal_list), p_s_sb);
- journal->j_num_lists--;
-
- vfree(journal->j_cnode_free_orig) ;
- free_list_bitmaps(p_s_sb, journal->j_list_bitmap) ;
- free_bitmap_nodes(p_s_sb) ; /* must be after free_list_bitmaps */
- if (journal->j_header_bh) {
- brelse(journal->j_header_bh) ;
- }
- /* j_header_bh is on the journal dev, make sure not to release the journal
- * dev until we brelse j_header_bh
- */
- release_journal_dev(p_s_sb, journal);
- vfree(journal) ;
+ struct reiserfs_journal_cnode **table,
+ struct reiserfs_journal_list *jl,
+ unsigned long block, int remove_freed)
+{
+ struct reiserfs_journal_cnode *cur;
+ struct reiserfs_journal_cnode **head;
+
+ head = &(journal_hash(table, sb, block));
+ if (!head) {
+ return;
+ }
+ cur = *head;
+ while (cur) {
+ if (cur->blocknr == block && cur->sb == sb
+ && (jl == NULL || jl == cur->jlist)
+ && (!test_bit(BLOCK_FREED, &cur->state) || remove_freed)) {
+ if (cur->hnext) {
+ cur->hnext->hprev = cur->hprev;
+ }
+ if (cur->hprev) {
+ cur->hprev->hnext = cur->hnext;
+ } else {
+ *head = cur->hnext;
+ }
+ cur->blocknr = 0;
+ cur->sb = NULL;
+ cur->state = 0;
+ if (cur->bh && cur->jlist) /* anybody who clears the cur->bh will also dec the nonzerolen */
+ atomic_dec(&(cur->jlist->j_nonzerolen));
+ cur->bh = NULL;
+ cur->jlist = NULL;
+ }
+ cur = cur->hnext;
+ }
+}
+
+static void free_journal_ram(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ reiserfs_kfree(journal->j_current_jl,
+ sizeof(struct reiserfs_journal_list), p_s_sb);
+ journal->j_num_lists--;
+
+ vfree(journal->j_cnode_free_orig);
+ free_list_bitmaps(p_s_sb, journal->j_list_bitmap);
+ free_bitmap_nodes(p_s_sb); /* must be after free_list_bitmaps */
+ if (journal->j_header_bh) {
+ brelse(journal->j_header_bh);
+ }
+ /* j_header_bh is on the journal dev, make sure not to release the journal
+ * dev until we brelse j_header_bh
+ */
+ release_journal_dev(p_s_sb, journal);
+ vfree(journal);
}
/*
** call on unmount. Only set error to 1 if you haven't made your way out
** of read_super() yet. Any other caller must keep error at 0.
*/
-static int do_journal_release(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, int error) {
- struct reiserfs_transaction_handle myth ;
- int flushed = 0;
- struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
-
- /* we only want to flush out transactions if we were called with error == 0
- */
- if (!error && !(p_s_sb->s_flags & MS_RDONLY)) {
- /* end the current trans */
- BUG_ON (!th->t_trans_id);
- do_journal_end(th, p_s_sb,10, FLUSH_ALL) ;
-
- /* make sure something gets logged to force our way into the flush code */
- if (!journal_join(&myth, p_s_sb, 1)) {
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(&myth, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
- do_journal_end(&myth, p_s_sb,1, FLUSH_ALL) ;
- flushed = 1;
- }
- }
-
- /* this also catches errors during the do_journal_end above */
- if (!error && reiserfs_is_journal_aborted(journal)) {
- memset(&myth, 0, sizeof(myth));
- if (!journal_join_abort(&myth, p_s_sb, 1)) {
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(&myth, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
- do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL) ;
- }
- }
-
- reiserfs_mounted_fs_count-- ;
- /* wait for all commits to finish */
- cancel_delayed_work(&SB_JOURNAL(p_s_sb)->j_work);
- flush_workqueue(commit_wq);
- if (!reiserfs_mounted_fs_count) {
- destroy_workqueue(commit_wq);
- commit_wq = NULL;
- }
-
- free_journal_ram(p_s_sb) ;
-
- return 0 ;
+static int do_journal_release(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, int error)
+{
+ struct reiserfs_transaction_handle myth;
+ int flushed = 0;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+
+ /* we only want to flush out transactions if we were called with error == 0
+ */
+ if (!error && !(p_s_sb->s_flags & MS_RDONLY)) {
+ /* end the current trans */
+ BUG_ON(!th->t_trans_id);
+ do_journal_end(th, p_s_sb, 10, FLUSH_ALL);
+
+ /* make sure something gets logged to force our way into the flush code */
+ if (!journal_join(&myth, p_s_sb, 1)) {
+ reiserfs_prepare_for_journal(p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb),
+ 1);
+ journal_mark_dirty(&myth, p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb));
+ do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL);
+ flushed = 1;
+ }
+ }
+
+ /* this also catches errors during the do_journal_end above */
+ if (!error && reiserfs_is_journal_aborted(journal)) {
+ memset(&myth, 0, sizeof(myth));
+ if (!journal_join_abort(&myth, p_s_sb, 1)) {
+ reiserfs_prepare_for_journal(p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb),
+ 1);
+ journal_mark_dirty(&myth, p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb));
+ do_journal_end(&myth, p_s_sb, 1, FLUSH_ALL);
+ }
+ }
+
+ reiserfs_mounted_fs_count--;
+ /* wait for all commits to finish */
+ cancel_delayed_work(&SB_JOURNAL(p_s_sb)->j_work);
+ flush_workqueue(commit_wq);
+ if (!reiserfs_mounted_fs_count) {
+ destroy_workqueue(commit_wq);
+ commit_wq = NULL;
+ }
+
+ free_journal_ram(p_s_sb);
+
+ return 0;
}
/*
** call on unmount. flush all journal trans, release all alloc'd ram
*/
-int journal_release(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb) {
- return do_journal_release(th, p_s_sb, 0) ;
+int journal_release(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb)
+{
+ return do_journal_release(th, p_s_sb, 0);
}
+
/*
** only call from an error condition inside reiserfs_read_super!
*/
-int journal_release_error(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb) {
- return do_journal_release(th, p_s_sb, 1) ;
+int journal_release_error(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb)
+{
+ return do_journal_release(th, p_s_sb, 1);
}
/* compares description block with commit block. returns 1 if they differ, 0 if they are the same */
-static int journal_compare_desc_commit(struct super_block *p_s_sb, struct reiserfs_journal_desc *desc,
- struct reiserfs_journal_commit *commit) {
- if (get_commit_trans_id (commit) != get_desc_trans_id (desc) ||
- get_commit_trans_len (commit) != get_desc_trans_len (desc) ||
- get_commit_trans_len (commit) > SB_JOURNAL(p_s_sb)->j_trans_max ||
- get_commit_trans_len (commit) <= 0
- ) {
- return 1 ;
- }
- return 0 ;
+static int journal_compare_desc_commit(struct super_block *p_s_sb,
+ struct reiserfs_journal_desc *desc,
+ struct reiserfs_journal_commit *commit)
+{
+ if (get_commit_trans_id(commit) != get_desc_trans_id(desc) ||
+ get_commit_trans_len(commit) != get_desc_trans_len(desc) ||
+ get_commit_trans_len(commit) > SB_JOURNAL(p_s_sb)->j_trans_max ||
+ get_commit_trans_len(commit) <= 0) {
+ return 1;
+ }
+ return 0;
}
+
/* returns 0 if it did not find a description block
** returns -1 if it found a corrupt commit block
** returns 1 if both desc and commit were valid
*/
-static int journal_transaction_is_valid(struct super_block *p_s_sb, struct buffer_head *d_bh, unsigned long *oldest_invalid_trans_id, unsigned long *newest_mount_id) {
- struct reiserfs_journal_desc *desc ;
- struct reiserfs_journal_commit *commit ;
- struct buffer_head *c_bh ;
- unsigned long offset ;
-
- if (!d_bh)
- return 0 ;
-
- desc = (struct reiserfs_journal_desc *)d_bh->b_data ;
- if (get_desc_trans_len(desc) > 0 && !memcmp(get_journal_desc_magic (d_bh), JOURNAL_DESC_MAGIC, 8)) {
- if (oldest_invalid_trans_id && *oldest_invalid_trans_id && get_desc_trans_id(desc) > *oldest_invalid_trans_id) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-986: transaction "
- "is valid returning because trans_id %d is greater than "
- "oldest_invalid %lu", get_desc_trans_id(desc),
- *oldest_invalid_trans_id);
- return 0 ;
- }
- if (newest_mount_id && *newest_mount_id > get_desc_mount_id (desc)) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1087: transaction "
- "is valid returning because mount_id %d is less than "
- "newest_mount_id %lu", get_desc_mount_id (desc),
- *newest_mount_id) ;
- return -1 ;
- }
- if ( get_desc_trans_len(desc) > SB_JOURNAL(p_s_sb)->j_trans_max ) {
- reiserfs_warning(p_s_sb, "journal-2018: Bad transaction length %d encountered, ignoring transaction", get_desc_trans_len(desc));
- return -1 ;
- }
- offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
-
- /* ok, we have a journal description block, lets see if the transaction was valid */
- c_bh = journal_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- ((offset + get_desc_trans_len(desc) + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
- if (!c_bh)
- return 0 ;
- commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
- if (journal_compare_desc_commit(p_s_sb, desc, commit)) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
- "journal_transaction_is_valid, commit offset %ld had bad "
- "time %d or length %d",
- c_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- get_commit_trans_id (commit),
- get_commit_trans_len(commit));
- brelse(c_bh) ;
- if (oldest_invalid_trans_id) {
- *oldest_invalid_trans_id = get_desc_trans_id(desc) ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1004: "
- "transaction_is_valid setting oldest invalid trans_id "
- "to %d", get_desc_trans_id(desc)) ;
- }
- return -1;
- }
- brelse(c_bh) ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1006: found valid "
- "transaction start offset %llu, len %d id %d",
- d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- get_desc_trans_len(desc), get_desc_trans_id(desc)) ;
- return 1 ;
- } else {
- return 0 ;
- }
-}
-
-static void brelse_array(struct buffer_head **heads, int num) {
- int i ;
- for (i = 0 ; i < num ; i++) {
- brelse(heads[i]) ;
- }
+static int journal_transaction_is_valid(struct super_block *p_s_sb,
+ struct buffer_head *d_bh,
+ unsigned long *oldest_invalid_trans_id,
+ unsigned long *newest_mount_id)
+{
+ struct reiserfs_journal_desc *desc;
+ struct reiserfs_journal_commit *commit;
+ struct buffer_head *c_bh;
+ unsigned long offset;
+
+ if (!d_bh)
+ return 0;
+
+ desc = (struct reiserfs_journal_desc *)d_bh->b_data;
+ if (get_desc_trans_len(desc) > 0
+ && !memcmp(get_journal_desc_magic(d_bh), JOURNAL_DESC_MAGIC, 8)) {
+ if (oldest_invalid_trans_id && *oldest_invalid_trans_id
+ && get_desc_trans_id(desc) > *oldest_invalid_trans_id) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-986: transaction "
+ "is valid returning because trans_id %d is greater than "
+ "oldest_invalid %lu",
+ get_desc_trans_id(desc),
+ *oldest_invalid_trans_id);
+ return 0;
+ }
+ if (newest_mount_id
+ && *newest_mount_id > get_desc_mount_id(desc)) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1087: transaction "
+ "is valid returning because mount_id %d is less than "
+ "newest_mount_id %lu",
+ get_desc_mount_id(desc),
+ *newest_mount_id);
+ return -1;
+ }
+ if (get_desc_trans_len(desc) > SB_JOURNAL(p_s_sb)->j_trans_max) {
+ reiserfs_warning(p_s_sb,
+ "journal-2018: Bad transaction length %d encountered, ignoring transaction",
+ get_desc_trans_len(desc));
+ return -1;
+ }
+ offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
+
+ /* ok, we have a journal description block, lets see if the transaction was valid */
+ c_bh =
+ journal_bread(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ ((offset + get_desc_trans_len(desc) +
+ 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)));
+ if (!c_bh)
+ return 0;
+ commit = (struct reiserfs_journal_commit *)c_bh->b_data;
+ if (journal_compare_desc_commit(p_s_sb, desc, commit)) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal_transaction_is_valid, commit offset %ld had bad "
+ "time %d or length %d",
+ c_bh->b_blocknr -
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ get_commit_trans_id(commit),
+ get_commit_trans_len(commit));
+ brelse(c_bh);
+ if (oldest_invalid_trans_id) {
+ *oldest_invalid_trans_id =
+ get_desc_trans_id(desc);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1004: "
+ "transaction_is_valid setting oldest invalid trans_id "
+ "to %d",
+ get_desc_trans_id(desc));
+ }
+ return -1;
+ }
+ brelse(c_bh);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1006: found valid "
+ "transaction start offset %llu, len %d id %d",
+ d_bh->b_blocknr -
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ get_desc_trans_len(desc),
+ get_desc_trans_id(desc));
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+static void brelse_array(struct buffer_head **heads, int num)
+{
+ int i;
+ for (i = 0; i < num; i++) {
+ brelse(heads[i]);
+ }
}
/*
@@ -1873,149 +2018,202 @@ static void brelse_array(struct buffer_head **heads, int num) {
** this either reads in a replays a transaction, or returns because the transaction
** is invalid, or too old.
*/
-static int journal_read_transaction(struct super_block *p_s_sb, unsigned long cur_dblock, unsigned long oldest_start,
- unsigned long oldest_trans_id, unsigned long newest_mount_id) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_desc *desc ;
- struct reiserfs_journal_commit *commit ;
- unsigned long trans_id = 0 ;
- struct buffer_head *c_bh ;
- struct buffer_head *d_bh ;
- struct buffer_head **log_blocks = NULL ;
- struct buffer_head **real_blocks = NULL ;
- unsigned long trans_offset ;
- int i;
- int trans_half;
-
- d_bh = journal_bread(p_s_sb, cur_dblock) ;
- if (!d_bh)
- return 1 ;
- desc = (struct reiserfs_journal_desc *)d_bh->b_data ;
- trans_offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1037: "
- "journal_read_transaction, offset %llu, len %d mount_id %d",
- d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- get_desc_trans_len(desc), get_desc_mount_id(desc)) ;
- if (get_desc_trans_id(desc) < oldest_trans_id) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1039: "
- "journal_read_trans skipping because %lu is too old",
- cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)) ;
- brelse(d_bh) ;
- return 1 ;
- }
- if (get_desc_mount_id(desc) != newest_mount_id) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1146: "
- "journal_read_trans skipping because %d is != "
- "newest_mount_id %lu", get_desc_mount_id(desc),
- newest_mount_id) ;
- brelse(d_bh) ;
- return 1 ;
- }
- c_bh = journal_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- ((trans_offset + get_desc_trans_len(desc) + 1) %
- SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
- if (!c_bh) {
- brelse(d_bh) ;
- return 1 ;
- }
- commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
- if (journal_compare_desc_commit(p_s_sb, desc, commit)) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal_read_transaction, "
- "commit offset %llu had bad time %d or length %d",
- c_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- get_commit_trans_id(commit), get_commit_trans_len(commit));
- brelse(c_bh) ;
- brelse(d_bh) ;
- return 1;
- }
- trans_id = get_desc_trans_id(desc) ;
- /* now we know we've got a good transaction, and it was inside the valid time ranges */
- log_blocks = reiserfs_kmalloc(get_desc_trans_len(desc) * sizeof(struct buffer_head *), GFP_NOFS, p_s_sb) ;
- real_blocks = reiserfs_kmalloc(get_desc_trans_len(desc) * sizeof(struct buffer_head *), GFP_NOFS, p_s_sb) ;
- if (!log_blocks || !real_blocks) {
- brelse(c_bh) ;
- brelse(d_bh) ;
- reiserfs_kfree(log_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_kfree(real_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_warning(p_s_sb, "journal-1169: kmalloc failed, unable to mount FS") ;
- return -1 ;
- }
- /* get all the buffer heads */
- trans_half = journal_trans_half (p_s_sb->s_blocksize) ;
- for(i = 0 ; i < get_desc_trans_len(desc) ; i++) {
- log_blocks[i] = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + (trans_offset + 1 + i) % SB_ONDISK_JOURNAL_SIZE(p_s_sb));
- if (i < trans_half) {
- real_blocks[i] = sb_getblk(p_s_sb, le32_to_cpu(desc->j_realblock[i])) ;
- } else {
- real_blocks[i] = sb_getblk(p_s_sb, le32_to_cpu(commit->j_realblock[i - trans_half])) ;
- }
- if ( real_blocks[i]->b_blocknr > SB_BLOCK_COUNT(p_s_sb) ) {
- reiserfs_warning(p_s_sb, "journal-1207: REPLAY FAILURE fsck required! Block to replay is outside of filesystem");
- goto abort_replay;
- }
- /* make sure we don't try to replay onto log or reserved area */
- if (is_block_in_log_or_reserved_area(p_s_sb, real_blocks[i]->b_blocknr)) {
- reiserfs_warning(p_s_sb, "journal-1204: REPLAY FAILURE fsck required! Trying to replay onto a log block") ;
-abort_replay:
- brelse_array(log_blocks, i) ;
- brelse_array(real_blocks, i) ;
- brelse(c_bh) ;
- brelse(d_bh) ;
- reiserfs_kfree(log_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_kfree(real_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- return -1 ;
- }
- }
- /* read in the log blocks, memcpy to the corresponding real block */
- ll_rw_block(READ, get_desc_trans_len(desc), log_blocks) ;
- for (i = 0 ; i < get_desc_trans_len(desc) ; i++) {
- wait_on_buffer(log_blocks[i]) ;
- if (!buffer_uptodate(log_blocks[i])) {
- reiserfs_warning(p_s_sb, "journal-1212: REPLAY FAILURE fsck required! buffer write failed") ;
- brelse_array(log_blocks + i, get_desc_trans_len(desc) - i) ;
- brelse_array(real_blocks, get_desc_trans_len(desc)) ;
- brelse(c_bh) ;
- brelse(d_bh) ;
- reiserfs_kfree(log_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_kfree(real_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- return -1 ;
- }
- memcpy(real_blocks[i]->b_data, log_blocks[i]->b_data, real_blocks[i]->b_size) ;
- set_buffer_uptodate(real_blocks[i]) ;
- brelse(log_blocks[i]) ;
- }
- /* flush out the real blocks */
- for (i = 0 ; i < get_desc_trans_len(desc) ; i++) {
- set_buffer_dirty(real_blocks[i]) ;
- ll_rw_block(WRITE, 1, real_blocks + i) ;
- }
- for (i = 0 ; i < get_desc_trans_len(desc) ; i++) {
- wait_on_buffer(real_blocks[i]) ;
- if (!buffer_uptodate(real_blocks[i])) {
- reiserfs_warning(p_s_sb, "journal-1226: REPLAY FAILURE, fsck required! buffer write failed") ;
- brelse_array(real_blocks + i, get_desc_trans_len(desc) - i) ;
- brelse(c_bh) ;
- brelse(d_bh) ;
- reiserfs_kfree(log_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_kfree(real_blocks, get_desc_trans_len(desc) * sizeof(struct buffer_head *), p_s_sb) ;
- return -1 ;
- }
- brelse(real_blocks[i]) ;
- }
- cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + ((trans_offset + get_desc_trans_len(desc) + 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)) ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1095: setting journal "
- "start to offset %ld",
- cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)) ;
-
- /* init starting values for the first transaction, in case this is the last transaction to be replayed. */
- journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
- journal->j_last_flush_trans_id = trans_id ;
- journal->j_trans_id = trans_id + 1;
- brelse(c_bh) ;
- brelse(d_bh) ;
- reiserfs_kfree(log_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
- reiserfs_kfree(real_blocks, le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *), p_s_sb) ;
- return 0 ;
+static int journal_read_transaction(struct super_block *p_s_sb,
+ unsigned long cur_dblock,
+ unsigned long oldest_start,
+ unsigned long oldest_trans_id,
+ unsigned long newest_mount_id)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_desc *desc;
+ struct reiserfs_journal_commit *commit;
+ unsigned long trans_id = 0;
+ struct buffer_head *c_bh;
+ struct buffer_head *d_bh;
+ struct buffer_head **log_blocks = NULL;
+ struct buffer_head **real_blocks = NULL;
+ unsigned long trans_offset;
+ int i;
+ int trans_half;
+
+ d_bh = journal_bread(p_s_sb, cur_dblock);
+ if (!d_bh)
+ return 1;
+ desc = (struct reiserfs_journal_desc *)d_bh->b_data;
+ trans_offset = d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1037: "
+ "journal_read_transaction, offset %llu, len %d mount_id %d",
+ d_bh->b_blocknr - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ get_desc_trans_len(desc), get_desc_mount_id(desc));
+ if (get_desc_trans_id(desc) < oldest_trans_id) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1039: "
+ "journal_read_trans skipping because %lu is too old",
+ cur_dblock -
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb));
+ brelse(d_bh);
+ return 1;
+ }
+ if (get_desc_mount_id(desc) != newest_mount_id) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1146: "
+ "journal_read_trans skipping because %d is != "
+ "newest_mount_id %lu", get_desc_mount_id(desc),
+ newest_mount_id);
+ brelse(d_bh);
+ return 1;
+ }
+ c_bh = journal_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ ((trans_offset + get_desc_trans_len(desc) + 1) %
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)));
+ if (!c_bh) {
+ brelse(d_bh);
+ return 1;
+ }
+ commit = (struct reiserfs_journal_commit *)c_bh->b_data;
+ if (journal_compare_desc_commit(p_s_sb, desc, commit)) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal_read_transaction, "
+ "commit offset %llu had bad time %d or length %d",
+ c_bh->b_blocknr -
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ get_commit_trans_id(commit),
+ get_commit_trans_len(commit));
+ brelse(c_bh);
+ brelse(d_bh);
+ return 1;
+ }
+ trans_id = get_desc_trans_id(desc);
+ /* now we know we've got a good transaction, and it was inside the valid time ranges */
+ log_blocks =
+ reiserfs_kmalloc(get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), GFP_NOFS, p_s_sb);
+ real_blocks =
+ reiserfs_kmalloc(get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), GFP_NOFS, p_s_sb);
+ if (!log_blocks || !real_blocks) {
+ brelse(c_bh);
+ brelse(d_bh);
+ reiserfs_kfree(log_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ reiserfs_kfree(real_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ reiserfs_warning(p_s_sb,
+ "journal-1169: kmalloc failed, unable to mount FS");
+ return -1;
+ }
+ /* get all the buffer heads */
+ trans_half = journal_trans_half(p_s_sb->s_blocksize);
+ for (i = 0; i < get_desc_trans_len(desc); i++) {
+ log_blocks[i] =
+ journal_getblk(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ (trans_offset + 1 +
+ i) % SB_ONDISK_JOURNAL_SIZE(p_s_sb));
+ if (i < trans_half) {
+ real_blocks[i] =
+ sb_getblk(p_s_sb,
+ le32_to_cpu(desc->j_realblock[i]));
+ } else {
+ real_blocks[i] =
+ sb_getblk(p_s_sb,
+ le32_to_cpu(commit->
+ j_realblock[i - trans_half]));
+ }
+ if (real_blocks[i]->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
+ reiserfs_warning(p_s_sb,
+ "journal-1207: REPLAY FAILURE fsck required! Block to replay is outside of filesystem");
+ goto abort_replay;
+ }
+ /* make sure we don't try to replay onto log or reserved area */
+ if (is_block_in_log_or_reserved_area
+ (p_s_sb, real_blocks[i]->b_blocknr)) {
+ reiserfs_warning(p_s_sb,
+ "journal-1204: REPLAY FAILURE fsck required! Trying to replay onto a log block");
+ abort_replay:
+ brelse_array(log_blocks, i);
+ brelse_array(real_blocks, i);
+ brelse(c_bh);
+ brelse(d_bh);
+ reiserfs_kfree(log_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ reiserfs_kfree(real_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ return -1;
+ }
+ }
+ /* read in the log blocks, memcpy to the corresponding real block */
+ ll_rw_block(READ, get_desc_trans_len(desc), log_blocks);
+ for (i = 0; i < get_desc_trans_len(desc); i++) {
+ wait_on_buffer(log_blocks[i]);
+ if (!buffer_uptodate(log_blocks[i])) {
+ reiserfs_warning(p_s_sb,
+ "journal-1212: REPLAY FAILURE fsck required! buffer write failed");
+ brelse_array(log_blocks + i,
+ get_desc_trans_len(desc) - i);
+ brelse_array(real_blocks, get_desc_trans_len(desc));
+ brelse(c_bh);
+ brelse(d_bh);
+ reiserfs_kfree(log_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ reiserfs_kfree(real_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ return -1;
+ }
+ memcpy(real_blocks[i]->b_data, log_blocks[i]->b_data,
+ real_blocks[i]->b_size);
+ set_buffer_uptodate(real_blocks[i]);
+ brelse(log_blocks[i]);
+ }
+ /* flush out the real blocks */
+ for (i = 0; i < get_desc_trans_len(desc); i++) {
+ set_buffer_dirty(real_blocks[i]);
+ ll_rw_block(WRITE, 1, real_blocks + i);
+ }
+ for (i = 0; i < get_desc_trans_len(desc); i++) {
+ wait_on_buffer(real_blocks[i]);
+ if (!buffer_uptodate(real_blocks[i])) {
+ reiserfs_warning(p_s_sb,
+ "journal-1226: REPLAY FAILURE, fsck required! buffer write failed");
+ brelse_array(real_blocks + i,
+ get_desc_trans_len(desc) - i);
+ brelse(c_bh);
+ brelse(d_bh);
+ reiserfs_kfree(log_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ reiserfs_kfree(real_blocks,
+ get_desc_trans_len(desc) *
+ sizeof(struct buffer_head *), p_s_sb);
+ return -1;
+ }
+ brelse(real_blocks[i]);
+ }
+ cur_dblock =
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ ((trans_offset + get_desc_trans_len(desc) +
+ 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb));
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1095: setting journal " "start to offset %ld",
+ cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb));
+
+ /* init starting values for the first transaction, in case this is the last transaction to be replayed. */
+ journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
+ journal->j_last_flush_trans_id = trans_id;
+ journal->j_trans_id = trans_id + 1;
+ brelse(c_bh);
+ brelse(d_bh);
+ reiserfs_kfree(log_blocks,
+ le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *),
+ p_s_sb);
+ reiserfs_kfree(real_blocks,
+ le32_to_cpu(desc->j_len) * sizeof(struct buffer_head *),
+ p_s_sb);
+ return 0;
}
/* This function reads blocks starting from block and to max_block of bufsize
@@ -2024,39 +2222,39 @@ abort_replay:
Right now it is only used from journal code. But later we might use it
from other places.
Note: Do not use journal_getblk/sb_getblk functions here! */
-static struct buffer_head * reiserfs_breada (struct block_device *dev, int block, int bufsize,
- unsigned int max_block)
+static struct buffer_head *reiserfs_breada(struct block_device *dev, int block,
+ int bufsize, unsigned int max_block)
{
- struct buffer_head * bhlist[BUFNR];
+ struct buffer_head *bhlist[BUFNR];
unsigned int blocks = BUFNR;
- struct buffer_head * bh;
+ struct buffer_head *bh;
int i, j;
-
- bh = __getblk (dev, block, bufsize );
- if (buffer_uptodate (bh))
- return (bh);
-
+
+ bh = __getblk(dev, block, bufsize);
+ if (buffer_uptodate(bh))
+ return (bh);
+
if (block + BUFNR > max_block) {
blocks = max_block - block;
}
bhlist[0] = bh;
j = 1;
for (i = 1; i < blocks; i++) {
- bh = __getblk (dev, block + i, bufsize);
- if (buffer_uptodate (bh)) {
- brelse (bh);
+ bh = __getblk(dev, block + i, bufsize);
+ if (buffer_uptodate(bh)) {
+ brelse(bh);
break;
- }
- else bhlist[j++] = bh;
+ } else
+ bhlist[j++] = bh;
}
- ll_rw_block (READ, j, bhlist);
- for(i = 1; i < j; i++)
- brelse (bhlist[i]);
+ ll_rw_block(READ, j, bhlist);
+ for (i = 1; i < j; i++)
+ brelse(bhlist[i]);
bh = bhlist[0];
- wait_on_buffer (bh);
- if (buffer_uptodate (bh))
+ wait_on_buffer(bh);
+ if (buffer_uptodate(bh))
return bh;
- brelse (bh);
+ brelse(bh);
return NULL;
}
@@ -2069,218 +2267,250 @@ static struct buffer_head * reiserfs_breada (struct block_device *dev, int block
**
** On exit, it sets things up so the first transaction will work correctly.
*/
-static int journal_read(struct super_block *p_s_sb) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_desc *desc ;
- unsigned long oldest_trans_id = 0;
- unsigned long oldest_invalid_trans_id = 0 ;
- time_t start ;
- unsigned long oldest_start = 0;
- unsigned long cur_dblock = 0 ;
- unsigned long newest_mount_id = 9 ;
- struct buffer_head *d_bh ;
- struct reiserfs_journal_header *jh ;
- int valid_journal_header = 0 ;
- int replay_count = 0 ;
- int continue_replay = 1 ;
- int ret ;
- char b[BDEVNAME_SIZE];
-
- cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) ;
- reiserfs_info (p_s_sb, "checking transaction log (%s)\n",
- bdevname(journal->j_dev_bd, b));
- start = get_seconds();
-
- /* step 1, read in the journal header block. Check the transaction it says
- ** is the first unflushed, and if that transaction is not valid,
- ** replay is done
- */
- journal->j_header_bh = journal_bread(p_s_sb,
- SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- SB_ONDISK_JOURNAL_SIZE(p_s_sb));
- if (!journal->j_header_bh) {
- return 1 ;
- }
- jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data) ;
- if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 &&
- le32_to_cpu(jh->j_first_unflushed_offset) < SB_ONDISK_JOURNAL_SIZE(p_s_sb) &&
- le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
- oldest_start = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- le32_to_cpu(jh->j_first_unflushed_offset) ;
- oldest_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
- newest_mount_id = le32_to_cpu(jh->j_mount_id);
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1153: found in "
- "header: first_unflushed_offset %d, last_flushed_trans_id "
- "%lu", le32_to_cpu(jh->j_first_unflushed_offset),
- le32_to_cpu(jh->j_last_flush_trans_id)) ;
- valid_journal_header = 1 ;
-
- /* now, we try to read the first unflushed offset. If it is not valid,
- ** there is nothing more we can do, and it makes no sense to read
- ** through the whole log.
- */
- d_bh = journal_bread(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + le32_to_cpu(jh->j_first_unflushed_offset)) ;
- ret = journal_transaction_is_valid(p_s_sb, d_bh, NULL, NULL) ;
- if (!ret) {
- continue_replay = 0 ;
- }
- brelse(d_bh) ;
- goto start_log_replay;
- }
-
- if (continue_replay && bdev_read_only(p_s_sb->s_bdev)) {
- reiserfs_warning (p_s_sb,
- "clm-2076: device is readonly, unable to replay log") ;
- return -1 ;
- }
-
- /* ok, there are transactions that need to be replayed. start with the first log block, find
- ** all the valid transactions, and pick out the oldest.
- */
- while(continue_replay && cur_dblock < (SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb))) {
- /* Note that it is required for blocksize of primary fs device and journal
- device to be the same */
- d_bh = reiserfs_breada(journal->j_dev_bd, cur_dblock, p_s_sb->s_blocksize,
- SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb)) ;
- ret = journal_transaction_is_valid(p_s_sb, d_bh, &oldest_invalid_trans_id, &newest_mount_id) ;
- if (ret == 1) {
- desc = (struct reiserfs_journal_desc *)d_bh->b_data ;
- if (oldest_start == 0) { /* init all oldest_ values */
- oldest_trans_id = get_desc_trans_id(desc) ;
- oldest_start = d_bh->b_blocknr ;
- newest_mount_id = get_desc_mount_id(desc) ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1179: Setting "
- "oldest_start to offset %llu, trans_id %lu",
- oldest_start - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- oldest_trans_id) ;
- } else if (oldest_trans_id > get_desc_trans_id(desc)) {
- /* one we just read was older */
- oldest_trans_id = get_desc_trans_id(desc) ;
- oldest_start = d_bh->b_blocknr ;
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1180: Resetting "
- "oldest_start to offset %lu, trans_id %lu",
- oldest_start - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- oldest_trans_id) ;
- }
- if (newest_mount_id < get_desc_mount_id(desc)) {
- newest_mount_id = get_desc_mount_id(desc) ;
+static int journal_read(struct super_block *p_s_sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_desc *desc;
+ unsigned long oldest_trans_id = 0;
+ unsigned long oldest_invalid_trans_id = 0;
+ time_t start;
+ unsigned long oldest_start = 0;
+ unsigned long cur_dblock = 0;
+ unsigned long newest_mount_id = 9;
+ struct buffer_head *d_bh;
+ struct reiserfs_journal_header *jh;
+ int valid_journal_header = 0;
+ int replay_count = 0;
+ int continue_replay = 1;
+ int ret;
+ char b[BDEVNAME_SIZE];
+
+ cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
+ reiserfs_info(p_s_sb, "checking transaction log (%s)\n",
+ bdevname(journal->j_dev_bd, b));
+ start = get_seconds();
+
+ /* step 1, read in the journal header block. Check the transaction it says
+ ** is the first unflushed, and if that transaction is not valid,
+ ** replay is done
+ */
+ journal->j_header_bh = journal_bread(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb)
+ + SB_ONDISK_JOURNAL_SIZE(p_s_sb));
+ if (!journal->j_header_bh) {
+ return 1;
+ }
+ jh = (struct reiserfs_journal_header *)(journal->j_header_bh->b_data);
+ if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 &&
+ le32_to_cpu(jh->j_first_unflushed_offset) <
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)
+ && le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
+ oldest_start =
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ le32_to_cpu(jh->j_first_unflushed_offset);
+ oldest_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
+ newest_mount_id = le32_to_cpu(jh->j_mount_id);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1153: found in "
+ "header: first_unflushed_offset %d, last_flushed_trans_id "
+ "%lu", le32_to_cpu(jh->j_first_unflushed_offset),
+ le32_to_cpu(jh->j_last_flush_trans_id));
+ valid_journal_header = 1;
+
+ /* now, we try to read the first unflushed offset. If it is not valid,
+ ** there is nothing more we can do, and it makes no sense to read
+ ** through the whole log.
+ */
+ d_bh =
+ journal_bread(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ le32_to_cpu(jh->j_first_unflushed_offset));
+ ret = journal_transaction_is_valid(p_s_sb, d_bh, NULL, NULL);
+ if (!ret) {
+ continue_replay = 0;
+ }
+ brelse(d_bh);
+ goto start_log_replay;
+ }
+
+ if (continue_replay && bdev_read_only(p_s_sb->s_bdev)) {
+ reiserfs_warning(p_s_sb,
+ "clm-2076: device is readonly, unable to replay log");
+ return -1;
+ }
+
+ /* ok, there are transactions that need to be replayed. start with the first log block, find
+ ** all the valid transactions, and pick out the oldest.
+ */
+ while (continue_replay
+ && cur_dblock <
+ (SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb))) {
+ /* Note that it is required for blocksize of primary fs device and journal
+ device to be the same */
+ d_bh =
+ reiserfs_breada(journal->j_dev_bd, cur_dblock,
+ p_s_sb->s_blocksize,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb));
+ ret =
+ journal_transaction_is_valid(p_s_sb, d_bh,
+ &oldest_invalid_trans_id,
+ &newest_mount_id);
+ if (ret == 1) {
+ desc = (struct reiserfs_journal_desc *)d_bh->b_data;
+ if (oldest_start == 0) { /* init all oldest_ values */
+ oldest_trans_id = get_desc_trans_id(desc);
+ oldest_start = d_bh->b_blocknr;
+ newest_mount_id = get_desc_mount_id(desc);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1179: Setting "
+ "oldest_start to offset %llu, trans_id %lu",
+ oldest_start -
+ SB_ONDISK_JOURNAL_1st_BLOCK
+ (p_s_sb), oldest_trans_id);
+ } else if (oldest_trans_id > get_desc_trans_id(desc)) {
+ /* one we just read was older */
+ oldest_trans_id = get_desc_trans_id(desc);
+ oldest_start = d_bh->b_blocknr;
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1180: Resetting "
+ "oldest_start to offset %lu, trans_id %lu",
+ oldest_start -
+ SB_ONDISK_JOURNAL_1st_BLOCK
+ (p_s_sb), oldest_trans_id);
+ }
+ if (newest_mount_id < get_desc_mount_id(desc)) {
+ newest_mount_id = get_desc_mount_id(desc);
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1299: Setting "
+ "newest_mount_id to %d",
+ get_desc_mount_id(desc));
+ }
+ cur_dblock += get_desc_trans_len(desc) + 2;
+ } else {
+ cur_dblock++;
+ }
+ brelse(d_bh);
+ }
+
+ start_log_replay:
+ cur_dblock = oldest_start;
+ if (oldest_trans_id) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1206: Starting replay "
+ "from offset %llu, trans_id %lu",
+ cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ oldest_trans_id);
+
+ }
+ replay_count = 0;
+ while (continue_replay && oldest_trans_id > 0) {
+ ret =
+ journal_read_transaction(p_s_sb, cur_dblock, oldest_start,
+ oldest_trans_id, newest_mount_id);
+ if (ret < 0) {
+ return ret;
+ } else if (ret != 0) {
+ break;
+ }
+ cur_dblock =
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start;
+ replay_count++;
+ if (cur_dblock == oldest_start)
+ break;
+ }
+
+ if (oldest_trans_id == 0) {
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "journal-1225: No valid " "transactions found");
+ }
+ /* j_start does not get set correctly if we don't replay any transactions.
+ ** if we had a valid journal_header, set j_start to the first unflushed transaction value,
+ ** copy the trans_id from the header
+ */
+ if (valid_journal_header && replay_count == 0) {
+ journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset);
+ journal->j_trans_id =
+ le32_to_cpu(jh->j_last_flush_trans_id) + 1;
+ journal->j_last_flush_trans_id =
+ le32_to_cpu(jh->j_last_flush_trans_id);
+ journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1;
+ } else {
+ journal->j_mount_id = newest_mount_id + 1;
+ }
reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1299: Setting "
- "newest_mount_id to %d", get_desc_mount_id(desc));
- }
- cur_dblock += get_desc_trans_len(desc) + 2 ;
- } else {
- cur_dblock++ ;
- }
- brelse(d_bh) ;
- }
-
-start_log_replay:
- cur_dblock = oldest_start ;
- if (oldest_trans_id) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1206: Starting replay "
- "from offset %llu, trans_id %lu",
- cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- oldest_trans_id) ;
-
- }
- replay_count = 0 ;
- while(continue_replay && oldest_trans_id > 0) {
- ret = journal_read_transaction(p_s_sb, cur_dblock, oldest_start, oldest_trans_id, newest_mount_id) ;
- if (ret < 0) {
- return ret ;
- } else if (ret != 0) {
- break ;
- }
- cur_dblock = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start ;
- replay_count++ ;
- if (cur_dblock == oldest_start)
- break;
- }
-
- if (oldest_trans_id == 0) {
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1225: No valid "
- "transactions found") ;
- }
- /* j_start does not get set correctly if we don't replay any transactions.
- ** if we had a valid journal_header, set j_start to the first unflushed transaction value,
- ** copy the trans_id from the header
- */
- if (valid_journal_header && replay_count == 0) {
- journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset) ;
- journal->j_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
- journal->j_last_flush_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) ;
- journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1;
- } else {
- journal->j_mount_id = newest_mount_id + 1 ;
- }
- reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1299: Setting "
- "newest_mount_id to %lu", journal->j_mount_id) ;
- journal->j_first_unflushed_offset = journal->j_start ;
- if (replay_count > 0) {
- reiserfs_info (p_s_sb, "replayed %d transactions in %lu seconds\n",
- replay_count, get_seconds() - start) ;
- }
- if (!bdev_read_only(p_s_sb->s_bdev) &&
- _update_journal_header_block(p_s_sb, journal->j_start,
- journal->j_last_flush_trans_id))
- {
- /* replay failed, caller must call free_journal_ram and abort
- ** the mount
- */
- return -1 ;
- }
- return 0 ;
+ "newest_mount_id to %lu", journal->j_mount_id);
+ journal->j_first_unflushed_offset = journal->j_start;
+ if (replay_count > 0) {
+ reiserfs_info(p_s_sb,
+ "replayed %d transactions in %lu seconds\n",
+ replay_count, get_seconds() - start);
+ }
+ if (!bdev_read_only(p_s_sb->s_bdev) &&
+ _update_journal_header_block(p_s_sb, journal->j_start,
+ journal->j_last_flush_trans_id)) {
+ /* replay failed, caller must call free_journal_ram and abort
+ ** the mount
+ */
+ return -1;
+ }
+ return 0;
}
static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s)
{
- struct reiserfs_journal_list *jl;
-retry:
- jl = reiserfs_kmalloc(sizeof(struct reiserfs_journal_list), GFP_NOFS, s);
- if (!jl) {
- yield();
- goto retry;
- }
- memset(jl, 0, sizeof(*jl));
- INIT_LIST_HEAD(&jl->j_list);
- INIT_LIST_HEAD(&jl->j_working_list);
- INIT_LIST_HEAD(&jl->j_tail_bh_list);
- INIT_LIST_HEAD(&jl->j_bh_list);
- sema_init(&jl->j_commit_lock, 1);
- SB_JOURNAL(s)->j_num_lists++;
- get_journal_list(jl);
- return jl;
-}
-
-static void journal_list_init(struct super_block *p_s_sb) {
- SB_JOURNAL(p_s_sb)->j_current_jl = alloc_journal_list(p_s_sb);
-}
-
-static int release_journal_dev( struct super_block *super,
- struct reiserfs_journal *journal )
-{
- int result;
-
- result = 0;
-
- if( journal -> j_dev_file != NULL ) {
- result = filp_close( journal -> j_dev_file, NULL );
- journal -> j_dev_file = NULL;
- journal -> j_dev_bd = NULL;
- } else if( journal -> j_dev_bd != NULL ) {
- result = blkdev_put( journal -> j_dev_bd );
- journal -> j_dev_bd = NULL;
- }
-
- if( result != 0 ) {
- reiserfs_warning(super, "sh-457: release_journal_dev: Cannot release journal device: %i", result );
- }
- return result;
-}
-
-static int journal_init_dev( struct super_block *super,
- struct reiserfs_journal *journal,
- const char *jdev_name )
+ struct reiserfs_journal_list *jl;
+ retry:
+ jl = reiserfs_kmalloc(sizeof(struct reiserfs_journal_list), GFP_NOFS,
+ s);
+ if (!jl) {
+ yield();
+ goto retry;
+ }
+ memset(jl, 0, sizeof(*jl));
+ INIT_LIST_HEAD(&jl->j_list);
+ INIT_LIST_HEAD(&jl->j_working_list);
+ INIT_LIST_HEAD(&jl->j_tail_bh_list);
+ INIT_LIST_HEAD(&jl->j_bh_list);
+ sema_init(&jl->j_commit_lock, 1);
+ SB_JOURNAL(s)->j_num_lists++;
+ get_journal_list(jl);
+ return jl;
+}
+
+static void journal_list_init(struct super_block *p_s_sb)
+{
+ SB_JOURNAL(p_s_sb)->j_current_jl = alloc_journal_list(p_s_sb);
+}
+
+static int release_journal_dev(struct super_block *super,
+ struct reiserfs_journal *journal)
+{
+ int result;
+
+ result = 0;
+
+ if (journal->j_dev_file != NULL) {
+ result = filp_close(journal->j_dev_file, NULL);
+ journal->j_dev_file = NULL;
+ journal->j_dev_bd = NULL;
+ } else if (journal->j_dev_bd != NULL) {
+ result = blkdev_put(journal->j_dev_bd);
+ journal->j_dev_bd = NULL;
+ }
+
+ if (result != 0) {
+ reiserfs_warning(super,
+ "sh-457: release_journal_dev: Cannot release journal device: %i",
+ result);
+ }
+ return result;
+}
+
+static int journal_init_dev(struct super_block *super,
+ struct reiserfs_journal *journal,
+ const char *jdev_name)
{
int result;
dev_t jdev;
@@ -2289,50 +2519,51 @@ static int journal_init_dev( struct super_block *super,
result = 0;
- journal -> j_dev_bd = NULL;
- journal -> j_dev_file = NULL;
- jdev = SB_ONDISK_JOURNAL_DEVICE( super ) ?
- new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev;
+ journal->j_dev_bd = NULL;
+ journal->j_dev_file = NULL;
+ jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
+ new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev;
if (bdev_read_only(super->s_bdev))
- blkdev_mode = FMODE_READ;
+ blkdev_mode = FMODE_READ;
/* there is no "jdev" option and journal is on separate device */
- if( ( !jdev_name || !jdev_name[ 0 ] ) ) {
+ if ((!jdev_name || !jdev_name[0])) {
journal->j_dev_bd = open_by_devnum(jdev, blkdev_mode);
if (IS_ERR(journal->j_dev_bd)) {
result = PTR_ERR(journal->j_dev_bd);
journal->j_dev_bd = NULL;
- reiserfs_warning (super, "sh-458: journal_init_dev: "
- "cannot init journal device '%s': %i",
- __bdevname(jdev, b), result );
+ reiserfs_warning(super, "sh-458: journal_init_dev: "
+ "cannot init journal device '%s': %i",
+ __bdevname(jdev, b), result);
return result;
} else if (jdev != super->s_dev)
set_blocksize(journal->j_dev_bd, super->s_blocksize);
return 0;
}
- journal -> j_dev_file = filp_open( jdev_name, 0, 0 );
- if( !IS_ERR( journal -> j_dev_file ) ) {
+ journal->j_dev_file = filp_open(jdev_name, 0, 0);
+ if (!IS_ERR(journal->j_dev_file)) {
struct inode *jdev_inode = journal->j_dev_file->f_mapping->host;
- if( !S_ISBLK( jdev_inode -> i_mode ) ) {
+ if (!S_ISBLK(jdev_inode->i_mode)) {
reiserfs_warning(super, "journal_init_dev: '%s' is "
- "not a block device", jdev_name );
+ "not a block device", jdev_name);
result = -ENOTBLK;
- release_journal_dev( super, journal );
- } else {
+ release_journal_dev(super, journal);
+ } else {
/* ok */
journal->j_dev_bd = I_BDEV(jdev_inode);
set_blocksize(journal->j_dev_bd, super->s_blocksize);
- reiserfs_info(super, "journal_init_dev: journal device: %s\n",
+ reiserfs_info(super,
+ "journal_init_dev: journal device: %s\n",
bdevname(journal->j_dev_bd, b));
}
} else {
- result = PTR_ERR( journal -> j_dev_file );
- journal -> j_dev_file = NULL;
- reiserfs_warning (super,
- "journal_init_dev: Cannot open '%s': %i",
- jdev_name, result );
+ result = PTR_ERR(journal->j_dev_file);
+ journal->j_dev_file = NULL;
+ reiserfs_warning(super,
+ "journal_init_dev: Cannot open '%s': %i",
+ jdev_name, result);
}
return result;
}
@@ -2340,193 +2571,214 @@ static int journal_init_dev( struct super_block *super,
/*
** must be called once on fs mount. calls journal_read for you
*/
-int journal_init(struct super_block *p_s_sb, const char * j_dev_name, int old_format, unsigned int commit_max_age) {
- int num_cnodes = SB_ONDISK_JOURNAL_SIZE(p_s_sb) * 2 ;
- struct buffer_head *bhjh;
- struct reiserfs_super_block * rs;
- struct reiserfs_journal_header *jh;
- struct reiserfs_journal *journal;
- struct reiserfs_journal_list *jl;
- char b[BDEVNAME_SIZE];
-
- journal = SB_JOURNAL(p_s_sb) = vmalloc(sizeof (struct reiserfs_journal)) ;
- if (!journal) {
- reiserfs_warning (p_s_sb, "journal-1256: unable to get memory for journal structure") ;
- return 1 ;
- }
- memset(journal, 0, sizeof(struct reiserfs_journal)) ;
- INIT_LIST_HEAD(&journal->j_bitmap_nodes) ;
- INIT_LIST_HEAD (&journal->j_prealloc_list);
- INIT_LIST_HEAD(&journal->j_working_list);
- INIT_LIST_HEAD(&journal->j_journal_list);
- journal->j_persistent_trans = 0;
- if (reiserfs_allocate_list_bitmaps(p_s_sb,
- journal->j_list_bitmap,
- SB_BMAP_NR(p_s_sb)))
- goto free_and_return ;
- allocate_bitmap_nodes(p_s_sb) ;
-
- /* reserved for journal area support */
- SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) = (old_format ?
- REISERFS_OLD_DISK_OFFSET_IN_BYTES / p_s_sb->s_blocksize +
- SB_BMAP_NR(p_s_sb) + 1 :
- REISERFS_DISK_OFFSET_IN_BYTES / p_s_sb->s_blocksize + 2);
-
- /* Sanity check to see is the standard journal fitting withing first bitmap
- (actual for small blocksizes) */
- if ( !SB_ONDISK_JOURNAL_DEVICE( p_s_sb ) &&
- (SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb) > p_s_sb->s_blocksize * 8) ) {
- reiserfs_warning (p_s_sb, "journal-1393: journal does not fit for area "
- "addressed by first of bitmap blocks. It starts at "
- "%u and its size is %u. Block size %ld",
- SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb),
- SB_ONDISK_JOURNAL_SIZE(p_s_sb), p_s_sb->s_blocksize);
- goto free_and_return;
- }
-
- if( journal_init_dev( p_s_sb, journal, j_dev_name ) != 0 ) {
- reiserfs_warning (p_s_sb, "sh-462: unable to initialize jornal device");
- goto free_and_return;
- }
-
- rs = SB_DISK_SUPER_BLOCK(p_s_sb);
-
- /* read journal header */
- bhjh = journal_bread(p_s_sb,
- SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + SB_ONDISK_JOURNAL_SIZE(p_s_sb));
- if (!bhjh) {
- reiserfs_warning (p_s_sb, "sh-459: unable to read journal header");
- goto free_and_return;
- }
- jh = (struct reiserfs_journal_header *)(bhjh->b_data);
-
- /* make sure that journal matches to the super block */
- if (is_reiserfs_jr(rs) && (le32_to_cpu(jh->jh_journal.jp_journal_magic) != sb_jp_journal_magic(rs))) {
- reiserfs_warning (p_s_sb, "sh-460: journal header magic %x "
- "(device %s) does not match to magic found in super "
- "block %x",
- jh->jh_journal.jp_journal_magic,
- bdevname( journal->j_dev_bd, b),
- sb_jp_journal_magic(rs));
- brelse (bhjh);
- goto free_and_return;
- }
-
- journal->j_trans_max = le32_to_cpu (jh->jh_journal.jp_journal_trans_max);
- journal->j_max_batch = le32_to_cpu (jh->jh_journal.jp_journal_max_batch);
- journal->j_max_commit_age = le32_to_cpu (jh->jh_journal.jp_journal_max_commit_age);
- journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
-
- if (journal->j_trans_max) {
- /* make sure these parameters are available, assign it if they are not */
- __u32 initial = journal->j_trans_max;
- __u32 ratio = 1;
-
- if (p_s_sb->s_blocksize < 4096)
- ratio = 4096 / p_s_sb->s_blocksize;
-
- if (SB_ONDISK_JOURNAL_SIZE(p_s_sb)/journal->j_trans_max < JOURNAL_MIN_RATIO)
- journal->j_trans_max = SB_ONDISK_JOURNAL_SIZE(p_s_sb) / JOURNAL_MIN_RATIO;
- if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio)
- journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT / ratio;
- if (journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio)
- journal->j_trans_max = JOURNAL_TRANS_MIN_DEFAULT / ratio;
-
- if (journal->j_trans_max != initial)
- reiserfs_warning (p_s_sb, "sh-461: journal_init: wrong transaction max size (%u). Changed to %u",
- initial, journal->j_trans_max);
-
- journal->j_max_batch = journal->j_trans_max*
- JOURNAL_MAX_BATCH_DEFAULT/JOURNAL_TRANS_MAX_DEFAULT;
- }
-
- if (!journal->j_trans_max) {
- /*we have the file system was created by old version of mkreiserfs
- so this field contains zero value */
- journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT ;
- journal->j_max_batch = JOURNAL_MAX_BATCH_DEFAULT ;
- journal->j_max_commit_age = JOURNAL_MAX_COMMIT_AGE ;
-
- /* for blocksize >= 4096 - max transaction size is 1024. For block size < 4096
- trans max size is decreased proportionally */
- if (p_s_sb->s_blocksize < 4096) {
- journal->j_trans_max /= (4096 / p_s_sb->s_blocksize) ;
- journal->j_max_batch = (journal->j_trans_max) * 9 / 10 ;
- }
- }
-
- journal->j_default_max_commit_age = journal->j_max_commit_age;
-
- if (commit_max_age != 0) {
- journal->j_max_commit_age = commit_max_age;
- journal->j_max_trans_age = commit_max_age;
- }
-
- reiserfs_info (p_s_sb, "journal params: device %s, size %u, "
- "journal first block %u, max trans len %u, max batch %u, "
- "max commit age %u, max trans age %u\n",
- bdevname( journal->j_dev_bd, b),
- SB_ONDISK_JOURNAL_SIZE(p_s_sb),
- SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
- journal->j_trans_max,
- journal->j_max_batch,
- journal->j_max_commit_age,
- journal->j_max_trans_age);
-
- brelse (bhjh);
-
- journal->j_list_bitmap_index = 0 ;
- journal_list_init(p_s_sb) ;
-
- memset(journal->j_list_hash_table, 0, JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *)) ;
-
- INIT_LIST_HEAD(&journal->j_dirty_buffers) ;
- spin_lock_init(&journal->j_dirty_buffers_lock) ;
-
- journal->j_start = 0 ;
- journal->j_len = 0 ;
- journal->j_len_alloc = 0 ;
- atomic_set(&(journal->j_wcount), 0) ;
- atomic_set(&(journal->j_async_throttle), 0) ;
- journal->j_bcount = 0 ;
- journal->j_trans_start_time = 0 ;
- journal->j_last = NULL ;
- journal->j_first = NULL ;
- init_waitqueue_head(&(journal->j_join_wait)) ;
- sema_init(&journal->j_lock, 1);
- sema_init(&journal->j_flush_sem, 1);
-
- journal->j_trans_id = 10 ;
- journal->j_mount_id = 10 ;
- journal->j_state = 0 ;
- atomic_set(&(journal->j_jlock), 0) ;
- journal->j_cnode_free_list = allocate_cnodes(num_cnodes) ;
- journal->j_cnode_free_orig = journal->j_cnode_free_list ;
- journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0 ;
- journal->j_cnode_used = 0 ;
- journal->j_must_wait = 0 ;
-
- init_journal_hash(p_s_sb) ;
- jl = journal->j_current_jl;
- jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
- if (!jl->j_list_bitmap) {
- reiserfs_warning(p_s_sb, "journal-2005, get_list_bitmap failed for journal list 0") ;
- goto free_and_return;
- }
- if (journal_read(p_s_sb) < 0) {
- reiserfs_warning(p_s_sb, "Replay Failure, unable to mount") ;
- goto free_and_return;
- }
-
- reiserfs_mounted_fs_count++ ;
- if (reiserfs_mounted_fs_count <= 1)
- commit_wq = create_workqueue("reiserfs");
-
- INIT_WORK(&journal->j_work, flush_async_commits, p_s_sb);
- return 0 ;
-free_and_return:
- free_journal_ram(p_s_sb);
- return 1;
+int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
+ int old_format, unsigned int commit_max_age)
+{
+ int num_cnodes = SB_ONDISK_JOURNAL_SIZE(p_s_sb) * 2;
+ struct buffer_head *bhjh;
+ struct reiserfs_super_block *rs;
+ struct reiserfs_journal_header *jh;
+ struct reiserfs_journal *journal;
+ struct reiserfs_journal_list *jl;
+ char b[BDEVNAME_SIZE];
+
+ journal = SB_JOURNAL(p_s_sb) = vmalloc(sizeof(struct reiserfs_journal));
+ if (!journal) {
+ reiserfs_warning(p_s_sb,
+ "journal-1256: unable to get memory for journal structure");
+ return 1;
+ }
+ memset(journal, 0, sizeof(struct reiserfs_journal));
+ INIT_LIST_HEAD(&journal->j_bitmap_nodes);
+ INIT_LIST_HEAD(&journal->j_prealloc_list);
+ INIT_LIST_HEAD(&journal->j_working_list);
+ INIT_LIST_HEAD(&journal->j_journal_list);
+ journal->j_persistent_trans = 0;
+ if (reiserfs_allocate_list_bitmaps(p_s_sb,
+ journal->j_list_bitmap,
+ SB_BMAP_NR(p_s_sb)))
+ goto free_and_return;
+ allocate_bitmap_nodes(p_s_sb);
+
+ /* reserved for journal area support */
+ SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) = (old_format ?
+ REISERFS_OLD_DISK_OFFSET_IN_BYTES
+ / p_s_sb->s_blocksize +
+ SB_BMAP_NR(p_s_sb) +
+ 1 :
+ REISERFS_DISK_OFFSET_IN_BYTES /
+ p_s_sb->s_blocksize + 2);
+
+ /* Sanity check to see is the standard journal fitting withing first bitmap
+ (actual for small blocksizes) */
+ if (!SB_ONDISK_JOURNAL_DEVICE(p_s_sb) &&
+ (SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) +
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb) > p_s_sb->s_blocksize * 8)) {
+ reiserfs_warning(p_s_sb,
+ "journal-1393: journal does not fit for area "
+ "addressed by first of bitmap blocks. It starts at "
+ "%u and its size is %u. Block size %ld",
+ SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb),
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb),
+ p_s_sb->s_blocksize);
+ goto free_and_return;
+ }
+
+ if (journal_init_dev(p_s_sb, journal, j_dev_name) != 0) {
+ reiserfs_warning(p_s_sb,
+ "sh-462: unable to initialize jornal device");
+ goto free_and_return;
+ }
+
+ rs = SB_DISK_SUPER_BLOCK(p_s_sb);
+
+ /* read journal header */
+ bhjh = journal_bread(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb));
+ if (!bhjh) {
+ reiserfs_warning(p_s_sb,
+ "sh-459: unable to read journal header");
+ goto free_and_return;
+ }
+ jh = (struct reiserfs_journal_header *)(bhjh->b_data);
+
+ /* make sure that journal matches to the super block */
+ if (is_reiserfs_jr(rs)
+ && (le32_to_cpu(jh->jh_journal.jp_journal_magic) !=
+ sb_jp_journal_magic(rs))) {
+ reiserfs_warning(p_s_sb,
+ "sh-460: journal header magic %x "
+ "(device %s) does not match to magic found in super "
+ "block %x", jh->jh_journal.jp_journal_magic,
+ bdevname(journal->j_dev_bd, b),
+ sb_jp_journal_magic(rs));
+ brelse(bhjh);
+ goto free_and_return;
+ }
+
+ journal->j_trans_max = le32_to_cpu(jh->jh_journal.jp_journal_trans_max);
+ journal->j_max_batch = le32_to_cpu(jh->jh_journal.jp_journal_max_batch);
+ journal->j_max_commit_age =
+ le32_to_cpu(jh->jh_journal.jp_journal_max_commit_age);
+ journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
+
+ if (journal->j_trans_max) {
+ /* make sure these parameters are available, assign it if they are not */
+ __u32 initial = journal->j_trans_max;
+ __u32 ratio = 1;
+
+ if (p_s_sb->s_blocksize < 4096)
+ ratio = 4096 / p_s_sb->s_blocksize;
+
+ if (SB_ONDISK_JOURNAL_SIZE(p_s_sb) / journal->j_trans_max <
+ JOURNAL_MIN_RATIO)
+ journal->j_trans_max =
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb) / JOURNAL_MIN_RATIO;
+ if (journal->j_trans_max > JOURNAL_TRANS_MAX_DEFAULT / ratio)
+ journal->j_trans_max =
+ JOURNAL_TRANS_MAX_DEFAULT / ratio;
+ if (journal->j_trans_max < JOURNAL_TRANS_MIN_DEFAULT / ratio)
+ journal->j_trans_max =
+ JOURNAL_TRANS_MIN_DEFAULT / ratio;
+
+ if (journal->j_trans_max != initial)
+ reiserfs_warning(p_s_sb,
+ "sh-461: journal_init: wrong transaction max size (%u). Changed to %u",
+ initial, journal->j_trans_max);
+
+ journal->j_max_batch = journal->j_trans_max *
+ JOURNAL_MAX_BATCH_DEFAULT / JOURNAL_TRANS_MAX_DEFAULT;
+ }
+
+ if (!journal->j_trans_max) {
+ /*we have the file system was created by old version of mkreiserfs
+ so this field contains zero value */
+ journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT;
+ journal->j_max_batch = JOURNAL_MAX_BATCH_DEFAULT;
+ journal->j_max_commit_age = JOURNAL_MAX_COMMIT_AGE;
+
+ /* for blocksize >= 4096 - max transaction size is 1024. For block size < 4096
+ trans max size is decreased proportionally */
+ if (p_s_sb->s_blocksize < 4096) {
+ journal->j_trans_max /= (4096 / p_s_sb->s_blocksize);
+ journal->j_max_batch = (journal->j_trans_max) * 9 / 10;
+ }
+ }
+
+ journal->j_default_max_commit_age = journal->j_max_commit_age;
+
+ if (commit_max_age != 0) {
+ journal->j_max_commit_age = commit_max_age;
+ journal->j_max_trans_age = commit_max_age;
+ }
+
+ reiserfs_info(p_s_sb, "journal params: device %s, size %u, "
+ "journal first block %u, max trans len %u, max batch %u, "
+ "max commit age %u, max trans age %u\n",
+ bdevname(journal->j_dev_bd, b),
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb),
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb),
+ journal->j_trans_max,
+ journal->j_max_batch,
+ journal->j_max_commit_age, journal->j_max_trans_age);
+
+ brelse(bhjh);
+
+ journal->j_list_bitmap_index = 0;
+ journal_list_init(p_s_sb);
+
+ memset(journal->j_list_hash_table, 0,
+ JOURNAL_HASH_SIZE * sizeof(struct reiserfs_journal_cnode *));
+
+ INIT_LIST_HEAD(&journal->j_dirty_buffers);
+ spin_lock_init(&journal->j_dirty_buffers_lock);
+
+ journal->j_start = 0;
+ journal->j_len = 0;
+ journal->j_len_alloc = 0;
+ atomic_set(&(journal->j_wcount), 0);
+ atomic_set(&(journal->j_async_throttle), 0);
+ journal->j_bcount = 0;
+ journal->j_trans_start_time = 0;
+ journal->j_last = NULL;
+ journal->j_first = NULL;
+ init_waitqueue_head(&(journal->j_join_wait));
+ sema_init(&journal->j_lock, 1);
+ sema_init(&journal->j_flush_sem, 1);
+
+ journal->j_trans_id = 10;
+ journal->j_mount_id = 10;
+ journal->j_state = 0;
+ atomic_set(&(journal->j_jlock), 0);
+ journal->j_cnode_free_list = allocate_cnodes(num_cnodes);
+ journal->j_cnode_free_orig = journal->j_cnode_free_list;
+ journal->j_cnode_free = journal->j_cnode_free_list ? num_cnodes : 0;
+ journal->j_cnode_used = 0;
+ journal->j_must_wait = 0;
+
+ init_journal_hash(p_s_sb);
+ jl = journal->j_current_jl;
+ jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
+ if (!jl->j_list_bitmap) {
+ reiserfs_warning(p_s_sb,
+ "journal-2005, get_list_bitmap failed for journal list 0");
+ goto free_and_return;
+ }
+ if (journal_read(p_s_sb) < 0) {
+ reiserfs_warning(p_s_sb, "Replay Failure, unable to mount");
+ goto free_and_return;
+ }
+
+ reiserfs_mounted_fs_count++;
+ if (reiserfs_mounted_fs_count <= 1)
+ commit_wq = create_workqueue("reiserfs");
+
+ INIT_WORK(&journal->j_work, flush_async_commits, p_s_sb);
+ return 0;
+ free_and_return:
+ free_journal_ram(p_s_sb);
+ return 1;
}
/*
@@ -2534,96 +2786,102 @@ free_and_return:
** be used by delete to make sure they don't write more than can fit inside a single
** transaction
*/
-int journal_transaction_should_end(struct reiserfs_transaction_handle *th, int new_alloc) {
- struct reiserfs_journal *journal = SB_JOURNAL (th->t_super);
- time_t now = get_seconds() ;
- /* cannot restart while nested */
- BUG_ON (!th->t_trans_id);
- if (th->t_refcount > 1)
- return 0 ;
- if ( journal->j_must_wait > 0 ||
- (journal->j_len_alloc + new_alloc) >= journal->j_max_batch ||
- atomic_read(&(journal->j_jlock)) ||
- (now - journal->j_trans_start_time) > journal->j_max_trans_age ||
- journal->j_cnode_free < (journal->j_trans_max * 3)) {
- return 1 ;
- }
- return 0 ;
+int journal_transaction_should_end(struct reiserfs_transaction_handle *th,
+ int new_alloc)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(th->t_super);
+ time_t now = get_seconds();
+ /* cannot restart while nested */
+ BUG_ON(!th->t_trans_id);
+ if (th->t_refcount > 1)
+ return 0;
+ if (journal->j_must_wait > 0 ||
+ (journal->j_len_alloc + new_alloc) >= journal->j_max_batch ||
+ atomic_read(&(journal->j_jlock)) ||
+ (now - journal->j_trans_start_time) > journal->j_max_trans_age ||
+ journal->j_cnode_free < (journal->j_trans_max * 3)) {
+ return 1;
+ }
+ return 0;
}
/* this must be called inside a transaction, and requires the
** kernel_lock to be held
*/
-void reiserfs_block_writes(struct reiserfs_transaction_handle *th) {
- struct reiserfs_journal *journal = SB_JOURNAL (th->t_super);
- BUG_ON (!th->t_trans_id);
- journal->j_must_wait = 1 ;
- set_bit(J_WRITERS_BLOCKED, &journal->j_state) ;
- return ;
+void reiserfs_block_writes(struct reiserfs_transaction_handle *th)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(th->t_super);
+ BUG_ON(!th->t_trans_id);
+ journal->j_must_wait = 1;
+ set_bit(J_WRITERS_BLOCKED, &journal->j_state);
+ return;
}
/* this must be called without a transaction started, and does not
** require BKL
*/
-void reiserfs_allow_writes(struct super_block *s) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- clear_bit(J_WRITERS_BLOCKED, &journal->j_state) ;
- wake_up(&journal->j_join_wait) ;
+void reiserfs_allow_writes(struct super_block *s)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ clear_bit(J_WRITERS_BLOCKED, &journal->j_state);
+ wake_up(&journal->j_join_wait);
}
/* this must be called without a transaction started, and does not
** require BKL
*/
-void reiserfs_wait_on_write_block(struct super_block *s) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- wait_event(journal->j_join_wait,
- !test_bit(J_WRITERS_BLOCKED, &journal->j_state)) ;
-}
-
-static void queue_log_writer(struct super_block *s) {
- wait_queue_t wait;
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- set_bit(J_WRITERS_QUEUED, &journal->j_state);
-
- /*
- * we don't want to use wait_event here because
- * we only want to wait once.
- */
- init_waitqueue_entry(&wait, current);
- add_wait_queue(&journal->j_join_wait, &wait);
- set_current_state(TASK_UNINTERRUPTIBLE);
- if (test_bit(J_WRITERS_QUEUED, &journal->j_state))
- schedule();
- current->state = TASK_RUNNING;
- remove_wait_queue(&journal->j_join_wait, &wait);
-}
-
-static void wake_queued_writers(struct super_block *s) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- if (test_and_clear_bit(J_WRITERS_QUEUED, &journal->j_state))
- wake_up(&journal->j_join_wait);
-}
-
-static void let_transaction_grow(struct super_block *sb,
- unsigned long trans_id)
-{
- struct reiserfs_journal *journal = SB_JOURNAL (sb);
- unsigned long bcount = journal->j_bcount;
- while(1) {
+void reiserfs_wait_on_write_block(struct super_block *s)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ wait_event(journal->j_join_wait,
+ !test_bit(J_WRITERS_BLOCKED, &journal->j_state));
+}
+
+static void queue_log_writer(struct super_block *s)
+{
+ wait_queue_t wait;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ set_bit(J_WRITERS_QUEUED, &journal->j_state);
+
+ /*
+ * we don't want to use wait_event here because
+ * we only want to wait once.
+ */
+ init_waitqueue_entry(&wait, current);
+ add_wait_queue(&journal->j_join_wait, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
- schedule_timeout(1);
- journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
- while ((atomic_read(&journal->j_wcount) > 0 ||
- atomic_read(&journal->j_jlock)) &&
- journal->j_trans_id == trans_id) {
- queue_log_writer(sb);
+ if (test_bit(J_WRITERS_QUEUED, &journal->j_state))
+ schedule();
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&journal->j_join_wait, &wait);
+}
+
+static void wake_queued_writers(struct super_block *s)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ if (test_and_clear_bit(J_WRITERS_QUEUED, &journal->j_state))
+ wake_up(&journal->j_join_wait);
+}
+
+static void let_transaction_grow(struct super_block *sb, unsigned long trans_id)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(sb);
+ unsigned long bcount = journal->j_bcount;
+ while (1) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(1);
+ journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
+ while ((atomic_read(&journal->j_wcount) > 0 ||
+ atomic_read(&journal->j_jlock)) &&
+ journal->j_trans_id == trans_id) {
+ queue_log_writer(sb);
+ }
+ if (journal->j_trans_id != trans_id)
+ break;
+ if (bcount == journal->j_bcount)
+ break;
+ bcount = journal->j_bcount;
}
- if (journal->j_trans_id != trans_id)
- break;
- if (bcount == journal->j_bcount)
- break;
- bcount = journal->j_bcount;
- }
}
/* join == true if you must join an existing transaction.
@@ -2632,224 +2890,244 @@ static void let_transaction_grow(struct super_block *sb,
** this will block until the transaction is joinable. send the number of blocks you
** expect to use in nblocks.
*/
-static int do_journal_begin_r(struct reiserfs_transaction_handle *th, struct super_block * p_s_sb,unsigned long nblocks,int join) {
- time_t now = get_seconds() ;
- int old_trans_id ;
- struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
- struct reiserfs_transaction_handle myth;
- int sched_count = 0;
- int retval;
-
- reiserfs_check_lock_depth(p_s_sb, "journal_begin") ;
- if (nblocks > journal->j_trans_max)
- BUG();
-
- PROC_INFO_INC( p_s_sb, journal.journal_being );
- /* set here for journal_join */
- th->t_refcount = 1;
- th->t_super = p_s_sb ;
-
-relock:
- lock_journal(p_s_sb) ;
- if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted (journal)) {
- unlock_journal (p_s_sb);
- retval = journal->j_errno;
- goto out_fail;
- }
- journal->j_bcount++;
-
- if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) {
- unlock_journal(p_s_sb) ;
- reiserfs_wait_on_write_block(p_s_sb) ;
- PROC_INFO_INC( p_s_sb, journal.journal_relock_writers );
- goto relock ;
- }
- now = get_seconds();
-
- /* if there is no room in the journal OR
- ** if this transaction is too old, and we weren't called joinable, wait for it to finish before beginning
- ** we don't sleep if there aren't other writers
- */
-
- if ( (!join && journal->j_must_wait > 0) ||
- ( !join && (journal->j_len_alloc + nblocks + 2) >= journal->j_max_batch) ||
- (!join && atomic_read(&journal->j_wcount) > 0 && journal->j_trans_start_time > 0 &&
- (now - journal->j_trans_start_time) > journal->j_max_trans_age) ||
- (!join && atomic_read(&journal->j_jlock)) ||
- (!join && journal->j_cnode_free < (journal->j_trans_max * 3))) {
-
- old_trans_id = journal->j_trans_id;
- unlock_journal(p_s_sb) ; /* allow others to finish this transaction */
-
- if (!join && (journal->j_len_alloc + nblocks + 2) >=
- journal->j_max_batch &&
- ((journal->j_len + nblocks + 2) * 100) < (journal->j_len_alloc * 75))
- {
- if (atomic_read(&journal->j_wcount) > 10) {
- sched_count++;
- queue_log_writer(p_s_sb);
- goto relock;
- }
- }
- /* don't mess with joining the transaction if all we have to do is
- * wait for someone else to do a commit
- */
- if (atomic_read(&journal->j_jlock)) {
- while (journal->j_trans_id == old_trans_id &&
- atomic_read(&journal->j_jlock)) {
- queue_log_writer(p_s_sb);
- }
- goto relock;
- }
- retval = journal_join(&myth, p_s_sb, 1) ;
- if (retval)
- goto out_fail;
-
- /* someone might have ended the transaction while we joined */
- if (old_trans_id != journal->j_trans_id) {
- retval = do_journal_end(&myth, p_s_sb, 1, 0) ;
- } else {
- retval = do_journal_end(&myth, p_s_sb, 1, COMMIT_NOW) ;
- }
-
- if (retval)
- goto out_fail;
-
- PROC_INFO_INC( p_s_sb, journal.journal_relock_wcount );
- goto relock ;
- }
- /* we are the first writer, set trans_id */
- if (journal->j_trans_start_time == 0) {
- journal->j_trans_start_time = get_seconds();
- }
- atomic_inc(&(journal->j_wcount)) ;
- journal->j_len_alloc += nblocks ;
- th->t_blocks_logged = 0 ;
- th->t_blocks_allocated = nblocks ;
- th->t_trans_id = journal->j_trans_id ;
- unlock_journal(p_s_sb) ;
- INIT_LIST_HEAD (&th->t_list);
- get_fs_excl();
- return 0 ;
-
-out_fail:
- memset (th, 0, sizeof (*th));
- /* Re-set th->t_super, so we can properly keep track of how many
- * persistent transactions there are. We need to do this so if this
- * call is part of a failed restart_transaction, we can free it later */
- th->t_super = p_s_sb;
- return retval;
-}
-
-struct reiserfs_transaction_handle *
-reiserfs_persistent_transaction(struct super_block *s, int nblocks) {
- int ret ;
- struct reiserfs_transaction_handle *th ;
-
- /* if we're nesting into an existing transaction. It will be
- ** persistent on its own
- */
- if (reiserfs_transaction_running(s)) {
- th = current->journal_info ;
- th->t_refcount++ ;
- if (th->t_refcount < 2) {
- BUG() ;
- }
- return th ;
- }
- th = reiserfs_kmalloc(sizeof(struct reiserfs_transaction_handle), GFP_NOFS, s) ;
- if (!th)
- return NULL;
- ret = journal_begin(th, s, nblocks) ;
- if (ret) {
- reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), s) ;
- return NULL;
- }
-
- SB_JOURNAL(s)->j_persistent_trans++;
- return th ;
-}
-
-int
-reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th) {
- struct super_block *s = th->t_super;
- int ret = 0;
- if (th->t_trans_id)
- ret = journal_end(th, th->t_super, th->t_blocks_allocated);
- else
- ret = -EIO;
- if (th->t_refcount == 0) {
- SB_JOURNAL(s)->j_persistent_trans--;
- reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle), s) ;
- }
- return ret;
-}
-
-static int journal_join(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
- struct reiserfs_transaction_handle *cur_th = current->journal_info;
-
- /* this keeps do_journal_end from NULLing out the current->journal_info
- ** pointer
- */
- th->t_handle_save = cur_th ;
- if (cur_th && cur_th->t_refcount > 1) {
- BUG() ;
- }
- return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN) ;
-}
-
-int journal_join_abort(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
- struct reiserfs_transaction_handle *cur_th = current->journal_info;
-
- /* this keeps do_journal_end from NULLing out the current->journal_info
- ** pointer
- */
- th->t_handle_save = cur_th ;
- if (cur_th && cur_th->t_refcount > 1) {
- BUG() ;
- }
- return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT) ;
-}
-
-int journal_begin(struct reiserfs_transaction_handle *th, struct super_block * p_s_sb, unsigned long nblocks) {
- struct reiserfs_transaction_handle *cur_th = current->journal_info ;
- int ret ;
-
- th->t_handle_save = NULL ;
- if (cur_th) {
- /* we are nesting into the current transaction */
- if (cur_th->t_super == p_s_sb) {
- BUG_ON (!cur_th->t_refcount);
- cur_th->t_refcount++ ;
- memcpy(th, cur_th, sizeof(*th));
- if (th->t_refcount <= 1)
- reiserfs_warning (p_s_sb, "BAD: refcount <= 1, but journal_info != 0");
- return 0;
+static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks,
+ int join)
+{
+ time_t now = get_seconds();
+ int old_trans_id;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_transaction_handle myth;
+ int sched_count = 0;
+ int retval;
+
+ reiserfs_check_lock_depth(p_s_sb, "journal_begin");
+ if (nblocks > journal->j_trans_max)
+ BUG();
+
+ PROC_INFO_INC(p_s_sb, journal.journal_being);
+ /* set here for journal_join */
+ th->t_refcount = 1;
+ th->t_super = p_s_sb;
+
+ relock:
+ lock_journal(p_s_sb);
+ if (join != JBEGIN_ABORT && reiserfs_is_journal_aborted(journal)) {
+ unlock_journal(p_s_sb);
+ retval = journal->j_errno;
+ goto out_fail;
+ }
+ journal->j_bcount++;
+
+ if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) {
+ unlock_journal(p_s_sb);
+ reiserfs_wait_on_write_block(p_s_sb);
+ PROC_INFO_INC(p_s_sb, journal.journal_relock_writers);
+ goto relock;
+ }
+ now = get_seconds();
+
+ /* if there is no room in the journal OR
+ ** if this transaction is too old, and we weren't called joinable, wait for it to finish before beginning
+ ** we don't sleep if there aren't other writers
+ */
+
+ if ((!join && journal->j_must_wait > 0) ||
+ (!join
+ && (journal->j_len_alloc + nblocks + 2) >= journal->j_max_batch)
+ || (!join && atomic_read(&journal->j_wcount) > 0
+ && journal->j_trans_start_time > 0
+ && (now - journal->j_trans_start_time) >
+ journal->j_max_trans_age) || (!join
+ && atomic_read(&journal->j_jlock))
+ || (!join && journal->j_cnode_free < (journal->j_trans_max * 3))) {
+
+ old_trans_id = journal->j_trans_id;
+ unlock_journal(p_s_sb); /* allow others to finish this transaction */
+
+ if (!join && (journal->j_len_alloc + nblocks + 2) >=
+ journal->j_max_batch &&
+ ((journal->j_len + nblocks + 2) * 100) <
+ (journal->j_len_alloc * 75)) {
+ if (atomic_read(&journal->j_wcount) > 10) {
+ sched_count++;
+ queue_log_writer(p_s_sb);
+ goto relock;
+ }
+ }
+ /* don't mess with joining the transaction if all we have to do is
+ * wait for someone else to do a commit
+ */
+ if (atomic_read(&journal->j_jlock)) {
+ while (journal->j_trans_id == old_trans_id &&
+ atomic_read(&journal->j_jlock)) {
+ queue_log_writer(p_s_sb);
+ }
+ goto relock;
+ }
+ retval = journal_join(&myth, p_s_sb, 1);
+ if (retval)
+ goto out_fail;
+
+ /* someone might have ended the transaction while we joined */
+ if (old_trans_id != journal->j_trans_id) {
+ retval = do_journal_end(&myth, p_s_sb, 1, 0);
+ } else {
+ retval = do_journal_end(&myth, p_s_sb, 1, COMMIT_NOW);
+ }
+
+ if (retval)
+ goto out_fail;
+
+ PROC_INFO_INC(p_s_sb, journal.journal_relock_wcount);
+ goto relock;
+ }
+ /* we are the first writer, set trans_id */
+ if (journal->j_trans_start_time == 0) {
+ journal->j_trans_start_time = get_seconds();
+ }
+ atomic_inc(&(journal->j_wcount));
+ journal->j_len_alloc += nblocks;
+ th->t_blocks_logged = 0;
+ th->t_blocks_allocated = nblocks;
+ th->t_trans_id = journal->j_trans_id;
+ unlock_journal(p_s_sb);
+ INIT_LIST_HEAD(&th->t_list);
+ get_fs_excl();
+ return 0;
+
+ out_fail:
+ memset(th, 0, sizeof(*th));
+ /* Re-set th->t_super, so we can properly keep track of how many
+ * persistent transactions there are. We need to do this so if this
+ * call is part of a failed restart_transaction, we can free it later */
+ th->t_super = p_s_sb;
+ return retval;
+}
+
+struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
+ super_block
+ *s,
+ int nblocks)
+{
+ int ret;
+ struct reiserfs_transaction_handle *th;
+
+ /* if we're nesting into an existing transaction. It will be
+ ** persistent on its own
+ */
+ if (reiserfs_transaction_running(s)) {
+ th = current->journal_info;
+ th->t_refcount++;
+ if (th->t_refcount < 2) {
+ BUG();
+ }
+ return th;
+ }
+ th = reiserfs_kmalloc(sizeof(struct reiserfs_transaction_handle),
+ GFP_NOFS, s);
+ if (!th)
+ return NULL;
+ ret = journal_begin(th, s, nblocks);
+ if (ret) {
+ reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle),
+ s);
+ return NULL;
+ }
+
+ SB_JOURNAL(s)->j_persistent_trans++;
+ return th;
+}
+
+int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *th)
+{
+ struct super_block *s = th->t_super;
+ int ret = 0;
+ if (th->t_trans_id)
+ ret = journal_end(th, th->t_super, th->t_blocks_allocated);
+ else
+ ret = -EIO;
+ if (th->t_refcount == 0) {
+ SB_JOURNAL(s)->j_persistent_trans--;
+ reiserfs_kfree(th, sizeof(struct reiserfs_transaction_handle),
+ s);
+ }
+ return ret;
+}
+
+static int journal_join(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks)
+{
+ struct reiserfs_transaction_handle *cur_th = current->journal_info;
+
+ /* this keeps do_journal_end from NULLing out the current->journal_info
+ ** pointer
+ */
+ th->t_handle_save = cur_th;
+ if (cur_th && cur_th->t_refcount > 1) {
+ BUG();
+ }
+ return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_JOIN);
+}
+
+int journal_join_abort(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks)
+{
+ struct reiserfs_transaction_handle *cur_th = current->journal_info;
+
+ /* this keeps do_journal_end from NULLing out the current->journal_info
+ ** pointer
+ */
+ th->t_handle_save = cur_th;
+ if (cur_th && cur_th->t_refcount > 1) {
+ BUG();
+ }
+ return do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_ABORT);
+}
+
+int journal_begin(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks)
+{
+ struct reiserfs_transaction_handle *cur_th = current->journal_info;
+ int ret;
+
+ th->t_handle_save = NULL;
+ if (cur_th) {
+ /* we are nesting into the current transaction */
+ if (cur_th->t_super == p_s_sb) {
+ BUG_ON(!cur_th->t_refcount);
+ cur_th->t_refcount++;
+ memcpy(th, cur_th, sizeof(*th));
+ if (th->t_refcount <= 1)
+ reiserfs_warning(p_s_sb,
+ "BAD: refcount <= 1, but journal_info != 0");
+ return 0;
+ } else {
+ /* we've ended up with a handle from a different filesystem.
+ ** save it and restore on journal_end. This should never
+ ** really happen...
+ */
+ reiserfs_warning(p_s_sb,
+ "clm-2100: nesting info a different FS");
+ th->t_handle_save = current->journal_info;
+ current->journal_info = th;
+ }
} else {
- /* we've ended up with a handle from a different filesystem.
- ** save it and restore on journal_end. This should never
- ** really happen...
- */
- reiserfs_warning(p_s_sb, "clm-2100: nesting info a different FS") ;
- th->t_handle_save = current->journal_info ;
- current->journal_info = th;
- }
- } else {
- current->journal_info = th;
- }
- ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG) ;
- if (current->journal_info != th)
- BUG() ;
+ current->journal_info = th;
+ }
+ ret = do_journal_begin_r(th, p_s_sb, nblocks, JBEGIN_REG);
+ if (current->journal_info != th)
+ BUG();
- /* I guess this boils down to being the reciprocal of clm-2100 above.
- * If do_journal_begin_r fails, we need to put it back, since journal_end
- * won't be called to do it. */
- if (ret)
- current->journal_info = th->t_handle_save;
- else
- BUG_ON (!th->t_refcount);
+ /* I guess this boils down to being the reciprocal of clm-2100 above.
+ * If do_journal_begin_r fails, we need to put it back, since journal_end
+ * won't be called to do it. */
+ if (ret)
+ current->journal_info = th->t_handle_save;
+ else
+ BUG_ON(!th->t_refcount);
- return ret ;
+ return ret;
}
/*
@@ -2861,129 +3139,140 @@ int journal_begin(struct reiserfs_transaction_handle *th, struct super_block *
**
** if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len.
*/
-int journal_mark_dirty(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, struct buffer_head *bh) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_cnode *cn = NULL;
- int count_already_incd = 0 ;
- int prepared = 0 ;
- BUG_ON (!th->t_trans_id);
-
- PROC_INFO_INC( p_s_sb, journal.mark_dirty );
- if (th->t_trans_id != journal->j_trans_id) {
- reiserfs_panic(th->t_super, "journal-1577: handle trans id %ld != current trans id %ld\n",
- th->t_trans_id, journal->j_trans_id);
- }
-
- p_s_sb->s_dirt = 1;
-
- prepared = test_clear_buffer_journal_prepared (bh);
- clear_buffer_journal_restore_dirty (bh);
- /* already in this transaction, we are done */
- if (buffer_journaled(bh)) {
- PROC_INFO_INC( p_s_sb, journal.mark_dirty_already );
- return 0 ;
- }
-
- /* this must be turned into a panic instead of a warning. We can't allow
- ** a dirty or journal_dirty or locked buffer to be logged, as some changes
- ** could get to disk too early. NOT GOOD.
- */
- if (!prepared || buffer_dirty(bh)) {
- reiserfs_warning (p_s_sb, "journal-1777: buffer %llu bad state "
- "%cPREPARED %cLOCKED %cDIRTY %cJDIRTY_WAIT",
- (unsigned long long)bh->b_blocknr, prepared ? ' ' : '!',
- buffer_locked(bh) ? ' ' : '!',
- buffer_dirty(bh) ? ' ' : '!',
- buffer_journal_dirty(bh) ? ' ' : '!') ;
- }
-
- if (atomic_read(&(journal->j_wcount)) <= 0) {
- reiserfs_warning (p_s_sb, "journal-1409: journal_mark_dirty returning because j_wcount was %d", atomic_read(&(journal->j_wcount))) ;
- return 1 ;
- }
- /* this error means I've screwed up, and we've overflowed the transaction.
- ** Nothing can be done here, except make the FS readonly or panic.
- */
- if (journal->j_len >= journal->j_trans_max) {
- reiserfs_panic(th->t_super, "journal-1413: journal_mark_dirty: j_len (%lu) is too big\n", journal->j_len) ;
- }
-
- if (buffer_journal_dirty(bh)) {
- count_already_incd = 1 ;
- PROC_INFO_INC( p_s_sb, journal.mark_dirty_notjournal );
- clear_buffer_journal_dirty (bh);
- }
-
- if (journal->j_len > journal->j_len_alloc) {
- journal->j_len_alloc = journal->j_len + JOURNAL_PER_BALANCE_CNT ;
- }
-
- set_buffer_journaled (bh);
-
- /* now put this guy on the end */
- if (!cn) {
- cn = get_cnode(p_s_sb) ;
- if (!cn) {
- reiserfs_panic(p_s_sb, "get_cnode failed!\n");
- }
-
- if (th->t_blocks_logged == th->t_blocks_allocated) {
- th->t_blocks_allocated += JOURNAL_PER_BALANCE_CNT ;
- journal->j_len_alloc += JOURNAL_PER_BALANCE_CNT ;
- }
- th->t_blocks_logged++ ;
- journal->j_len++ ;
-
- cn->bh = bh ;
- cn->blocknr = bh->b_blocknr ;
- cn->sb = p_s_sb;
- cn->jlist = NULL ;
- insert_journal_hash(journal->j_hash_table, cn) ;
- if (!count_already_incd) {
- get_bh(bh) ;
- }
- }
- cn->next = NULL ;
- cn->prev = journal->j_last ;
- cn->bh = bh ;
- if (journal->j_last) {
- journal->j_last->next = cn ;
- journal->j_last = cn ;
- } else {
- journal->j_first = cn ;
- journal->j_last = cn ;
- }
- return 0 ;
-}
-
-int journal_end(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
- if (!current->journal_info && th->t_refcount > 1)
- reiserfs_warning (p_s_sb, "REISER-NESTING: th NULL, refcount %d",
- th->t_refcount);
-
- if (!th->t_trans_id) {
- WARN_ON (1);
- return -EIO;
- }
-
- th->t_refcount--;
- if (th->t_refcount > 0) {
- struct reiserfs_transaction_handle *cur_th = current->journal_info ;
-
- /* we aren't allowed to close a nested transaction on a different
- ** filesystem from the one in the task struct
- */
- if (cur_th->t_super != th->t_super)
- BUG() ;
-
- if (th != cur_th) {
- memcpy(current->journal_info, th, sizeof(*th));
- th->t_trans_id = 0;
- }
- return 0;
- } else {
- return do_journal_end(th, p_s_sb, nblocks, 0) ;
- }
+int journal_mark_dirty(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, struct buffer_head *bh)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_cnode *cn = NULL;
+ int count_already_incd = 0;
+ int prepared = 0;
+ BUG_ON(!th->t_trans_id);
+
+ PROC_INFO_INC(p_s_sb, journal.mark_dirty);
+ if (th->t_trans_id != journal->j_trans_id) {
+ reiserfs_panic(th->t_super,
+ "journal-1577: handle trans id %ld != current trans id %ld\n",
+ th->t_trans_id, journal->j_trans_id);
+ }
+
+ p_s_sb->s_dirt = 1;
+
+ prepared = test_clear_buffer_journal_prepared(bh);
+ clear_buffer_journal_restore_dirty(bh);
+ /* already in this transaction, we are done */
+ if (buffer_journaled(bh)) {
+ PROC_INFO_INC(p_s_sb, journal.mark_dirty_already);
+ return 0;
+ }
+
+ /* this must be turned into a panic instead of a warning. We can't allow
+ ** a dirty or journal_dirty or locked buffer to be logged, as some changes
+ ** could get to disk too early. NOT GOOD.
+ */
+ if (!prepared || buffer_dirty(bh)) {
+ reiserfs_warning(p_s_sb, "journal-1777: buffer %llu bad state "
+ "%cPREPARED %cLOCKED %cDIRTY %cJDIRTY_WAIT",
+ (unsigned long long)bh->b_blocknr,
+ prepared ? ' ' : '!',
+ buffer_locked(bh) ? ' ' : '!',
+ buffer_dirty(bh) ? ' ' : '!',
+ buffer_journal_dirty(bh) ? ' ' : '!');
+ }
+
+ if (atomic_read(&(journal->j_wcount)) <= 0) {
+ reiserfs_warning(p_s_sb,
+ "journal-1409: journal_mark_dirty returning because j_wcount was %d",
+ atomic_read(&(journal->j_wcount)));
+ return 1;
+ }
+ /* this error means I've screwed up, and we've overflowed the transaction.
+ ** Nothing can be done here, except make the FS readonly or panic.
+ */
+ if (journal->j_len >= journal->j_trans_max) {
+ reiserfs_panic(th->t_super,
+ "journal-1413: journal_mark_dirty: j_len (%lu) is too big\n",
+ journal->j_len);
+ }
+
+ if (buffer_journal_dirty(bh)) {
+ count_already_incd = 1;
+ PROC_INFO_INC(p_s_sb, journal.mark_dirty_notjournal);
+ clear_buffer_journal_dirty(bh);
+ }
+
+ if (journal->j_len > journal->j_len_alloc) {
+ journal->j_len_alloc = journal->j_len + JOURNAL_PER_BALANCE_CNT;
+ }
+
+ set_buffer_journaled(bh);
+
+ /* now put this guy on the end */
+ if (!cn) {
+ cn = get_cnode(p_s_sb);
+ if (!cn) {
+ reiserfs_panic(p_s_sb, "get_cnode failed!\n");
+ }
+
+ if (th->t_blocks_logged == th->t_blocks_allocated) {
+ th->t_blocks_allocated += JOURNAL_PER_BALANCE_CNT;
+ journal->j_len_alloc += JOURNAL_PER_BALANCE_CNT;
+ }
+ th->t_blocks_logged++;
+ journal->j_len++;
+
+ cn->bh = bh;
+ cn->blocknr = bh->b_blocknr;
+ cn->sb = p_s_sb;
+ cn->jlist = NULL;
+ insert_journal_hash(journal->j_hash_table, cn);
+ if (!count_already_incd) {
+ get_bh(bh);
+ }
+ }
+ cn->next = NULL;
+ cn->prev = journal->j_last;
+ cn->bh = bh;
+ if (journal->j_last) {
+ journal->j_last->next = cn;
+ journal->j_last = cn;
+ } else {
+ journal->j_first = cn;
+ journal->j_last = cn;
+ }
+ return 0;
+}
+
+int journal_end(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks)
+{
+ if (!current->journal_info && th->t_refcount > 1)
+ reiserfs_warning(p_s_sb, "REISER-NESTING: th NULL, refcount %d",
+ th->t_refcount);
+
+ if (!th->t_trans_id) {
+ WARN_ON(1);
+ return -EIO;
+ }
+
+ th->t_refcount--;
+ if (th->t_refcount > 0) {
+ struct reiserfs_transaction_handle *cur_th =
+ current->journal_info;
+
+ /* we aren't allowed to close a nested transaction on a different
+ ** filesystem from the one in the task struct
+ */
+ if (cur_th->t_super != th->t_super)
+ BUG();
+
+ if (th != cur_th) {
+ memcpy(current->journal_info, th, sizeof(*th));
+ th->t_trans_id = 0;
+ }
+ return 0;
+ } else {
+ return do_journal_end(th, p_s_sb, nblocks, 0);
+ }
}
/* removes from the current transaction, relsing and descrementing any counters.
@@ -2993,47 +3282,51 @@ int journal_end(struct reiserfs_transaction_handle *th, struct super_block *p_s_
**
** returns 1 if it cleaned and relsed the buffer. 0 otherwise
*/
-static int remove_from_transaction(struct super_block *p_s_sb, b_blocknr_t blocknr, int already_cleaned) {
- struct buffer_head *bh ;
- struct reiserfs_journal_cnode *cn ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- int ret = 0;
-
- cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr) ;
- if (!cn || !cn->bh) {
- return ret ;
- }
- bh = cn->bh ;
- if (cn->prev) {
- cn->prev->next = cn->next ;
- }
- if (cn->next) {
- cn->next->prev = cn->prev ;
- }
- if (cn == journal->j_first) {
- journal->j_first = cn->next ;
- }
- if (cn == journal->j_last) {
- journal->j_last = cn->prev ;
- }
- if (bh)
- remove_journal_hash(p_s_sb, journal->j_hash_table, NULL, bh->b_blocknr, 0) ;
- clear_buffer_journaled (bh); /* don't log this one */
-
- if (!already_cleaned) {
- clear_buffer_journal_dirty (bh);
- clear_buffer_dirty(bh);
- clear_buffer_journal_test (bh);
- put_bh(bh) ;
- if (atomic_read(&(bh->b_count)) < 0) {
- reiserfs_warning (p_s_sb, "journal-1752: remove from trans, b_count < 0");
- }
- ret = 1 ;
- }
- journal->j_len-- ;
- journal->j_len_alloc-- ;
- free_cnode(p_s_sb, cn) ;
- return ret ;
+static int remove_from_transaction(struct super_block *p_s_sb,
+ b_blocknr_t blocknr, int already_cleaned)
+{
+ struct buffer_head *bh;
+ struct reiserfs_journal_cnode *cn;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ int ret = 0;
+
+ cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr);
+ if (!cn || !cn->bh) {
+ return ret;
+ }
+ bh = cn->bh;
+ if (cn->prev) {
+ cn->prev->next = cn->next;
+ }
+ if (cn->next) {
+ cn->next->prev = cn->prev;
+ }
+ if (cn == journal->j_first) {
+ journal->j_first = cn->next;
+ }
+ if (cn == journal->j_last) {
+ journal->j_last = cn->prev;
+ }
+ if (bh)
+ remove_journal_hash(p_s_sb, journal->j_hash_table, NULL,
+ bh->b_blocknr, 0);
+ clear_buffer_journaled(bh); /* don't log this one */
+
+ if (!already_cleaned) {
+ clear_buffer_journal_dirty(bh);
+ clear_buffer_dirty(bh);
+ clear_buffer_journal_test(bh);
+ put_bh(bh);
+ if (atomic_read(&(bh->b_count)) < 0) {
+ reiserfs_warning(p_s_sb,
+ "journal-1752: remove from trans, b_count < 0");
+ }
+ ret = 1;
+ }
+ journal->j_len--;
+ journal->j_len_alloc--;
+ free_cnode(p_s_sb, cn);
+ return ret;
}
/*
@@ -3046,120 +3339,129 @@ static int remove_from_transaction(struct super_block *p_s_sb, b_blocknr_t block
** blocks for a given transaction on disk
**
*/
-static int can_dirty(struct reiserfs_journal_cnode *cn) {
- struct super_block *sb = cn->sb;
- b_blocknr_t blocknr = cn->blocknr ;
- struct reiserfs_journal_cnode *cur = cn->hprev ;
- int can_dirty = 1 ;
-
- /* first test hprev. These are all newer than cn, so any node here
- ** with the same block number and dev means this node can't be sent
- ** to disk right now.
- */
- while(cur && can_dirty) {
- if (cur->jlist && cur->bh && cur->blocknr && cur->sb == sb &&
- cur->blocknr == blocknr) {
- can_dirty = 0 ;
- }
- cur = cur->hprev ;
- }
- /* then test hnext. These are all older than cn. As long as they
- ** are committed to the log, it is safe to write cn to disk
- */
- cur = cn->hnext ;
- while(cur && can_dirty) {
- if (cur->jlist && cur->jlist->j_len > 0 &&
- atomic_read(&(cur->jlist->j_commit_left)) > 0 && cur->bh &&
- cur->blocknr && cur->sb == sb && cur->blocknr == blocknr) {
- can_dirty = 0 ;
- }
- cur = cur->hnext ;
- }
- return can_dirty ;
+static int can_dirty(struct reiserfs_journal_cnode *cn)
+{
+ struct super_block *sb = cn->sb;
+ b_blocknr_t blocknr = cn->blocknr;
+ struct reiserfs_journal_cnode *cur = cn->hprev;
+ int can_dirty = 1;
+
+ /* first test hprev. These are all newer than cn, so any node here
+ ** with the same block number and dev means this node can't be sent
+ ** to disk right now.
+ */
+ while (cur && can_dirty) {
+ if (cur->jlist && cur->bh && cur->blocknr && cur->sb == sb &&
+ cur->blocknr == blocknr) {
+ can_dirty = 0;
+ }
+ cur = cur->hprev;
+ }
+ /* then test hnext. These are all older than cn. As long as they
+ ** are committed to the log, it is safe to write cn to disk
+ */
+ cur = cn->hnext;
+ while (cur && can_dirty) {
+ if (cur->jlist && cur->jlist->j_len > 0 &&
+ atomic_read(&(cur->jlist->j_commit_left)) > 0 && cur->bh &&
+ cur->blocknr && cur->sb == sb && cur->blocknr == blocknr) {
+ can_dirty = 0;
+ }
+ cur = cur->hnext;
+ }
+ return can_dirty;
}
/* syncs the commit blocks, but does not force the real buffers to disk
** will wait until the current transaction is done/commited before returning
*/
-int journal_end_sync(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, unsigned long nblocks) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
+int journal_end_sync(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
- BUG_ON (!th->t_trans_id);
- /* you can sync while nested, very, very bad */
- if (th->t_refcount > 1) {
- BUG() ;
- }
- if (journal->j_len == 0) {
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
- }
- return do_journal_end(th, p_s_sb, nblocks, COMMIT_NOW | WAIT) ;
+ BUG_ON(!th->t_trans_id);
+ /* you can sync while nested, very, very bad */
+ if (th->t_refcount > 1) {
+ BUG();
+ }
+ if (journal->j_len == 0) {
+ reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb),
+ 1);
+ journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb));
+ }
+ return do_journal_end(th, p_s_sb, nblocks, COMMIT_NOW | WAIT);
}
/*
** writeback the pending async commits to disk
*/
-static void flush_async_commits(void *p) {
- struct super_block *p_s_sb = p;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_list *jl;
- struct list_head *entry;
-
- lock_kernel();
- if (!list_empty(&journal->j_journal_list)) {
- /* last entry is the youngest, commit it and you get everything */
- entry = journal->j_journal_list.prev;
- jl = JOURNAL_LIST_ENTRY(entry);
- flush_commit_list(p_s_sb, jl, 1);
- }
- unlock_kernel();
- /*
- * this is a little racey, but there's no harm in missing
- * the filemap_fdata_write
- */
- if (!atomic_read(&journal->j_async_throttle) && !reiserfs_is_journal_aborted (journal)) {
- atomic_inc(&journal->j_async_throttle);
- filemap_fdatawrite(p_s_sb->s_bdev->bd_inode->i_mapping);
- atomic_dec(&journal->j_async_throttle);
- }
+static void flush_async_commits(void *p)
+{
+ struct super_block *p_s_sb = p;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_list *jl;
+ struct list_head *entry;
+
+ lock_kernel();
+ if (!list_empty(&journal->j_journal_list)) {
+ /* last entry is the youngest, commit it and you get everything */
+ entry = journal->j_journal_list.prev;
+ jl = JOURNAL_LIST_ENTRY(entry);
+ flush_commit_list(p_s_sb, jl, 1);
+ }
+ unlock_kernel();
+ /*
+ * this is a little racey, but there's no harm in missing
+ * the filemap_fdata_write
+ */
+ if (!atomic_read(&journal->j_async_throttle)
+ && !reiserfs_is_journal_aborted(journal)) {
+ atomic_inc(&journal->j_async_throttle);
+ filemap_fdatawrite(p_s_sb->s_bdev->bd_inode->i_mapping);
+ atomic_dec(&journal->j_async_throttle);
+ }
}
/*
** flushes any old transactions to disk
** ends the current transaction if it is too old
*/
-int reiserfs_flush_old_commits(struct super_block *p_s_sb) {
- time_t now ;
- struct reiserfs_transaction_handle th ;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
-
- now = get_seconds();
- /* safety check so we don't flush while we are replaying the log during
- * mount
- */
- if (list_empty(&journal->j_journal_list)) {
- return 0 ;
- }
-
- /* check the current transaction. If there are no writers, and it is
- * too old, finish it, and force the commit blocks to disk
- */
- if (atomic_read(&journal->j_wcount) <= 0 &&
- journal->j_trans_start_time > 0 &&
- journal->j_len > 0 &&
- (now - journal->j_trans_start_time) > journal->j_max_trans_age)
- {
- if (!journal_join(&th, p_s_sb, 1)) {
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(&th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
-
- /* we're only being called from kreiserfsd, it makes no sense to do
- ** an async commit so that kreiserfsd can do it later
- */
- do_journal_end(&th, p_s_sb,1, COMMIT_NOW | WAIT) ;
- }
- }
- return p_s_sb->s_dirt;
+int reiserfs_flush_old_commits(struct super_block *p_s_sb)
+{
+ time_t now;
+ struct reiserfs_transaction_handle th;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+
+ now = get_seconds();
+ /* safety check so we don't flush while we are replaying the log during
+ * mount
+ */
+ if (list_empty(&journal->j_journal_list)) {
+ return 0;
+ }
+
+ /* check the current transaction. If there are no writers, and it is
+ * too old, finish it, and force the commit blocks to disk
+ */
+ if (atomic_read(&journal->j_wcount) <= 0 &&
+ journal->j_trans_start_time > 0 &&
+ journal->j_len > 0 &&
+ (now - journal->j_trans_start_time) > journal->j_max_trans_age) {
+ if (!journal_join(&th, p_s_sb, 1)) {
+ reiserfs_prepare_for_journal(p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb),
+ 1);
+ journal_mark_dirty(&th, p_s_sb,
+ SB_BUFFER_WITH_SB(p_s_sb));
+
+ /* we're only being called from kreiserfsd, it makes no sense to do
+ ** an async commit so that kreiserfsd can do it later
+ */
+ do_journal_end(&th, p_s_sb, 1, COMMIT_NOW | WAIT);
+ }
+ }
+ return p_s_sb->s_dirt;
}
/*
@@ -3173,101 +3475,108 @@ int reiserfs_flush_old_commits(struct super_block *p_s_sb) {
**
** Note, we can't allow the journal_end to proceed while there are still writers in the log.
*/
-static int check_journal_end(struct reiserfs_transaction_handle *th, struct super_block * p_s_sb,
- unsigned long nblocks, int flags) {
-
- time_t now ;
- int flush = flags & FLUSH_ALL ;
- int commit_now = flags & COMMIT_NOW ;
- int wait_on_commit = flags & WAIT ;
- struct reiserfs_journal_list *jl;
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
-
- BUG_ON (!th->t_trans_id);
-
- if (th->t_trans_id != journal->j_trans_id) {
- reiserfs_panic(th->t_super, "journal-1577: handle trans id %ld != current trans id %ld\n",
- th->t_trans_id, journal->j_trans_id);
- }
-
- journal->j_len_alloc -= (th->t_blocks_allocated - th->t_blocks_logged) ;
- if (atomic_read(&(journal->j_wcount)) > 0) { /* <= 0 is allowed. unmounting might not call begin */
- atomic_dec(&(journal->j_wcount)) ;
- }
-
- /* BUG, deal with case where j_len is 0, but people previously freed blocks need to be released
- ** will be dealt with by next transaction that actually writes something, but should be taken
- ** care of in this trans
- */
- if (journal->j_len == 0) {
- BUG();
- }
- /* if wcount > 0, and we are called to with flush or commit_now,
- ** we wait on j_join_wait. We will wake up when the last writer has
- ** finished the transaction, and started it on its way to the disk.
- ** Then, we flush the commit or journal list, and just return 0
- ** because the rest of journal end was already done for this transaction.
- */
- if (atomic_read(&(journal->j_wcount)) > 0) {
- if (flush || commit_now) {
- unsigned trans_id ;
-
- jl = journal->j_current_jl;
- trans_id = jl->j_trans_id;
- if (wait_on_commit)
- jl->j_state |= LIST_COMMIT_PENDING;
- atomic_set(&(journal->j_jlock), 1) ;
- if (flush) {
- journal->j_next_full_flush = 1 ;
- }
- unlock_journal(p_s_sb) ;
-
- /* sleep while the current transaction is still j_jlocked */
- while(journal->j_trans_id == trans_id) {
- if (atomic_read(&journal->j_jlock)) {
- queue_log_writer(p_s_sb);
- } else {
- lock_journal(p_s_sb);
- if (journal->j_trans_id == trans_id) {
- atomic_set(&(journal->j_jlock), 1) ;
- }
- unlock_journal(p_s_sb);
- }
- }
- if (journal->j_trans_id == trans_id) {
- BUG();
- }
- if (commit_now && journal_list_still_alive(p_s_sb, trans_id) &&
- wait_on_commit)
- {
- flush_commit_list(p_s_sb, jl, 1) ;
- }
- return 0 ;
- }
- unlock_journal(p_s_sb) ;
- return 0 ;
- }
-
- /* deal with old transactions where we are the last writers */
- now = get_seconds();
- if ((now - journal->j_trans_start_time) > journal->j_max_trans_age) {
- commit_now = 1 ;
- journal->j_next_async_flush = 1 ;
- }
- /* don't batch when someone is waiting on j_join_wait */
- /* don't batch when syncing the commit or flushing the whole trans */
- if (!(journal->j_must_wait > 0) && !(atomic_read(&(journal->j_jlock))) && !flush && !commit_now &&
- (journal->j_len < journal->j_max_batch) &&
- journal->j_len_alloc < journal->j_max_batch && journal->j_cnode_free > (journal->j_trans_max * 3)) {
- journal->j_bcount++ ;
- unlock_journal(p_s_sb) ;
- return 0 ;
- }
-
- if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
- reiserfs_panic(p_s_sb, "journal-003: journal_end: j_start (%ld) is too high\n", journal->j_start) ;
- }
- return 1 ;
+static int check_journal_end(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks,
+ int flags)
+{
+
+ time_t now;
+ int flush = flags & FLUSH_ALL;
+ int commit_now = flags & COMMIT_NOW;
+ int wait_on_commit = flags & WAIT;
+ struct reiserfs_journal_list *jl;
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+
+ BUG_ON(!th->t_trans_id);
+
+ if (th->t_trans_id != journal->j_trans_id) {
+ reiserfs_panic(th->t_super,
+ "journal-1577: handle trans id %ld != current trans id %ld\n",
+ th->t_trans_id, journal->j_trans_id);
+ }
+
+ journal->j_len_alloc -= (th->t_blocks_allocated - th->t_blocks_logged);
+ if (atomic_read(&(journal->j_wcount)) > 0) { /* <= 0 is allowed. unmounting might not call begin */
+ atomic_dec(&(journal->j_wcount));
+ }
+
+ /* BUG, deal with case where j_len is 0, but people previously freed blocks need to be released
+ ** will be dealt with by next transaction that actually writes something, but should be taken
+ ** care of in this trans
+ */
+ if (journal->j_len == 0) {
+ BUG();
+ }
+ /* if wcount > 0, and we are called to with flush or commit_now,
+ ** we wait on j_join_wait. We will wake up when the last writer has
+ ** finished the transaction, and started it on its way to the disk.
+ ** Then, we flush the commit or journal list, and just return 0
+ ** because the rest of journal end was already done for this transaction.
+ */
+ if (atomic_read(&(journal->j_wcount)) > 0) {
+ if (flush || commit_now) {
+ unsigned trans_id;
+
+ jl = journal->j_current_jl;
+ trans_id = jl->j_trans_id;
+ if (wait_on_commit)
+ jl->j_state |= LIST_COMMIT_PENDING;
+ atomic_set(&(journal->j_jlock), 1);
+ if (flush) {
+ journal->j_next_full_flush = 1;
+ }
+ unlock_journal(p_s_sb);
+
+ /* sleep while the current transaction is still j_jlocked */
+ while (journal->j_trans_id == trans_id) {
+ if (atomic_read(&journal->j_jlock)) {
+ queue_log_writer(p_s_sb);
+ } else {
+ lock_journal(p_s_sb);
+ if (journal->j_trans_id == trans_id) {
+ atomic_set(&(journal->j_jlock),
+ 1);
+ }
+ unlock_journal(p_s_sb);
+ }
+ }
+ if (journal->j_trans_id == trans_id) {
+ BUG();
+ }
+ if (commit_now
+ && journal_list_still_alive(p_s_sb, trans_id)
+ && wait_on_commit) {
+ flush_commit_list(p_s_sb, jl, 1);
+ }
+ return 0;
+ }
+ unlock_journal(p_s_sb);
+ return 0;
+ }
+
+ /* deal with old transactions where we are the last writers */
+ now = get_seconds();
+ if ((now - journal->j_trans_start_time) > journal->j_max_trans_age) {
+ commit_now = 1;
+ journal->j_next_async_flush = 1;
+ }
+ /* don't batch when someone is waiting on j_join_wait */
+ /* don't batch when syncing the commit or flushing the whole trans */
+ if (!(journal->j_must_wait > 0) && !(atomic_read(&(journal->j_jlock)))
+ && !flush && !commit_now && (journal->j_len < journal->j_max_batch)
+ && journal->j_len_alloc < journal->j_max_batch
+ && journal->j_cnode_free > (journal->j_trans_max * 3)) {
+ journal->j_bcount++;
+ unlock_journal(p_s_sb);
+ return 0;
+ }
+
+ if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
+ reiserfs_panic(p_s_sb,
+ "journal-003: journal_end: j_start (%ld) is too high\n",
+ journal->j_start);
+ }
+ return 1;
}
/*
@@ -3284,83 +3593,95 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, struct supe
**
** Then remove it from the current transaction, decrementing any counters and filing it on the clean list.
*/
-int journal_mark_freed(struct reiserfs_transaction_handle *th, struct super_block *p_s_sb, b_blocknr_t blocknr) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_cnode *cn = NULL ;
- struct buffer_head *bh = NULL ;
- struct reiserfs_list_bitmap *jb = NULL ;
- int cleaned = 0 ;
- BUG_ON (!th->t_trans_id);
-
- cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr);
- if (cn && cn->bh) {
- bh = cn->bh ;
- get_bh(bh) ;
- }
- /* if it is journal new, we just remove it from this transaction */
- if (bh && buffer_journal_new(bh)) {
- clear_buffer_journal_new (bh);
- clear_prepared_bits(bh) ;
- reiserfs_clean_and_file_buffer(bh) ;
- cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned) ;
- } else {
- /* set the bit for this block in the journal bitmap for this transaction */
- jb = journal->j_current_jl->j_list_bitmap;
- if (!jb) {
- reiserfs_panic(p_s_sb, "journal-1702: journal_mark_freed, journal_list_bitmap is NULL\n") ;
- }
- set_bit_in_list_bitmap(p_s_sb, blocknr, jb) ;
-
- /* Note, the entire while loop is not allowed to schedule. */
-
- if (bh) {
- clear_prepared_bits(bh) ;
- reiserfs_clean_and_file_buffer(bh) ;
- }
- cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned) ;
-
- /* find all older transactions with this block, make sure they don't try to write it out */
- cn = get_journal_hash_dev(p_s_sb,journal->j_list_hash_table, blocknr) ;
- while (cn) {
- if (p_s_sb == cn->sb && blocknr == cn->blocknr) {
- set_bit(BLOCK_FREED, &cn->state) ;
- if (cn->bh) {
- if (!cleaned) {
- /* remove_from_transaction will brelse the buffer if it was
- ** in the current trans
- */
- clear_buffer_journal_dirty (cn->bh);
- clear_buffer_dirty(cn->bh);
- clear_buffer_journal_test(cn->bh);
- cleaned = 1 ;
- put_bh(cn->bh) ;
- if (atomic_read(&(cn->bh->b_count)) < 0) {
- reiserfs_warning (p_s_sb, "journal-2138: cn->bh->b_count < 0");
- }
- }
- if (cn->jlist) { /* since we are clearing the bh, we MUST dec nonzerolen */
- atomic_dec(&(cn->jlist->j_nonzerolen)) ;
- }
- cn->bh = NULL ;
- }
- }
- cn = cn->hnext ;
- }
- }
-
- if (bh) {
- put_bh(bh) ; /* get_hash grabs the buffer */
- if (atomic_read(&(bh->b_count)) < 0) {
- reiserfs_warning (p_s_sb, "journal-2165: bh->b_count < 0");
- }
- }
- return 0 ;
-}
-
-void reiserfs_update_inode_transaction(struct inode *inode) {
- struct reiserfs_journal *journal = SB_JOURNAL (inode->i_sb);
- REISERFS_I(inode)->i_jl = journal->j_current_jl;
- REISERFS_I(inode)->i_trans_id = journal->j_trans_id ;
+int journal_mark_freed(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, b_blocknr_t blocknr)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_cnode *cn = NULL;
+ struct buffer_head *bh = NULL;
+ struct reiserfs_list_bitmap *jb = NULL;
+ int cleaned = 0;
+ BUG_ON(!th->t_trans_id);
+
+ cn = get_journal_hash_dev(p_s_sb, journal->j_hash_table, blocknr);
+ if (cn && cn->bh) {
+ bh = cn->bh;
+ get_bh(bh);
+ }
+ /* if it is journal new, we just remove it from this transaction */
+ if (bh && buffer_journal_new(bh)) {
+ clear_buffer_journal_new(bh);
+ clear_prepared_bits(bh);
+ reiserfs_clean_and_file_buffer(bh);
+ cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned);
+ } else {
+ /* set the bit for this block in the journal bitmap for this transaction */
+ jb = journal->j_current_jl->j_list_bitmap;
+ if (!jb) {
+ reiserfs_panic(p_s_sb,
+ "journal-1702: journal_mark_freed, journal_list_bitmap is NULL\n");
+ }
+ set_bit_in_list_bitmap(p_s_sb, blocknr, jb);
+
+ /* Note, the entire while loop is not allowed to schedule. */
+
+ if (bh) {
+ clear_prepared_bits(bh);
+ reiserfs_clean_and_file_buffer(bh);
+ }
+ cleaned = remove_from_transaction(p_s_sb, blocknr, cleaned);
+
+ /* find all older transactions with this block, make sure they don't try to write it out */
+ cn = get_journal_hash_dev(p_s_sb, journal->j_list_hash_table,
+ blocknr);
+ while (cn) {
+ if (p_s_sb == cn->sb && blocknr == cn->blocknr) {
+ set_bit(BLOCK_FREED, &cn->state);
+ if (cn->bh) {
+ if (!cleaned) {
+ /* remove_from_transaction will brelse the buffer if it was
+ ** in the current trans
+ */
+ clear_buffer_journal_dirty(cn->
+ bh);
+ clear_buffer_dirty(cn->bh);
+ clear_buffer_journal_test(cn->
+ bh);
+ cleaned = 1;
+ put_bh(cn->bh);
+ if (atomic_read
+ (&(cn->bh->b_count)) < 0) {
+ reiserfs_warning(p_s_sb,
+ "journal-2138: cn->bh->b_count < 0");
+ }
+ }
+ if (cn->jlist) { /* since we are clearing the bh, we MUST dec nonzerolen */
+ atomic_dec(&
+ (cn->jlist->
+ j_nonzerolen));
+ }
+ cn->bh = NULL;
+ }
+ }
+ cn = cn->hnext;
+ }
+ }
+
+ if (bh) {
+ put_bh(bh); /* get_hash grabs the buffer */
+ if (atomic_read(&(bh->b_count)) < 0) {
+ reiserfs_warning(p_s_sb,
+ "journal-2165: bh->b_count < 0");
+ }
+ }
+ return 0;
+}
+
+void reiserfs_update_inode_transaction(struct inode *inode)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(inode->i_sb);
+ REISERFS_I(inode)->i_jl = journal->j_current_jl;
+ REISERFS_I(inode)->i_trans_id = journal->j_trans_id;
}
/*
@@ -3368,99 +3689,102 @@ void reiserfs_update_inode_transaction(struct inode *inode) {
* if a transaction was actually committed and the barrier was done
*/
static int __commit_trans_jl(struct inode *inode, unsigned long id,
- struct reiserfs_journal_list *jl)
+ struct reiserfs_journal_list *jl)
{
- struct reiserfs_transaction_handle th ;
- struct super_block *sb = inode->i_sb ;
- struct reiserfs_journal *journal = SB_JOURNAL (sb);
- int ret = 0;
+ struct reiserfs_transaction_handle th;
+ struct super_block *sb = inode->i_sb;
+ struct reiserfs_journal *journal = SB_JOURNAL(sb);
+ int ret = 0;
+
+ /* is it from the current transaction, or from an unknown transaction? */
+ if (id == journal->j_trans_id) {
+ jl = journal->j_current_jl;
+ /* try to let other writers come in and grow this transaction */
+ let_transaction_grow(sb, id);
+ if (journal->j_trans_id != id) {
+ goto flush_commit_only;
+ }
- /* is it from the current transaction, or from an unknown transaction? */
- if (id == journal->j_trans_id) {
- jl = journal->j_current_jl;
- /* try to let other writers come in and grow this transaction */
- let_transaction_grow(sb, id);
- if (journal->j_trans_id != id) {
- goto flush_commit_only;
- }
+ ret = journal_begin(&th, sb, 1);
+ if (ret)
+ return ret;
+
+ /* someone might have ended this transaction while we joined */
+ if (journal->j_trans_id != id) {
+ reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb),
+ 1);
+ journal_mark_dirty(&th, sb, SB_BUFFER_WITH_SB(sb));
+ ret = journal_end(&th, sb, 1);
+ goto flush_commit_only;
+ }
- ret = journal_begin(&th, sb, 1) ;
- if (ret)
- return ret;
+ ret = journal_end_sync(&th, sb, 1);
+ if (!ret)
+ ret = 1;
- /* someone might have ended this transaction while we joined */
- if (journal->j_trans_id != id) {
- reiserfs_prepare_for_journal(sb, SB_BUFFER_WITH_SB(sb), 1) ;
- journal_mark_dirty(&th, sb, SB_BUFFER_WITH_SB(sb)) ;
- ret = journal_end(&th, sb, 1) ;
- goto flush_commit_only;
+ } else {
+ /* this gets tricky, we have to make sure the journal list in
+ * the inode still exists. We know the list is still around
+ * if we've got a larger transaction id than the oldest list
+ */
+ flush_commit_only:
+ if (journal_list_still_alive(inode->i_sb, id)) {
+ /*
+ * we only set ret to 1 when we know for sure
+ * the barrier hasn't been started yet on the commit
+ * block.
+ */
+ if (atomic_read(&jl->j_commit_left) > 1)
+ ret = 1;
+ flush_commit_list(sb, jl, 1);
+ if (journal->j_errno)
+ ret = journal->j_errno;
+ }
}
+ /* otherwise the list is gone, and long since committed */
+ return ret;
+}
- ret = journal_end_sync(&th, sb, 1) ;
- if (!ret)
- ret = 1;
+int reiserfs_commit_for_inode(struct inode *inode)
+{
+ unsigned long id = REISERFS_I(inode)->i_trans_id;
+ struct reiserfs_journal_list *jl = REISERFS_I(inode)->i_jl;
- } else {
- /* this gets tricky, we have to make sure the journal list in
- * the inode still exists. We know the list is still around
- * if we've got a larger transaction id than the oldest list
+ /* for the whole inode, assume unset id means it was
+ * changed in the current transaction. More conservative
*/
-flush_commit_only:
- if (journal_list_still_alive(inode->i_sb, id)) {
- /*
- * we only set ret to 1 when we know for sure
- * the barrier hasn't been started yet on the commit
- * block.
- */
- if (atomic_read(&jl->j_commit_left) > 1)
- ret = 1;
- flush_commit_list(sb, jl, 1) ;
- if (journal->j_errno)
- ret = journal->j_errno;
- }
- }
- /* otherwise the list is gone, and long since committed */
- return ret;
-}
-
-int reiserfs_commit_for_inode(struct inode *inode) {
- unsigned long id = REISERFS_I(inode)->i_trans_id;
- struct reiserfs_journal_list *jl = REISERFS_I(inode)->i_jl;
-
- /* for the whole inode, assume unset id means it was
- * changed in the current transaction. More conservative
- */
- if (!id || !jl) {
- reiserfs_update_inode_transaction(inode) ;
- id = REISERFS_I(inode)->i_trans_id;
- /* jl will be updated in __commit_trans_jl */
- }
-
- return __commit_trans_jl(inode, id, jl);
-}
-
-void reiserfs_restore_prepared_buffer(struct super_block *p_s_sb,
- struct buffer_head *bh) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- PROC_INFO_INC( p_s_sb, journal.restore_prepared );
- if (!bh) {
- return ;
- }
- if (test_clear_buffer_journal_restore_dirty (bh) &&
- buffer_journal_dirty(bh)) {
- struct reiserfs_journal_cnode *cn;
- cn = get_journal_hash_dev(p_s_sb,
- journal->j_list_hash_table,
- bh->b_blocknr);
- if (cn && can_dirty(cn)) {
- set_buffer_journal_test (bh);
- mark_buffer_dirty(bh);
- }
- }
- clear_buffer_journal_prepared (bh);
-}
-
-extern struct tree_balance *cur_tb ;
+ if (!id || !jl) {
+ reiserfs_update_inode_transaction(inode);
+ id = REISERFS_I(inode)->i_trans_id;
+ /* jl will be updated in __commit_trans_jl */
+ }
+
+ return __commit_trans_jl(inode, id, jl);
+}
+
+void reiserfs_restore_prepared_buffer(struct super_block *p_s_sb,
+ struct buffer_head *bh)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ PROC_INFO_INC(p_s_sb, journal.restore_prepared);
+ if (!bh) {
+ return;
+ }
+ if (test_clear_buffer_journal_restore_dirty(bh) &&
+ buffer_journal_dirty(bh)) {
+ struct reiserfs_journal_cnode *cn;
+ cn = get_journal_hash_dev(p_s_sb,
+ journal->j_list_hash_table,
+ bh->b_blocknr);
+ if (cn && can_dirty(cn)) {
+ set_buffer_journal_test(bh);
+ mark_buffer_dirty(bh);
+ }
+ }
+ clear_buffer_journal_prepared(bh);
+}
+
+extern struct tree_balance *cur_tb;
/*
** before we can change a metadata block, we have to make sure it won't
** be written to disk while we are altering it. So, we must:
@@ -3469,39 +3793,41 @@ extern struct tree_balance *cur_tb ;
**
*/
int reiserfs_prepare_for_journal(struct super_block *p_s_sb,
- struct buffer_head *bh, int wait) {
- PROC_INFO_INC( p_s_sb, journal.prepare );
-
- if (test_set_buffer_locked(bh)) {
- if (!wait)
- return 0;
- lock_buffer(bh);
- }
- set_buffer_journal_prepared (bh);
- if (test_clear_buffer_dirty(bh) && buffer_journal_dirty(bh)) {
- clear_buffer_journal_test (bh);
- set_buffer_journal_restore_dirty (bh);
- }
- unlock_buffer(bh);
- return 1;
-}
-
-static void flush_old_journal_lists(struct super_block *s) {
- struct reiserfs_journal *journal = SB_JOURNAL (s);
- struct reiserfs_journal_list *jl;
- struct list_head *entry;
- time_t now = get_seconds();
-
- while(!list_empty(&journal->j_journal_list)) {
- entry = journal->j_journal_list.next;
- jl = JOURNAL_LIST_ENTRY(entry);
- /* this check should always be run, to send old lists to disk */
- if (jl->j_timestamp < (now - (JOURNAL_MAX_TRANS_AGE * 4))) {
- flush_used_journal_lists(s, jl);
- } else {
- break;
+ struct buffer_head *bh, int wait)
+{
+ PROC_INFO_INC(p_s_sb, journal.prepare);
+
+ if (test_set_buffer_locked(bh)) {
+ if (!wait)
+ return 0;
+ lock_buffer(bh);
+ }
+ set_buffer_journal_prepared(bh);
+ if (test_clear_buffer_dirty(bh) && buffer_journal_dirty(bh)) {
+ clear_buffer_journal_test(bh);
+ set_buffer_journal_restore_dirty(bh);
+ }
+ unlock_buffer(bh);
+ return 1;
+}
+
+static void flush_old_journal_lists(struct super_block *s)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ struct reiserfs_journal_list *jl;
+ struct list_head *entry;
+ time_t now = get_seconds();
+
+ while (!list_empty(&journal->j_journal_list)) {
+ entry = journal->j_journal_list.next;
+ jl = JOURNAL_LIST_ENTRY(entry);
+ /* this check should always be run, to send old lists to disk */
+ if (jl->j_timestamp < (now - (JOURNAL_MAX_TRANS_AGE * 4))) {
+ flush_used_journal_lists(s, jl);
+ } else {
+ break;
+ }
}
- }
}
/*
@@ -3514,375 +3840,390 @@ static void flush_old_journal_lists(struct super_block *s) {
** If the journal is aborted, we just clean up. Things like flushing
** journal lists, etc just won't happen.
*/
-static int do_journal_end(struct reiserfs_transaction_handle *th, struct super_block * p_s_sb, unsigned long nblocks,
- int flags) {
- struct reiserfs_journal *journal = SB_JOURNAL (p_s_sb);
- struct reiserfs_journal_cnode *cn, *next, *jl_cn;
- struct reiserfs_journal_cnode *last_cn = NULL;
- struct reiserfs_journal_desc *desc ;
- struct reiserfs_journal_commit *commit ;
- struct buffer_head *c_bh ; /* commit bh */
- struct buffer_head *d_bh ; /* desc bh */
- int cur_write_start = 0 ; /* start index of current log write */
- int old_start ;
- int i ;
- int flush = flags & FLUSH_ALL ;
- int wait_on_commit = flags & WAIT ;
- struct reiserfs_journal_list *jl, *temp_jl;
- struct list_head *entry, *safe;
- unsigned long jindex;
- unsigned long commit_trans_id;
- int trans_half;
-
- BUG_ON (th->t_refcount > 1);
- BUG_ON (!th->t_trans_id);
-
- put_fs_excl();
- current->journal_info = th->t_handle_save;
- reiserfs_check_lock_depth(p_s_sb, "journal end");
- if (journal->j_len == 0) {
- reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb), 1) ;
- journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb)) ;
- }
-
- lock_journal(p_s_sb) ;
- if (journal->j_next_full_flush) {
- flags |= FLUSH_ALL ;
- flush = 1 ;
- }
- if (journal->j_next_async_flush) {
- flags |= COMMIT_NOW | WAIT;
- wait_on_commit = 1;
- }
-
- /* check_journal_end locks the journal, and unlocks if it does not return 1
- ** it tells us if we should continue with the journal_end, or just return
- */
- if (!check_journal_end(th, p_s_sb, nblocks, flags)) {
- p_s_sb->s_dirt = 1;
- wake_queued_writers(p_s_sb);
- reiserfs_async_progress_wait(p_s_sb);
- goto out ;
- }
-
- /* check_journal_end might set these, check again */
- if (journal->j_next_full_flush) {
- flush = 1 ;
- }
-
- /*
- ** j must wait means we have to flush the log blocks, and the real blocks for
- ** this transaction
- */
- if (journal->j_must_wait > 0) {
- flush = 1 ;
- }
+static int do_journal_end(struct reiserfs_transaction_handle *th,
+ struct super_block *p_s_sb, unsigned long nblocks,
+ int flags)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb);
+ struct reiserfs_journal_cnode *cn, *next, *jl_cn;
+ struct reiserfs_journal_cnode *last_cn = NULL;
+ struct reiserfs_journal_desc *desc;
+ struct reiserfs_journal_commit *commit;
+ struct buffer_head *c_bh; /* commit bh */
+ struct buffer_head *d_bh; /* desc bh */
+ int cur_write_start = 0; /* start index of current log write */
+ int old_start;
+ int i;
+ int flush = flags & FLUSH_ALL;
+ int wait_on_commit = flags & WAIT;
+ struct reiserfs_journal_list *jl, *temp_jl;
+ struct list_head *entry, *safe;
+ unsigned long jindex;
+ unsigned long commit_trans_id;
+ int trans_half;
+
+ BUG_ON(th->t_refcount > 1);
+ BUG_ON(!th->t_trans_id);
+
+ put_fs_excl();
+ current->journal_info = th->t_handle_save;
+ reiserfs_check_lock_depth(p_s_sb, "journal end");
+ if (journal->j_len == 0) {
+ reiserfs_prepare_for_journal(p_s_sb, SB_BUFFER_WITH_SB(p_s_sb),
+ 1);
+ journal_mark_dirty(th, p_s_sb, SB_BUFFER_WITH_SB(p_s_sb));
+ }
+ lock_journal(p_s_sb);
+ if (journal->j_next_full_flush) {
+ flags |= FLUSH_ALL;
+ flush = 1;
+ }
+ if (journal->j_next_async_flush) {
+ flags |= COMMIT_NOW | WAIT;
+ wait_on_commit = 1;
+ }
+
+ /* check_journal_end locks the journal, and unlocks if it does not return 1
+ ** it tells us if we should continue with the journal_end, or just return
+ */
+ if (!check_journal_end(th, p_s_sb, nblocks, flags)) {
+ p_s_sb->s_dirt = 1;
+ wake_queued_writers(p_s_sb);
+ reiserfs_async_progress_wait(p_s_sb);
+ goto out;
+ }
+
+ /* check_journal_end might set these, check again */
+ if (journal->j_next_full_flush) {
+ flush = 1;
+ }
+
+ /*
+ ** j must wait means we have to flush the log blocks, and the real blocks for
+ ** this transaction
+ */
+ if (journal->j_must_wait > 0) {
+ flush = 1;
+ }
#ifdef REISERFS_PREALLOCATE
- /* quota ops might need to nest, setup the journal_info pointer for them */
- current->journal_info = th ;
- reiserfs_discard_all_prealloc(th); /* it should not involve new blocks into
- * the transaction */
- current->journal_info = th->t_handle_save ;
+ /* quota ops might need to nest, setup the journal_info pointer for them */
+ current->journal_info = th;
+ reiserfs_discard_all_prealloc(th); /* it should not involve new blocks into
+ * the transaction */
+ current->journal_info = th->t_handle_save;
#endif
-
- /* setup description block */
- d_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + journal->j_start) ;
- set_buffer_uptodate(d_bh);
- desc = (struct reiserfs_journal_desc *)(d_bh)->b_data ;
- memset(d_bh->b_data, 0, d_bh->b_size) ;
- memcpy(get_journal_desc_magic (d_bh), JOURNAL_DESC_MAGIC, 8) ;
- set_desc_trans_id(desc, journal->j_trans_id) ;
-
- /* setup commit block. Don't write (keep it clean too) this one until after everyone else is written */
- c_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- ((journal->j_start + journal->j_len + 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
- commit = (struct reiserfs_journal_commit *)c_bh->b_data ;
- memset(c_bh->b_data, 0, c_bh->b_size) ;
- set_commit_trans_id(commit, journal->j_trans_id) ;
- set_buffer_uptodate(c_bh) ;
-
- /* init this journal list */
- jl = journal->j_current_jl;
-
- /* we lock the commit before doing anything because
- * we want to make sure nobody tries to run flush_commit_list until
- * the new transaction is fully setup, and we've already flushed the
- * ordered bh list
- */
- down(&jl->j_commit_lock);
-
- /* save the transaction id in case we need to commit it later */
- commit_trans_id = jl->j_trans_id;
-
- atomic_set(&jl->j_older_commits_done, 0) ;
- jl->j_trans_id = journal->j_trans_id ;
- jl->j_timestamp = journal->j_trans_start_time ;
- jl->j_commit_bh = c_bh ;
- jl->j_start = journal->j_start ;
- jl->j_len = journal->j_len ;
- atomic_set(&jl->j_nonzerolen, journal->j_len) ;
- atomic_set(&jl->j_commit_left, journal->j_len + 2);
- jl->j_realblock = NULL ;
-
- /* The ENTIRE FOR LOOP MUST not cause schedule to occur.
- ** for each real block, add it to the journal list hash,
- ** copy into real block index array in the commit or desc block
- */
- trans_half = journal_trans_half(p_s_sb->s_blocksize);
- for (i = 0, cn = journal->j_first ; cn ; cn = cn->next, i++) {
- if (buffer_journaled (cn->bh)) {
- jl_cn = get_cnode(p_s_sb) ;
- if (!jl_cn) {
- reiserfs_panic(p_s_sb, "journal-1676, get_cnode returned NULL\n") ;
- }
- if (i == 0) {
- jl->j_realblock = jl_cn ;
- }
- jl_cn->prev = last_cn ;
- jl_cn->next = NULL ;
- if (last_cn) {
- last_cn->next = jl_cn ;
- }
- last_cn = jl_cn ;
- /* make sure the block we are trying to log is not a block
- of journal or reserved area */
-
- if (is_block_in_log_or_reserved_area(p_s_sb, cn->bh->b_blocknr)) {
- reiserfs_panic(p_s_sb, "journal-2332: Trying to log block %lu, which is a log block\n", cn->bh->b_blocknr) ;
- }
- jl_cn->blocknr = cn->bh->b_blocknr ;
- jl_cn->state = 0 ;
- jl_cn->sb = p_s_sb;
- jl_cn->bh = cn->bh ;
- jl_cn->jlist = jl;
- insert_journal_hash(journal->j_list_hash_table, jl_cn) ;
- if (i < trans_half) {
- desc->j_realblock[i] = cpu_to_le32(cn->bh->b_blocknr) ;
- } else {
- commit->j_realblock[i - trans_half] = cpu_to_le32(cn->bh->b_blocknr) ;
- }
- } else {
- i-- ;
- }
- }
- set_desc_trans_len(desc, journal->j_len) ;
- set_desc_mount_id(desc, journal->j_mount_id) ;
- set_desc_trans_id(desc, journal->j_trans_id) ;
- set_commit_trans_len(commit, journal->j_len);
-
- /* special check in case all buffers in the journal were marked for not logging */
- if (journal->j_len == 0) {
- BUG();
- }
-
- /* we're about to dirty all the log blocks, mark the description block
- * dirty now too. Don't mark the commit block dirty until all the
- * others are on disk
- */
- mark_buffer_dirty(d_bh);
-
- /* first data block is j_start + 1, so add one to cur_write_start wherever you use it */
- cur_write_start = journal->j_start ;
- cn = journal->j_first ;
- jindex = 1 ; /* start at one so we don't get the desc again */
- while(cn) {
- clear_buffer_journal_new (cn->bh);
- /* copy all the real blocks into log area. dirty log blocks */
- if (buffer_journaled (cn->bh)) {
- struct buffer_head *tmp_bh ;
- char *addr;
- struct page *page;
- tmp_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
- ((cur_write_start + jindex) % SB_ONDISK_JOURNAL_SIZE(p_s_sb))) ;
- set_buffer_uptodate(tmp_bh);
- page = cn->bh->b_page;
- addr = kmap(page);
- memcpy(tmp_bh->b_data, addr + offset_in_page(cn->bh->b_data),
- cn->bh->b_size);
- kunmap(page);
- mark_buffer_dirty(tmp_bh);
- jindex++ ;
- set_buffer_journal_dirty (cn->bh);
- clear_buffer_journaled (cn->bh);
- } else {
- /* JDirty cleared sometime during transaction. don't log this one */
- reiserfs_warning(p_s_sb, "journal-2048: do_journal_end: BAD, buffer in journal hash, but not JDirty!") ;
- brelse(cn->bh) ;
- }
- next = cn->next ;
- free_cnode(p_s_sb, cn) ;
- cn = next ;
- cond_resched();
- }
-
- /* we are done with both the c_bh and d_bh, but
- ** c_bh must be written after all other commit blocks,
- ** so we dirty/relse c_bh in flush_commit_list, with commit_left <= 1.
- */
-
- journal->j_current_jl = alloc_journal_list(p_s_sb);
-
- /* now it is safe to insert this transaction on the main list */
- list_add_tail(&jl->j_list, &journal->j_journal_list);
- list_add_tail(&jl->j_working_list, &journal->j_working_list);
- journal->j_num_work_lists++;
-
- /* reset journal values for the next transaction */
- old_start = journal->j_start ;
- journal->j_start = (journal->j_start + journal->j_len + 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb);
- atomic_set(&(journal->j_wcount), 0) ;
- journal->j_bcount = 0 ;
- journal->j_last = NULL ;
- journal->j_first = NULL ;
- journal->j_len = 0 ;
- journal->j_trans_start_time = 0 ;
- journal->j_trans_id++ ;
- journal->j_current_jl->j_trans_id = journal->j_trans_id;
- journal->j_must_wait = 0 ;
- journal->j_len_alloc = 0 ;
- journal->j_next_full_flush = 0 ;
- journal->j_next_async_flush = 0 ;
- init_journal_hash(p_s_sb) ;
-
- // make sure reiserfs_add_jh sees the new current_jl before we
- // write out the tails
- smp_mb();
-
- /* tail conversion targets have to hit the disk before we end the
- * transaction. Otherwise a later transaction might repack the tail
- * before this transaction commits, leaving the data block unflushed and
- * clean, if we crash before the later transaction commits, the data block
- * is lost.
- */
- if (!list_empty(&jl->j_tail_bh_list)) {
- unlock_kernel();
- write_ordered_buffers(&journal->j_dirty_buffers_lock,
- journal, jl, &jl->j_tail_bh_list);
- lock_kernel();
- }
- if (!list_empty(&jl->j_tail_bh_list))
- BUG();
- up(&jl->j_commit_lock);
-
- /* honor the flush wishes from the caller, simple commits can
- ** be done outside the journal lock, they are done below
- **
- ** if we don't flush the commit list right now, we put it into
- ** the work queue so the people waiting on the async progress work
- ** queue don't wait for this proc to flush journal lists and such.
- */
- if (flush) {
- flush_commit_list(p_s_sb, jl, 1) ;
- flush_journal_list(p_s_sb, jl, 1) ;
- } else if (!(jl->j_state & LIST_COMMIT_PENDING))
- queue_delayed_work(commit_wq, &journal->j_work, HZ/10);
-
-
- /* if the next transaction has any chance of wrapping, flush
- ** transactions that might get overwritten. If any journal lists are very
- ** old flush them as well.
- */
-first_jl:
- list_for_each_safe(entry, safe, &journal->j_journal_list) {
- temp_jl = JOURNAL_LIST_ENTRY(entry);
- if (journal->j_start <= temp_jl->j_start) {
- if ((journal->j_start + journal->j_trans_max + 1) >=
- temp_jl->j_start)
- {
- flush_used_journal_lists(p_s_sb, temp_jl);
- goto first_jl;
- } else if ((journal->j_start +
- journal->j_trans_max + 1) <
- SB_ONDISK_JOURNAL_SIZE(p_s_sb))
- {
- /* if we don't cross into the next transaction and we don't
- * wrap, there is no way we can overlap any later transactions
- * break now
- */
- break;
- }
- } else if ((journal->j_start +
- journal->j_trans_max + 1) >
- SB_ONDISK_JOURNAL_SIZE(p_s_sb))
- {
- if (((journal->j_start + journal->j_trans_max + 1) %
- SB_ONDISK_JOURNAL_SIZE(p_s_sb)) >= temp_jl->j_start)
- {
- flush_used_journal_lists(p_s_sb, temp_jl);
- goto first_jl;
- } else {
- /* we don't overlap anything from out start to the end of the
- * log, and our wrapped portion doesn't overlap anything at
- * the start of the log. We can break
- */
- break;
- }
- }
- }
- flush_old_journal_lists(p_s_sb);
-
- journal->j_current_jl->j_list_bitmap = get_list_bitmap(p_s_sb, journal->j_current_jl) ;
-
- if (!(journal->j_current_jl->j_list_bitmap)) {
- reiserfs_panic(p_s_sb, "journal-1996: do_journal_end, could not get a list bitmap\n") ;
- }
-
- atomic_set(&(journal->j_jlock), 0) ;
- unlock_journal(p_s_sb) ;
- /* wake up any body waiting to join. */
- clear_bit(J_WRITERS_QUEUED, &journal->j_state);
- wake_up(&(journal->j_join_wait)) ;
-
- if (!flush && wait_on_commit &&
- journal_list_still_alive(p_s_sb, commit_trans_id)) {
- flush_commit_list(p_s_sb, jl, 1) ;
- }
-out:
- reiserfs_check_lock_depth(p_s_sb, "journal end2");
-
- memset (th, 0, sizeof (*th));
- /* Re-set th->t_super, so we can properly keep track of how many
- * persistent transactions there are. We need to do this so if this
- * call is part of a failed restart_transaction, we can free it later */
- th->t_super = p_s_sb;
-
- return journal->j_errno;
-}
-
-static void
-__reiserfs_journal_abort_hard (struct super_block *sb)
-{
- struct reiserfs_journal *journal = SB_JOURNAL (sb);
- if (test_bit (J_ABORTED, &journal->j_state))
- return;
-
- printk (KERN_CRIT "REISERFS: Aborting journal for filesystem on %s\n",
- reiserfs_bdevname (sb));
-
- sb->s_flags |= MS_RDONLY;
- set_bit (J_ABORTED, &journal->j_state);
+
+ /* setup description block */
+ d_bh =
+ journal_getblk(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ journal->j_start);
+ set_buffer_uptodate(d_bh);
+ desc = (struct reiserfs_journal_desc *)(d_bh)->b_data;
+ memset(d_bh->b_data, 0, d_bh->b_size);
+ memcpy(get_journal_desc_magic(d_bh), JOURNAL_DESC_MAGIC, 8);
+ set_desc_trans_id(desc, journal->j_trans_id);
+
+ /* setup commit block. Don't write (keep it clean too) this one until after everyone else is written */
+ c_bh = journal_getblk(p_s_sb, SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ ((journal->j_start + journal->j_len +
+ 1) % SB_ONDISK_JOURNAL_SIZE(p_s_sb)));
+ commit = (struct reiserfs_journal_commit *)c_bh->b_data;
+ memset(c_bh->b_data, 0, c_bh->b_size);
+ set_commit_trans_id(commit, journal->j_trans_id);
+ set_buffer_uptodate(c_bh);
+
+ /* init this journal list */
+ jl = journal->j_current_jl;
+
+ /* we lock the commit before doing anything because
+ * we want to make sure nobody tries to run flush_commit_list until
+ * the new transaction is fully setup, and we've already flushed the
+ * ordered bh list
+ */
+ down(&jl->j_commit_lock);
+
+ /* save the transaction id in case we need to commit it later */
+ commit_trans_id = jl->j_trans_id;
+
+ atomic_set(&jl->j_older_commits_done, 0);
+ jl->j_trans_id = journal->j_trans_id;
+ jl->j_timestamp = journal->j_trans_start_time;
+ jl->j_commit_bh = c_bh;
+ jl->j_start = journal->j_start;
+ jl->j_len = journal->j_len;
+ atomic_set(&jl->j_nonzerolen, journal->j_len);
+ atomic_set(&jl->j_commit_left, journal->j_len + 2);
+ jl->j_realblock = NULL;
+
+ /* The ENTIRE FOR LOOP MUST not cause schedule to occur.
+ ** for each real block, add it to the journal list hash,
+ ** copy into real block index array in the commit or desc block
+ */
+ trans_half = journal_trans_half(p_s_sb->s_blocksize);
+ for (i = 0, cn = journal->j_first; cn; cn = cn->next, i++) {
+ if (buffer_journaled(cn->bh)) {
+ jl_cn = get_cnode(p_s_sb);
+ if (!jl_cn) {
+ reiserfs_panic(p_s_sb,
+ "journal-1676, get_cnode returned NULL\n");
+ }
+ if (i == 0) {
+ jl->j_realblock = jl_cn;
+ }
+ jl_cn->prev = last_cn;
+ jl_cn->next = NULL;
+ if (last_cn) {
+ last_cn->next = jl_cn;
+ }
+ last_cn = jl_cn;
+ /* make sure the block we are trying to log is not a block
+ of journal or reserved area */
+
+ if (is_block_in_log_or_reserved_area
+ (p_s_sb, cn->bh->b_blocknr)) {
+ reiserfs_panic(p_s_sb,
+ "journal-2332: Trying to log block %lu, which is a log block\n",
+ cn->bh->b_blocknr);
+ }
+ jl_cn->blocknr = cn->bh->b_blocknr;
+ jl_cn->state = 0;
+ jl_cn->sb = p_s_sb;
+ jl_cn->bh = cn->bh;
+ jl_cn->jlist = jl;
+ insert_journal_hash(journal->j_list_hash_table, jl_cn);
+ if (i < trans_half) {
+ desc->j_realblock[i] =
+ cpu_to_le32(cn->bh->b_blocknr);
+ } else {
+ commit->j_realblock[i - trans_half] =
+ cpu_to_le32(cn->bh->b_blocknr);
+ }
+ } else {
+ i--;
+ }
+ }
+ set_desc_trans_len(desc, journal->j_len);
+ set_desc_mount_id(desc, journal->j_mount_id);
+ set_desc_trans_id(desc, journal->j_trans_id);
+ set_commit_trans_len(commit, journal->j_len);
+
+ /* special check in case all buffers in the journal were marked for not logging */
+ if (journal->j_len == 0) {
+ BUG();
+ }
+
+ /* we're about to dirty all the log blocks, mark the description block
+ * dirty now too. Don't mark the commit block dirty until all the
+ * others are on disk
+ */
+ mark_buffer_dirty(d_bh);
+
+ /* first data block is j_start + 1, so add one to cur_write_start wherever you use it */
+ cur_write_start = journal->j_start;
+ cn = journal->j_first;
+ jindex = 1; /* start at one so we don't get the desc again */
+ while (cn) {
+ clear_buffer_journal_new(cn->bh);
+ /* copy all the real blocks into log area. dirty log blocks */
+ if (buffer_journaled(cn->bh)) {
+ struct buffer_head *tmp_bh;
+ char *addr;
+ struct page *page;
+ tmp_bh =
+ journal_getblk(p_s_sb,
+ SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
+ ((cur_write_start +
+ jindex) %
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)));
+ set_buffer_uptodate(tmp_bh);
+ page = cn->bh->b_page;
+ addr = kmap(page);
+ memcpy(tmp_bh->b_data,
+ addr + offset_in_page(cn->bh->b_data),
+ cn->bh->b_size);
+ kunmap(page);
+ mark_buffer_dirty(tmp_bh);
+ jindex++;
+ set_buffer_journal_dirty(cn->bh);
+ clear_buffer_journaled(cn->bh);
+ } else {
+ /* JDirty cleared sometime during transaction. don't log this one */
+ reiserfs_warning(p_s_sb,
+ "journal-2048: do_journal_end: BAD, buffer in journal hash, but not JDirty!");
+ brelse(cn->bh);
+ }
+ next = cn->next;
+ free_cnode(p_s_sb, cn);
+ cn = next;
+ cond_resched();
+ }
+
+ /* we are done with both the c_bh and d_bh, but
+ ** c_bh must be written after all other commit blocks,
+ ** so we dirty/relse c_bh in flush_commit_list, with commit_left <= 1.
+ */
+
+ journal->j_current_jl = alloc_journal_list(p_s_sb);
+
+ /* now it is safe to insert this transaction on the main list */
+ list_add_tail(&jl->j_list, &journal->j_journal_list);
+ list_add_tail(&jl->j_working_list, &journal->j_working_list);
+ journal->j_num_work_lists++;
+
+ /* reset journal values for the next transaction */
+ old_start = journal->j_start;
+ journal->j_start =
+ (journal->j_start + journal->j_len +
+ 2) % SB_ONDISK_JOURNAL_SIZE(p_s_sb);
+ atomic_set(&(journal->j_wcount), 0);
+ journal->j_bcount = 0;
+ journal->j_last = NULL;
+ journal->j_first = NULL;
+ journal->j_len = 0;
+ journal->j_trans_start_time = 0;
+ journal->j_trans_id++;
+ journal->j_current_jl->j_trans_id = journal->j_trans_id;
+ journal->j_must_wait = 0;
+ journal->j_len_alloc = 0;
+ journal->j_next_full_flush = 0;
+ journal->j_next_async_flush = 0;
+ init_journal_hash(p_s_sb);
+
+ // make sure reiserfs_add_jh sees the new current_jl before we
+ // write out the tails
+ smp_mb();
+
+ /* tail conversion targets have to hit the disk before we end the
+ * transaction. Otherwise a later transaction might repack the tail
+ * before this transaction commits, leaving the data block unflushed and
+ * clean, if we crash before the later transaction commits, the data block
+ * is lost.
+ */
+ if (!list_empty(&jl->j_tail_bh_list)) {
+ unlock_kernel();
+ write_ordered_buffers(&journal->j_dirty_buffers_lock,
+ journal, jl, &jl->j_tail_bh_list);
+ lock_kernel();
+ }
+ if (!list_empty(&jl->j_tail_bh_list))
+ BUG();
+ up(&jl->j_commit_lock);
+
+ /* honor the flush wishes from the caller, simple commits can
+ ** be done outside the journal lock, they are done below
+ **
+ ** if we don't flush the commit list right now, we put it into
+ ** the work queue so the people waiting on the async progress work
+ ** queue don't wait for this proc to flush journal lists and such.
+ */
+ if (flush) {
+ flush_commit_list(p_s_sb, jl, 1);
+ flush_journal_list(p_s_sb, jl, 1);
+ } else if (!(jl->j_state & LIST_COMMIT_PENDING))
+ queue_delayed_work(commit_wq, &journal->j_work, HZ / 10);
+
+ /* if the next transaction has any chance of wrapping, flush
+ ** transactions that might get overwritten. If any journal lists are very
+ ** old flush them as well.
+ */
+ first_jl:
+ list_for_each_safe(entry, safe, &journal->j_journal_list) {
+ temp_jl = JOURNAL_LIST_ENTRY(entry);
+ if (journal->j_start <= temp_jl->j_start) {
+ if ((journal->j_start + journal->j_trans_max + 1) >=
+ temp_jl->j_start) {
+ flush_used_journal_lists(p_s_sb, temp_jl);
+ goto first_jl;
+ } else if ((journal->j_start +
+ journal->j_trans_max + 1) <
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
+ /* if we don't cross into the next transaction and we don't
+ * wrap, there is no way we can overlap any later transactions
+ * break now
+ */
+ break;
+ }
+ } else if ((journal->j_start +
+ journal->j_trans_max + 1) >
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
+ if (((journal->j_start + journal->j_trans_max + 1) %
+ SB_ONDISK_JOURNAL_SIZE(p_s_sb)) >=
+ temp_jl->j_start) {
+ flush_used_journal_lists(p_s_sb, temp_jl);
+ goto first_jl;
+ } else {
+ /* we don't overlap anything from out start to the end of the
+ * log, and our wrapped portion doesn't overlap anything at
+ * the start of the log. We can break
+ */
+ break;
+ }
+ }
+ }
+ flush_old_journal_lists(p_s_sb);
+
+ journal->j_current_jl->j_list_bitmap =
+ get_list_bitmap(p_s_sb, journal->j_current_jl);
+
+ if (!(journal->j_current_jl->j_list_bitmap)) {
+ reiserfs_panic(p_s_sb,
+ "journal-1996: do_journal_end, could not get a list bitmap\n");
+ }
+
+ atomic_set(&(journal->j_jlock), 0);
+ unlock_journal(p_s_sb);
+ /* wake up any body waiting to join. */
+ clear_bit(J_WRITERS_QUEUED, &journal->j_state);
+ wake_up(&(journal->j_join_wait));
+
+ if (!flush && wait_on_commit &&
+ journal_list_still_alive(p_s_sb, commit_trans_id)) {
+ flush_commit_list(p_s_sb, jl, 1);
+ }
+ out:
+ reiserfs_check_lock_depth(p_s_sb, "journal end2");
+
+ memset(th, 0, sizeof(*th));
+ /* Re-set th->t_super, so we can properly keep track of how many
+ * persistent transactions there are. We need to do this so if this
+ * call is part of a failed restart_transaction, we can free it later */
+ th->t_super = p_s_sb;
+
+ return journal->j_errno;
+}
+
+static void __reiserfs_journal_abort_hard(struct super_block *sb)
+{
+ struct reiserfs_journal *journal = SB_JOURNAL(sb);
+ if (test_bit(J_ABORTED, &journal->j_state))
+ return;
+
+ printk(KERN_CRIT "REISERFS: Aborting journal for filesystem on %s\n",
+ reiserfs_bdevname(sb));
+
+ sb->s_flags |= MS_RDONLY;
+ set_bit(J_ABORTED, &journal->j_state);
#ifdef CONFIG_REISERFS_CHECK
- dump_stack();
+ dump_stack();
#endif
}
-static void
-__reiserfs_journal_abort_soft (struct super_block *sb, int errno)
+static void __reiserfs_journal_abort_soft(struct super_block *sb, int errno)
{
- struct reiserfs_journal *journal = SB_JOURNAL (sb);
- if (test_bit (J_ABORTED, &journal->j_state))
- return;
+ struct reiserfs_journal *journal = SB_JOURNAL(sb);
+ if (test_bit(J_ABORTED, &journal->j_state))
+ return;
- if (!journal->j_errno)
- journal->j_errno = errno;
+ if (!journal->j_errno)
+ journal->j_errno = errno;
- __reiserfs_journal_abort_hard (sb);
+ __reiserfs_journal_abort_hard(sb);
}
-void
-reiserfs_journal_abort (struct super_block *sb, int errno)
+void reiserfs_journal_abort(struct super_block *sb, int errno)
{
- return __reiserfs_journal_abort_soft (sb, errno);
+ return __reiserfs_journal_abort_soft(sb, errno);
}
diff --git a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c
index 2406608fc5c..2533c1f64ab 100644
--- a/fs/reiserfs/lbalance.c
+++ b/fs/reiserfs/lbalance.c
@@ -21,648 +21,709 @@
leaf_paste_entries
*/
-
/* copy copy_count entries from source directory item to dest buffer (creating new item if needed) */
-static void leaf_copy_dir_entries (struct buffer_info * dest_bi, struct buffer_head * source,
- int last_first, int item_num, int from, int copy_count)
+static void leaf_copy_dir_entries(struct buffer_info *dest_bi,
+ struct buffer_head *source, int last_first,
+ int item_num, int from, int copy_count)
{
- struct buffer_head * dest = dest_bi->bi_bh;
- int item_num_in_dest; /* either the number of target item,
- or if we must create a new item,
- the number of the item we will
- create it next to */
- struct item_head * ih;
- struct reiserfs_de_head * deh;
- int copy_records_len; /* length of all records in item to be copied */
- char * records;
-
- ih = B_N_PITEM_HEAD (source, item_num);
-
- RFALSE( !is_direntry_le_ih (ih), "vs-10000: item must be directory item");
-
- /* length of all record to be copied and first byte of the last of them */
- deh = B_I_DEH (source, ih);
- if (copy_count) {
- copy_records_len = (from ? deh_location( &(deh[from - 1]) ) :
- ih_item_len(ih)) - deh_location( &(deh[from + copy_count - 1]));
- records = source->b_data + ih_location(ih) +
- deh_location( &(deh[from + copy_count - 1]));
- } else {
- copy_records_len = 0;
- records = NULL;
- }
-
- /* when copy last to first, dest buffer can contain 0 items */
- item_num_in_dest = (last_first == LAST_TO_FIRST) ? (( B_NR_ITEMS(dest) ) ? 0 : -1) : (B_NR_ITEMS(dest) - 1);
-
- /* if there are no items in dest or the first/last item in dest is not item of the same directory */
- if ( (item_num_in_dest == - 1) ||
- (last_first == FIRST_TO_LAST && le_ih_k_offset (ih) == DOT_OFFSET) ||
- (last_first == LAST_TO_FIRST && comp_short_le_keys/*COMP_SHORT_KEYS*/ (&ih->ih_key, B_N_PKEY (dest, item_num_in_dest)))) {
- /* create new item in dest */
- struct item_head new_ih;
-
- /* form item header */
- memcpy (&new_ih.ih_key, &ih->ih_key, KEY_SIZE);
- put_ih_version( &new_ih, KEY_FORMAT_3_5 );
- /* calculate item len */
- put_ih_item_len( &new_ih, DEH_SIZE * copy_count + copy_records_len );
- put_ih_entry_count( &new_ih, 0 );
-
- if (last_first == LAST_TO_FIRST) {
- /* form key by the following way */
- if (from < I_ENTRY_COUNT(ih)) {
- set_le_ih_k_offset( &new_ih, deh_offset( &(deh[from]) ) );
- /*memcpy (&new_ih.ih_key.k_offset, &deh[from].deh_offset, SHORT_KEY_SIZE);*/
- } else {
- /* no entries will be copied to this item in this function */
- set_le_ih_k_offset (&new_ih, U32_MAX);
- /* this item is not yet valid, but we want I_IS_DIRECTORY_ITEM to return 1 for it, so we -1 */
- }
- set_le_key_k_type (KEY_FORMAT_3_5, &(new_ih.ih_key), TYPE_DIRENTRY);
+ struct buffer_head *dest = dest_bi->bi_bh;
+ int item_num_in_dest; /* either the number of target item,
+ or if we must create a new item,
+ the number of the item we will
+ create it next to */
+ struct item_head *ih;
+ struct reiserfs_de_head *deh;
+ int copy_records_len; /* length of all records in item to be copied */
+ char *records;
+
+ ih = B_N_PITEM_HEAD(source, item_num);
+
+ RFALSE(!is_direntry_le_ih(ih), "vs-10000: item must be directory item");
+
+ /* length of all record to be copied and first byte of the last of them */
+ deh = B_I_DEH(source, ih);
+ if (copy_count) {
+ copy_records_len = (from ? deh_location(&(deh[from - 1])) :
+ ih_item_len(ih)) -
+ deh_location(&(deh[from + copy_count - 1]));
+ records =
+ source->b_data + ih_location(ih) +
+ deh_location(&(deh[from + copy_count - 1]));
+ } else {
+ copy_records_len = 0;
+ records = NULL;
+ }
+
+ /* when copy last to first, dest buffer can contain 0 items */
+ item_num_in_dest =
+ (last_first ==
+ LAST_TO_FIRST) ? ((B_NR_ITEMS(dest)) ? 0 : -1) : (B_NR_ITEMS(dest)
+ - 1);
+
+ /* if there are no items in dest or the first/last item in dest is not item of the same directory */
+ if ((item_num_in_dest == -1) ||
+ (last_first == FIRST_TO_LAST && le_ih_k_offset(ih) == DOT_OFFSET) ||
+ (last_first == LAST_TO_FIRST
+ && comp_short_le_keys /*COMP_SHORT_KEYS */ (&ih->ih_key,
+ B_N_PKEY(dest,
+ item_num_in_dest))))
+ {
+ /* create new item in dest */
+ struct item_head new_ih;
+
+ /* form item header */
+ memcpy(&new_ih.ih_key, &ih->ih_key, KEY_SIZE);
+ put_ih_version(&new_ih, KEY_FORMAT_3_5);
+ /* calculate item len */
+ put_ih_item_len(&new_ih,
+ DEH_SIZE * copy_count + copy_records_len);
+ put_ih_entry_count(&new_ih, 0);
+
+ if (last_first == LAST_TO_FIRST) {
+ /* form key by the following way */
+ if (from < I_ENTRY_COUNT(ih)) {
+ set_le_ih_k_offset(&new_ih,
+ deh_offset(&(deh[from])));
+ /*memcpy (&new_ih.ih_key.k_offset, &deh[from].deh_offset, SHORT_KEY_SIZE); */
+ } else {
+ /* no entries will be copied to this item in this function */
+ set_le_ih_k_offset(&new_ih, U32_MAX);
+ /* this item is not yet valid, but we want I_IS_DIRECTORY_ITEM to return 1 for it, so we -1 */
+ }
+ set_le_key_k_type(KEY_FORMAT_3_5, &(new_ih.ih_key),
+ TYPE_DIRENTRY);
+ }
+
+ /* insert item into dest buffer */
+ leaf_insert_into_buf(dest_bi,
+ (last_first ==
+ LAST_TO_FIRST) ? 0 : B_NR_ITEMS(dest),
+ &new_ih, NULL, 0);
+ } else {
+ /* prepare space for entries */
+ leaf_paste_in_buffer(dest_bi,
+ (last_first ==
+ FIRST_TO_LAST) ? (B_NR_ITEMS(dest) -
+ 1) : 0, MAX_US_INT,
+ DEH_SIZE * copy_count + copy_records_len,
+ records, 0);
}
-
- /* insert item into dest buffer */
- leaf_insert_into_buf (dest_bi, (last_first == LAST_TO_FIRST) ? 0 : B_NR_ITEMS(dest), &new_ih, NULL, 0);
- } else {
- /* prepare space for entries */
- leaf_paste_in_buffer (dest_bi, (last_first==FIRST_TO_LAST) ? (B_NR_ITEMS(dest) - 1) : 0, MAX_US_INT,
- DEH_SIZE * copy_count + copy_records_len, records, 0
- );
- }
-
- item_num_in_dest = (last_first == FIRST_TO_LAST) ? (B_NR_ITEMS(dest)-1) : 0;
-
- leaf_paste_entries (dest_bi->bi_bh, item_num_in_dest,
- (last_first == FIRST_TO_LAST) ? I_ENTRY_COUNT(B_N_PITEM_HEAD (dest, item_num_in_dest)) : 0,
- copy_count, deh + from, records,
- DEH_SIZE * copy_count + copy_records_len
- );
-}
+ item_num_in_dest =
+ (last_first == FIRST_TO_LAST) ? (B_NR_ITEMS(dest) - 1) : 0;
+
+ leaf_paste_entries(dest_bi->bi_bh, item_num_in_dest,
+ (last_first ==
+ FIRST_TO_LAST) ? I_ENTRY_COUNT(B_N_PITEM_HEAD(dest,
+ item_num_in_dest))
+ : 0, copy_count, deh + from, records,
+ DEH_SIZE * copy_count + copy_records_len);
+}
/* Copy the first (if last_first == FIRST_TO_LAST) or last (last_first == LAST_TO_FIRST) item or
part of it or nothing (see the return 0 below) from SOURCE to the end
(if last_first) or beginning (!last_first) of the DEST */
/* returns 1 if anything was copied, else 0 */
-static int leaf_copy_boundary_item (struct buffer_info * dest_bi, struct buffer_head * src, int last_first,
- int bytes_or_entries)
+static int leaf_copy_boundary_item(struct buffer_info *dest_bi,
+ struct buffer_head *src, int last_first,
+ int bytes_or_entries)
{
- struct buffer_head * dest = dest_bi->bi_bh;
- int dest_nr_item, src_nr_item; /* number of items in the source and destination buffers */
- struct item_head * ih;
- struct item_head * dih;
-
- dest_nr_item = B_NR_ITEMS(dest);
-
- if ( last_first == FIRST_TO_LAST ) {
- /* if ( DEST is empty or first item of SOURCE and last item of DEST are the items of different objects
- or of different types ) then there is no need to treat this item differently from the other items
- that we copy, so we return */
- ih = B_N_PITEM_HEAD (src, 0);
- dih = B_N_PITEM_HEAD (dest, dest_nr_item - 1);
- if (!dest_nr_item || (!op_is_left_mergeable (&(ih->ih_key), src->b_size)))
- /* there is nothing to merge */
- return 0;
-
- RFALSE( ! ih_item_len(ih), "vs-10010: item can not have empty length");
-
- if ( is_direntry_le_ih (ih) ) {
- if ( bytes_or_entries == -1 )
- /* copy all entries to dest */
- bytes_or_entries = ih_entry_count(ih);
- leaf_copy_dir_entries (dest_bi, src, FIRST_TO_LAST, 0, 0, bytes_or_entries);
- return 1;
- }
-
- /* copy part of the body of the first item of SOURCE to the end of the body of the last item of the DEST
- part defined by 'bytes_or_entries'; if bytes_or_entries == -1 copy whole body; don't create new item header
- */
- if ( bytes_or_entries == -1 )
- bytes_or_entries = ih_item_len(ih);
+ struct buffer_head *dest = dest_bi->bi_bh;
+ int dest_nr_item, src_nr_item; /* number of items in the source and destination buffers */
+ struct item_head *ih;
+ struct item_head *dih;
+
+ dest_nr_item = B_NR_ITEMS(dest);
+
+ if (last_first == FIRST_TO_LAST) {
+ /* if ( DEST is empty or first item of SOURCE and last item of DEST are the items of different objects
+ or of different types ) then there is no need to treat this item differently from the other items
+ that we copy, so we return */
+ ih = B_N_PITEM_HEAD(src, 0);
+ dih = B_N_PITEM_HEAD(dest, dest_nr_item - 1);
+ if (!dest_nr_item
+ || (!op_is_left_mergeable(&(ih->ih_key), src->b_size)))
+ /* there is nothing to merge */
+ return 0;
+
+ RFALSE(!ih_item_len(ih),
+ "vs-10010: item can not have empty length");
+
+ if (is_direntry_le_ih(ih)) {
+ if (bytes_or_entries == -1)
+ /* copy all entries to dest */
+ bytes_or_entries = ih_entry_count(ih);
+ leaf_copy_dir_entries(dest_bi, src, FIRST_TO_LAST, 0, 0,
+ bytes_or_entries);
+ return 1;
+ }
+
+ /* copy part of the body of the first item of SOURCE to the end of the body of the last item of the DEST
+ part defined by 'bytes_or_entries'; if bytes_or_entries == -1 copy whole body; don't create new item header
+ */
+ if (bytes_or_entries == -1)
+ bytes_or_entries = ih_item_len(ih);
#ifdef CONFIG_REISERFS_CHECK
- else {
- if (bytes_or_entries == ih_item_len(ih) && is_indirect_le_ih(ih))
- if (get_ih_free_space (ih))
- reiserfs_panic (NULL, "vs-10020: leaf_copy_boundary_item: "
- "last unformatted node must be filled entirely (%h)",
- ih);
- }
+ else {
+ if (bytes_or_entries == ih_item_len(ih)
+ && is_indirect_le_ih(ih))
+ if (get_ih_free_space(ih))
+ reiserfs_panic(NULL,
+ "vs-10020: leaf_copy_boundary_item: "
+ "last unformatted node must be filled entirely (%h)",
+ ih);
+ }
#endif
-
- /* merge first item (or its part) of src buffer with the last
- item of dest buffer. Both are of the same file */
- leaf_paste_in_buffer (dest_bi,
- dest_nr_item - 1, ih_item_len(dih), bytes_or_entries, B_I_PITEM(src,ih), 0
- );
-
- if (is_indirect_le_ih (dih)) {
- RFALSE( get_ih_free_space (dih),
- "vs-10030: merge to left: last unformatted node of non-last indirect item %h must have zerto free space",
- ih);
- if (bytes_or_entries == ih_item_len(ih))
- set_ih_free_space (dih, get_ih_free_space (ih));
- }
-
- return 1;
- }
-
-
- /* copy boundary item to right (last_first == LAST_TO_FIRST) */
-
- /* ( DEST is empty or last item of SOURCE and first item of DEST
- are the items of different object or of different types )
- */
- src_nr_item = B_NR_ITEMS (src);
- ih = B_N_PITEM_HEAD (src, src_nr_item - 1);
- dih = B_N_PITEM_HEAD (dest, 0);
-
- if (!dest_nr_item || !op_is_left_mergeable (&(dih->ih_key), src->b_size))
- return 0;
-
- if ( is_direntry_le_ih (ih)) {
- if ( bytes_or_entries == -1 )
- /* bytes_or_entries = entries number in last item body of SOURCE */
- bytes_or_entries = ih_entry_count(ih);
-
- leaf_copy_dir_entries (dest_bi, src, LAST_TO_FIRST, src_nr_item - 1, ih_entry_count(ih) - bytes_or_entries, bytes_or_entries);
- return 1;
- }
-
- /* copy part of the body of the last item of SOURCE to the begin of the body of the first item of the DEST;
- part defined by 'bytes_or_entries'; if byte_or_entriess == -1 copy whole body; change first item key of the DEST;
- don't create new item header
- */
-
- RFALSE( is_indirect_le_ih(ih) && get_ih_free_space (ih),
- "vs-10040: merge to right: last unformatted node of non-last indirect item must be filled entirely (%h)",
- ih);
-
- if ( bytes_or_entries == -1 ) {
- /* bytes_or_entries = length of last item body of SOURCE */
- bytes_or_entries = ih_item_len(ih);
-
- RFALSE( le_ih_k_offset (dih) !=
- le_ih_k_offset (ih) + op_bytes_number (ih, src->b_size),
- "vs-10050: items %h and %h do not match", ih, dih);
-
- /* change first item key of the DEST */
- set_le_ih_k_offset (dih, le_ih_k_offset (ih));
-
- /* item becomes non-mergeable */
- /* or mergeable if left item was */
- set_le_ih_k_type (dih, le_ih_k_type (ih));
- } else {
- /* merge to right only part of item */
- RFALSE( ih_item_len(ih) <= bytes_or_entries,
- "vs-10060: no so much bytes %lu (needed %lu)",
- ( unsigned long )ih_item_len(ih), ( unsigned long )bytes_or_entries);
-
- /* change first item key of the DEST */
- if ( is_direct_le_ih (dih) ) {
- RFALSE( le_ih_k_offset (dih) <= (unsigned long)bytes_or_entries,
- "vs-10070: dih %h, bytes_or_entries(%d)", dih, bytes_or_entries);
- set_le_ih_k_offset (dih, le_ih_k_offset (dih) - bytes_or_entries);
- } else {
- RFALSE( le_ih_k_offset (dih) <=
- (bytes_or_entries / UNFM_P_SIZE) * dest->b_size,
- "vs-10080: dih %h, bytes_or_entries(%d)",
- dih, (bytes_or_entries/UNFM_P_SIZE)*dest->b_size);
- set_le_ih_k_offset (dih, le_ih_k_offset (dih) - ((bytes_or_entries / UNFM_P_SIZE) * dest->b_size));
- }
- }
-
- leaf_paste_in_buffer (dest_bi, 0, 0, bytes_or_entries, B_I_PITEM(src,ih) + ih_item_len(ih) - bytes_or_entries, 0);
- return 1;
-}
+ /* merge first item (or its part) of src buffer with the last
+ item of dest buffer. Both are of the same file */
+ leaf_paste_in_buffer(dest_bi,
+ dest_nr_item - 1, ih_item_len(dih),
+ bytes_or_entries, B_I_PITEM(src, ih), 0);
+
+ if (is_indirect_le_ih(dih)) {
+ RFALSE(get_ih_free_space(dih),
+ "vs-10030: merge to left: last unformatted node of non-last indirect item %h must have zerto free space",
+ ih);
+ if (bytes_or_entries == ih_item_len(ih))
+ set_ih_free_space(dih, get_ih_free_space(ih));
+ }
+
+ return 1;
+ }
+
+ /* copy boundary item to right (last_first == LAST_TO_FIRST) */
+
+ /* ( DEST is empty or last item of SOURCE and first item of DEST
+ are the items of different object or of different types )
+ */
+ src_nr_item = B_NR_ITEMS(src);
+ ih = B_N_PITEM_HEAD(src, src_nr_item - 1);
+ dih = B_N_PITEM_HEAD(dest, 0);
+
+ if (!dest_nr_item || !op_is_left_mergeable(&(dih->ih_key), src->b_size))
+ return 0;
+
+ if (is_direntry_le_ih(ih)) {
+ if (bytes_or_entries == -1)
+ /* bytes_or_entries = entries number in last item body of SOURCE */
+ bytes_or_entries = ih_entry_count(ih);
+
+ leaf_copy_dir_entries(dest_bi, src, LAST_TO_FIRST,
+ src_nr_item - 1,
+ ih_entry_count(ih) - bytes_or_entries,
+ bytes_or_entries);
+ return 1;
+ }
+
+ /* copy part of the body of the last item of SOURCE to the begin of the body of the first item of the DEST;
+ part defined by 'bytes_or_entries'; if byte_or_entriess == -1 copy whole body; change first item key of the DEST;
+ don't create new item header
+ */
+
+ RFALSE(is_indirect_le_ih(ih) && get_ih_free_space(ih),
+ "vs-10040: merge to right: last unformatted node of non-last indirect item must be filled entirely (%h)",
+ ih);
+
+ if (bytes_or_entries == -1) {
+ /* bytes_or_entries = length of last item body of SOURCE */
+ bytes_or_entries = ih_item_len(ih);
+
+ RFALSE(le_ih_k_offset(dih) !=
+ le_ih_k_offset(ih) + op_bytes_number(ih, src->b_size),
+ "vs-10050: items %h and %h do not match", ih, dih);
+
+ /* change first item key of the DEST */
+ set_le_ih_k_offset(dih, le_ih_k_offset(ih));
+
+ /* item becomes non-mergeable */
+ /* or mergeable if left item was */
+ set_le_ih_k_type(dih, le_ih_k_type(ih));
+ } else {
+ /* merge to right only part of item */
+ RFALSE(ih_item_len(ih) <= bytes_or_entries,
+ "vs-10060: no so much bytes %lu (needed %lu)",
+ (unsigned long)ih_item_len(ih),
+ (unsigned long)bytes_or_entries);
+
+ /* change first item key of the DEST */
+ if (is_direct_le_ih(dih)) {
+ RFALSE(le_ih_k_offset(dih) <=
+ (unsigned long)bytes_or_entries,
+ "vs-10070: dih %h, bytes_or_entries(%d)", dih,
+ bytes_or_entries);
+ set_le_ih_k_offset(dih,
+ le_ih_k_offset(dih) -
+ bytes_or_entries);
+ } else {
+ RFALSE(le_ih_k_offset(dih) <=
+ (bytes_or_entries / UNFM_P_SIZE) * dest->b_size,
+ "vs-10080: dih %h, bytes_or_entries(%d)",
+ dih,
+ (bytes_or_entries / UNFM_P_SIZE) * dest->b_size);
+ set_le_ih_k_offset(dih,
+ le_ih_k_offset(dih) -
+ ((bytes_or_entries / UNFM_P_SIZE) *
+ dest->b_size));
+ }
+ }
+
+ leaf_paste_in_buffer(dest_bi, 0, 0, bytes_or_entries,
+ B_I_PITEM(src,
+ ih) + ih_item_len(ih) - bytes_or_entries,
+ 0);
+ return 1;
+}
/* copy cpy_mun items from buffer src to buffer dest
* last_first == FIRST_TO_LAST means, that we copy cpy_num items beginning from first-th item in src to tail of dest
* last_first == LAST_TO_FIRST means, that we copy cpy_num items beginning from first-th item in src to head of dest
*/
-static void leaf_copy_items_entirely (struct buffer_info * dest_bi, struct buffer_head * src, int last_first,
- int first, int cpy_num)
+static void leaf_copy_items_entirely(struct buffer_info *dest_bi,
+ struct buffer_head *src, int last_first,
+ int first, int cpy_num)
{
- struct buffer_head * dest;
- int nr, free_space;
- int dest_before;
- int last_loc, last_inserted_loc, location;
- int i, j;
- struct block_head * blkh;
- struct item_head * ih;
-
- RFALSE( last_first != LAST_TO_FIRST && last_first != FIRST_TO_LAST,
- "vs-10090: bad last_first parameter %d", last_first);
- RFALSE( B_NR_ITEMS (src) - first < cpy_num,
- "vs-10100: too few items in source %d, required %d from %d",
- B_NR_ITEMS(src), cpy_num, first);
- RFALSE( cpy_num < 0, "vs-10110: can not copy negative amount of items");
- RFALSE( ! dest_bi, "vs-10120: can not copy negative amount of items");
-
- dest = dest_bi->bi_bh;
-
- RFALSE( ! dest, "vs-10130: can not copy negative amount of items");
-
- if (cpy_num == 0)
- return;
-
- blkh = B_BLK_HEAD(dest);
- nr = blkh_nr_item( blkh );
- free_space = blkh_free_space(blkh);
-
- /* we will insert items before 0-th or nr-th item in dest buffer. It depends of last_first parameter */
- dest_before = (last_first == LAST_TO_FIRST) ? 0 : nr;
-
- /* location of head of first new item */
- ih = B_N_PITEM_HEAD (dest, dest_before);
-
- RFALSE( blkh_free_space(blkh) < cpy_num * IH_SIZE,
- "vs-10140: not enough free space for headers %d (needed %d)",
- B_FREE_SPACE (dest), cpy_num * IH_SIZE);
-
- /* prepare space for headers */
- memmove (ih + cpy_num, ih, (nr-dest_before) * IH_SIZE);
-
- /* copy item headers */
- memcpy (ih, B_N_PITEM_HEAD (src, first), cpy_num * IH_SIZE);
-
- free_space -= (IH_SIZE * cpy_num);
- set_blkh_free_space( blkh, free_space );
-
- /* location of unmovable item */
- j = location = (dest_before == 0) ? dest->b_size : ih_location(ih-1);
- for (i = dest_before; i < nr + cpy_num; i ++) {
- location -= ih_item_len( ih + i - dest_before );
- put_ih_location( ih + i - dest_before, location );
- }
-
- /* prepare space for items */
- last_loc = ih_location( &(ih[nr+cpy_num-1-dest_before]) );
- last_inserted_loc = ih_location( &(ih[cpy_num-1]) );
-
- /* check free space */
- RFALSE( free_space < j - last_inserted_loc,
- "vs-10150: not enough free space for items %d (needed %d)",
- free_space, j - last_inserted_loc);
-
- memmove (dest->b_data + last_loc,
- dest->b_data + last_loc + j - last_inserted_loc,
- last_inserted_loc - last_loc);
-
- /* copy items */
- memcpy (dest->b_data + last_inserted_loc, B_N_PITEM(src,(first + cpy_num - 1)),
- j - last_inserted_loc);
-
- /* sizes, item number */
- set_blkh_nr_item( blkh, nr + cpy_num );
- set_blkh_free_space( blkh, free_space - (j - last_inserted_loc) );
-
- do_balance_mark_leaf_dirty (dest_bi->tb, dest, 0);
-
- if (dest_bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD (dest_bi->bi_parent, dest_bi->bi_position);
- RFALSE( dc_block_number(t_dc) != dest->b_blocknr,
- "vs-10160: block number in bh does not match to field in disk_child structure %lu and %lu",
- ( long unsigned ) dest->b_blocknr,
- ( long unsigned ) dc_block_number(t_dc));
- put_dc_size( t_dc, dc_size(t_dc) + (j - last_inserted_loc + IH_SIZE * cpy_num ) );
-
- do_balance_mark_internal_dirty (dest_bi->tb, dest_bi->bi_parent, 0);
- }
-}
+ struct buffer_head *dest;
+ int nr, free_space;
+ int dest_before;
+ int last_loc, last_inserted_loc, location;
+ int i, j;
+ struct block_head *blkh;
+ struct item_head *ih;
+
+ RFALSE(last_first != LAST_TO_FIRST && last_first != FIRST_TO_LAST,
+ "vs-10090: bad last_first parameter %d", last_first);
+ RFALSE(B_NR_ITEMS(src) - first < cpy_num,
+ "vs-10100: too few items in source %d, required %d from %d",
+ B_NR_ITEMS(src), cpy_num, first);
+ RFALSE(cpy_num < 0, "vs-10110: can not copy negative amount of items");
+ RFALSE(!dest_bi, "vs-10120: can not copy negative amount of items");
+
+ dest = dest_bi->bi_bh;
+
+ RFALSE(!dest, "vs-10130: can not copy negative amount of items");
+
+ if (cpy_num == 0)
+ return;
+
+ blkh = B_BLK_HEAD(dest);
+ nr = blkh_nr_item(blkh);
+ free_space = blkh_free_space(blkh);
+
+ /* we will insert items before 0-th or nr-th item in dest buffer. It depends of last_first parameter */
+ dest_before = (last_first == LAST_TO_FIRST) ? 0 : nr;
+
+ /* location of head of first new item */
+ ih = B_N_PITEM_HEAD(dest, dest_before);
+
+ RFALSE(blkh_free_space(blkh) < cpy_num * IH_SIZE,
+ "vs-10140: not enough free space for headers %d (needed %d)",
+ B_FREE_SPACE(dest), cpy_num * IH_SIZE);
+
+ /* prepare space for headers */
+ memmove(ih + cpy_num, ih, (nr - dest_before) * IH_SIZE);
+ /* copy item headers */
+ memcpy(ih, B_N_PITEM_HEAD(src, first), cpy_num * IH_SIZE);
+
+ free_space -= (IH_SIZE * cpy_num);
+ set_blkh_free_space(blkh, free_space);
+
+ /* location of unmovable item */
+ j = location = (dest_before == 0) ? dest->b_size : ih_location(ih - 1);
+ for (i = dest_before; i < nr + cpy_num; i++) {
+ location -= ih_item_len(ih + i - dest_before);
+ put_ih_location(ih + i - dest_before, location);
+ }
+
+ /* prepare space for items */
+ last_loc = ih_location(&(ih[nr + cpy_num - 1 - dest_before]));
+ last_inserted_loc = ih_location(&(ih[cpy_num - 1]));
+
+ /* check free space */
+ RFALSE(free_space < j - last_inserted_loc,
+ "vs-10150: not enough free space for items %d (needed %d)",
+ free_space, j - last_inserted_loc);
+
+ memmove(dest->b_data + last_loc,
+ dest->b_data + last_loc + j - last_inserted_loc,
+ last_inserted_loc - last_loc);
+
+ /* copy items */
+ memcpy(dest->b_data + last_inserted_loc,
+ B_N_PITEM(src, (first + cpy_num - 1)), j - last_inserted_loc);
+
+ /* sizes, item number */
+ set_blkh_nr_item(blkh, nr + cpy_num);
+ set_blkh_free_space(blkh, free_space - (j - last_inserted_loc));
+
+ do_balance_mark_leaf_dirty(dest_bi->tb, dest, 0);
+
+ if (dest_bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(dest_bi->bi_parent, dest_bi->bi_position);
+ RFALSE(dc_block_number(t_dc) != dest->b_blocknr,
+ "vs-10160: block number in bh does not match to field in disk_child structure %lu and %lu",
+ (long unsigned)dest->b_blocknr,
+ (long unsigned)dc_block_number(t_dc));
+ put_dc_size(t_dc,
+ dc_size(t_dc) + (j - last_inserted_loc +
+ IH_SIZE * cpy_num));
+
+ do_balance_mark_internal_dirty(dest_bi->tb, dest_bi->bi_parent,
+ 0);
+ }
+}
/* This function splits the (liquid) item into two items (useful when
shifting part of an item into another node.) */
-static void leaf_item_bottle (struct buffer_info * dest_bi, struct buffer_head * src, int last_first,
- int item_num, int cpy_bytes)
+static void leaf_item_bottle(struct buffer_info *dest_bi,
+ struct buffer_head *src, int last_first,
+ int item_num, int cpy_bytes)
{
- struct buffer_head * dest = dest_bi->bi_bh;
- struct item_head * ih;
-
- RFALSE( cpy_bytes == -1, "vs-10170: bytes == - 1 means: do not split item");
-
- if ( last_first == FIRST_TO_LAST ) {
- /* if ( if item in position item_num in buffer SOURCE is directory item ) */
- if (is_direntry_le_ih (ih = B_N_PITEM_HEAD(src,item_num)))
- leaf_copy_dir_entries (dest_bi, src, FIRST_TO_LAST, item_num, 0, cpy_bytes);
- else {
- struct item_head n_ih;
-
- /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST
- part defined by 'cpy_bytes'; create new item header; change old item_header (????);
- n_ih = new item_header;
- */
- memcpy (&n_ih, ih, IH_SIZE);
- put_ih_item_len( &n_ih, cpy_bytes );
- if (is_indirect_le_ih (ih)) {
- RFALSE( cpy_bytes == ih_item_len(ih) && get_ih_free_space(ih),
- "vs-10180: when whole indirect item is bottle to left neighbor, it must have free_space==0 (not %lu)",
- ( long unsigned ) get_ih_free_space (ih));
- set_ih_free_space (&n_ih, 0);
- }
-
- RFALSE( op_is_left_mergeable (&(ih->ih_key), src->b_size),
- "vs-10190: bad mergeability of item %h", ih);
- n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
- leaf_insert_into_buf (dest_bi, B_NR_ITEMS(dest), &n_ih, B_N_PITEM (src, item_num), 0);
+ struct buffer_head *dest = dest_bi->bi_bh;
+ struct item_head *ih;
+
+ RFALSE(cpy_bytes == -1,
+ "vs-10170: bytes == - 1 means: do not split item");
+
+ if (last_first == FIRST_TO_LAST) {
+ /* if ( if item in position item_num in buffer SOURCE is directory item ) */
+ if (is_direntry_le_ih(ih = B_N_PITEM_HEAD(src, item_num)))
+ leaf_copy_dir_entries(dest_bi, src, FIRST_TO_LAST,
+ item_num, 0, cpy_bytes);
+ else {
+ struct item_head n_ih;
+
+ /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST
+ part defined by 'cpy_bytes'; create new item header; change old item_header (????);
+ n_ih = new item_header;
+ */
+ memcpy(&n_ih, ih, IH_SIZE);
+ put_ih_item_len(&n_ih, cpy_bytes);
+ if (is_indirect_le_ih(ih)) {
+ RFALSE(cpy_bytes == ih_item_len(ih)
+ && get_ih_free_space(ih),
+ "vs-10180: when whole indirect item is bottle to left neighbor, it must have free_space==0 (not %lu)",
+ (long unsigned)get_ih_free_space(ih));
+ set_ih_free_space(&n_ih, 0);
+ }
+
+ RFALSE(op_is_left_mergeable(&(ih->ih_key), src->b_size),
+ "vs-10190: bad mergeability of item %h", ih);
+ n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
+ leaf_insert_into_buf(dest_bi, B_NR_ITEMS(dest), &n_ih,
+ B_N_PITEM(src, item_num), 0);
+ }
+ } else {
+ /* if ( if item in position item_num in buffer SOURCE is directory item ) */
+ if (is_direntry_le_ih(ih = B_N_PITEM_HEAD(src, item_num)))
+ leaf_copy_dir_entries(dest_bi, src, LAST_TO_FIRST,
+ item_num,
+ I_ENTRY_COUNT(ih) - cpy_bytes,
+ cpy_bytes);
+ else {
+ struct item_head n_ih;
+
+ /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST
+ part defined by 'cpy_bytes'; create new item header;
+ n_ih = new item_header;
+ */
+ memcpy(&n_ih, ih, SHORT_KEY_SIZE);
+
+ n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
+
+ if (is_direct_le_ih(ih)) {
+ set_le_ih_k_offset(&n_ih,
+ le_ih_k_offset(ih) +
+ ih_item_len(ih) - cpy_bytes);
+ set_le_ih_k_type(&n_ih, TYPE_DIRECT);
+ set_ih_free_space(&n_ih, MAX_US_INT);
+ } else {
+ /* indirect item */
+ RFALSE(!cpy_bytes && get_ih_free_space(ih),
+ "vs-10200: ih->ih_free_space must be 0 when indirect item will be appended");
+ set_le_ih_k_offset(&n_ih,
+ le_ih_k_offset(ih) +
+ (ih_item_len(ih) -
+ cpy_bytes) / UNFM_P_SIZE *
+ dest->b_size);
+ set_le_ih_k_type(&n_ih, TYPE_INDIRECT);
+ set_ih_free_space(&n_ih, get_ih_free_space(ih));
+ }
+
+ /* set item length */
+ put_ih_item_len(&n_ih, cpy_bytes);
+
+ n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
+
+ leaf_insert_into_buf(dest_bi, 0, &n_ih,
+ B_N_PITEM(src,
+ item_num) +
+ ih_item_len(ih) - cpy_bytes, 0);
+ }
}
- } else {
- /* if ( if item in position item_num in buffer SOURCE is directory item ) */
- if (is_direntry_le_ih(ih = B_N_PITEM_HEAD (src, item_num)))
- leaf_copy_dir_entries (dest_bi, src, LAST_TO_FIRST, item_num, I_ENTRY_COUNT(ih) - cpy_bytes, cpy_bytes);
- else {
- struct item_head n_ih;
-
- /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST
- part defined by 'cpy_bytes'; create new item header;
- n_ih = new item_header;
- */
- memcpy (&n_ih, ih, SHORT_KEY_SIZE);
-
- n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
-
- if (is_direct_le_ih (ih)) {
- set_le_ih_k_offset (&n_ih, le_ih_k_offset (ih) + ih_item_len(ih) - cpy_bytes);
- set_le_ih_k_type (&n_ih, TYPE_DIRECT);
- set_ih_free_space (&n_ih, MAX_US_INT);
- } else {
- /* indirect item */
- RFALSE( !cpy_bytes && get_ih_free_space (ih),
- "vs-10200: ih->ih_free_space must be 0 when indirect item will be appended");
- set_le_ih_k_offset (&n_ih, le_ih_k_offset (ih) + (ih_item_len(ih) - cpy_bytes) / UNFM_P_SIZE * dest->b_size);
- set_le_ih_k_type (&n_ih, TYPE_INDIRECT);
- set_ih_free_space (&n_ih, get_ih_free_space (ih));
- }
-
- /* set item length */
- put_ih_item_len( &n_ih, cpy_bytes );
-
- n_ih.ih_version = ih->ih_version; /* JDM Endian safe, both le */
-
- leaf_insert_into_buf (dest_bi, 0, &n_ih, B_N_PITEM(src,item_num) + ih_item_len(ih) - cpy_bytes, 0);
- }
- }
}
-
/* If cpy_bytes equals minus one than copy cpy_num whole items from SOURCE to DEST.
If cpy_bytes not equal to minus one than copy cpy_num-1 whole items from SOURCE to DEST.
From last item copy cpy_num bytes for regular item and cpy_num directory entries for
directory item. */
-static int leaf_copy_items (struct buffer_info * dest_bi, struct buffer_head * src, int last_first, int cpy_num,
- int cpy_bytes)
+static int leaf_copy_items(struct buffer_info *dest_bi, struct buffer_head *src,
+ int last_first, int cpy_num, int cpy_bytes)
{
- struct buffer_head * dest;
- int pos, i, src_nr_item, bytes;
-
- dest = dest_bi->bi_bh;
- RFALSE( !dest || !src, "vs-10210: !dest || !src");
- RFALSE( last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST,
- "vs-10220:last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST");
- RFALSE( B_NR_ITEMS(src) < cpy_num,
- "vs-10230: No enough items: %d, req. %d", B_NR_ITEMS(src), cpy_num);
- RFALSE( cpy_num < 0,"vs-10240: cpy_num < 0 (%d)", cpy_num);
-
- if ( cpy_num == 0 )
- return 0;
-
- if ( last_first == FIRST_TO_LAST ) {
- /* copy items to left */
- pos = 0;
- if ( cpy_num == 1 )
- bytes = cpy_bytes;
- else
- bytes = -1;
-
- /* copy the first item or it part or nothing to the end of the DEST (i = leaf_copy_boundary_item(DEST,SOURCE,0,bytes)) */
- i = leaf_copy_boundary_item (dest_bi, src, FIRST_TO_LAST, bytes);
- cpy_num -= i;
- if ( cpy_num == 0 )
- return i;
- pos += i;
- if ( cpy_bytes == -1 )
- /* copy first cpy_num items starting from position 'pos' of SOURCE to end of DEST */
- leaf_copy_items_entirely (dest_bi, src, FIRST_TO_LAST, pos, cpy_num);
- else {
- /* copy first cpy_num-1 items starting from position 'pos-1' of the SOURCE to the end of the DEST */
- leaf_copy_items_entirely (dest_bi, src, FIRST_TO_LAST, pos, cpy_num-1);
-
- /* copy part of the item which number is cpy_num+pos-1 to the end of the DEST */
- leaf_item_bottle (dest_bi, src, FIRST_TO_LAST, cpy_num+pos-1, cpy_bytes);
- }
- } else {
- /* copy items to right */
- src_nr_item = B_NR_ITEMS (src);
- if ( cpy_num == 1 )
- bytes = cpy_bytes;
- else
- bytes = -1;
-
- /* copy the last item or it part or nothing to the begin of the DEST (i = leaf_copy_boundary_item(DEST,SOURCE,1,bytes)); */
- i = leaf_copy_boundary_item (dest_bi, src, LAST_TO_FIRST, bytes);
-
- cpy_num -= i;
- if ( cpy_num == 0 )
- return i;
-
- pos = src_nr_item - cpy_num - i;
- if ( cpy_bytes == -1 ) {
- /* starting from position 'pos' copy last cpy_num items of SOURCE to begin of DEST */
- leaf_copy_items_entirely (dest_bi, src, LAST_TO_FIRST, pos, cpy_num);
- } else {
- /* copy last cpy_num-1 items starting from position 'pos+1' of the SOURCE to the begin of the DEST; */
- leaf_copy_items_entirely (dest_bi, src, LAST_TO_FIRST, pos+1, cpy_num-1);
-
- /* copy part of the item which number is pos to the begin of the DEST */
- leaf_item_bottle (dest_bi, src, LAST_TO_FIRST, pos, cpy_bytes);
- }
- }
- return i;
+ struct buffer_head *dest;
+ int pos, i, src_nr_item, bytes;
+
+ dest = dest_bi->bi_bh;
+ RFALSE(!dest || !src, "vs-10210: !dest || !src");
+ RFALSE(last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST,
+ "vs-10220:last_first != FIRST_TO_LAST && last_first != LAST_TO_FIRST");
+ RFALSE(B_NR_ITEMS(src) < cpy_num,
+ "vs-10230: No enough items: %d, req. %d", B_NR_ITEMS(src),
+ cpy_num);
+ RFALSE(cpy_num < 0, "vs-10240: cpy_num < 0 (%d)", cpy_num);
+
+ if (cpy_num == 0)
+ return 0;
+
+ if (last_first == FIRST_TO_LAST) {
+ /* copy items to left */
+ pos = 0;
+ if (cpy_num == 1)
+ bytes = cpy_bytes;
+ else
+ bytes = -1;
+
+ /* copy the first item or it part or nothing to the end of the DEST (i = leaf_copy_boundary_item(DEST,SOURCE,0,bytes)) */
+ i = leaf_copy_boundary_item(dest_bi, src, FIRST_TO_LAST, bytes);
+ cpy_num -= i;
+ if (cpy_num == 0)
+ return i;
+ pos += i;
+ if (cpy_bytes == -1)
+ /* copy first cpy_num items starting from position 'pos' of SOURCE to end of DEST */
+ leaf_copy_items_entirely(dest_bi, src, FIRST_TO_LAST,
+ pos, cpy_num);
+ else {
+ /* copy first cpy_num-1 items starting from position 'pos-1' of the SOURCE to the end of the DEST */
+ leaf_copy_items_entirely(dest_bi, src, FIRST_TO_LAST,
+ pos, cpy_num - 1);
+
+ /* copy part of the item which number is cpy_num+pos-1 to the end of the DEST */
+ leaf_item_bottle(dest_bi, src, FIRST_TO_LAST,
+ cpy_num + pos - 1, cpy_bytes);
+ }
+ } else {
+ /* copy items to right */
+ src_nr_item = B_NR_ITEMS(src);
+ if (cpy_num == 1)
+ bytes = cpy_bytes;
+ else
+ bytes = -1;
+
+ /* copy the last item or it part or nothing to the begin of the DEST (i = leaf_copy_boundary_item(DEST,SOURCE,1,bytes)); */
+ i = leaf_copy_boundary_item(dest_bi, src, LAST_TO_FIRST, bytes);
+
+ cpy_num -= i;
+ if (cpy_num == 0)
+ return i;
+
+ pos = src_nr_item - cpy_num - i;
+ if (cpy_bytes == -1) {
+ /* starting from position 'pos' copy last cpy_num items of SOURCE to begin of DEST */
+ leaf_copy_items_entirely(dest_bi, src, LAST_TO_FIRST,
+ pos, cpy_num);
+ } else {
+ /* copy last cpy_num-1 items starting from position 'pos+1' of the SOURCE to the begin of the DEST; */
+ leaf_copy_items_entirely(dest_bi, src, LAST_TO_FIRST,
+ pos + 1, cpy_num - 1);
+
+ /* copy part of the item which number is pos to the begin of the DEST */
+ leaf_item_bottle(dest_bi, src, LAST_TO_FIRST, pos,
+ cpy_bytes);
+ }
+ }
+ return i;
}
-
/* there are types of coping: from S[0] to L[0], from S[0] to R[0],
from R[0] to L[0]. for each of these we have to define parent and
positions of destination and source buffers */
-static void leaf_define_dest_src_infos (int shift_mode, struct tree_balance * tb, struct buffer_info * dest_bi,
- struct buffer_info * src_bi, int * first_last,
- struct buffer_head * Snew)
+static void leaf_define_dest_src_infos(int shift_mode, struct tree_balance *tb,
+ struct buffer_info *dest_bi,
+ struct buffer_info *src_bi,
+ int *first_last,
+ struct buffer_head *Snew)
{
- memset (dest_bi, 0, sizeof (struct buffer_info));
- memset (src_bi, 0, sizeof (struct buffer_info));
-
- /* define dest, src, dest parent, dest position */
- switch (shift_mode) {
- case LEAF_FROM_S_TO_L: /* it is used in leaf_shift_left */
- src_bi->tb = tb;
- src_bi->bi_bh = PATH_PLAST_BUFFER (tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER (tb->tb_path, 0); /* src->b_item_order */
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->L[0];
- dest_bi->bi_parent = tb->FL[0];
- dest_bi->bi_position = get_left_neighbor_position (tb, 0);
- *first_last = FIRST_TO_LAST;
- break;
-
- case LEAF_FROM_S_TO_R: /* it is used in leaf_shift_right */
- src_bi->tb = tb;
- src_bi->bi_bh = PATH_PLAST_BUFFER (tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER (tb->tb_path, 0);
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->R[0];
- dest_bi->bi_parent = tb->FR[0];
- dest_bi->bi_position = get_right_neighbor_position (tb, 0);
- *first_last = LAST_TO_FIRST;
- break;
-
- case LEAF_FROM_R_TO_L: /* it is used in balance_leaf_when_delete */
- src_bi->tb = tb;
- src_bi->bi_bh = tb->R[0];
- src_bi->bi_parent = tb->FR[0];
- src_bi->bi_position = get_right_neighbor_position (tb, 0);
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->L[0];
- dest_bi->bi_parent = tb->FL[0];
- dest_bi->bi_position = get_left_neighbor_position (tb, 0);
- *first_last = FIRST_TO_LAST;
- break;
-
- case LEAF_FROM_L_TO_R: /* it is used in balance_leaf_when_delete */
- src_bi->tb = tb;
- src_bi->bi_bh = tb->L[0];
- src_bi->bi_parent = tb->FL[0];
- src_bi->bi_position = get_left_neighbor_position (tb, 0);
- dest_bi->tb = tb;
- dest_bi->bi_bh = tb->R[0];
- dest_bi->bi_parent = tb->FR[0];
- dest_bi->bi_position = get_right_neighbor_position (tb, 0);
- *first_last = LAST_TO_FIRST;
- break;
-
- case LEAF_FROM_S_TO_SNEW:
- src_bi->tb = tb;
- src_bi->bi_bh = PATH_PLAST_BUFFER (tb->tb_path);
- src_bi->bi_parent = PATH_H_PPARENT (tb->tb_path, 0);
- src_bi->bi_position = PATH_H_B_ITEM_ORDER (tb->tb_path, 0);
- dest_bi->tb = tb;
- dest_bi->bi_bh = Snew;
- dest_bi->bi_parent = NULL;
- dest_bi->bi_position = 0;
- *first_last = LAST_TO_FIRST;
- break;
-
- default:
- reiserfs_panic (NULL, "vs-10250: leaf_define_dest_src_infos: shift type is unknown (%d)", shift_mode);
- }
- RFALSE( src_bi->bi_bh == 0 || dest_bi->bi_bh == 0,
- "vs-10260: mode==%d, source (%p) or dest (%p) buffer is initialized incorrectly",
- shift_mode, src_bi->bi_bh, dest_bi->bi_bh);
+ memset(dest_bi, 0, sizeof(struct buffer_info));
+ memset(src_bi, 0, sizeof(struct buffer_info));
+
+ /* define dest, src, dest parent, dest position */
+ switch (shift_mode) {
+ case LEAF_FROM_S_TO_L: /* it is used in leaf_shift_left */
+ src_bi->tb = tb;
+ src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
+ src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0); /* src->b_item_order */
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->L[0];
+ dest_bi->bi_parent = tb->FL[0];
+ dest_bi->bi_position = get_left_neighbor_position(tb, 0);
+ *first_last = FIRST_TO_LAST;
+ break;
+
+ case LEAF_FROM_S_TO_R: /* it is used in leaf_shift_right */
+ src_bi->tb = tb;
+ src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
+ src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->R[0];
+ dest_bi->bi_parent = tb->FR[0];
+ dest_bi->bi_position = get_right_neighbor_position(tb, 0);
+ *first_last = LAST_TO_FIRST;
+ break;
+
+ case LEAF_FROM_R_TO_L: /* it is used in balance_leaf_when_delete */
+ src_bi->tb = tb;
+ src_bi->bi_bh = tb->R[0];
+ src_bi->bi_parent = tb->FR[0];
+ src_bi->bi_position = get_right_neighbor_position(tb, 0);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->L[0];
+ dest_bi->bi_parent = tb->FL[0];
+ dest_bi->bi_position = get_left_neighbor_position(tb, 0);
+ *first_last = FIRST_TO_LAST;
+ break;
+
+ case LEAF_FROM_L_TO_R: /* it is used in balance_leaf_when_delete */
+ src_bi->tb = tb;
+ src_bi->bi_bh = tb->L[0];
+ src_bi->bi_parent = tb->FL[0];
+ src_bi->bi_position = get_left_neighbor_position(tb, 0);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = tb->R[0];
+ dest_bi->bi_parent = tb->FR[0];
+ dest_bi->bi_position = get_right_neighbor_position(tb, 0);
+ *first_last = LAST_TO_FIRST;
+ break;
+
+ case LEAF_FROM_S_TO_SNEW:
+ src_bi->tb = tb;
+ src_bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
+ src_bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ src_bi->bi_position = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
+ dest_bi->tb = tb;
+ dest_bi->bi_bh = Snew;
+ dest_bi->bi_parent = NULL;
+ dest_bi->bi_position = 0;
+ *first_last = LAST_TO_FIRST;
+ break;
+
+ default:
+ reiserfs_panic(NULL,
+ "vs-10250: leaf_define_dest_src_infos: shift type is unknown (%d)",
+ shift_mode);
+ }
+ RFALSE(src_bi->bi_bh == 0 || dest_bi->bi_bh == 0,
+ "vs-10260: mode==%d, source (%p) or dest (%p) buffer is initialized incorrectly",
+ shift_mode, src_bi->bi_bh, dest_bi->bi_bh);
}
-
-
-
/* copy mov_num items and mov_bytes of the (mov_num-1)th item to
neighbor. Delete them from source */
-int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew)
+int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num,
+ int mov_bytes, struct buffer_head *Snew)
{
- int ret_value;
- struct buffer_info dest_bi, src_bi;
- int first_last;
+ int ret_value;
+ struct buffer_info dest_bi, src_bi;
+ int first_last;
- leaf_define_dest_src_infos (shift_mode, tb, &dest_bi, &src_bi, &first_last, Snew);
+ leaf_define_dest_src_infos(shift_mode, tb, &dest_bi, &src_bi,
+ &first_last, Snew);
- ret_value = leaf_copy_items (&dest_bi, src_bi.bi_bh, first_last, mov_num, mov_bytes);
+ ret_value =
+ leaf_copy_items(&dest_bi, src_bi.bi_bh, first_last, mov_num,
+ mov_bytes);
- leaf_delete_items (&src_bi, first_last, (first_last == FIRST_TO_LAST) ? 0 : (B_NR_ITEMS(src_bi.bi_bh) - mov_num), mov_num, mov_bytes);
+ leaf_delete_items(&src_bi, first_last,
+ (first_last ==
+ FIRST_TO_LAST) ? 0 : (B_NR_ITEMS(src_bi.bi_bh) -
+ mov_num), mov_num, mov_bytes);
-
- return ret_value;
+ return ret_value;
}
-
/* Shift shift_num items (and shift_bytes of last shifted item if shift_bytes != -1)
from S[0] to L[0] and replace the delimiting key */
-int leaf_shift_left (struct tree_balance * tb, int shift_num, int shift_bytes)
+int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes)
{
- struct buffer_head * S0 = PATH_PLAST_BUFFER (tb->tb_path);
- int i;
+ struct buffer_head *S0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int i;
- /* move shift_num (and shift_bytes bytes) items from S[0] to left neighbor L[0] */
- i = leaf_move_items (LEAF_FROM_S_TO_L, tb, shift_num, shift_bytes, NULL);
+ /* move shift_num (and shift_bytes bytes) items from S[0] to left neighbor L[0] */
+ i = leaf_move_items(LEAF_FROM_S_TO_L, tb, shift_num, shift_bytes, NULL);
- if ( shift_num ) {
- if (B_NR_ITEMS (S0) == 0) { /* number of items in S[0] == 0 */
+ if (shift_num) {
+ if (B_NR_ITEMS(S0) == 0) { /* number of items in S[0] == 0 */
- RFALSE( shift_bytes != -1,
- "vs-10270: S0 is empty now, but shift_bytes != -1 (%d)",
- shift_bytes);
+ RFALSE(shift_bytes != -1,
+ "vs-10270: S0 is empty now, but shift_bytes != -1 (%d)",
+ shift_bytes);
#ifdef CONFIG_REISERFS_CHECK
- if (tb->tb_mode == M_PASTE || tb->tb_mode == M_INSERT) {
- print_cur_tb ("vs-10275");
- reiserfs_panic (tb->tb_sb, "vs-10275: leaf_shift_left: balance condition corrupted (%c)", tb->tb_mode);
- }
+ if (tb->tb_mode == M_PASTE || tb->tb_mode == M_INSERT) {
+ print_cur_tb("vs-10275");
+ reiserfs_panic(tb->tb_sb,
+ "vs-10275: leaf_shift_left: balance condition corrupted (%c)",
+ tb->tb_mode);
+ }
#endif
- if (PATH_H_POSITION (tb->tb_path, 1) == 0)
- replace_key (tb, tb->CFL[0], tb->lkey[0], PATH_H_PPARENT (tb->tb_path, 0), 0);
-
- } else {
- /* replace lkey in CFL[0] by 0-th key from S[0]; */
- replace_key (tb, tb->CFL[0], tb->lkey[0], S0, 0);
-
- RFALSE( (shift_bytes != -1 &&
- !(is_direntry_le_ih (B_N_PITEM_HEAD (S0, 0))
- && !I_ENTRY_COUNT (B_N_PITEM_HEAD (S0, 0)))) &&
- (!op_is_left_mergeable (B_N_PKEY (S0, 0), S0->b_size)),
- "vs-10280: item must be mergeable");
- }
- }
-
- return i;
-}
-
-
-
+ if (PATH_H_POSITION(tb->tb_path, 1) == 0)
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ PATH_H_PPARENT(tb->tb_path, 0), 0);
+
+ } else {
+ /* replace lkey in CFL[0] by 0-th key from S[0]; */
+ replace_key(tb, tb->CFL[0], tb->lkey[0], S0, 0);
+
+ RFALSE((shift_bytes != -1 &&
+ !(is_direntry_le_ih(B_N_PITEM_HEAD(S0, 0))
+ && !I_ENTRY_COUNT(B_N_PITEM_HEAD(S0, 0)))) &&
+ (!op_is_left_mergeable
+ (B_N_PKEY(S0, 0), S0->b_size)),
+ "vs-10280: item must be mergeable");
+ }
+ }
+ return i;
+}
/* CLEANING STOPPED HERE */
-
-
-
/* Shift shift_num (shift_bytes) items from S[0] to the right neighbor, and replace the delimiting key */
-int leaf_shift_right(
- struct tree_balance * tb,
- int shift_num,
- int shift_bytes
- )
+int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes)
{
- // struct buffer_head * S0 = PATH_PLAST_BUFFER (tb->tb_path);
- int ret_value;
+ // struct buffer_head * S0 = PATH_PLAST_BUFFER (tb->tb_path);
+ int ret_value;
- /* move shift_num (and shift_bytes) items from S[0] to right neighbor R[0] */
- ret_value = leaf_move_items (LEAF_FROM_S_TO_R, tb, shift_num, shift_bytes, NULL);
+ /* move shift_num (and shift_bytes) items from S[0] to right neighbor R[0] */
+ ret_value =
+ leaf_move_items(LEAF_FROM_S_TO_R, tb, shift_num, shift_bytes, NULL);
- /* replace rkey in CFR[0] by the 0-th key from R[0] */
- if (shift_num) {
- replace_key (tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
+ /* replace rkey in CFR[0] by the 0-th key from R[0] */
+ if (shift_num) {
+ replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
- }
+ }
- return ret_value;
+ return ret_value;
}
-
-
-static void leaf_delete_items_entirely (struct buffer_info * bi,
- int first, int del_num);
+static void leaf_delete_items_entirely(struct buffer_info *bi,
+ int first, int del_num);
/* If del_bytes == -1, starting from position 'first' delete del_num items in whole in buffer CUR.
If not.
If last_first == 0. Starting from position 'first' delete del_num-1 items in whole. Delete part of body of
@@ -670,287 +731,292 @@ static void leaf_delete_items_entirely (struct buffer_info * bi,
If last_first == 1. Starting from position 'first+1' delete del_num-1 items in whole. Delete part of body of
the last item . Part defined by del_bytes. Don't delete last item header.
*/
-void leaf_delete_items (struct buffer_info * cur_bi, int last_first,
- int first, int del_num, int del_bytes)
+void leaf_delete_items(struct buffer_info *cur_bi, int last_first,
+ int first, int del_num, int del_bytes)
{
- struct buffer_head * bh;
- int item_amount = B_NR_ITEMS (bh = cur_bi->bi_bh);
-
- RFALSE( !bh, "10155: bh is not defined");
- RFALSE( del_num < 0, "10160: del_num can not be < 0. del_num==%d", del_num);
- RFALSE( first < 0 || first + del_num > item_amount,
- "10165: invalid number of first item to be deleted (%d) or "
- "no so much items (%d) to delete (only %d)",
- first, first + del_num, item_amount);
-
- if ( del_num == 0 )
- return;
-
- if ( first == 0 && del_num == item_amount && del_bytes == -1 ) {
- make_empty_node (cur_bi);
- do_balance_mark_leaf_dirty (cur_bi->tb, bh, 0);
- return;
- }
-
- if ( del_bytes == -1 )
- /* delete del_num items beginning from item in position first */
- leaf_delete_items_entirely (cur_bi, first, del_num);
- else {
- if ( last_first == FIRST_TO_LAST ) {
- /* delete del_num-1 items beginning from item in position first */
- leaf_delete_items_entirely (cur_bi, first, del_num-1);
-
- /* delete the part of the first item of the bh
- do not delete item header
- */
- leaf_cut_from_buffer (cur_bi, 0, 0, del_bytes);
- } else {
- struct item_head * ih;
- int len;
-
- /* delete del_num-1 items beginning from item in position first+1 */
- leaf_delete_items_entirely (cur_bi, first+1, del_num-1);
-
- if (is_direntry_le_ih (ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh)-1))) /* the last item is directory */
- /* len = numbers of directory entries in this item */
- len = ih_entry_count(ih);
- else
- /* len = body len of item */
- len = ih_item_len(ih);
-
- /* delete the part of the last item of the bh
- do not delete item header
- */
- leaf_cut_from_buffer (cur_bi, B_NR_ITEMS(bh)-1, len - del_bytes, del_bytes);
+ struct buffer_head *bh;
+ int item_amount = B_NR_ITEMS(bh = cur_bi->bi_bh);
+
+ RFALSE(!bh, "10155: bh is not defined");
+ RFALSE(del_num < 0, "10160: del_num can not be < 0. del_num==%d",
+ del_num);
+ RFALSE(first < 0
+ || first + del_num > item_amount,
+ "10165: invalid number of first item to be deleted (%d) or "
+ "no so much items (%d) to delete (only %d)", first,
+ first + del_num, item_amount);
+
+ if (del_num == 0)
+ return;
+
+ if (first == 0 && del_num == item_amount && del_bytes == -1) {
+ make_empty_node(cur_bi);
+ do_balance_mark_leaf_dirty(cur_bi->tb, bh, 0);
+ return;
}
- }
-}
+ if (del_bytes == -1)
+ /* delete del_num items beginning from item in position first */
+ leaf_delete_items_entirely(cur_bi, first, del_num);
+ else {
+ if (last_first == FIRST_TO_LAST) {
+ /* delete del_num-1 items beginning from item in position first */
+ leaf_delete_items_entirely(cur_bi, first, del_num - 1);
+
+ /* delete the part of the first item of the bh
+ do not delete item header
+ */
+ leaf_cut_from_buffer(cur_bi, 0, 0, del_bytes);
+ } else {
+ struct item_head *ih;
+ int len;
+
+ /* delete del_num-1 items beginning from item in position first+1 */
+ leaf_delete_items_entirely(cur_bi, first + 1,
+ del_num - 1);
+
+ if (is_direntry_le_ih
+ (ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1)))
+ /* the last item is directory */
+ /* len = numbers of directory entries in this item */
+ len = ih_entry_count(ih);
+ else
+ /* len = body len of item */
+ len = ih_item_len(ih);
+
+ /* delete the part of the last item of the bh
+ do not delete item header
+ */
+ leaf_cut_from_buffer(cur_bi, B_NR_ITEMS(bh) - 1,
+ len - del_bytes, del_bytes);
+ }
+ }
+}
/* insert item into the leaf node in position before */
-void leaf_insert_into_buf (struct buffer_info * bi, int before,
- struct item_head * inserted_item_ih,
- const char * inserted_item_body,
- int zeros_number)
+void leaf_insert_into_buf(struct buffer_info *bi, int before,
+ struct item_head *inserted_item_ih,
+ const char *inserted_item_body, int zeros_number)
{
- struct buffer_head * bh = bi->bi_bh;
- int nr, free_space;
- struct block_head * blkh;
- struct item_head * ih;
- int i;
- int last_loc, unmoved_loc;
- char * to;
-
-
- blkh = B_BLK_HEAD(bh);
- nr = blkh_nr_item(blkh);
- free_space = blkh_free_space( blkh );
-
- /* check free space */
- RFALSE( free_space < ih_item_len(inserted_item_ih) + IH_SIZE,
- "vs-10170: not enough free space in block %z, new item %h",
- bh, inserted_item_ih);
- RFALSE( zeros_number > ih_item_len(inserted_item_ih),
- "vs-10172: zero number == %d, item length == %d",
- zeros_number, ih_item_len(inserted_item_ih));
-
-
- /* get item new item must be inserted before */
- ih = B_N_PITEM_HEAD (bh, before);
-
- /* prepare space for the body of new item */
- last_loc = nr ? ih_location( &(ih[nr - before - 1]) ) : bh->b_size;
- unmoved_loc = before ? ih_location( ih-1 ) : bh->b_size;
-
-
- memmove (bh->b_data + last_loc - ih_item_len(inserted_item_ih),
- bh->b_data + last_loc, unmoved_loc - last_loc);
-
- to = bh->b_data + unmoved_loc - ih_item_len(inserted_item_ih);
- memset (to, 0, zeros_number);
- to += zeros_number;
-
- /* copy body to prepared space */
- if (inserted_item_body)
- memmove (to, inserted_item_body, ih_item_len(inserted_item_ih) - zeros_number);
- else
- memset(to, '\0', ih_item_len(inserted_item_ih) - zeros_number);
-
- /* insert item header */
- memmove (ih + 1, ih, IH_SIZE * (nr - before));
- memmove (ih, inserted_item_ih, IH_SIZE);
-
- /* change locations */
- for (i = before; i < nr + 1; i ++)
- {
- unmoved_loc -= ih_item_len( &(ih[i-before]));
- put_ih_location( &(ih[i-before]), unmoved_loc );
- }
-
- /* sizes, free space, item number */
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) + 1 );
- set_blkh_free_space( blkh,
- free_space - (IH_SIZE + ih_item_len(inserted_item_ih ) ) );
- do_balance_mark_leaf_dirty (bi->tb, bh, 1);
-
- if (bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD (bi->bi_parent, bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) + (IH_SIZE + ih_item_len(inserted_item_ih)));
- do_balance_mark_internal_dirty (bi->tb, bi->bi_parent, 0);
- }
-}
+ struct buffer_head *bh = bi->bi_bh;
+ int nr, free_space;
+ struct block_head *blkh;
+ struct item_head *ih;
+ int i;
+ int last_loc, unmoved_loc;
+ char *to;
+
+ blkh = B_BLK_HEAD(bh);
+ nr = blkh_nr_item(blkh);
+ free_space = blkh_free_space(blkh);
+
+ /* check free space */
+ RFALSE(free_space < ih_item_len(inserted_item_ih) + IH_SIZE,
+ "vs-10170: not enough free space in block %z, new item %h",
+ bh, inserted_item_ih);
+ RFALSE(zeros_number > ih_item_len(inserted_item_ih),
+ "vs-10172: zero number == %d, item length == %d",
+ zeros_number, ih_item_len(inserted_item_ih));
+
+ /* get item new item must be inserted before */
+ ih = B_N_PITEM_HEAD(bh, before);
+
+ /* prepare space for the body of new item */
+ last_loc = nr ? ih_location(&(ih[nr - before - 1])) : bh->b_size;
+ unmoved_loc = before ? ih_location(ih - 1) : bh->b_size;
+
+ memmove(bh->b_data + last_loc - ih_item_len(inserted_item_ih),
+ bh->b_data + last_loc, unmoved_loc - last_loc);
+
+ to = bh->b_data + unmoved_loc - ih_item_len(inserted_item_ih);
+ memset(to, 0, zeros_number);
+ to += zeros_number;
+
+ /* copy body to prepared space */
+ if (inserted_item_body)
+ memmove(to, inserted_item_body,
+ ih_item_len(inserted_item_ih) - zeros_number);
+ else
+ memset(to, '\0', ih_item_len(inserted_item_ih) - zeros_number);
+
+ /* insert item header */
+ memmove(ih + 1, ih, IH_SIZE * (nr - before));
+ memmove(ih, inserted_item_ih, IH_SIZE);
+
+ /* change locations */
+ for (i = before; i < nr + 1; i++) {
+ unmoved_loc -= ih_item_len(&(ih[i - before]));
+ put_ih_location(&(ih[i - before]), unmoved_loc);
+ }
+ /* sizes, free space, item number */
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) + 1);
+ set_blkh_free_space(blkh,
+ free_space - (IH_SIZE +
+ ih_item_len(inserted_item_ih)));
+ do_balance_mark_leaf_dirty(bi->tb, bh, 1);
+
+ if (bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(bi->bi_parent, bi->bi_position);
+ put_dc_size(t_dc,
+ dc_size(t_dc) + (IH_SIZE +
+ ih_item_len(inserted_item_ih)));
+ do_balance_mark_internal_dirty(bi->tb, bi->bi_parent, 0);
+ }
+}
/* paste paste_size bytes to affected_item_num-th item.
When item is a directory, this only prepare space for new entries */
-void leaf_paste_in_buffer (struct buffer_info * bi, int affected_item_num,
- int pos_in_item, int paste_size,
- const char * body,
- int zeros_number)
+void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num,
+ int pos_in_item, int paste_size,
+ const char *body, int zeros_number)
{
- struct buffer_head * bh = bi->bi_bh;
- int nr, free_space;
- struct block_head * blkh;
- struct item_head * ih;
- int i;
- int last_loc, unmoved_loc;
-
- blkh = B_BLK_HEAD(bh);
- nr = blkh_nr_item(blkh);
- free_space = blkh_free_space(blkh);
-
-
- /* check free space */
- RFALSE( free_space < paste_size,
- "vs-10175: not enough free space: needed %d, available %d",
- paste_size, free_space);
+ struct buffer_head *bh = bi->bi_bh;
+ int nr, free_space;
+ struct block_head *blkh;
+ struct item_head *ih;
+ int i;
+ int last_loc, unmoved_loc;
+
+ blkh = B_BLK_HEAD(bh);
+ nr = blkh_nr_item(blkh);
+ free_space = blkh_free_space(blkh);
+
+ /* check free space */
+ RFALSE(free_space < paste_size,
+ "vs-10175: not enough free space: needed %d, available %d",
+ paste_size, free_space);
#ifdef CONFIG_REISERFS_CHECK
- if (zeros_number > paste_size) {
- print_cur_tb ("10177");
- reiserfs_panic ( NULL, "vs-10177: leaf_paste_in_buffer: ero number == %d, paste_size == %d",
- zeros_number, paste_size);
- }
-#endif /* CONFIG_REISERFS_CHECK */
-
-
- /* item to be appended */
- ih = B_N_PITEM_HEAD(bh, affected_item_num);
-
- last_loc = ih_location( &(ih[nr - affected_item_num - 1]) );
- unmoved_loc = affected_item_num ? ih_location( ih-1 ) : bh->b_size;
-
- /* prepare space */
- memmove (bh->b_data + last_loc - paste_size, bh->b_data + last_loc,
- unmoved_loc - last_loc);
-
-
- /* change locations */
- for (i = affected_item_num; i < nr; i ++)
- put_ih_location( &(ih[i-affected_item_num]),
- ih_location( &(ih[i-affected_item_num])) - paste_size );
-
- if ( body ) {
- if (!is_direntry_le_ih (ih)) {
- if (!pos_in_item) {
- /* shift data to right */
- memmove (bh->b_data + ih_location(ih) + paste_size,
- bh->b_data + ih_location(ih), ih_item_len(ih));
- /* paste data in the head of item */
- memset (bh->b_data + ih_location(ih), 0, zeros_number);
- memcpy (bh->b_data + ih_location(ih) + zeros_number, body, paste_size - zeros_number);
- } else {
- memset (bh->b_data + unmoved_loc - paste_size, 0, zeros_number);
- memcpy (bh->b_data + unmoved_loc - paste_size + zeros_number, body, paste_size - zeros_number);
- }
+ if (zeros_number > paste_size) {
+ print_cur_tb("10177");
+ reiserfs_panic(NULL,
+ "vs-10177: leaf_paste_in_buffer: ero number == %d, paste_size == %d",
+ zeros_number, paste_size);
+ }
+#endif /* CONFIG_REISERFS_CHECK */
+
+ /* item to be appended */
+ ih = B_N_PITEM_HEAD(bh, affected_item_num);
+
+ last_loc = ih_location(&(ih[nr - affected_item_num - 1]));
+ unmoved_loc = affected_item_num ? ih_location(ih - 1) : bh->b_size;
+
+ /* prepare space */
+ memmove(bh->b_data + last_loc - paste_size, bh->b_data + last_loc,
+ unmoved_loc - last_loc);
+
+ /* change locations */
+ for (i = affected_item_num; i < nr; i++)
+ put_ih_location(&(ih[i - affected_item_num]),
+ ih_location(&(ih[i - affected_item_num])) -
+ paste_size);
+
+ if (body) {
+ if (!is_direntry_le_ih(ih)) {
+ if (!pos_in_item) {
+ /* shift data to right */
+ memmove(bh->b_data + ih_location(ih) +
+ paste_size,
+ bh->b_data + ih_location(ih),
+ ih_item_len(ih));
+ /* paste data in the head of item */
+ memset(bh->b_data + ih_location(ih), 0,
+ zeros_number);
+ memcpy(bh->b_data + ih_location(ih) +
+ zeros_number, body,
+ paste_size - zeros_number);
+ } else {
+ memset(bh->b_data + unmoved_loc - paste_size, 0,
+ zeros_number);
+ memcpy(bh->b_data + unmoved_loc - paste_size +
+ zeros_number, body,
+ paste_size - zeros_number);
+ }
+ }
+ } else
+ memset(bh->b_data + unmoved_loc - paste_size, '\0', paste_size);
+
+ put_ih_item_len(ih, ih_item_len(ih) + paste_size);
+
+ /* change free space */
+ set_blkh_free_space(blkh, free_space - paste_size);
+
+ do_balance_mark_leaf_dirty(bi->tb, bh, 0);
+
+ if (bi->bi_parent) {
+ struct disk_child *t_dc =
+ B_N_CHILD(bi->bi_parent, bi->bi_position);
+ put_dc_size(t_dc, dc_size(t_dc) + paste_size);
+ do_balance_mark_internal_dirty(bi->tb, bi->bi_parent, 0);
}
- }
- else
- memset(bh->b_data + unmoved_loc - paste_size, '\0', paste_size);
-
- put_ih_item_len( ih, ih_item_len(ih) + paste_size );
-
- /* change free space */
- set_blkh_free_space( blkh, free_space - paste_size );
-
- do_balance_mark_leaf_dirty (bi->tb, bh, 0);
-
- if (bi->bi_parent) {
- struct disk_child *t_dc = B_N_CHILD (bi->bi_parent, bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) + paste_size );
- do_balance_mark_internal_dirty (bi->tb, bi->bi_parent, 0);
- }
}
-
/* cuts DEL_COUNT entries beginning from FROM-th entry. Directory item
does not have free space, so it moves DEHs and remaining records as
necessary. Return value is size of removed part of directory item
in bytes. */
-static int leaf_cut_entries (
- struct buffer_head * bh,
- struct item_head * ih,
- int from,
- int del_count
- )
+static int leaf_cut_entries(struct buffer_head *bh,
+ struct item_head *ih, int from, int del_count)
{
- char * item;
- struct reiserfs_de_head * deh;
- int prev_record_offset; /* offset of record, that is (from-1)th */
- char * prev_record; /* */
- int cut_records_len; /* length of all removed records */
- int i;
-
-
- /* make sure, that item is directory and there are enough entries to
- remove */
- RFALSE( !is_direntry_le_ih (ih), "10180: item is not directory item");
- RFALSE( I_ENTRY_COUNT(ih) < from + del_count,
- "10185: item contains not enough entries: entry_cout = %d, from = %d, to delete = %d",
- I_ENTRY_COUNT(ih), from, del_count);
-
- if (del_count == 0)
- return 0;
-
- /* first byte of item */
- item = bh->b_data + ih_location(ih);
-
- /* entry head array */
- deh = B_I_DEH (bh, ih);
-
- /* first byte of remaining entries, those are BEFORE cut entries
- (prev_record) and length of all removed records (cut_records_len) */
- prev_record_offset = (from ? deh_location( &(deh[from - 1])) : ih_item_len(ih));
- cut_records_len = prev_record_offset/*from_record*/ -
- deh_location( &(deh[from + del_count - 1]));
- prev_record = item + prev_record_offset;
-
-
- /* adjust locations of remaining entries */
- for (i = I_ENTRY_COUNT(ih) - 1; i > from + del_count - 1; i --)
- put_deh_location( &(deh[i]),
- deh_location( &deh[i] ) - (DEH_SIZE * del_count ) );
-
- for (i = 0; i < from; i ++)
- put_deh_location( &(deh[i]),
- deh_location( &deh[i] ) - (DEH_SIZE * del_count + cut_records_len) );
-
- put_ih_entry_count( ih, ih_entry_count(ih) - del_count );
-
- /* shift entry head array and entries those are AFTER removed entries */
- memmove ((char *)(deh + from),
- deh + from + del_count,
- prev_record - cut_records_len - (char *)(deh + from + del_count));
-
- /* shift records, those are BEFORE removed entries */
- memmove (prev_record - cut_records_len - DEH_SIZE * del_count,
- prev_record, item + ih_item_len(ih) - prev_record);
-
- return DEH_SIZE * del_count + cut_records_len;
+ char *item;
+ struct reiserfs_de_head *deh;
+ int prev_record_offset; /* offset of record, that is (from-1)th */
+ char *prev_record; /* */
+ int cut_records_len; /* length of all removed records */
+ int i;
+
+ /* make sure, that item is directory and there are enough entries to
+ remove */
+ RFALSE(!is_direntry_le_ih(ih), "10180: item is not directory item");
+ RFALSE(I_ENTRY_COUNT(ih) < from + del_count,
+ "10185: item contains not enough entries: entry_cout = %d, from = %d, to delete = %d",
+ I_ENTRY_COUNT(ih), from, del_count);
+
+ if (del_count == 0)
+ return 0;
+
+ /* first byte of item */
+ item = bh->b_data + ih_location(ih);
+
+ /* entry head array */
+ deh = B_I_DEH(bh, ih);
+
+ /* first byte of remaining entries, those are BEFORE cut entries
+ (prev_record) and length of all removed records (cut_records_len) */
+ prev_record_offset =
+ (from ? deh_location(&(deh[from - 1])) : ih_item_len(ih));
+ cut_records_len = prev_record_offset /*from_record */ -
+ deh_location(&(deh[from + del_count - 1]));
+ prev_record = item + prev_record_offset;
+
+ /* adjust locations of remaining entries */
+ for (i = I_ENTRY_COUNT(ih) - 1; i > from + del_count - 1; i--)
+ put_deh_location(&(deh[i]),
+ deh_location(&deh[i]) -
+ (DEH_SIZE * del_count));
+
+ for (i = 0; i < from; i++)
+ put_deh_location(&(deh[i]),
+ deh_location(&deh[i]) - (DEH_SIZE * del_count +
+ cut_records_len));
+
+ put_ih_entry_count(ih, ih_entry_count(ih) - del_count);
+
+ /* shift entry head array and entries those are AFTER removed entries */
+ memmove((char *)(deh + from),
+ deh + from + del_count,
+ prev_record - cut_records_len - (char *)(deh + from +
+ del_count));
+
+ /* shift records, those are BEFORE removed entries */
+ memmove(prev_record - cut_records_len - DEH_SIZE * del_count,
+ prev_record, item + ih_item_len(ih) - prev_record);
+
+ return DEH_SIZE * del_count + cut_records_len;
}
-
/* when cut item is part of regular file
pos_in_item - first byte that must be cut
cut_size - number of bytes to be cut beginning from pos_in_item
@@ -959,264 +1025,278 @@ static int leaf_cut_entries (
pos_in_item - number of first deleted entry
cut_size - count of deleted entries
*/
-void leaf_cut_from_buffer (struct buffer_info * bi, int cut_item_num,
- int pos_in_item, int cut_size)
+void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
+ int pos_in_item, int cut_size)
{
- int nr;
- struct buffer_head * bh = bi->bi_bh;
- struct block_head * blkh;
- struct item_head * ih;
- int last_loc, unmoved_loc;
- int i;
-
- blkh = B_BLK_HEAD(bh);
- nr = blkh_nr_item(blkh);
-
- /* item head of truncated item */
- ih = B_N_PITEM_HEAD (bh, cut_item_num);
-
- if (is_direntry_le_ih (ih)) {
- /* first cut entry ()*/
- cut_size = leaf_cut_entries (bh, ih, pos_in_item, cut_size);
- if (pos_in_item == 0) {
- /* change key */
- RFALSE( cut_item_num,
- "when 0-th enrty of item is cut, that item must be first in the node, not %d-th", cut_item_num);
- /* change item key by key of first entry in the item */
- set_le_ih_k_offset (ih, deh_offset(B_I_DEH (bh, ih)));
- /*memcpy (&ih->ih_key.k_offset, &(B_I_DEH (bh, ih)->deh_offset), SHORT_KEY_SIZE);*/
- }
- } else {
- /* item is direct or indirect */
- RFALSE( is_statdata_le_ih (ih), "10195: item is stat data");
- RFALSE( pos_in_item && pos_in_item + cut_size != ih_item_len(ih),
- "10200: invalid offset (%lu) or trunc_size (%lu) or ih_item_len (%lu)",
- ( long unsigned ) pos_in_item, ( long unsigned ) cut_size,
- ( long unsigned ) ih_item_len (ih));
-
- /* shift item body to left if cut is from the head of item */
- if (pos_in_item == 0) {
- memmove( bh->b_data + ih_location(ih),
- bh->b_data + ih_location(ih) + cut_size,
- ih_item_len(ih) - cut_size);
-
- /* change key of item */
- if (is_direct_le_ih (ih))
- set_le_ih_k_offset (ih, le_ih_k_offset (ih) + cut_size);
- else {
- set_le_ih_k_offset (ih, le_ih_k_offset (ih) + (cut_size / UNFM_P_SIZE) * bh->b_size);
- RFALSE( ih_item_len(ih) == cut_size && get_ih_free_space (ih),
- "10205: invalid ih_free_space (%h)", ih);
- }
- }
- }
-
-
- /* location of the last item */
- last_loc = ih_location( &(ih[nr - cut_item_num - 1]) );
-
- /* location of the item, which is remaining at the same place */
- unmoved_loc = cut_item_num ? ih_location(ih-1) : bh->b_size;
-
-
- /* shift */
- memmove (bh->b_data + last_loc + cut_size, bh->b_data + last_loc,
- unmoved_loc - last_loc - cut_size);
-
- /* change item length */
- put_ih_item_len( ih, ih_item_len(ih) - cut_size );
-
- if (is_indirect_le_ih (ih)) {
- if (pos_in_item)
- set_ih_free_space (ih, 0);
- }
-
- /* change locations */
- for (i = cut_item_num; i < nr; i ++)
- put_ih_location( &(ih[i-cut_item_num]), ih_location( &ih[i-cut_item_num]) + cut_size );
-
- /* size, free space */
- set_blkh_free_space( blkh, blkh_free_space(blkh) + cut_size );
-
- do_balance_mark_leaf_dirty (bi->tb, bh, 0);
-
- if (bi->bi_parent) {
- struct disk_child *t_dc;
- t_dc = B_N_CHILD (bi->bi_parent, bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) - cut_size );
- do_balance_mark_internal_dirty (bi->tb, bi->bi_parent, 0);
- }
-}
+ int nr;
+ struct buffer_head *bh = bi->bi_bh;
+ struct block_head *blkh;
+ struct item_head *ih;
+ int last_loc, unmoved_loc;
+ int i;
+
+ blkh = B_BLK_HEAD(bh);
+ nr = blkh_nr_item(blkh);
+
+ /* item head of truncated item */
+ ih = B_N_PITEM_HEAD(bh, cut_item_num);
+
+ if (is_direntry_le_ih(ih)) {
+ /* first cut entry () */
+ cut_size = leaf_cut_entries(bh, ih, pos_in_item, cut_size);
+ if (pos_in_item == 0) {
+ /* change key */
+ RFALSE(cut_item_num,
+ "when 0-th enrty of item is cut, that item must be first in the node, not %d-th",
+ cut_item_num);
+ /* change item key by key of first entry in the item */
+ set_le_ih_k_offset(ih, deh_offset(B_I_DEH(bh, ih)));
+ /*memcpy (&ih->ih_key.k_offset, &(B_I_DEH (bh, ih)->deh_offset), SHORT_KEY_SIZE); */
+ }
+ } else {
+ /* item is direct or indirect */
+ RFALSE(is_statdata_le_ih(ih), "10195: item is stat data");
+ RFALSE(pos_in_item && pos_in_item + cut_size != ih_item_len(ih),
+ "10200: invalid offset (%lu) or trunc_size (%lu) or ih_item_len (%lu)",
+ (long unsigned)pos_in_item, (long unsigned)cut_size,
+ (long unsigned)ih_item_len(ih));
+
+ /* shift item body to left if cut is from the head of item */
+ if (pos_in_item == 0) {
+ memmove(bh->b_data + ih_location(ih),
+ bh->b_data + ih_location(ih) + cut_size,
+ ih_item_len(ih) - cut_size);
+
+ /* change key of item */
+ if (is_direct_le_ih(ih))
+ set_le_ih_k_offset(ih,
+ le_ih_k_offset(ih) +
+ cut_size);
+ else {
+ set_le_ih_k_offset(ih,
+ le_ih_k_offset(ih) +
+ (cut_size / UNFM_P_SIZE) *
+ bh->b_size);
+ RFALSE(ih_item_len(ih) == cut_size
+ && get_ih_free_space(ih),
+ "10205: invalid ih_free_space (%h)", ih);
+ }
+ }
+ }
+
+ /* location of the last item */
+ last_loc = ih_location(&(ih[nr - cut_item_num - 1]));
+
+ /* location of the item, which is remaining at the same place */
+ unmoved_loc = cut_item_num ? ih_location(ih - 1) : bh->b_size;
+
+ /* shift */
+ memmove(bh->b_data + last_loc + cut_size, bh->b_data + last_loc,
+ unmoved_loc - last_loc - cut_size);
+
+ /* change item length */
+ put_ih_item_len(ih, ih_item_len(ih) - cut_size);
+ if (is_indirect_le_ih(ih)) {
+ if (pos_in_item)
+ set_ih_free_space(ih, 0);
+ }
+
+ /* change locations */
+ for (i = cut_item_num; i < nr; i++)
+ put_ih_location(&(ih[i - cut_item_num]),
+ ih_location(&ih[i - cut_item_num]) + cut_size);
+
+ /* size, free space */
+ set_blkh_free_space(blkh, blkh_free_space(blkh) + cut_size);
+
+ do_balance_mark_leaf_dirty(bi->tb, bh, 0);
+
+ if (bi->bi_parent) {
+ struct disk_child *t_dc;
+ t_dc = B_N_CHILD(bi->bi_parent, bi->bi_position);
+ put_dc_size(t_dc, dc_size(t_dc) - cut_size);
+ do_balance_mark_internal_dirty(bi->tb, bi->bi_parent, 0);
+ }
+}
/* delete del_num items from buffer starting from the first'th item */
-static void leaf_delete_items_entirely (struct buffer_info * bi,
- int first, int del_num)
+static void leaf_delete_items_entirely(struct buffer_info *bi,
+ int first, int del_num)
{
- struct buffer_head * bh = bi->bi_bh;
- int nr;
- int i, j;
- int last_loc, last_removed_loc;
- struct block_head * blkh;
- struct item_head * ih;
-
- RFALSE( bh == NULL, "10210: buffer is 0");
- RFALSE( del_num < 0, "10215: del_num less than 0 (%d)", del_num);
-
- if (del_num == 0)
- return;
-
- blkh = B_BLK_HEAD(bh);
- nr = blkh_nr_item(blkh);
-
- RFALSE( first < 0 || first + del_num > nr,
- "10220: first=%d, number=%d, there is %d items", first, del_num, nr);
-
- if (first == 0 && del_num == nr) {
- /* this does not work */
- make_empty_node (bi);
-
- do_balance_mark_leaf_dirty (bi->tb, bh, 0);
- return;
- }
-
- ih = B_N_PITEM_HEAD (bh, first);
-
- /* location of unmovable item */
- j = (first == 0) ? bh->b_size : ih_location(ih-1);
-
- /* delete items */
- last_loc = ih_location( &(ih[nr-1-first]) );
- last_removed_loc = ih_location( &(ih[del_num-1]) );
-
- memmove (bh->b_data + last_loc + j - last_removed_loc,
- bh->b_data + last_loc, last_removed_loc - last_loc);
-
- /* delete item headers */
- memmove (ih, ih + del_num, (nr - first - del_num) * IH_SIZE);
-
- /* change item location */
- for (i = first; i < nr - del_num; i ++)
- put_ih_location( &(ih[i-first]), ih_location( &(ih[i-first]) ) + (j - last_removed_loc) );
-
- /* sizes, item number */
- set_blkh_nr_item( blkh, blkh_nr_item(blkh) - del_num );
- set_blkh_free_space( blkh, blkh_free_space(blkh) + (j - last_removed_loc + IH_SIZE * del_num) );
-
- do_balance_mark_leaf_dirty (bi->tb, bh, 0);
-
- if (bi->bi_parent) {
- struct disk_child *t_dc = B_N_CHILD (bi->bi_parent, bi->bi_position);
- put_dc_size( t_dc, dc_size(t_dc) -
- (j - last_removed_loc + IH_SIZE * del_num));
- do_balance_mark_internal_dirty (bi->tb, bi->bi_parent, 0);
- }
-}
+ struct buffer_head *bh = bi->bi_bh;
+ int nr;
+ int i, j;
+ int last_loc, last_removed_loc;
+ struct block_head *blkh;
+ struct item_head *ih;
+
+ RFALSE(bh == NULL, "10210: buffer is 0");
+ RFALSE(del_num < 0, "10215: del_num less than 0 (%d)", del_num);
+
+ if (del_num == 0)
+ return;
+
+ blkh = B_BLK_HEAD(bh);
+ nr = blkh_nr_item(blkh);
+ RFALSE(first < 0 || first + del_num > nr,
+ "10220: first=%d, number=%d, there is %d items", first, del_num,
+ nr);
+
+ if (first == 0 && del_num == nr) {
+ /* this does not work */
+ make_empty_node(bi);
+
+ do_balance_mark_leaf_dirty(bi->tb, bh, 0);
+ return;
+ }
+ ih = B_N_PITEM_HEAD(bh, first);
+ /* location of unmovable item */
+ j = (first == 0) ? bh->b_size : ih_location(ih - 1);
+ /* delete items */
+ last_loc = ih_location(&(ih[nr - 1 - first]));
+ last_removed_loc = ih_location(&(ih[del_num - 1]));
+
+ memmove(bh->b_data + last_loc + j - last_removed_loc,
+ bh->b_data + last_loc, last_removed_loc - last_loc);
+
+ /* delete item headers */
+ memmove(ih, ih + del_num, (nr - first - del_num) * IH_SIZE);
+
+ /* change item location */
+ for (i = first; i < nr - del_num; i++)
+ put_ih_location(&(ih[i - first]),
+ ih_location(&(ih[i - first])) + (j -
+ last_removed_loc));
+
+ /* sizes, item number */
+ set_blkh_nr_item(blkh, blkh_nr_item(blkh) - del_num);
+ set_blkh_free_space(blkh,
+ blkh_free_space(blkh) + (j - last_removed_loc +
+ IH_SIZE * del_num));
+
+ do_balance_mark_leaf_dirty(bi->tb, bh, 0);
+
+ if (bi->bi_parent) {
+ struct disk_child *t_dc =
+ B_N_CHILD(bi->bi_parent, bi->bi_position);
+ put_dc_size(t_dc,
+ dc_size(t_dc) - (j - last_removed_loc +
+ IH_SIZE * del_num));
+ do_balance_mark_internal_dirty(bi->tb, bi->bi_parent, 0);
+ }
+}
/* paste new_entry_count entries (new_dehs, records) into position before to item_num-th item */
-void leaf_paste_entries (
- struct buffer_head * bh,
+void leaf_paste_entries(struct buffer_head *bh,
int item_num,
int before,
int new_entry_count,
- struct reiserfs_de_head * new_dehs,
- const char * records,
- int paste_size
- )
+ struct reiserfs_de_head *new_dehs,
+ const char *records, int paste_size)
{
- struct item_head * ih;
- char * item;
- struct reiserfs_de_head * deh;
- char * insert_point;
- int i, old_entry_num;
-
- if (new_entry_count == 0)
- return;
-
- ih = B_N_PITEM_HEAD(bh, item_num);
-
- /* make sure, that item is directory, and there are enough records in it */
- RFALSE( !is_direntry_le_ih (ih), "10225: item is not directory item");
- RFALSE( I_ENTRY_COUNT (ih) < before,
- "10230: there are no entry we paste entries before. entry_count = %d, before = %d",
- I_ENTRY_COUNT (ih), before);
-
-
- /* first byte of dest item */
- item = bh->b_data + ih_location(ih);
-
- /* entry head array */
- deh = B_I_DEH (bh, ih);
-
- /* new records will be pasted at this point */
- insert_point = item + (before ? deh_location( &(deh[before - 1])) : (ih_item_len(ih) - paste_size));
-
- /* adjust locations of records that will be AFTER new records */
- for (i = I_ENTRY_COUNT(ih) - 1; i >= before; i --)
- put_deh_location( &(deh[i]),
- deh_location(&(deh[i])) + (DEH_SIZE * new_entry_count ));
-
- /* adjust locations of records that will be BEFORE new records */
- for (i = 0; i < before; i ++)
- put_deh_location( &(deh[i]), deh_location(&(deh[i])) + paste_size );
-
- old_entry_num = I_ENTRY_COUNT(ih);
- put_ih_entry_count( ih, ih_entry_count(ih) + new_entry_count );
-
- /* prepare space for pasted records */
- memmove (insert_point + paste_size, insert_point, item + (ih_item_len(ih) - paste_size) - insert_point);
-
- /* copy new records */
- memcpy (insert_point + DEH_SIZE * new_entry_count, records,
- paste_size - DEH_SIZE * new_entry_count);
-
- /* prepare space for new entry heads */
- deh += before;
- memmove ((char *)(deh + new_entry_count), deh, insert_point - (char *)deh);
-
- /* copy new entry heads */
- deh = (struct reiserfs_de_head *)((char *)deh);
- memcpy (deh, new_dehs, DEH_SIZE * new_entry_count);
-
- /* set locations of new records */
- for (i = 0; i < new_entry_count; i ++)
- {
- put_deh_location( &(deh[i]),
- deh_location( &(deh[i] )) +
- (- deh_location( &(new_dehs[new_entry_count - 1])) +
- insert_point + DEH_SIZE * new_entry_count - item));
- }
-
-
- /* change item key if necessary (when we paste before 0-th entry */
- if (!before)
- {
- set_le_ih_k_offset (ih, deh_offset(new_dehs));
+ struct item_head *ih;
+ char *item;
+ struct reiserfs_de_head *deh;
+ char *insert_point;
+ int i, old_entry_num;
+
+ if (new_entry_count == 0)
+ return;
+
+ ih = B_N_PITEM_HEAD(bh, item_num);
+
+ /* make sure, that item is directory, and there are enough records in it */
+ RFALSE(!is_direntry_le_ih(ih), "10225: item is not directory item");
+ RFALSE(I_ENTRY_COUNT(ih) < before,
+ "10230: there are no entry we paste entries before. entry_count = %d, before = %d",
+ I_ENTRY_COUNT(ih), before);
+
+ /* first byte of dest item */
+ item = bh->b_data + ih_location(ih);
+
+ /* entry head array */
+ deh = B_I_DEH(bh, ih);
+
+ /* new records will be pasted at this point */
+ insert_point =
+ item +
+ (before ? deh_location(&(deh[before - 1]))
+ : (ih_item_len(ih) - paste_size));
+
+ /* adjust locations of records that will be AFTER new records */
+ for (i = I_ENTRY_COUNT(ih) - 1; i >= before; i--)
+ put_deh_location(&(deh[i]),
+ deh_location(&(deh[i])) +
+ (DEH_SIZE * new_entry_count));
+
+ /* adjust locations of records that will be BEFORE new records */
+ for (i = 0; i < before; i++)
+ put_deh_location(&(deh[i]),
+ deh_location(&(deh[i])) + paste_size);
+
+ old_entry_num = I_ENTRY_COUNT(ih);
+ put_ih_entry_count(ih, ih_entry_count(ih) + new_entry_count);
+
+ /* prepare space for pasted records */
+ memmove(insert_point + paste_size, insert_point,
+ item + (ih_item_len(ih) - paste_size) - insert_point);
+
+ /* copy new records */
+ memcpy(insert_point + DEH_SIZE * new_entry_count, records,
+ paste_size - DEH_SIZE * new_entry_count);
+
+ /* prepare space for new entry heads */
+ deh += before;
+ memmove((char *)(deh + new_entry_count), deh,
+ insert_point - (char *)deh);
+
+ /* copy new entry heads */
+ deh = (struct reiserfs_de_head *)((char *)deh);
+ memcpy(deh, new_dehs, DEH_SIZE * new_entry_count);
+
+ /* set locations of new records */
+ for (i = 0; i < new_entry_count; i++) {
+ put_deh_location(&(deh[i]),
+ deh_location(&(deh[i])) +
+ (-deh_location
+ (&(new_dehs[new_entry_count - 1])) +
+ insert_point + DEH_SIZE * new_entry_count -
+ item));
+ }
+
+ /* change item key if necessary (when we paste before 0-th entry */
+ if (!before) {
+ set_le_ih_k_offset(ih, deh_offset(new_dehs));
/* memcpy (&ih->ih_key.k_offset,
&new_dehs->deh_offset, SHORT_KEY_SIZE);*/
- }
-
+ }
#ifdef CONFIG_REISERFS_CHECK
- {
- int prev, next;
- /* check record locations */
- deh = B_I_DEH (bh, ih);
- for (i = 0; i < I_ENTRY_COUNT(ih); i ++) {
- next = (i < I_ENTRY_COUNT(ih) - 1) ? deh_location( &(deh[i + 1])) : 0;
- prev = (i != 0) ? deh_location( &(deh[i - 1]) ) : 0;
-
- if (prev && prev <= deh_location( &(deh[i])))
- reiserfs_warning (NULL, "vs-10240: leaf_paste_entries: directory item (%h) corrupted (prev %a, cur(%d) %a)",
- ih, deh + i - 1, i, deh + i);
- if (next && next >= deh_location( &(deh[i])))
- reiserfs_warning (NULL, "vs-10250: leaf_paste_entries: directory item (%h) corrupted (cur(%d) %a, next %a)",
- ih, i, deh + i, deh + i + 1);
- }
- }
+ {
+ int prev, next;
+ /* check record locations */
+ deh = B_I_DEH(bh, ih);
+ for (i = 0; i < I_ENTRY_COUNT(ih); i++) {
+ next =
+ (i <
+ I_ENTRY_COUNT(ih) -
+ 1) ? deh_location(&(deh[i + 1])) : 0;
+ prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0;
+
+ if (prev && prev <= deh_location(&(deh[i])))
+ reiserfs_warning(NULL,
+ "vs-10240: leaf_paste_entries: directory item (%h) corrupted (prev %a, cur(%d) %a)",
+ ih, deh + i - 1, i, deh + i);
+ if (next && next >= deh_location(&(deh[i])))
+ reiserfs_warning(NULL,
+ "vs-10250: leaf_paste_entries: directory item (%h) corrupted (cur(%d) %a, next %a)",
+ ih, i, deh + i, deh + i + 1);
+ }
+ }
#endif
}
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index 4a333255f27..a20bbc1642d 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -25,86 +25,85 @@
// directory item contains array of entry headers. This performs
// binary search through that array
-static int bin_search_in_dir_item (struct reiserfs_dir_entry * de, loff_t off)
+static int bin_search_in_dir_item(struct reiserfs_dir_entry *de, loff_t off)
{
- struct item_head * ih = de->de_ih;
- struct reiserfs_de_head * deh = de->de_deh;
- int rbound, lbound, j;
-
- lbound = 0;
- rbound = I_ENTRY_COUNT (ih) - 1;
-
- for (j = (rbound + lbound) / 2; lbound <= rbound; j = (rbound + lbound) / 2) {
- if (off < deh_offset (deh + j)) {
- rbound = j - 1;
- continue;
+ struct item_head *ih = de->de_ih;
+ struct reiserfs_de_head *deh = de->de_deh;
+ int rbound, lbound, j;
+
+ lbound = 0;
+ rbound = I_ENTRY_COUNT(ih) - 1;
+
+ for (j = (rbound + lbound) / 2; lbound <= rbound;
+ j = (rbound + lbound) / 2) {
+ if (off < deh_offset(deh + j)) {
+ rbound = j - 1;
+ continue;
+ }
+ if (off > deh_offset(deh + j)) {
+ lbound = j + 1;
+ continue;
+ }
+ // this is not name found, but matched third key component
+ de->de_entry_num = j;
+ return NAME_FOUND;
}
- if (off > deh_offset (deh + j)) {
- lbound = j + 1;
- continue;
- }
- // this is not name found, but matched third key component
- de->de_entry_num = j;
- return NAME_FOUND;
- }
- de->de_entry_num = lbound;
- return NAME_NOT_FOUND;
+ de->de_entry_num = lbound;
+ return NAME_NOT_FOUND;
}
-
// comment? maybe something like set de to point to what the path points to?
-static inline void set_de_item_location (struct reiserfs_dir_entry * de, struct path * path)
+static inline void set_de_item_location(struct reiserfs_dir_entry *de,
+ struct path *path)
{
- de->de_bh = get_last_bh (path);
- de->de_ih = get_ih (path);
- de->de_deh = B_I_DEH (de->de_bh, de->de_ih);
- de->de_item_num = PATH_LAST_POSITION (path);
-}
-
+ de->de_bh = get_last_bh(path);
+ de->de_ih = get_ih(path);
+ de->de_deh = B_I_DEH(de->de_bh, de->de_ih);
+ de->de_item_num = PATH_LAST_POSITION(path);
+}
// de_bh, de_ih, de_deh (points to first element of array), de_item_num is set
-inline void set_de_name_and_namelen (struct reiserfs_dir_entry * de)
+inline void set_de_name_and_namelen(struct reiserfs_dir_entry *de)
{
- struct reiserfs_de_head * deh = de->de_deh + de->de_entry_num;
+ struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
- if (de->de_entry_num >= ih_entry_count (de->de_ih))
- BUG ();
+ if (de->de_entry_num >= ih_entry_count(de->de_ih))
+ BUG();
- de->de_entrylen = entry_length (de->de_bh, de->de_ih, de->de_entry_num);
- de->de_namelen = de->de_entrylen - (de_with_sd (deh) ? SD_SIZE : 0);
- de->de_name = B_I_PITEM (de->de_bh, de->de_ih) + deh_location(deh);
- if (de->de_name[de->de_namelen - 1] == 0)
- de->de_namelen = strlen (de->de_name);
+ de->de_entrylen = entry_length(de->de_bh, de->de_ih, de->de_entry_num);
+ de->de_namelen = de->de_entrylen - (de_with_sd(deh) ? SD_SIZE : 0);
+ de->de_name = B_I_PITEM(de->de_bh, de->de_ih) + deh_location(deh);
+ if (de->de_name[de->de_namelen - 1] == 0)
+ de->de_namelen = strlen(de->de_name);
}
-
// what entry points to
-static inline void set_de_object_key (struct reiserfs_dir_entry * de)
+static inline void set_de_object_key(struct reiserfs_dir_entry *de)
{
- if (de->de_entry_num >= ih_entry_count (de->de_ih))
- BUG ();
- de->de_dir_id = deh_dir_id( &(de->de_deh[de->de_entry_num]));
- de->de_objectid = deh_objectid( &(de->de_deh[de->de_entry_num]));
+ if (de->de_entry_num >= ih_entry_count(de->de_ih))
+ BUG();
+ de->de_dir_id = deh_dir_id(&(de->de_deh[de->de_entry_num]));
+ de->de_objectid = deh_objectid(&(de->de_deh[de->de_entry_num]));
}
-
-static inline void store_de_entry_key (struct reiserfs_dir_entry * de)
+static inline void store_de_entry_key(struct reiserfs_dir_entry *de)
{
- struct reiserfs_de_head * deh = de->de_deh + de->de_entry_num;
-
- if (de->de_entry_num >= ih_entry_count (de->de_ih))
- BUG ();
-
- /* store key of the found entry */
- de->de_entry_key.version = KEY_FORMAT_3_5;
- de->de_entry_key.on_disk_key.k_dir_id = le32_to_cpu (de->de_ih->ih_key.k_dir_id);
- de->de_entry_key.on_disk_key.k_objectid = le32_to_cpu (de->de_ih->ih_key.k_objectid);
- set_cpu_key_k_offset (&(de->de_entry_key), deh_offset (deh));
- set_cpu_key_k_type (&(de->de_entry_key), TYPE_DIRENTRY);
+ struct reiserfs_de_head *deh = de->de_deh + de->de_entry_num;
+
+ if (de->de_entry_num >= ih_entry_count(de->de_ih))
+ BUG();
+
+ /* store key of the found entry */
+ de->de_entry_key.version = KEY_FORMAT_3_5;
+ de->de_entry_key.on_disk_key.k_dir_id =
+ le32_to_cpu(de->de_ih->ih_key.k_dir_id);
+ de->de_entry_key.on_disk_key.k_objectid =
+ le32_to_cpu(de->de_ih->ih_key.k_objectid);
+ set_cpu_key_k_offset(&(de->de_entry_key), deh_offset(deh));
+ set_cpu_key_k_type(&(de->de_entry_key), TYPE_DIRENTRY);
}
-
/* We assign a key to each directory item, and place multiple entries
in a single directory item. A directory item has a key equal to the
key of the first directory entry in it.
@@ -117,58 +116,60 @@ entry position in the item
*/
/* The function is NOT SCHEDULE-SAFE! */
-int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
- struct path * path, struct reiserfs_dir_entry * de)
+int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
+ struct path *path, struct reiserfs_dir_entry *de)
{
- int retval;
-
- retval = search_item (sb, key, path);
- switch (retval) {
- case ITEM_NOT_FOUND:
- if (!PATH_LAST_POSITION (path)) {
- reiserfs_warning (sb, "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
- pathrelse(path) ;
- return IO_ERROR ;
+ int retval;
+
+ retval = search_item(sb, key, path);
+ switch (retval) {
+ case ITEM_NOT_FOUND:
+ if (!PATH_LAST_POSITION(path)) {
+ reiserfs_warning(sb,
+ "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
+ pathrelse(path);
+ return IO_ERROR;
+ }
+ PATH_LAST_POSITION(path)--;
+
+ case ITEM_FOUND:
+ break;
+
+ case IO_ERROR:
+ return retval;
+
+ default:
+ pathrelse(path);
+ reiserfs_warning(sb,
+ "vs-7002: search_by_entry_key: no path to here");
+ return IO_ERROR;
}
- PATH_LAST_POSITION (path) --;
-
- case ITEM_FOUND:
- break;
-
- case IO_ERROR:
- return retval;
- default:
- pathrelse (path);
- reiserfs_warning (sb, "vs-7002: search_by_entry_key: no path to here");
- return IO_ERROR;
- }
-
- set_de_item_location (de, path);
+ set_de_item_location(de, path);
#ifdef CONFIG_REISERFS_CHECK
- if (!is_direntry_le_ih (de->de_ih) ||
- COMP_SHORT_KEYS (&(de->de_ih->ih_key), key)) {
- print_block (de->de_bh, 0, -1, -1);
- reiserfs_panic (sb, "vs-7005: search_by_entry_key: found item %h is not directory item or "
- "does not belong to the same directory as key %K", de->de_ih, key);
- }
-#endif /* CONFIG_REISERFS_CHECK */
-
- /* binary search in directory item by third componen t of the
- key. sets de->de_entry_num of de */
- retval = bin_search_in_dir_item (de, cpu_key_k_offset (key));
- path->pos_in_item = de->de_entry_num;
- if (retval != NAME_NOT_FOUND) {
- // ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
- set_de_name_and_namelen (de);
- set_de_object_key (de);
- }
- return retval;
+ if (!is_direntry_le_ih(de->de_ih) ||
+ COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
+ print_block(de->de_bh, 0, -1, -1);
+ reiserfs_panic(sb,
+ "vs-7005: search_by_entry_key: found item %h is not directory item or "
+ "does not belong to the same directory as key %K",
+ de->de_ih, key);
+ }
+#endif /* CONFIG_REISERFS_CHECK */
+
+ /* binary search in directory item by third componen t of the
+ key. sets de->de_entry_num of de */
+ retval = bin_search_in_dir_item(de, cpu_key_k_offset(key));
+ path->pos_in_item = de->de_entry_num;
+ if (retval != NAME_NOT_FOUND) {
+ // ugly, but rename needs de_bh, de_deh, de_name, de_namelen, de_objectid set
+ set_de_name_and_namelen(de);
+ set_de_object_key(de);
+ }
+ return retval;
}
-
-
/* Keyed 32-bit hash function using TEA in a Davis-Meyer function */
/* The third component is hashed, and you can choose from more than
@@ -176,197 +177,210 @@ int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
but are thought about. This function should be moved to hashes.c
Jedi, please do so. -Hans */
-static __u32 get_third_component (struct super_block * s,
- const char * name, int len)
+static __u32 get_third_component(struct super_block *s,
+ const char *name, int len)
{
- __u32 res;
-
- if (!len || (len == 1 && name[0] == '.'))
- return DOT_OFFSET;
- if (len == 2 && name[0] == '.' && name[1] == '.')
- return DOT_DOT_OFFSET;
-
- res = REISERFS_SB(s)->s_hash_function (name, len);
-
- // take bits from 7-th to 30-th including both bounds
- res = GET_HASH_VALUE(res);
- if (res == 0)
- // needed to have no names before "." and ".." those have hash
- // value == 0 and generation conters 1 and 2 accordingly
- res = 128;
- return res + MAX_GENERATION_NUMBER;
+ __u32 res;
+
+ if (!len || (len == 1 && name[0] == '.'))
+ return DOT_OFFSET;
+ if (len == 2 && name[0] == '.' && name[1] == '.')
+ return DOT_DOT_OFFSET;
+
+ res = REISERFS_SB(s)->s_hash_function(name, len);
+
+ // take bits from 7-th to 30-th including both bounds
+ res = GET_HASH_VALUE(res);
+ if (res == 0)
+ // needed to have no names before "." and ".." those have hash
+ // value == 0 and generation conters 1 and 2 accordingly
+ res = 128;
+ return res + MAX_GENERATION_NUMBER;
}
-
-static int reiserfs_match (struct reiserfs_dir_entry * de,
- const char * name, int namelen)
+static int reiserfs_match(struct reiserfs_dir_entry *de,
+ const char *name, int namelen)
{
- int retval = NAME_NOT_FOUND;
+ int retval = NAME_NOT_FOUND;
- if ((namelen == de->de_namelen) &&
- !memcmp(de->de_name, name, de->de_namelen))
- retval = (de_visible (de->de_deh + de->de_entry_num) ? NAME_FOUND : NAME_FOUND_INVISIBLE);
+ if ((namelen == de->de_namelen) &&
+ !memcmp(de->de_name, name, de->de_namelen))
+ retval =
+ (de_visible(de->de_deh + de->de_entry_num) ? NAME_FOUND :
+ NAME_FOUND_INVISIBLE);
- return retval;
+ return retval;
}
-
/* de's de_bh, de_ih, de_deh, de_item_num, de_entry_num are set already */
/* used when hash collisions exist */
-
-static int linear_search_in_dir_item (struct cpu_key * key, struct reiserfs_dir_entry * de,
- const char * name, int namelen)
+static int linear_search_in_dir_item(struct cpu_key *key,
+ struct reiserfs_dir_entry *de,
+ const char *name, int namelen)
{
- struct reiserfs_de_head * deh = de->de_deh;
- int retval;
- int i;
+ struct reiserfs_de_head *deh = de->de_deh;
+ int retval;
+ int i;
- i = de->de_entry_num;
+ i = de->de_entry_num;
- if (i == I_ENTRY_COUNT (de->de_ih) ||
- GET_HASH_VALUE (deh_offset (deh + i)) != GET_HASH_VALUE (cpu_key_k_offset (key))) {
- i --;
- }
+ if (i == I_ENTRY_COUNT(de->de_ih) ||
+ GET_HASH_VALUE(deh_offset(deh + i)) !=
+ GET_HASH_VALUE(cpu_key_k_offset(key))) {
+ i--;
+ }
- RFALSE( de->de_deh != B_I_DEH (de->de_bh, de->de_ih),
- "vs-7010: array of entry headers not found");
+ RFALSE(de->de_deh != B_I_DEH(de->de_bh, de->de_ih),
+ "vs-7010: array of entry headers not found");
- deh += i;
+ deh += i;
- for (; i >= 0; i --, deh --) {
- if (GET_HASH_VALUE (deh_offset (deh)) !=
- GET_HASH_VALUE (cpu_key_k_offset (key))) {
- // hash value does not match, no need to check whole name
- return NAME_NOT_FOUND;
- }
-
- /* mark, that this generation number is used */
- if (de->de_gen_number_bit_string)
- set_bit (GET_GENERATION_NUMBER (deh_offset (deh)), (unsigned long *)de->de_gen_number_bit_string);
+ for (; i >= 0; i--, deh--) {
+ if (GET_HASH_VALUE(deh_offset(deh)) !=
+ GET_HASH_VALUE(cpu_key_k_offset(key))) {
+ // hash value does not match, no need to check whole name
+ return NAME_NOT_FOUND;
+ }
+
+ /* mark, that this generation number is used */
+ if (de->de_gen_number_bit_string)
+ set_bit(GET_GENERATION_NUMBER(deh_offset(deh)),
+ (unsigned long *)de->de_gen_number_bit_string);
- // calculate pointer to name and namelen
- de->de_entry_num = i;
- set_de_name_and_namelen (de);
+ // calculate pointer to name and namelen
+ de->de_entry_num = i;
+ set_de_name_and_namelen(de);
- if ((retval = reiserfs_match (de, name, namelen)) != NAME_NOT_FOUND) {
- // de's de_name, de_namelen, de_recordlen are set. Fill the rest:
+ if ((retval =
+ reiserfs_match(de, name, namelen)) != NAME_NOT_FOUND) {
+ // de's de_name, de_namelen, de_recordlen are set. Fill the rest:
- // key of pointed object
- set_de_object_key (de);
+ // key of pointed object
+ set_de_object_key(de);
- store_de_entry_key (de);
+ store_de_entry_key(de);
- // retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
- return retval;
+ // retval can be NAME_FOUND or NAME_FOUND_INVISIBLE
+ return retval;
+ }
}
- }
-
- if (GET_GENERATION_NUMBER (le_ih_k_offset (de->de_ih)) == 0)
- /* we have reached left most entry in the node. In common we
- have to go to the left neighbor, but if generation counter
- is 0 already, we know for sure, that there is no name with
- the same hash value */
- // FIXME: this work correctly only because hash value can not
- // be 0. Btw, in case of Yura's hash it is probably possible,
- // so, this is a bug
- return NAME_NOT_FOUND;
- RFALSE( de->de_item_num,
- "vs-7015: two diritems of the same directory in one node?");
+ if (GET_GENERATION_NUMBER(le_ih_k_offset(de->de_ih)) == 0)
+ /* we have reached left most entry in the node. In common we
+ have to go to the left neighbor, but if generation counter
+ is 0 already, we know for sure, that there is no name with
+ the same hash value */
+ // FIXME: this work correctly only because hash value can not
+ // be 0. Btw, in case of Yura's hash it is probably possible,
+ // so, this is a bug
+ return NAME_NOT_FOUND;
- return GOTO_PREVIOUS_ITEM;
-}
+ RFALSE(de->de_item_num,
+ "vs-7015: two diritems of the same directory in one node?");
+ return GOTO_PREVIOUS_ITEM;
+}
// may return NAME_FOUND, NAME_FOUND_INVISIBLE, NAME_NOT_FOUND
// FIXME: should add something like IOERROR
-static int reiserfs_find_entry (struct inode * dir, const char * name, int namelen,
- struct path * path_to_entry, struct reiserfs_dir_entry * de)
+static int reiserfs_find_entry(struct inode *dir, const char *name, int namelen,
+ struct path *path_to_entry,
+ struct reiserfs_dir_entry *de)
{
- struct cpu_key key_to_search;
- int retval;
-
-
- if (namelen > REISERFS_MAX_NAME (dir->i_sb->s_blocksize))
- return NAME_NOT_FOUND;
-
- /* we will search for this key in the tree */
- make_cpu_key (&key_to_search, dir,
- get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
-
- while (1) {
- retval = search_by_entry_key (dir->i_sb, &key_to_search, path_to_entry, de);
- if (retval == IO_ERROR) {
- reiserfs_warning (dir->i_sb, "zam-7001: io error in %s",
- __FUNCTION__);
- return IO_ERROR;
- }
-
- /* compare names for all entries having given hash value */
- retval = linear_search_in_dir_item (&key_to_search, de, name, namelen);
- if (retval != GOTO_PREVIOUS_ITEM) {
- /* there is no need to scan directory anymore. Given entry found or does not exist */
- path_to_entry->pos_in_item = de->de_entry_num;
- return retval;
- }
-
- /* there is left neighboring item of this directory and given entry can be there */
- set_cpu_key_k_offset (&key_to_search, le_ih_k_offset (de->de_ih) - 1);
- pathrelse (path_to_entry);
-
- } /* while (1) */
+ struct cpu_key key_to_search;
+ int retval;
+
+ if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
+ return NAME_NOT_FOUND;
+
+ /* we will search for this key in the tree */
+ make_cpu_key(&key_to_search, dir,
+ get_third_component(dir->i_sb, name, namelen),
+ TYPE_DIRENTRY, 3);
+
+ while (1) {
+ retval =
+ search_by_entry_key(dir->i_sb, &key_to_search,
+ path_to_entry, de);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(dir->i_sb, "zam-7001: io error in %s",
+ __FUNCTION__);
+ return IO_ERROR;
+ }
+
+ /* compare names for all entries having given hash value */
+ retval =
+ linear_search_in_dir_item(&key_to_search, de, name,
+ namelen);
+ if (retval != GOTO_PREVIOUS_ITEM) {
+ /* there is no need to scan directory anymore. Given entry found or does not exist */
+ path_to_entry->pos_in_item = de->de_entry_num;
+ return retval;
+ }
+
+ /* there is left neighboring item of this directory and given entry can be there */
+ set_cpu_key_k_offset(&key_to_search,
+ le_ih_k_offset(de->de_ih) - 1);
+ pathrelse(path_to_entry);
+
+ } /* while (1) */
}
-
-static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dentry, struct nameidata *nd)
+static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
+ struct nameidata *nd)
{
- int retval;
- struct inode * inode = NULL;
- struct reiserfs_dir_entry de;
- INITIALIZE_PATH (path_to_entry);
-
- if (REISERFS_MAX_NAME (dir->i_sb->s_blocksize) < dentry->d_name.len)
- return ERR_PTR(-ENAMETOOLONG);
-
- reiserfs_write_lock(dir->i_sb);
- de.de_gen_number_bit_string = NULL;
- retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path_to_entry, &de);
- pathrelse (&path_to_entry);
- if (retval == NAME_FOUND) {
- /* Hide the .reiserfs_priv directory */
- if (reiserfs_xattrs (dir->i_sb) &&
- !old_format_only(dir->i_sb) &&
- REISERFS_SB(dir->i_sb)->priv_root &&
- REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
- de.de_objectid == le32_to_cpu (INODE_PKEY(REISERFS_SB(dir->i_sb)->priv_root->d_inode)->k_objectid)) {
- reiserfs_write_unlock (dir->i_sb);
- return ERR_PTR (-EACCES);
+ int retval;
+ struct inode *inode = NULL;
+ struct reiserfs_dir_entry de;
+ INITIALIZE_PATH(path_to_entry);
+
+ if (REISERFS_MAX_NAME(dir->i_sb->s_blocksize) < dentry->d_name.len)
+ return ERR_PTR(-ENAMETOOLONG);
+
+ reiserfs_write_lock(dir->i_sb);
+ de.de_gen_number_bit_string = NULL;
+ retval =
+ reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
+ &path_to_entry, &de);
+ pathrelse(&path_to_entry);
+ if (retval == NAME_FOUND) {
+ /* Hide the .reiserfs_priv directory */
+ if (reiserfs_xattrs(dir->i_sb) &&
+ !old_format_only(dir->i_sb) &&
+ REISERFS_SB(dir->i_sb)->priv_root &&
+ REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
+ de.de_objectid ==
+ le32_to_cpu(INODE_PKEY
+ (REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
+ k_objectid)) {
+ reiserfs_write_unlock(dir->i_sb);
+ return ERR_PTR(-EACCES);
+ }
+
+ inode =
+ reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
+ if (!inode || IS_ERR(inode)) {
+ reiserfs_write_unlock(dir->i_sb);
+ return ERR_PTR(-EACCES);
+ }
+
+ /* Propogate the priv_object flag so we know we're in the priv tree */
+ if (is_reiserfs_priv_object(dir))
+ reiserfs_mark_inode_private(inode);
+ }
+ reiserfs_write_unlock(dir->i_sb);
+ if (retval == IO_ERROR) {
+ return ERR_PTR(-EIO);
}
- inode = reiserfs_iget (dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
- if (!inode || IS_ERR(inode)) {
- reiserfs_write_unlock(dir->i_sb);
- return ERR_PTR(-EACCES);
- }
-
- /* Propogate the priv_object flag so we know we're in the priv tree */
- if (is_reiserfs_priv_object (dir))
- reiserfs_mark_inode_private (inode);
- }
- reiserfs_write_unlock(dir->i_sb);
- if ( retval == IO_ERROR ) {
- return ERR_PTR(-EIO);
- }
-
- if (inode)
- return d_splice_alias(inode, dentry);
-
- d_add(dentry, inode);
- return NULL;
-}
+ if (inode)
+ return d_splice_alias(inode, dentry);
+ d_add(dentry, inode);
+ return NULL;
+}
/*
** looks up the dentry of the parent directory for child.
@@ -374,40 +388,38 @@ static struct dentry * reiserfs_lookup (struct inode * dir, struct dentry * dent
*/
struct dentry *reiserfs_get_parent(struct dentry *child)
{
- int retval;
- struct inode * inode = NULL;
- struct reiserfs_dir_entry de;
- INITIALIZE_PATH (path_to_entry);
- struct dentry *parent;
- struct inode *dir = child->d_inode ;
-
-
- if (dir->i_nlink == 0) {
- return ERR_PTR(-ENOENT);
- }
- de.de_gen_number_bit_string = NULL;
-
- reiserfs_write_lock(dir->i_sb);
- retval = reiserfs_find_entry (dir, "..", 2, &path_to_entry, &de);
- pathrelse (&path_to_entry);
- if (retval != NAME_FOUND) {
+ int retval;
+ struct inode *inode = NULL;
+ struct reiserfs_dir_entry de;
+ INITIALIZE_PATH(path_to_entry);
+ struct dentry *parent;
+ struct inode *dir = child->d_inode;
+
+ if (dir->i_nlink == 0) {
+ return ERR_PTR(-ENOENT);
+ }
+ de.de_gen_number_bit_string = NULL;
+
+ reiserfs_write_lock(dir->i_sb);
+ retval = reiserfs_find_entry(dir, "..", 2, &path_to_entry, &de);
+ pathrelse(&path_to_entry);
+ if (retval != NAME_FOUND) {
+ reiserfs_write_unlock(dir->i_sb);
+ return ERR_PTR(-ENOENT);
+ }
+ inode = reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
reiserfs_write_unlock(dir->i_sb);
- return ERR_PTR(-ENOENT);
- }
- inode = reiserfs_iget (dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
- reiserfs_write_unlock(dir->i_sb);
-
- if (!inode || IS_ERR(inode)) {
- return ERR_PTR(-EACCES);
- }
- parent = d_alloc_anon(inode);
- if (!parent) {
- iput(inode);
- parent = ERR_PTR(-ENOMEM);
- }
- return parent;
-}
+ if (!inode || IS_ERR(inode)) {
+ return ERR_PTR(-EACCES);
+ }
+ parent = d_alloc_anon(inode);
+ if (!parent) {
+ iput(inode);
+ parent = ERR_PTR(-ENOMEM);
+ }
+ return parent;
+}
/* add entry to the directory (entry can be hidden).
@@ -415,132 +427,143 @@ insert definition of when hidden directories are used here -Hans
Does not mark dir inode dirty, do it after successesfull call to it */
-static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct inode * dir,
- const char * name, int namelen, struct inode * inode,
- int visible)
+static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
+ struct inode *dir, const char *name, int namelen,
+ struct inode *inode, int visible)
{
- struct cpu_key entry_key;
- struct reiserfs_de_head * deh;
- INITIALIZE_PATH (path);
- struct reiserfs_dir_entry de;
- int bit_string [MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
- int gen_number;
- char small_buf[32+DEH_SIZE] ; /* 48 bytes now and we avoid kmalloc
- if we create file with short name */
- char * buffer;
- int buflen, paste_size;
- int retval;
-
- BUG_ON (!th->t_trans_id);
-
- /* cannot allow items to be added into a busy deleted directory */
- if (!namelen)
- return -EINVAL;
-
- if (namelen > REISERFS_MAX_NAME (dir->i_sb->s_blocksize))
- return -ENAMETOOLONG;
-
- /* each entry has unique key. compose it */
- make_cpu_key (&entry_key, dir,
- get_third_component (dir->i_sb, name, namelen), TYPE_DIRENTRY, 3);
-
- /* get memory for composing the entry */
- buflen = DEH_SIZE + ROUND_UP (namelen);
- if (buflen > sizeof (small_buf)) {
- buffer = reiserfs_kmalloc (buflen, GFP_NOFS, dir->i_sb);
- if (buffer == 0)
- return -ENOMEM;
- } else
- buffer = small_buf;
-
- paste_size = (get_inode_sd_version (dir) == STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
-
- /* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
- deh = (struct reiserfs_de_head *)buffer;
- deh->deh_location = 0; /* JDM Endian safe if 0 */
- put_deh_offset( deh, cpu_key_k_offset( &entry_key ) );
- deh->deh_state = 0; /* JDM Endian safe if 0 */
- /* put key (ino analog) to de */
- deh->deh_dir_id = INODE_PKEY (inode)->k_dir_id; /* safe: k_dir_id is le */
- deh->deh_objectid = INODE_PKEY (inode)->k_objectid; /* safe: k_objectid is le */
-
- /* copy name */
- memcpy ((char *)(deh + 1), name, namelen);
- /* padd by 0s to the 4 byte boundary */
- padd_item ((char *)(deh + 1), ROUND_UP (namelen), namelen);
-
- /* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
- mark_de_without_sd (deh);
- visible ? mark_de_visible (deh) : mark_de_hidden (deh);
-
- /* find the proper place for the new entry */
- memset (bit_string, 0, sizeof (bit_string));
- de.de_gen_number_bit_string = (char *)bit_string;
- retval = reiserfs_find_entry (dir, name, namelen, &path, &de);
- if( retval != NAME_NOT_FOUND ) {
- if (buffer != small_buf)
- reiserfs_kfree (buffer, buflen, dir->i_sb);
- pathrelse (&path);
+ struct cpu_key entry_key;
+ struct reiserfs_de_head *deh;
+ INITIALIZE_PATH(path);
+ struct reiserfs_dir_entry de;
+ int bit_string[MAX_GENERATION_NUMBER / (sizeof(int) * 8) + 1];
+ int gen_number;
+ char small_buf[32 + DEH_SIZE]; /* 48 bytes now and we avoid kmalloc
+ if we create file with short name */
+ char *buffer;
+ int buflen, paste_size;
+ int retval;
+
+ BUG_ON(!th->t_trans_id);
+
+ /* cannot allow items to be added into a busy deleted directory */
+ if (!namelen)
+ return -EINVAL;
+
+ if (namelen > REISERFS_MAX_NAME(dir->i_sb->s_blocksize))
+ return -ENAMETOOLONG;
+
+ /* each entry has unique key. compose it */
+ make_cpu_key(&entry_key, dir,
+ get_third_component(dir->i_sb, name, namelen),
+ TYPE_DIRENTRY, 3);
+
+ /* get memory for composing the entry */
+ buflen = DEH_SIZE + ROUND_UP(namelen);
+ if (buflen > sizeof(small_buf)) {
+ buffer = reiserfs_kmalloc(buflen, GFP_NOFS, dir->i_sb);
+ if (buffer == 0)
+ return -ENOMEM;
+ } else
+ buffer = small_buf;
+
+ paste_size =
+ (get_inode_sd_version(dir) ==
+ STAT_DATA_V1) ? (DEH_SIZE + namelen) : buflen;
+
+ /* fill buffer : directory entry head, name[, dir objectid | , stat data | ,stat data, dir objectid ] */
+ deh = (struct reiserfs_de_head *)buffer;
+ deh->deh_location = 0; /* JDM Endian safe if 0 */
+ put_deh_offset(deh, cpu_key_k_offset(&entry_key));
+ deh->deh_state = 0; /* JDM Endian safe if 0 */
+ /* put key (ino analog) to de */
+ deh->deh_dir_id = INODE_PKEY(inode)->k_dir_id; /* safe: k_dir_id is le */
+ deh->deh_objectid = INODE_PKEY(inode)->k_objectid; /* safe: k_objectid is le */
+
+ /* copy name */
+ memcpy((char *)(deh + 1), name, namelen);
+ /* padd by 0s to the 4 byte boundary */
+ padd_item((char *)(deh + 1), ROUND_UP(namelen), namelen);
+
+ /* entry is ready to be pasted into tree, set 'visibility' and 'stat data in entry' attributes */
+ mark_de_without_sd(deh);
+ visible ? mark_de_visible(deh) : mark_de_hidden(deh);
+
+ /* find the proper place for the new entry */
+ memset(bit_string, 0, sizeof(bit_string));
+ de.de_gen_number_bit_string = (char *)bit_string;
+ retval = reiserfs_find_entry(dir, name, namelen, &path, &de);
+ if (retval != NAME_NOT_FOUND) {
+ if (buffer != small_buf)
+ reiserfs_kfree(buffer, buflen, dir->i_sb);
+ pathrelse(&path);
+
+ if (retval == IO_ERROR) {
+ return -EIO;
+ }
+
+ if (retval != NAME_FOUND) {
+ reiserfs_warning(dir->i_sb,
+ "zam-7002:%s: \"reiserfs_find_entry\" "
+ "has returned unexpected value (%d)",
+ __FUNCTION__, retval);
+ }
+
+ return -EEXIST;
+ }
- if ( retval == IO_ERROR ) {
- return -EIO;
+ gen_number =
+ find_first_zero_bit((unsigned long *)bit_string,
+ MAX_GENERATION_NUMBER + 1);
+ if (gen_number > MAX_GENERATION_NUMBER) {
+ /* there is no free generation number */
+ reiserfs_warning(dir->i_sb,
+ "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
+ if (buffer != small_buf)
+ reiserfs_kfree(buffer, buflen, dir->i_sb);
+ pathrelse(&path);
+ return -EBUSY;
+ }
+ /* adjust offset of directory enrty */
+ put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
+ set_cpu_key_k_offset(&entry_key, deh_offset(deh));
+
+ /* update max-hash-collisions counter in reiserfs_sb_info */
+ PROC_INFO_MAX(th->t_super, max_hash_collisions, gen_number);
+
+ if (gen_number != 0) { /* we need to re-search for the insertion point */
+ if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
+ NAME_NOT_FOUND) {
+ reiserfs_warning(dir->i_sb,
+ "vs-7032: reiserfs_add_entry: "
+ "entry with this key (%K) already exists",
+ &entry_key);
+
+ if (buffer != small_buf)
+ reiserfs_kfree(buffer, buflen, dir->i_sb);
+ pathrelse(&path);
+ return -EBUSY;
+ }
}
- if (retval != NAME_FOUND) {
- reiserfs_warning (dir->i_sb, "zam-7002:%s: \"reiserfs_find_entry\" "
- "has returned unexpected value (%d)",
- __FUNCTION__, retval);
- }
-
- return -EEXIST;
- }
-
- gen_number = find_first_zero_bit ((unsigned long *)bit_string, MAX_GENERATION_NUMBER + 1);
- if (gen_number > MAX_GENERATION_NUMBER) {
- /* there is no free generation number */
- reiserfs_warning (dir->i_sb, "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
- if (buffer != small_buf)
- reiserfs_kfree (buffer, buflen, dir->i_sb);
- pathrelse (&path);
- return -EBUSY;
- }
- /* adjust offset of directory enrty */
- put_deh_offset(deh, SET_GENERATION_NUMBER(deh_offset(deh), gen_number));
- set_cpu_key_k_offset (&entry_key, deh_offset(deh));
-
- /* update max-hash-collisions counter in reiserfs_sb_info */
- PROC_INFO_MAX( th -> t_super, max_hash_collisions, gen_number );
-
- if (gen_number != 0) { /* we need to re-search for the insertion point */
- if (search_by_entry_key (dir->i_sb, &entry_key, &path, &de) != NAME_NOT_FOUND) {
- reiserfs_warning (dir->i_sb, "vs-7032: reiserfs_add_entry: "
- "entry with this key (%K) already exists",
- &entry_key);
-
- if (buffer != small_buf)
- reiserfs_kfree (buffer, buflen, dir->i_sb);
- pathrelse (&path);
- return -EBUSY;
+ /* perform the insertion of the entry that we have prepared */
+ retval =
+ reiserfs_paste_into_item(th, &path, &entry_key, dir, buffer,
+ paste_size);
+ if (buffer != small_buf)
+ reiserfs_kfree(buffer, buflen, dir->i_sb);
+ if (retval) {
+ reiserfs_check_path(&path);
+ return retval;
}
- }
-
- /* perform the insertion of the entry that we have prepared */
- retval = reiserfs_paste_into_item (th, &path, &entry_key, dir, buffer, paste_size);
- if (buffer != small_buf)
- reiserfs_kfree (buffer, buflen, dir->i_sb);
- if (retval) {
- reiserfs_check_path(&path) ;
- return retval;
- }
- dir->i_size += paste_size;
- dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
- if (!S_ISDIR (inode->i_mode) && visible)
- // reiserfs_mkdir or reiserfs_rename will do that by itself
- reiserfs_update_sd (th, dir);
+ dir->i_size += paste_size;
+ dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
+ if (!S_ISDIR(inode->i_mode) && visible)
+ // reiserfs_mkdir or reiserfs_rename will do that by itself
+ reiserfs_update_sd(th, dir);
- reiserfs_check_path(&path) ;
- return 0;
+ reiserfs_check_path(&path);
+ return 0;
}
/* quota utility function, call if you've had to abort after calling
@@ -548,12 +571,13 @@ static int reiserfs_add_entry (struct reiserfs_transaction_handle *th, struct in
** This should only be called on inodes that do not have stat data
** inserted into the tree yet.
*/
-static int drop_new_inode(struct inode *inode) {
- DQUOT_DROP(inode);
- make_bad_inode(inode) ;
- inode->i_flags |= S_NOQUOTA;
- iput(inode) ;
- return 0 ;
+static int drop_new_inode(struct inode *inode)
+{
+ DQUOT_DROP(inode);
+ make_bad_inode(inode);
+ inode->i_flags |= S_NOQUOTA;
+ iput(inode);
+ return 0;
}
/* utility function that does setup for reiserfs_new_inode.
@@ -561,905 +585,968 @@ static int drop_new_inode(struct inode *inode) {
** outside of a transaction, so we had to pull some bits of
** reiserfs_new_inode out into this func.
*/
-static int new_inode_init(struct inode *inode, struct inode *dir, int mode) {
-
- /* the quota init calls have to know who to charge the quota to, so
- ** we have to set uid and gid here
- */
- inode->i_uid = current->fsuid;
- inode->i_mode = mode;
-
- if (dir->i_mode & S_ISGID) {
- inode->i_gid = dir->i_gid;
- if (S_ISDIR(mode))
- inode->i_mode |= S_ISGID;
- } else {
- inode->i_gid = current->fsgid;
- }
- DQUOT_INIT(inode);
- return 0 ;
+static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
+{
+
+ /* the quota init calls have to know who to charge the quota to, so
+ ** we have to set uid and gid here
+ */
+ inode->i_uid = current->fsuid;
+ inode->i_mode = mode;
+
+ if (dir->i_mode & S_ISGID) {
+ inode->i_gid = dir->i_gid;
+ if (S_ISDIR(mode))
+ inode->i_mode |= S_ISGID;
+ } else {
+ inode->i_gid = current->fsgid;
+ }
+ DQUOT_INIT(inode);
+ return 0;
}
-static int reiserfs_create (struct inode * dir, struct dentry *dentry, int mode,
- struct nameidata *nd)
+static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
+ struct nameidata *nd)
{
- int retval;
- struct inode * inode;
- /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
- struct reiserfs_transaction_handle th ;
- int locked;
-
- if (!(inode = new_inode(dir->i_sb))) {
- return -ENOMEM ;
- }
- new_inode_init(inode, dir, mode);
-
- locked = reiserfs_cache_default_acl (dir);
-
- reiserfs_write_lock(dir->i_sb);
-
- if (locked)
- reiserfs_write_lock_xattrs (dir->i_sb);
-
- retval = journal_begin(&th, dir->i_sb, jbegin_count);
- if (retval) {
- drop_new_inode (inode);
- goto out_failed;
- }
-
- retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
- if (retval)
- goto out_failed;
-
- if (locked) {
- reiserfs_write_unlock_xattrs (dir->i_sb);
- locked = 0;
- }
-
- inode->i_op = &reiserfs_file_inode_operations;
- inode->i_fop = &reiserfs_file_operations;
- inode->i_mapping->a_ops = &reiserfs_address_space_operations ;
-
- retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
- inode, 1/*visible*/);
- if (retval) {
- int err;
- inode->i_nlink--;
- reiserfs_update_sd (&th, inode);
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- if (err)
- retval = err;
- iput (inode);
- goto out_failed;
- }
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
-
- d_instantiate(dentry, inode);
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
-
-out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs (dir->i_sb);
- reiserfs_write_unlock(dir->i_sb);
- return retval;
-}
+ int retval;
+ struct inode *inode;
+ /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 2 +
+ 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
+ REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
+ struct reiserfs_transaction_handle th;
+ int locked;
+
+ if (!(inode = new_inode(dir->i_sb))) {
+ return -ENOMEM;
+ }
+ new_inode_init(inode, dir, mode);
+ locked = reiserfs_cache_default_acl(dir);
-static int reiserfs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
-{
- int retval;
- struct inode * inode;
- struct reiserfs_transaction_handle th ;
- /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
- int locked;
+ reiserfs_write_lock(dir->i_sb);
- if (!new_valid_dev(rdev))
- return -EINVAL;
+ if (locked)
+ reiserfs_write_lock_xattrs(dir->i_sb);
+
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval) {
+ drop_new_inode(inode);
+ goto out_failed;
+ }
+
+ retval =
+ reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
+ inode);
+ if (retval)
+ goto out_failed;
+
+ if (locked) {
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ locked = 0;
+ }
+
+ inode->i_op = &reiserfs_file_inode_operations;
+ inode->i_fop = &reiserfs_file_operations;
+ inode->i_mapping->a_ops = &reiserfs_address_space_operations;
+
+ retval =
+ reiserfs_add_entry(&th, dir, dentry->d_name.name,
+ dentry->d_name.len, inode, 1 /*visible */ );
+ if (retval) {
+ int err;
+ inode->i_nlink--;
+ reiserfs_update_sd(&th, inode);
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ if (err)
+ retval = err;
+ iput(inode);
+ goto out_failed;
+ }
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
- if (!(inode = new_inode(dir->i_sb))) {
- return -ENOMEM ;
- }
- new_inode_init(inode, dir, mode);
+ d_instantiate(dentry, inode);
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
- locked = reiserfs_cache_default_acl (dir);
+ out_failed:
+ if (locked)
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
+}
- reiserfs_write_lock(dir->i_sb);
+static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
+ dev_t rdev)
+{
+ int retval;
+ struct inode *inode;
+ struct reiserfs_transaction_handle th;
+ /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 +
+ 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
+ REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
+ int locked;
+
+ if (!new_valid_dev(rdev))
+ return -EINVAL;
+
+ if (!(inode = new_inode(dir->i_sb))) {
+ return -ENOMEM;
+ }
+ new_inode_init(inode, dir, mode);
- if (locked)
- reiserfs_write_lock_xattrs (dir->i_sb);
+ locked = reiserfs_cache_default_acl(dir);
- retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
- if (retval) {
- drop_new_inode (inode);
- goto out_failed;
- }
+ reiserfs_write_lock(dir->i_sb);
- retval = reiserfs_new_inode (&th, dir, mode, NULL, 0/*i_size*/, dentry, inode);
- if (retval) {
- goto out_failed;
- }
+ if (locked)
+ reiserfs_write_lock_xattrs(dir->i_sb);
- if (locked) {
- reiserfs_write_unlock_xattrs (dir->i_sb);
- locked = 0;
- }
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval) {
+ drop_new_inode(inode);
+ goto out_failed;
+ }
+ retval =
+ reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
+ inode);
+ if (retval) {
+ goto out_failed;
+ }
- inode->i_op = &reiserfs_special_inode_operations;
- init_special_inode(inode, inode->i_mode, rdev) ;
+ if (locked) {
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ locked = 0;
+ }
- //FIXME: needed for block and char devices only
- reiserfs_update_sd (&th, inode);
+ inode->i_op = &reiserfs_special_inode_operations;
+ init_special_inode(inode, inode->i_mode, rdev);
+
+ //FIXME: needed for block and char devices only
+ reiserfs_update_sd(&th, inode);
+
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
+
+ retval =
+ reiserfs_add_entry(&th, dir, dentry->d_name.name,
+ dentry->d_name.len, inode, 1 /*visible */ );
+ if (retval) {
+ int err;
+ inode->i_nlink--;
+ reiserfs_update_sd(&th, inode);
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ if (err)
+ retval = err;
+ iput(inode);
+ goto out_failed;
+ }
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
+ d_instantiate(dentry, inode);
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
- retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
- inode, 1/*visible*/);
- if (retval) {
- int err;
- inode->i_nlink--;
- reiserfs_update_sd (&th, inode);
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- if (err)
- retval = err;
- iput (inode);
- goto out_failed;
- }
-
- d_instantiate(dentry, inode);
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
-
-out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs (dir->i_sb);
- reiserfs_write_unlock(dir->i_sb);
- return retval;
+ out_failed:
+ if (locked)
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
}
-
-static int reiserfs_mkdir (struct inode * dir, struct dentry *dentry, int mode)
+static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{
- int retval;
- struct inode * inode;
- struct reiserfs_transaction_handle th ;
- /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
- int locked;
+ int retval;
+ struct inode *inode;
+ struct reiserfs_transaction_handle th;
+ /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 +
+ 2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
+ REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
+ int locked;
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- /* set flag that new packing locality created and new blocks for the content * of that directory are not displaced yet */
- REISERFS_I(dir)->new_packing_locality = 1;
+ /* set flag that new packing locality created and new blocks for the content * of that directory are not displaced yet */
+ REISERFS_I(dir)->new_packing_locality = 1;
#endif
- mode = S_IFDIR | mode;
- if (!(inode = new_inode(dir->i_sb))) {
- return -ENOMEM ;
- }
- new_inode_init(inode, dir, mode);
-
- locked = reiserfs_cache_default_acl (dir);
-
- reiserfs_write_lock(dir->i_sb);
- if (locked)
- reiserfs_write_lock_xattrs (dir->i_sb);
-
- retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
- if (retval) {
- drop_new_inode (inode);
- goto out_failed;
- }
-
-
- /* inc the link count now, so another writer doesn't overflow it while
- ** we sleep later on.
- */
- INC_DIR_INODE_NLINK(dir)
-
- retval = reiserfs_new_inode (&th, dir, mode, NULL/*symlink*/,
- old_format_only (dir->i_sb) ?
- EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
- dentry, inode);
- if (retval) {
- dir->i_nlink-- ;
- goto out_failed;
- }
-
- if (locked) {
- reiserfs_write_unlock_xattrs (dir->i_sb);
- locked = 0;
- }
-
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
-
- inode->i_op = &reiserfs_dir_inode_operations;
- inode->i_fop = &reiserfs_dir_operations;
-
- // note, _this_ add_entry will not update dir's stat data
- retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
- inode, 1/*visible*/);
- if (retval) {
- int err;
- inode->i_nlink = 0;
- DEC_DIR_INODE_NLINK(dir);
- reiserfs_update_sd (&th, inode);
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- if (err)
- retval = err;
- iput (inode);
- goto out_failed;
- }
-
- // the above add_entry did not update dir's stat data
- reiserfs_update_sd (&th, dir);
-
- d_instantiate(dentry, inode);
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
-out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs (dir->i_sb);
- reiserfs_write_unlock(dir->i_sb);
- return retval;
-}
+ mode = S_IFDIR | mode;
+ if (!(inode = new_inode(dir->i_sb))) {
+ return -ENOMEM;
+ }
+ new_inode_init(inode, dir, mode);
+
+ locked = reiserfs_cache_default_acl(dir);
+
+ reiserfs_write_lock(dir->i_sb);
+ if (locked)
+ reiserfs_write_lock_xattrs(dir->i_sb);
+
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval) {
+ drop_new_inode(inode);
+ goto out_failed;
+ }
-static inline int reiserfs_empty_dir(struct inode *inode) {
- /* we can cheat because an old format dir cannot have
- ** EMPTY_DIR_SIZE, and a new format dir cannot have
- ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
- ** regardless of disk format version, the directory is empty.
- */
- if (inode->i_size != EMPTY_DIR_SIZE &&
- inode->i_size != EMPTY_DIR_SIZE_V1) {
- return 0 ;
- }
- return 1 ;
+ /* inc the link count now, so another writer doesn't overflow it while
+ ** we sleep later on.
+ */
+ INC_DIR_INODE_NLINK(dir)
+
+ retval = reiserfs_new_inode(&th, dir, mode, NULL /*symlink */ ,
+ old_format_only(dir->i_sb) ?
+ EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
+ dentry, inode);
+ if (retval) {
+ dir->i_nlink--;
+ goto out_failed;
+ }
+
+ if (locked) {
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ locked = 0;
+ }
+
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
+
+ inode->i_op = &reiserfs_dir_inode_operations;
+ inode->i_fop = &reiserfs_dir_operations;
+
+ // note, _this_ add_entry will not update dir's stat data
+ retval =
+ reiserfs_add_entry(&th, dir, dentry->d_name.name,
+ dentry->d_name.len, inode, 1 /*visible */ );
+ if (retval) {
+ int err;
+ inode->i_nlink = 0;
+ DEC_DIR_INODE_NLINK(dir);
+ reiserfs_update_sd(&th, inode);
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ if (err)
+ retval = err;
+ iput(inode);
+ goto out_failed;
+ }
+ // the above add_entry did not update dir's stat data
+ reiserfs_update_sd(&th, dir);
+
+ d_instantiate(dentry, inode);
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
+ out_failed:
+ if (locked)
+ reiserfs_write_unlock_xattrs(dir->i_sb);
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
}
-static int reiserfs_rmdir (struct inode * dir, struct dentry *dentry)
+static inline int reiserfs_empty_dir(struct inode *inode)
{
- int retval, err;
- struct inode * inode;
- struct reiserfs_transaction_handle th ;
- int jbegin_count;
- INITIALIZE_PATH (path);
- struct reiserfs_dir_entry de;
-
-
- /* we will be doing 2 balancings and update 2 stat data, we change quotas
- * of the owner of the directory and of the owner of the parent directory.
- * The quota structure is possibly deleted only on last iput => outside
- * of this transaction */
- jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
-
- reiserfs_write_lock(dir->i_sb);
- retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
- if (retval)
- goto out_rmdir;
-
- de.de_gen_number_bit_string = NULL;
- if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
- retval = -ENOENT;
- goto end_rmdir;
- } else if ( retval == IO_ERROR) {
- retval = -EIO;
- goto end_rmdir;
- }
-
- inode = dentry->d_inode;
-
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
-
- if (de.de_objectid != inode->i_ino) {
- // FIXME: compare key of an object and a key found in the
- // entry
- retval = -EIO;
- goto end_rmdir;
- }
- if (!reiserfs_empty_dir(inode)) {
- retval = -ENOTEMPTY;
- goto end_rmdir;
- }
-
- /* cut entry from dir directory */
- retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir,
- NULL, /* page */
- 0/*new file size - not used here*/);
- if (retval < 0)
- goto end_rmdir;
-
- if ( inode->i_nlink != 2 && inode->i_nlink != 1 )
- reiserfs_warning (inode->i_sb, "%s: empty directory has nlink "
- "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
-
- inode->i_nlink = 0;
- inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
- reiserfs_update_sd (&th, inode);
-
- DEC_DIR_INODE_NLINK(dir)
- dir->i_size -= (DEH_SIZE + de.de_entrylen);
- reiserfs_update_sd (&th, dir);
-
- /* prevent empty directory from getting lost */
- add_save_link (&th, inode, 0/* not truncate */);
-
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_check_path(&path) ;
-out_rmdir:
- reiserfs_write_unlock(dir->i_sb);
- return retval;
-
- end_rmdir:
- /* we must release path, because we did not call
- reiserfs_cut_from_item, or reiserfs_cut_from_item does not
- release path if operation was not complete */
- pathrelse (&path);
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_write_unlock(dir->i_sb);
- return err ? err : retval;
+ /* we can cheat because an old format dir cannot have
+ ** EMPTY_DIR_SIZE, and a new format dir cannot have
+ ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
+ ** regardless of disk format version, the directory is empty.
+ */
+ if (inode->i_size != EMPTY_DIR_SIZE &&
+ inode->i_size != EMPTY_DIR_SIZE_V1) {
+ return 0;
+ }
+ return 1;
}
-static int reiserfs_unlink (struct inode * dir, struct dentry *dentry)
+static int reiserfs_rmdir(struct inode *dir, struct dentry *dentry)
{
- int retval, err;
- struct inode * inode;
- struct reiserfs_dir_entry de;
- INITIALIZE_PATH (path);
- struct reiserfs_transaction_handle th ;
- int jbegin_count;
- unsigned long savelink;
-
- inode = dentry->d_inode;
-
- /* in this transaction we can be doing at max two balancings and update
- * two stat datas, we change quotas of the owner of the directory and of
- * the owner of the parent directory. The quota structure is possibly
- * deleted only on iput => outside of this transaction */
- jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
-
- reiserfs_write_lock(dir->i_sb);
- retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
- if (retval)
- goto out_unlink;
-
- de.de_gen_number_bit_string = NULL;
- if ( (retval = reiserfs_find_entry (dir, dentry->d_name.name, dentry->d_name.len, &path, &de)) == NAME_NOT_FOUND) {
- retval = -ENOENT;
- goto end_unlink;
- } else if (retval == IO_ERROR) {
- retval = -EIO;
- goto end_unlink;
- }
-
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
-
- if (de.de_objectid != inode->i_ino) {
- // FIXME: compare key of an object and a key found in the
- // entry
- retval = -EIO;
- goto end_unlink;
- }
-
- if (!inode->i_nlink) {
- reiserfs_warning (inode->i_sb, "%s: deleting nonexistent file "
- "(%s:%lu), %d", __FUNCTION__,
- reiserfs_bdevname (inode->i_sb), inode->i_ino,
- inode->i_nlink);
- inode->i_nlink = 1;
- }
-
- inode->i_nlink--;
-
- /*
- * we schedule before doing the add_save_link call, save the link
- * count so we don't race
- */
- savelink = inode->i_nlink;
-
-
- retval = reiserfs_cut_from_item (&th, &path, &(de.de_entry_key), dir, NULL, 0);
- if (retval < 0) {
- inode->i_nlink++;
- goto end_unlink;
- }
- inode->i_ctime = CURRENT_TIME_SEC;
- reiserfs_update_sd (&th, inode);
-
- dir->i_size -= (de.de_entrylen + DEH_SIZE);
- dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
- reiserfs_update_sd (&th, dir);
-
- if (!savelink)
- /* prevent file from getting lost */
- add_save_link (&th, inode, 0/* not truncate */);
-
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_check_path(&path) ;
- reiserfs_write_unlock(dir->i_sb);
- return retval;
-
- end_unlink:
- pathrelse (&path);
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_check_path(&path) ;
- if (err)
- retval = err;
-out_unlink:
- reiserfs_write_unlock(dir->i_sb);
- return retval;
+ int retval, err;
+ struct inode *inode;
+ struct reiserfs_transaction_handle th;
+ int jbegin_count;
+ INITIALIZE_PATH(path);
+ struct reiserfs_dir_entry de;
+
+ /* we will be doing 2 balancings and update 2 stat data, we change quotas
+ * of the owner of the directory and of the owner of the parent directory.
+ * The quota structure is possibly deleted only on last iput => outside
+ * of this transaction */
+ jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 2 + 2 +
+ 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
+
+ reiserfs_write_lock(dir->i_sb);
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval)
+ goto out_rmdir;
+
+ de.de_gen_number_bit_string = NULL;
+ if ((retval =
+ reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
+ &path, &de)) == NAME_NOT_FOUND) {
+ retval = -ENOENT;
+ goto end_rmdir;
+ } else if (retval == IO_ERROR) {
+ retval = -EIO;
+ goto end_rmdir;
+ }
+
+ inode = dentry->d_inode;
+
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
+
+ if (de.de_objectid != inode->i_ino) {
+ // FIXME: compare key of an object and a key found in the
+ // entry
+ retval = -EIO;
+ goto end_rmdir;
+ }
+ if (!reiserfs_empty_dir(inode)) {
+ retval = -ENOTEMPTY;
+ goto end_rmdir;
+ }
+
+ /* cut entry from dir directory */
+ retval = reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL, /* page */
+ 0 /*new file size - not used here */ );
+ if (retval < 0)
+ goto end_rmdir;
+
+ if (inode->i_nlink != 2 && inode->i_nlink != 1)
+ reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
+ "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
+
+ inode->i_nlink = 0;
+ inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
+ reiserfs_update_sd(&th, inode);
+
+ DEC_DIR_INODE_NLINK(dir)
+ dir->i_size -= (DEH_SIZE + de.de_entrylen);
+ reiserfs_update_sd(&th, dir);
+
+ /* prevent empty directory from getting lost */
+ add_save_link(&th, inode, 0 /* not truncate */ );
+
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_check_path(&path);
+ out_rmdir:
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
+
+ end_rmdir:
+ /* we must release path, because we did not call
+ reiserfs_cut_from_item, or reiserfs_cut_from_item does not
+ release path if operation was not complete */
+ pathrelse(&path);
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(dir->i_sb);
+ return err ? err : retval;
}
-static int reiserfs_symlink (struct inode * parent_dir,
- struct dentry * dentry, const char * symname)
+static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
{
- int retval;
- struct inode * inode;
- char * name;
- int item_len;
- struct reiserfs_transaction_handle th ;
- int mode = S_IFLNK | S_IRWXUGO;
- /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb)+REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
-
- if (!(inode = new_inode(parent_dir->i_sb))) {
- return -ENOMEM ;
- }
- new_inode_init(inode, parent_dir, mode);
-
- reiserfs_write_lock(parent_dir->i_sb);
- item_len = ROUND_UP (strlen (symname));
- if (item_len > MAX_DIRECT_ITEM_LEN (parent_dir->i_sb->s_blocksize)) {
- retval = -ENAMETOOLONG;
- drop_new_inode(inode);
- goto out_failed;
- }
-
- name = reiserfs_kmalloc (item_len, GFP_NOFS, parent_dir->i_sb);
- if (!name) {
- drop_new_inode(inode);
- retval = -ENOMEM;
- goto out_failed;
- }
- memcpy (name, symname, strlen (symname));
- padd_item (name, item_len, strlen (symname));
-
- /* We would inherit the default ACL here, but symlinks don't get ACLs */
-
- retval = journal_begin(&th, parent_dir->i_sb, jbegin_count) ;
- if (retval) {
- drop_new_inode (inode);
- reiserfs_kfree (name, item_len, parent_dir->i_sb);
- goto out_failed;
- }
-
- retval = reiserfs_new_inode (&th, parent_dir, mode, name, strlen (symname),
- dentry, inode);
- reiserfs_kfree (name, item_len, parent_dir->i_sb);
- if (retval) { /* reiserfs_new_inode iputs for us */
- goto out_failed;
- }
-
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(parent_dir) ;
-
- inode->i_op = &reiserfs_symlink_inode_operations;
- inode->i_mapping->a_ops = &reiserfs_address_space_operations;
-
- // must be sure this inode is written with this transaction
- //
- //reiserfs_update_sd (&th, inode, READ_BLOCKS);
-
- retval = reiserfs_add_entry (&th, parent_dir, dentry->d_name.name,
- dentry->d_name.len, inode, 1/*visible*/);
- if (retval) {
- int err;
+ int retval, err;
+ struct inode *inode;
+ struct reiserfs_dir_entry de;
+ INITIALIZE_PATH(path);
+ struct reiserfs_transaction_handle th;
+ int jbegin_count;
+ unsigned long savelink;
+
+ inode = dentry->d_inode;
+
+ /* in this transaction we can be doing at max two balancings and update
+ * two stat datas, we change quotas of the owner of the directory and of
+ * the owner of the parent directory. The quota structure is possibly
+ * deleted only on iput => outside of this transaction */
+ jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 2 + 2 +
+ 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
+
+ reiserfs_write_lock(dir->i_sb);
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval)
+ goto out_unlink;
+
+ de.de_gen_number_bit_string = NULL;
+ if ((retval =
+ reiserfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len,
+ &path, &de)) == NAME_NOT_FOUND) {
+ retval = -ENOENT;
+ goto end_unlink;
+ } else if (retval == IO_ERROR) {
+ retval = -EIO;
+ goto end_unlink;
+ }
+
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
+
+ if (de.de_objectid != inode->i_ino) {
+ // FIXME: compare key of an object and a key found in the
+ // entry
+ retval = -EIO;
+ goto end_unlink;
+ }
+
+ if (!inode->i_nlink) {
+ reiserfs_warning(inode->i_sb, "%s: deleting nonexistent file "
+ "(%s:%lu), %d", __FUNCTION__,
+ reiserfs_bdevname(inode->i_sb), inode->i_ino,
+ inode->i_nlink);
+ inode->i_nlink = 1;
+ }
+
inode->i_nlink--;
- reiserfs_update_sd (&th, inode);
- err = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
+
+ /*
+ * we schedule before doing the add_save_link call, save the link
+ * count so we don't race
+ */
+ savelink = inode->i_nlink;
+
+ retval =
+ reiserfs_cut_from_item(&th, &path, &(de.de_entry_key), dir, NULL,
+ 0);
+ if (retval < 0) {
+ inode->i_nlink++;
+ goto end_unlink;
+ }
+ inode->i_ctime = CURRENT_TIME_SEC;
+ reiserfs_update_sd(&th, inode);
+
+ dir->i_size -= (de.de_entrylen + DEH_SIZE);
+ dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
+ reiserfs_update_sd(&th, dir);
+
+ if (!savelink)
+ /* prevent file from getting lost */
+ add_save_link(&th, inode, 0 /* not truncate */ );
+
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_check_path(&path);
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
+
+ end_unlink:
+ pathrelse(&path);
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_check_path(&path);
if (err)
- retval = err;
- iput (inode);
- goto out_failed;
- }
-
- d_instantiate(dentry, inode);
- retval = journal_end(&th, parent_dir->i_sb, jbegin_count) ;
-out_failed:
- reiserfs_write_unlock(parent_dir->i_sb);
- return retval;
+ retval = err;
+ out_unlink:
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
}
-static int reiserfs_link (struct dentry * old_dentry, struct inode * dir, struct dentry * dentry)
+static int reiserfs_symlink(struct inode *parent_dir,
+ struct dentry *dentry, const char *symname)
{
- int retval;
- struct inode *inode = old_dentry->d_inode;
- struct reiserfs_transaction_handle th ;
- /* We need blocks for transaction + update of quotas for the owners of the directory */
- int jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
-
- reiserfs_write_lock(dir->i_sb);
- if (inode->i_nlink >= REISERFS_LINK_MAX) {
- //FIXME: sd_nlink is 32 bit for new files
- reiserfs_write_unlock(dir->i_sb);
- return -EMLINK;
- }
- if (inode->i_nlink == 0) {
- reiserfs_write_unlock(dir->i_sb);
- return -ENOENT;
- }
-
- /* inc before scheduling so reiserfs_unlink knows we are here */
- inode->i_nlink++;
-
- retval = journal_begin(&th, dir->i_sb, jbegin_count) ;
- if (retval) {
- inode->i_nlink--;
- reiserfs_write_unlock (dir->i_sb);
- return retval;
- }
-
- /* create new entry */
- retval = reiserfs_add_entry (&th, dir, dentry->d_name.name, dentry->d_name.len,
- inode, 1/*visible*/);
-
- reiserfs_update_inode_transaction(inode) ;
- reiserfs_update_inode_transaction(dir) ;
-
- if (retval) {
- int err;
- inode->i_nlink--;
- err = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_write_unlock(dir->i_sb);
- return err ? err : retval;
- }
+ int retval;
+ struct inode *inode;
+ char *name;
+ int item_len;
+ struct reiserfs_transaction_handle th;
+ int mode = S_IFLNK | S_IRWXUGO;
+ /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 +
+ 2 * (REISERFS_QUOTA_INIT_BLOCKS(parent_dir->i_sb) +
+ REISERFS_QUOTA_TRANS_BLOCKS(parent_dir->i_sb));
+
+ if (!(inode = new_inode(parent_dir->i_sb))) {
+ return -ENOMEM;
+ }
+ new_inode_init(inode, parent_dir, mode);
+
+ reiserfs_write_lock(parent_dir->i_sb);
+ item_len = ROUND_UP(strlen(symname));
+ if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
+ retval = -ENAMETOOLONG;
+ drop_new_inode(inode);
+ goto out_failed;
+ }
+
+ name = reiserfs_kmalloc(item_len, GFP_NOFS, parent_dir->i_sb);
+ if (!name) {
+ drop_new_inode(inode);
+ retval = -ENOMEM;
+ goto out_failed;
+ }
+ memcpy(name, symname, strlen(symname));
+ padd_item(name, item_len, strlen(symname));
+
+ /* We would inherit the default ACL here, but symlinks don't get ACLs */
+
+ retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
+ if (retval) {
+ drop_new_inode(inode);
+ reiserfs_kfree(name, item_len, parent_dir->i_sb);
+ goto out_failed;
+ }
+
+ retval =
+ reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
+ dentry, inode);
+ reiserfs_kfree(name, item_len, parent_dir->i_sb);
+ if (retval) { /* reiserfs_new_inode iputs for us */
+ goto out_failed;
+ }
- inode->i_ctime = CURRENT_TIME_SEC;
- reiserfs_update_sd (&th, inode);
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(parent_dir);
+
+ inode->i_op = &reiserfs_symlink_inode_operations;
+ inode->i_mapping->a_ops = &reiserfs_address_space_operations;
+
+ // must be sure this inode is written with this transaction
+ //
+ //reiserfs_update_sd (&th, inode, READ_BLOCKS);
+
+ retval = reiserfs_add_entry(&th, parent_dir, dentry->d_name.name,
+ dentry->d_name.len, inode, 1 /*visible */ );
+ if (retval) {
+ int err;
+ inode->i_nlink--;
+ reiserfs_update_sd(&th, inode);
+ err = journal_end(&th, parent_dir->i_sb, jbegin_count);
+ if (err)
+ retval = err;
+ iput(inode);
+ goto out_failed;
+ }
- atomic_inc(&inode->i_count) ;
- d_instantiate(dentry, inode);
- retval = journal_end(&th, dir->i_sb, jbegin_count) ;
- reiserfs_write_unlock(dir->i_sb);
- return retval;
+ d_instantiate(dentry, inode);
+ retval = journal_end(&th, parent_dir->i_sb, jbegin_count);
+ out_failed:
+ reiserfs_write_unlock(parent_dir->i_sb);
+ return retval;
}
+static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
+ struct dentry *dentry)
+{
+ int retval;
+ struct inode *inode = old_dentry->d_inode;
+ struct reiserfs_transaction_handle th;
+ /* We need blocks for transaction + update of quotas for the owners of the directory */
+ int jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 +
+ 2 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
+
+ reiserfs_write_lock(dir->i_sb);
+ if (inode->i_nlink >= REISERFS_LINK_MAX) {
+ //FIXME: sd_nlink is 32 bit for new files
+ reiserfs_write_unlock(dir->i_sb);
+ return -EMLINK;
+ }
+ if (inode->i_nlink == 0) {
+ reiserfs_write_unlock(dir->i_sb);
+ return -ENOENT;
+ }
+
+ /* inc before scheduling so reiserfs_unlink knows we are here */
+ inode->i_nlink++;
+
+ retval = journal_begin(&th, dir->i_sb, jbegin_count);
+ if (retval) {
+ inode->i_nlink--;
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
+ }
+
+ /* create new entry */
+ retval =
+ reiserfs_add_entry(&th, dir, dentry->d_name.name,
+ dentry->d_name.len, inode, 1 /*visible */ );
+
+ reiserfs_update_inode_transaction(inode);
+ reiserfs_update_inode_transaction(dir);
+
+ if (retval) {
+ int err;
+ inode->i_nlink--;
+ err = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(dir->i_sb);
+ return err ? err : retval;
+ }
+
+ inode->i_ctime = CURRENT_TIME_SEC;
+ reiserfs_update_sd(&th, inode);
+
+ atomic_inc(&inode->i_count);
+ d_instantiate(dentry, inode);
+ retval = journal_end(&th, dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(dir->i_sb);
+ return retval;
+}
// de contains information pointing to an entry which
-static int de_still_valid (const char * name, int len, struct reiserfs_dir_entry * de)
+static int de_still_valid(const char *name, int len,
+ struct reiserfs_dir_entry *de)
{
- struct reiserfs_dir_entry tmp = *de;
-
- // recalculate pointer to name and name length
- set_de_name_and_namelen (&tmp);
- // FIXME: could check more
- if (tmp.de_namelen != len || memcmp (name, de->de_name, len))
- return 0;
- return 1;
+ struct reiserfs_dir_entry tmp = *de;
+
+ // recalculate pointer to name and name length
+ set_de_name_and_namelen(&tmp);
+ // FIXME: could check more
+ if (tmp.de_namelen != len || memcmp(name, de->de_name, len))
+ return 0;
+ return 1;
}
-
-static int entry_points_to_object (const char * name, int len, struct reiserfs_dir_entry * de, struct inode * inode)
+static int entry_points_to_object(const char *name, int len,
+ struct reiserfs_dir_entry *de,
+ struct inode *inode)
{
- if (!de_still_valid (name, len, de))
- return 0;
-
- if (inode) {
- if (!de_visible (de->de_deh + de->de_entry_num))
- reiserfs_panic (NULL, "vs-7042: entry_points_to_object: entry must be visible");
- return (de->de_objectid == inode->i_ino) ? 1 : 0;
- }
+ if (!de_still_valid(name, len, de))
+ return 0;
+
+ if (inode) {
+ if (!de_visible(de->de_deh + de->de_entry_num))
+ reiserfs_panic(NULL,
+ "vs-7042: entry_points_to_object: entry must be visible");
+ return (de->de_objectid == inode->i_ino) ? 1 : 0;
+ }
- /* this must be added hidden entry */
- if (de_visible (de->de_deh + de->de_entry_num))
- reiserfs_panic (NULL, "vs-7043: entry_points_to_object: entry must be visible");
+ /* this must be added hidden entry */
+ if (de_visible(de->de_deh + de->de_entry_num))
+ reiserfs_panic(NULL,
+ "vs-7043: entry_points_to_object: entry must be visible");
- return 1;
+ return 1;
}
-
/* sets key of objectid the entry has to point to */
-static void set_ino_in_dir_entry (struct reiserfs_dir_entry * de, struct reiserfs_key * key)
+static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
+ struct reiserfs_key *key)
{
- /* JDM These operations are endian safe - both are le */
- de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
- de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
+ /* JDM These operations are endian safe - both are le */
+ de->de_deh[de->de_entry_num].deh_dir_id = key->k_dir_id;
+ de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
}
-
/*
* process, that is going to call fix_nodes/do_balance must hold only
* one path. If it holds 2 or more, it can get into endless waiting in
* get_empty_nodes or its clones
*/
-static int reiserfs_rename (struct inode * old_dir, struct dentry *old_dentry,
- struct inode * new_dir, struct dentry *new_dentry)
+static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
{
- int retval;
- INITIALIZE_PATH (old_entry_path);
- INITIALIZE_PATH (new_entry_path);
- INITIALIZE_PATH (dot_dot_entry_path);
- struct item_head new_entry_ih, old_entry_ih, dot_dot_ih ;
- struct reiserfs_dir_entry old_de, new_de, dot_dot_de;
- struct inode * old_inode, * new_dentry_inode;
- struct reiserfs_transaction_handle th ;
- int jbegin_count ;
- umode_t old_inode_mode;
- unsigned long savelink = 1;
- struct timespec ctime;
-
- /* three balancings: (1) old name removal, (2) new name insertion
- and (3) maybe "save" link insertion
- stat data updates: (1) old directory,
- (2) new directory and (3) maybe old object stat data (when it is
- directory) and (4) maybe stat data of object to which new entry
- pointed initially and (5) maybe block containing ".." of
- renamed directory
- quota updates: two parent directories */
- jbegin_count = JOURNAL_PER_BALANCE_CNT * 3 + 5 + 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
-
- old_inode = old_dentry->d_inode;
- new_dentry_inode = new_dentry->d_inode;
-
- // make sure, that oldname still exists and points to an object we
- // are going to rename
- old_de.de_gen_number_bit_string = NULL;
- reiserfs_write_lock(old_dir->i_sb);
- retval = reiserfs_find_entry (old_dir, old_dentry->d_name.name, old_dentry->d_name.len,
- &old_entry_path, &old_de);
- pathrelse (&old_entry_path);
- if (retval == IO_ERROR) {
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
- }
-
- if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
- reiserfs_write_unlock(old_dir->i_sb);
- return -ENOENT;
- }
-
- old_inode_mode = old_inode->i_mode;
- if (S_ISDIR(old_inode_mode)) {
- // make sure, that directory being renamed has correct ".."
- // and that its new parent directory has not too many links
- // already
-
- if (new_dentry_inode) {
- if (!reiserfs_empty_dir(new_dentry_inode)) {
+ int retval;
+ INITIALIZE_PATH(old_entry_path);
+ INITIALIZE_PATH(new_entry_path);
+ INITIALIZE_PATH(dot_dot_entry_path);
+ struct item_head new_entry_ih, old_entry_ih, dot_dot_ih;
+ struct reiserfs_dir_entry old_de, new_de, dot_dot_de;
+ struct inode *old_inode, *new_dentry_inode;
+ struct reiserfs_transaction_handle th;
+ int jbegin_count;
+ umode_t old_inode_mode;
+ unsigned long savelink = 1;
+ struct timespec ctime;
+
+ /* three balancings: (1) old name removal, (2) new name insertion
+ and (3) maybe "save" link insertion
+ stat data updates: (1) old directory,
+ (2) new directory and (3) maybe old object stat data (when it is
+ directory) and (4) maybe stat data of object to which new entry
+ pointed initially and (5) maybe block containing ".." of
+ renamed directory
+ quota updates: two parent directories */
+ jbegin_count =
+ JOURNAL_PER_BALANCE_CNT * 3 + 5 +
+ 4 * REISERFS_QUOTA_TRANS_BLOCKS(old_dir->i_sb);
+
+ old_inode = old_dentry->d_inode;
+ new_dentry_inode = new_dentry->d_inode;
+
+ // make sure, that oldname still exists and points to an object we
+ // are going to rename
+ old_de.de_gen_number_bit_string = NULL;
+ reiserfs_write_lock(old_dir->i_sb);
+ retval =
+ reiserfs_find_entry(old_dir, old_dentry->d_name.name,
+ old_dentry->d_name.len, &old_entry_path,
+ &old_de);
+ pathrelse(&old_entry_path);
+ if (retval == IO_ERROR) {
reiserfs_write_unlock(old_dir->i_sb);
- return -ENOTEMPTY;
- }
+ return -EIO;
}
-
- /* directory is renamed, its parent directory will be changed,
- ** so find ".." entry
- */
- dot_dot_de.de_gen_number_bit_string = NULL;
- retval = reiserfs_find_entry (old_inode, "..", 2, &dot_dot_entry_path, &dot_dot_de);
- pathrelse (&dot_dot_entry_path);
- if (retval != NAME_FOUND) {
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
+
+ if (retval != NAME_FOUND || old_de.de_objectid != old_inode->i_ino) {
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -ENOENT;
}
- /* inode number of .. must equal old_dir->i_ino */
- if (dot_dot_de.de_objectid != old_dir->i_ino) {
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
+ old_inode_mode = old_inode->i_mode;
+ if (S_ISDIR(old_inode_mode)) {
+ // make sure, that directory being renamed has correct ".."
+ // and that its new parent directory has not too many links
+ // already
+
+ if (new_dentry_inode) {
+ if (!reiserfs_empty_dir(new_dentry_inode)) {
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -ENOTEMPTY;
+ }
+ }
+
+ /* directory is renamed, its parent directory will be changed,
+ ** so find ".." entry
+ */
+ dot_dot_de.de_gen_number_bit_string = NULL;
+ retval =
+ reiserfs_find_entry(old_inode, "..", 2, &dot_dot_entry_path,
+ &dot_dot_de);
+ pathrelse(&dot_dot_entry_path);
+ if (retval != NAME_FOUND) {
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -EIO;
+ }
+
+ /* inode number of .. must equal old_dir->i_ino */
+ if (dot_dot_de.de_objectid != old_dir->i_ino) {
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -EIO;
+ }
}
- }
-
- retval = journal_begin(&th, old_dir->i_sb, jbegin_count) ;
- if (retval) {
- reiserfs_write_unlock (old_dir->i_sb);
- return retval;
- }
-
- /* add new entry (or find the existing one) */
- retval = reiserfs_add_entry (&th, new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
- old_inode, 0);
- if (retval == -EEXIST) {
- if (!new_dentry_inode) {
- reiserfs_panic (old_dir->i_sb,
- "vs-7050: new entry is found, new inode == 0\n");
+
+ retval = journal_begin(&th, old_dir->i_sb, jbegin_count);
+ if (retval) {
+ reiserfs_write_unlock(old_dir->i_sb);
+ return retval;
}
- } else if (retval) {
- int err = journal_end(&th, old_dir->i_sb, jbegin_count) ;
- reiserfs_write_unlock(old_dir->i_sb);
- return err ? err : retval;
- }
-
- reiserfs_update_inode_transaction(old_dir) ;
- reiserfs_update_inode_transaction(new_dir) ;
-
- /* this makes it so an fsync on an open fd for the old name will
- ** commit the rename operation
- */
- reiserfs_update_inode_transaction(old_inode) ;
-
- if (new_dentry_inode)
- reiserfs_update_inode_transaction(new_dentry_inode) ;
-
- while (1) {
- // look for old name using corresponding entry key (found by reiserfs_find_entry)
- if ((retval = search_by_entry_key (new_dir->i_sb, &old_de.de_entry_key,
- &old_entry_path, &old_de)) != NAME_FOUND) {
- pathrelse(&old_entry_path);
- journal_end(&th, old_dir->i_sb, jbegin_count);
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
+
+ /* add new entry (or find the existing one) */
+ retval =
+ reiserfs_add_entry(&th, new_dir, new_dentry->d_name.name,
+ new_dentry->d_name.len, old_inode, 0);
+ if (retval == -EEXIST) {
+ if (!new_dentry_inode) {
+ reiserfs_panic(old_dir->i_sb,
+ "vs-7050: new entry is found, new inode == 0\n");
+ }
+ } else if (retval) {
+ int err = journal_end(&th, old_dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(old_dir->i_sb);
+ return err ? err : retval;
}
- copy_item_head(&old_entry_ih, get_ih(&old_entry_path)) ;
-
- reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1) ;
-
- // look for new name by reiserfs_find_entry
- new_de.de_gen_number_bit_string = NULL;
- retval = reiserfs_find_entry (new_dir, new_dentry->d_name.name, new_dentry->d_name.len,
- &new_entry_path, &new_de);
- // reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
- // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
- if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
- pathrelse(&new_entry_path);
- pathrelse(&old_entry_path);
- journal_end(&th, old_dir->i_sb, jbegin_count);
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
+ reiserfs_update_inode_transaction(old_dir);
+ reiserfs_update_inode_transaction(new_dir);
+
+ /* this makes it so an fsync on an open fd for the old name will
+ ** commit the rename operation
+ */
+ reiserfs_update_inode_transaction(old_inode);
+
+ if (new_dentry_inode)
+ reiserfs_update_inode_transaction(new_dentry_inode);
+
+ while (1) {
+ // look for old name using corresponding entry key (found by reiserfs_find_entry)
+ if ((retval =
+ search_by_entry_key(new_dir->i_sb, &old_de.de_entry_key,
+ &old_entry_path,
+ &old_de)) != NAME_FOUND) {
+ pathrelse(&old_entry_path);
+ journal_end(&th, old_dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -EIO;
+ }
+
+ copy_item_head(&old_entry_ih, get_ih(&old_entry_path));
+
+ reiserfs_prepare_for_journal(old_inode->i_sb, old_de.de_bh, 1);
+
+ // look for new name by reiserfs_find_entry
+ new_de.de_gen_number_bit_string = NULL;
+ retval =
+ reiserfs_find_entry(new_dir, new_dentry->d_name.name,
+ new_dentry->d_name.len, &new_entry_path,
+ &new_de);
+ // reiserfs_add_entry should not return IO_ERROR, because it is called with essentially same parameters from
+ // reiserfs_add_entry above, and we'll catch any i/o errors before we get here.
+ if (retval != NAME_FOUND_INVISIBLE && retval != NAME_FOUND) {
+ pathrelse(&new_entry_path);
+ pathrelse(&old_entry_path);
+ journal_end(&th, old_dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -EIO;
+ }
+
+ copy_item_head(&new_entry_ih, get_ih(&new_entry_path));
+
+ reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1);
+
+ if (S_ISDIR(old_inode->i_mode)) {
+ if ((retval =
+ search_by_entry_key(new_dir->i_sb,
+ &dot_dot_de.de_entry_key,
+ &dot_dot_entry_path,
+ &dot_dot_de)) != NAME_FOUND) {
+ pathrelse(&dot_dot_entry_path);
+ pathrelse(&new_entry_path);
+ pathrelse(&old_entry_path);
+ journal_end(&th, old_dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(old_dir->i_sb);
+ return -EIO;
+ }
+ copy_item_head(&dot_dot_ih,
+ get_ih(&dot_dot_entry_path));
+ // node containing ".." gets into transaction
+ reiserfs_prepare_for_journal(old_inode->i_sb,
+ dot_dot_de.de_bh, 1);
+ }
+ /* we should check seals here, not do
+ this stuff, yes? Then, having
+ gathered everything into RAM we
+ should lock the buffers, yes? -Hans */
+ /* probably. our rename needs to hold more
+ ** than one path at once. The seals would
+ ** have to be written to deal with multi-path
+ ** issues -chris
+ */
+ /* sanity checking before doing the rename - avoid races many
+ ** of the above checks could have scheduled. We have to be
+ ** sure our items haven't been shifted by another process.
+ */
+ if (item_moved(&new_entry_ih, &new_entry_path) ||
+ !entry_points_to_object(new_dentry->d_name.name,
+ new_dentry->d_name.len,
+ &new_de, new_dentry_inode) ||
+ item_moved(&old_entry_ih, &old_entry_path) ||
+ !entry_points_to_object(old_dentry->d_name.name,
+ old_dentry->d_name.len,
+ &old_de, old_inode)) {
+ reiserfs_restore_prepared_buffer(old_inode->i_sb,
+ new_de.de_bh);
+ reiserfs_restore_prepared_buffer(old_inode->i_sb,
+ old_de.de_bh);
+ if (S_ISDIR(old_inode_mode))
+ reiserfs_restore_prepared_buffer(old_inode->
+ i_sb,
+ dot_dot_de.
+ de_bh);
+ continue;
+ }
+ if (S_ISDIR(old_inode_mode)) {
+ if (item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
+ !entry_points_to_object("..", 2, &dot_dot_de,
+ old_dir)) {
+ reiserfs_restore_prepared_buffer(old_inode->
+ i_sb,
+ old_de.de_bh);
+ reiserfs_restore_prepared_buffer(old_inode->
+ i_sb,
+ new_de.de_bh);
+ reiserfs_restore_prepared_buffer(old_inode->
+ i_sb,
+ dot_dot_de.
+ de_bh);
+ continue;
+ }
+ }
+
+ RFALSE(S_ISDIR(old_inode_mode) &&
+ !buffer_journal_prepared(dot_dot_de.de_bh), "");
+
+ break;
}
- copy_item_head(&new_entry_ih, get_ih(&new_entry_path)) ;
+ /* ok, all the changes can be done in one fell swoop when we
+ have claimed all the buffers needed. */
- reiserfs_prepare_for_journal(old_inode->i_sb, new_de.de_bh, 1) ;
+ mark_de_visible(new_de.de_deh + new_de.de_entry_num);
+ set_ino_in_dir_entry(&new_de, INODE_PKEY(old_inode));
+ journal_mark_dirty(&th, old_dir->i_sb, new_de.de_bh);
- if (S_ISDIR(old_inode->i_mode)) {
- if ((retval = search_by_entry_key (new_dir->i_sb, &dot_dot_de.de_entry_key,
- &dot_dot_entry_path, &dot_dot_de)) != NAME_FOUND) {
- pathrelse(&dot_dot_entry_path);
- pathrelse(&new_entry_path);
- pathrelse(&old_entry_path);
- journal_end(&th, old_dir->i_sb, jbegin_count);
- reiserfs_write_unlock(old_dir->i_sb);
- return -EIO;
- }
- copy_item_head(&dot_dot_ih, get_ih(&dot_dot_entry_path)) ;
- // node containing ".." gets into transaction
- reiserfs_prepare_for_journal(old_inode->i_sb, dot_dot_de.de_bh, 1) ;
- }
- /* we should check seals here, not do
- this stuff, yes? Then, having
- gathered everything into RAM we
- should lock the buffers, yes? -Hans */
- /* probably. our rename needs to hold more
- ** than one path at once. The seals would
- ** have to be written to deal with multi-path
- ** issues -chris
- */
- /* sanity checking before doing the rename - avoid races many
- ** of the above checks could have scheduled. We have to be
- ** sure our items haven't been shifted by another process.
- */
- if (item_moved(&new_entry_ih, &new_entry_path) ||
- !entry_points_to_object(new_dentry->d_name.name,
- new_dentry->d_name.len,
- &new_de, new_dentry_inode) ||
- item_moved(&old_entry_ih, &old_entry_path) ||
- !entry_points_to_object (old_dentry->d_name.name,
- old_dentry->d_name.len,
- &old_de, old_inode)) {
- reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
- reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
- if (S_ISDIR(old_inode_mode))
- reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
- continue;
+ mark_de_hidden(old_de.de_deh + old_de.de_entry_num);
+ journal_mark_dirty(&th, old_dir->i_sb, old_de.de_bh);
+ ctime = CURRENT_TIME_SEC;
+ old_dir->i_ctime = old_dir->i_mtime = ctime;
+ new_dir->i_ctime = new_dir->i_mtime = ctime;
+ /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of
+ renamed object */
+ old_inode->i_ctime = ctime;
+
+ if (new_dentry_inode) {
+ // adjust link number of the victim
+ if (S_ISDIR(new_dentry_inode->i_mode)) {
+ new_dentry_inode->i_nlink = 0;
+ } else {
+ new_dentry_inode->i_nlink--;
+ }
+ new_dentry_inode->i_ctime = ctime;
+ savelink = new_dentry_inode->i_nlink;
}
+
if (S_ISDIR(old_inode_mode)) {
- if ( item_moved(&dot_dot_ih, &dot_dot_entry_path) ||
- !entry_points_to_object ( "..", 2, &dot_dot_de, old_dir) ) {
- reiserfs_restore_prepared_buffer (old_inode->i_sb, old_de.de_bh);
- reiserfs_restore_prepared_buffer (old_inode->i_sb, new_de.de_bh);
- reiserfs_restore_prepared_buffer (old_inode->i_sb, dot_dot_de.de_bh);
- continue;
- }
+ // adjust ".." of renamed directory
+ set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
+ journal_mark_dirty(&th, new_dir->i_sb, dot_dot_de.de_bh);
+
+ if (!new_dentry_inode)
+ /* there (in new_dir) was no directory, so it got new link
+ (".." of renamed directory) */
+ INC_DIR_INODE_NLINK(new_dir);
+
+ /* old directory lost one link - ".. " of renamed directory */
+ DEC_DIR_INODE_NLINK(old_dir);
}
+ // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
+ pathrelse(&new_entry_path);
+ pathrelse(&dot_dot_entry_path);
- RFALSE( S_ISDIR(old_inode_mode) &&
- !buffer_journal_prepared(dot_dot_de.de_bh), "" );
-
- break;
- }
-
- /* ok, all the changes can be done in one fell swoop when we
- have claimed all the buffers needed.*/
-
- mark_de_visible (new_de.de_deh + new_de.de_entry_num);
- set_ino_in_dir_entry (&new_de, INODE_PKEY (old_inode));
- journal_mark_dirty (&th, old_dir->i_sb, new_de.de_bh);
-
- mark_de_hidden (old_de.de_deh + old_de.de_entry_num);
- journal_mark_dirty (&th, old_dir->i_sb, old_de.de_bh);
- ctime = CURRENT_TIME_SEC;
- old_dir->i_ctime = old_dir->i_mtime = ctime;
- new_dir->i_ctime = new_dir->i_mtime = ctime;
- /* thanks to Alex Adriaanse <alex_a@caltech.edu> for patch which adds ctime update of
- renamed object */
- old_inode->i_ctime = ctime;
-
- if (new_dentry_inode) {
- // adjust link number of the victim
- if (S_ISDIR(new_dentry_inode->i_mode)) {
- new_dentry_inode->i_nlink = 0;
- } else {
- new_dentry_inode->i_nlink--;
+ // FIXME: this reiserfs_cut_from_item's return value may screw up
+ // anybody, but it will panic if will not be able to find the
+ // entry. This needs one more clean up
+ if (reiserfs_cut_from_item
+ (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
+ 0) < 0)
+ reiserfs_warning(old_dir->i_sb,
+ "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
+
+ old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
+
+ reiserfs_update_sd(&th, old_dir);
+ reiserfs_update_sd(&th, new_dir);
+ reiserfs_update_sd(&th, old_inode);
+
+ if (new_dentry_inode) {
+ if (savelink == 0)
+ add_save_link(&th, new_dentry_inode,
+ 0 /* not truncate */ );
+ reiserfs_update_sd(&th, new_dentry_inode);
}
- new_dentry_inode->i_ctime = ctime;
- savelink = new_dentry_inode->i_nlink;
- }
-
- if (S_ISDIR(old_inode_mode)) {
- // adjust ".." of renamed directory
- set_ino_in_dir_entry (&dot_dot_de, INODE_PKEY (new_dir));
- journal_mark_dirty (&th, new_dir->i_sb, dot_dot_de.de_bh);
-
- if (!new_dentry_inode)
- /* there (in new_dir) was no directory, so it got new link
- (".." of renamed directory) */
- INC_DIR_INODE_NLINK(new_dir);
-
- /* old directory lost one link - ".. " of renamed directory */
- DEC_DIR_INODE_NLINK(old_dir);
- }
-
- // looks like in 2.3.99pre3 brelse is atomic. so we can use pathrelse
- pathrelse (&new_entry_path);
- pathrelse (&dot_dot_entry_path);
-
- // FIXME: this reiserfs_cut_from_item's return value may screw up
- // anybody, but it will panic if will not be able to find the
- // entry. This needs one more clean up
- if (reiserfs_cut_from_item (&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL, 0) < 0)
- reiserfs_warning (old_dir->i_sb, "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
-
- old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
-
- reiserfs_update_sd (&th, old_dir);
- reiserfs_update_sd (&th, new_dir);
- reiserfs_update_sd (&th, old_inode);
-
- if (new_dentry_inode) {
- if (savelink == 0)
- add_save_link (&th, new_dentry_inode, 0/* not truncate */);
- reiserfs_update_sd (&th, new_dentry_inode);
- }
-
- retval = journal_end(&th, old_dir->i_sb, jbegin_count) ;
- reiserfs_write_unlock(old_dir->i_sb);
- return retval;
+
+ retval = journal_end(&th, old_dir->i_sb, jbegin_count);
+ reiserfs_write_unlock(old_dir->i_sb);
+ return retval;
}
/*
* directories can handle most operations...
*/
struct inode_operations reiserfs_dir_inode_operations = {
- //&reiserfs_dir_operations, /* default_file_ops */
- .create = reiserfs_create,
- .lookup = reiserfs_lookup,
- .link = reiserfs_link,
- .unlink = reiserfs_unlink,
- .symlink = reiserfs_symlink,
- .mkdir = reiserfs_mkdir,
- .rmdir = reiserfs_rmdir,
- .mknod = reiserfs_mknod,
- .rename = reiserfs_rename,
- .setattr = reiserfs_setattr,
- .setxattr = reiserfs_setxattr,
- .getxattr = reiserfs_getxattr,
- .listxattr = reiserfs_listxattr,
- .removexattr = reiserfs_removexattr,
- .permission = reiserfs_permission,
+ //&reiserfs_dir_operations, /* default_file_ops */
+ .create = reiserfs_create,
+ .lookup = reiserfs_lookup,
+ .link = reiserfs_link,
+ .unlink = reiserfs_unlink,
+ .symlink = reiserfs_symlink,
+ .mkdir = reiserfs_mkdir,
+ .rmdir = reiserfs_rmdir,
+ .mknod = reiserfs_mknod,
+ .rename = reiserfs_rename,
+ .setattr = reiserfs_setattr,
+ .setxattr = reiserfs_setxattr,
+ .getxattr = reiserfs_getxattr,
+ .listxattr = reiserfs_listxattr,
+ .removexattr = reiserfs_removexattr,
+ .permission = reiserfs_permission,
};
/*
@@ -1467,28 +1554,27 @@ struct inode_operations reiserfs_dir_inode_operations = {
* stuff added
*/
struct inode_operations reiserfs_symlink_inode_operations = {
- .readlink = generic_readlink,
- .follow_link = page_follow_link_light,
- .put_link = page_put_link,
- .setattr = reiserfs_setattr,
- .setxattr = reiserfs_setxattr,
- .getxattr = reiserfs_getxattr,
- .listxattr = reiserfs_listxattr,
- .removexattr = reiserfs_removexattr,
- .permission = reiserfs_permission,
+ .readlink = generic_readlink,
+ .follow_link = page_follow_link_light,
+ .put_link = page_put_link,
+ .setattr = reiserfs_setattr,
+ .setxattr = reiserfs_setxattr,
+ .getxattr = reiserfs_getxattr,
+ .listxattr = reiserfs_listxattr,
+ .removexattr = reiserfs_removexattr,
+ .permission = reiserfs_permission,
};
-
/*
* special file operations.. just xattr/acl stuff
*/
struct inode_operations reiserfs_special_inode_operations = {
- .setattr = reiserfs_setattr,
- .setxattr = reiserfs_setxattr,
- .getxattr = reiserfs_getxattr,
- .listxattr = reiserfs_listxattr,
- .removexattr = reiserfs_removexattr,
- .permission = reiserfs_permission,
+ .setattr = reiserfs_setattr,
+ .setxattr = reiserfs_setxattr,
+ .getxattr = reiserfs_getxattr,
+ .listxattr = reiserfs_listxattr,
+ .removexattr = reiserfs_removexattr,
+ .permission = reiserfs_permission,
};
diff --git a/fs/reiserfs/objectid.c b/fs/reiserfs/objectid.c
index bfe8e25ef29..f62590aa9c9 100644
--- a/fs/reiserfs/objectid.c
+++ b/fs/reiserfs/objectid.c
@@ -14,24 +14,24 @@
(__le32 *)((struct reiserfs_super_block_v1 *)(rs) + 1) :\
(__le32 *)((rs) + 1))
-
#ifdef CONFIG_REISERFS_CHECK
-static void check_objectid_map (struct super_block * s, __le32 * map)
+static void check_objectid_map(struct super_block *s, __le32 * map)
{
- if (le32_to_cpu (map[0]) != 1)
- reiserfs_panic (s, "vs-15010: check_objectid_map: map corrupted: %lx",
- ( long unsigned int ) le32_to_cpu (map[0]));
+ if (le32_to_cpu(map[0]) != 1)
+ reiserfs_panic(s,
+ "vs-15010: check_objectid_map: map corrupted: %lx",
+ (long unsigned int)le32_to_cpu(map[0]));
- // FIXME: add something else here
+ // FIXME: add something else here
}
#else
-static void check_objectid_map (struct super_block * s, __le32 * map)
-{;}
+static void check_objectid_map(struct super_block *s, __le32 * map)
+{;
+}
#endif
-
/* When we allocate objectids we allocate the first unused objectid.
Each sequence of objectids in use (the odd sequences) is followed
by a sequence of objectids not in use (the even sequences). We
@@ -46,161 +46,162 @@ static void check_objectid_map (struct super_block * s, __le32 * map)
interesting optimizations of layout could result from complicating
objectid assignment, but we have deferred making them for now. */
-
/* get unique object identifier */
-__u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th)
+__u32 reiserfs_get_unused_objectid(struct reiserfs_transaction_handle *th)
{
- struct super_block * s = th->t_super;
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
- __le32 * map = objectid_map (s, rs);
- __u32 unused_objectid;
-
- BUG_ON (!th->t_trans_id);
+ struct super_block *s = th->t_super;
+ struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
+ __le32 *map = objectid_map(s, rs);
+ __u32 unused_objectid;
+
+ BUG_ON(!th->t_trans_id);
+
+ check_objectid_map(s, map);
+
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+ /* comment needed -Hans */
+ unused_objectid = le32_to_cpu(map[1]);
+ if (unused_objectid == U32_MAX) {
+ reiserfs_warning(s, "%s: no more object ids", __FUNCTION__);
+ reiserfs_restore_prepared_buffer(s, SB_BUFFER_WITH_SB(s));
+ return 0;
+ }
- check_objectid_map (s, map);
+ /* This incrementation allocates the first unused objectid. That
+ is to say, the first entry on the objectid map is the first
+ unused objectid, and by incrementing it we use it. See below
+ where we check to see if we eliminated a sequence of unused
+ objectids.... */
+ map[1] = cpu_to_le32(unused_objectid + 1);
+
+ /* Now we check to see if we eliminated the last remaining member of
+ the first even sequence (and can eliminate the sequence by
+ eliminating its last objectid from oids), and can collapse the
+ first two odd sequences into one sequence. If so, then the net
+ result is to eliminate a pair of objectids from oids. We do this
+ by shifting the entire map to the left. */
+ if (sb_oid_cursize(rs) > 2 && map[1] == map[2]) {
+ memmove(map + 1, map + 3,
+ (sb_oid_cursize(rs) - 3) * sizeof(__u32));
+ set_sb_oid_cursize(rs, sb_oid_cursize(rs) - 2);
+ }
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
- /* comment needed -Hans */
- unused_objectid = le32_to_cpu (map[1]);
- if (unused_objectid == U32_MAX) {
- reiserfs_warning (s, "%s: no more object ids", __FUNCTION__);
- reiserfs_restore_prepared_buffer(s, SB_BUFFER_WITH_SB(s)) ;
- return 0;
- }
-
- /* This incrementation allocates the first unused objectid. That
- is to say, the first entry on the objectid map is the first
- unused objectid, and by incrementing it we use it. See below
- where we check to see if we eliminated a sequence of unused
- objectids.... */
- map[1] = cpu_to_le32 (unused_objectid + 1);
-
- /* Now we check to see if we eliminated the last remaining member of
- the first even sequence (and can eliminate the sequence by
- eliminating its last objectid from oids), and can collapse the
- first two odd sequences into one sequence. If so, then the net
- result is to eliminate a pair of objectids from oids. We do this
- by shifting the entire map to the left. */
- if (sb_oid_cursize(rs) > 2 && map[1] == map[2]) {
- memmove (map + 1, map + 3, (sb_oid_cursize(rs) - 3) * sizeof(__u32));
- set_sb_oid_cursize( rs, sb_oid_cursize(rs) - 2 );
- }
-
- journal_mark_dirty(th, s, SB_BUFFER_WITH_SB (s));
- return unused_objectid;
+ journal_mark_dirty(th, s, SB_BUFFER_WITH_SB(s));
+ return unused_objectid;
}
-
/* makes object identifier unused */
-void reiserfs_release_objectid (struct reiserfs_transaction_handle *th,
- __u32 objectid_to_release)
+void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
+ __u32 objectid_to_release)
{
- struct super_block * s = th->t_super;
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
- __le32 * map = objectid_map (s, rs);
- int i = 0;
-
- BUG_ON (!th->t_trans_id);
- //return;
- check_objectid_map (s, map);
-
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
- journal_mark_dirty(th, s, SB_BUFFER_WITH_SB (s));
-
- /* start at the beginning of the objectid map (i = 0) and go to
- the end of it (i = disk_sb->s_oid_cursize). Linear search is
- what we use, though it is possible that binary search would be
- more efficient after performing lots of deletions (which is
- when oids is large.) We only check even i's. */
- while (i < sb_oid_cursize(rs)) {
- if (objectid_to_release == le32_to_cpu (map[i])) {
- /* This incrementation unallocates the objectid. */
- //map[i]++;
- map[i] = cpu_to_le32 (le32_to_cpu (map[i]) + 1);
-
- /* Did we unallocate the last member of an odd sequence, and can shrink oids? */
- if (map[i] == map[i+1]) {
- /* shrink objectid map */
- memmove (map + i, map + i + 2,
- (sb_oid_cursize(rs) - i - 2) * sizeof (__u32));
- //disk_sb->s_oid_cursize -= 2;
- set_sb_oid_cursize( rs, sb_oid_cursize(rs) - 2 );
-
- RFALSE( sb_oid_cursize(rs) < 2 ||
- sb_oid_cursize(rs) > sb_oid_maxsize(rs),
- "vs-15005: objectid map corrupted cur_size == %d (max == %d)",
- sb_oid_cursize(rs), sb_oid_maxsize(rs));
- }
- return;
+ struct super_block *s = th->t_super;
+ struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
+ __le32 *map = objectid_map(s, rs);
+ int i = 0;
+
+ BUG_ON(!th->t_trans_id);
+ //return;
+ check_objectid_map(s, map);
+
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+ journal_mark_dirty(th, s, SB_BUFFER_WITH_SB(s));
+
+ /* start at the beginning of the objectid map (i = 0) and go to
+ the end of it (i = disk_sb->s_oid_cursize). Linear search is
+ what we use, though it is possible that binary search would be
+ more efficient after performing lots of deletions (which is
+ when oids is large.) We only check even i's. */
+ while (i < sb_oid_cursize(rs)) {
+ if (objectid_to_release == le32_to_cpu(map[i])) {
+ /* This incrementation unallocates the objectid. */
+ //map[i]++;
+ map[i] = cpu_to_le32(le32_to_cpu(map[i]) + 1);
+
+ /* Did we unallocate the last member of an odd sequence, and can shrink oids? */
+ if (map[i] == map[i + 1]) {
+ /* shrink objectid map */
+ memmove(map + i, map + i + 2,
+ (sb_oid_cursize(rs) - i -
+ 2) * sizeof(__u32));
+ //disk_sb->s_oid_cursize -= 2;
+ set_sb_oid_cursize(rs, sb_oid_cursize(rs) - 2);
+
+ RFALSE(sb_oid_cursize(rs) < 2 ||
+ sb_oid_cursize(rs) > sb_oid_maxsize(rs),
+ "vs-15005: objectid map corrupted cur_size == %d (max == %d)",
+ sb_oid_cursize(rs), sb_oid_maxsize(rs));
+ }
+ return;
+ }
+
+ if (objectid_to_release > le32_to_cpu(map[i]) &&
+ objectid_to_release < le32_to_cpu(map[i + 1])) {
+ /* size of objectid map is not changed */
+ if (objectid_to_release + 1 == le32_to_cpu(map[i + 1])) {
+ //objectid_map[i+1]--;
+ map[i + 1] =
+ cpu_to_le32(le32_to_cpu(map[i + 1]) - 1);
+ return;
+ }
+
+ /* JDM comparing two little-endian values for equality -- safe */
+ if (sb_oid_cursize(rs) == sb_oid_maxsize(rs)) {
+ /* objectid map must be expanded, but there is no space */
+ PROC_INFO_INC(s, leaked_oid);
+ return;
+ }
+
+ /* expand the objectid map */
+ memmove(map + i + 3, map + i + 1,
+ (sb_oid_cursize(rs) - i - 1) * sizeof(__u32));
+ map[i + 1] = cpu_to_le32(objectid_to_release);
+ map[i + 2] = cpu_to_le32(objectid_to_release + 1);
+ set_sb_oid_cursize(rs, sb_oid_cursize(rs) + 2);
+ return;
+ }
+ i += 2;
}
- if (objectid_to_release > le32_to_cpu (map[i]) &&
- objectid_to_release < le32_to_cpu (map[i + 1])) {
- /* size of objectid map is not changed */
- if (objectid_to_release + 1 == le32_to_cpu (map[i + 1])) {
- //objectid_map[i+1]--;
- map[i + 1] = cpu_to_le32 (le32_to_cpu (map[i + 1]) - 1);
- return;
- }
-
- /* JDM comparing two little-endian values for equality -- safe */
- if (sb_oid_cursize(rs) == sb_oid_maxsize(rs)) {
- /* objectid map must be expanded, but there is no space */
- PROC_INFO_INC( s, leaked_oid );
- return;
- }
+ reiserfs_warning(s,
+ "vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)",
+ (long unsigned)objectid_to_release);
+}
- /* expand the objectid map*/
- memmove (map + i + 3, map + i + 1,
- (sb_oid_cursize(rs) - i - 1) * sizeof(__u32));
- map[i + 1] = cpu_to_le32 (objectid_to_release);
- map[i + 2] = cpu_to_le32 (objectid_to_release + 1);
- set_sb_oid_cursize( rs, sb_oid_cursize(rs) + 2 );
- return;
+int reiserfs_convert_objectid_map_v1(struct super_block *s)
+{
+ struct reiserfs_super_block *disk_sb = SB_DISK_SUPER_BLOCK(s);
+ int cur_size = sb_oid_cursize(disk_sb);
+ int new_size = (s->s_blocksize - SB_SIZE) / sizeof(__u32) / 2 * 2;
+ int old_max = sb_oid_maxsize(disk_sb);
+ struct reiserfs_super_block_v1 *disk_sb_v1;
+ __le32 *objectid_map, *new_objectid_map;
+ int i;
+
+ disk_sb_v1 =
+ (struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data);
+ objectid_map = (__le32 *) (disk_sb_v1 + 1);
+ new_objectid_map = (__le32 *) (disk_sb + 1);
+
+ if (cur_size > new_size) {
+ /* mark everyone used that was listed as free at the end of the objectid
+ ** map
+ */
+ objectid_map[new_size - 1] = objectid_map[cur_size - 1];
+ set_sb_oid_cursize(disk_sb, new_size);
+ }
+ /* move the smaller objectid map past the end of the new super */
+ for (i = new_size - 1; i >= 0; i--) {
+ objectid_map[i + (old_max - new_size)] = objectid_map[i];
}
- i += 2;
- }
- reiserfs_warning (s, "vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)",
- ( long unsigned ) objectid_to_release);
-}
+ /* set the max size so we don't overflow later */
+ set_sb_oid_maxsize(disk_sb, new_size);
+ /* Zero out label and generate random UUID */
+ memset(disk_sb->s_label, 0, sizeof(disk_sb->s_label));
+ generate_random_uuid(disk_sb->s_uuid);
-int reiserfs_convert_objectid_map_v1(struct super_block *s) {
- struct reiserfs_super_block *disk_sb = SB_DISK_SUPER_BLOCK (s);
- int cur_size = sb_oid_cursize(disk_sb);
- int new_size = (s->s_blocksize - SB_SIZE) / sizeof(__u32) / 2 * 2 ;
- int old_max = sb_oid_maxsize(disk_sb);
- struct reiserfs_super_block_v1 *disk_sb_v1 ;
- __le32 *objectid_map, *new_objectid_map ;
- int i ;
-
- disk_sb_v1=(struct reiserfs_super_block_v1 *)(SB_BUFFER_WITH_SB(s)->b_data);
- objectid_map = (__le32 *)(disk_sb_v1 + 1) ;
- new_objectid_map = (__le32 *)(disk_sb + 1) ;
-
- if (cur_size > new_size) {
- /* mark everyone used that was listed as free at the end of the objectid
- ** map
- */
- objectid_map[new_size - 1] = objectid_map[cur_size - 1] ;
- set_sb_oid_cursize(disk_sb,new_size) ;
- }
- /* move the smaller objectid map past the end of the new super */
- for (i = new_size - 1 ; i >= 0 ; i--) {
- objectid_map[i + (old_max - new_size)] = objectid_map[i] ;
- }
-
-
- /* set the max size so we don't overflow later */
- set_sb_oid_maxsize(disk_sb,new_size) ;
-
- /* Zero out label and generate random UUID */
- memset(disk_sb->s_label, 0, sizeof(disk_sb->s_label)) ;
- generate_random_uuid(disk_sb->s_uuid);
-
- /* finally, zero out the unused chunk of the new super */
- memset(disk_sb->s_unused, 0, sizeof(disk_sb->s_unused)) ;
- return 0 ;
+ /* finally, zero out the unused chunk of the new super */
+ memset(disk_sb->s_unused, 0, sizeof(disk_sb->s_unused));
+ return 0;
}
-
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index 16fdca1d4bd..d55e164bd5c 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -15,168 +15,166 @@ static char error_buf[1024];
static char fmt_buf[1024];
static char off_buf[80];
-
-static char * reiserfs_cpu_offset (struct cpu_key * key)
+static char *reiserfs_cpu_offset(struct cpu_key *key)
{
- if (cpu_key_k_type(key) == TYPE_DIRENTRY)
- sprintf (off_buf, "%Lu(%Lu)",
- (unsigned long long)GET_HASH_VALUE (cpu_key_k_offset (key)),
- (unsigned long long)GET_GENERATION_NUMBER (cpu_key_k_offset (key)));
- else
- sprintf (off_buf, "0x%Lx", (unsigned long long)cpu_key_k_offset (key));
- return off_buf;
+ if (cpu_key_k_type(key) == TYPE_DIRENTRY)
+ sprintf(off_buf, "%Lu(%Lu)",
+ (unsigned long long)
+ GET_HASH_VALUE(cpu_key_k_offset(key)),
+ (unsigned long long)
+ GET_GENERATION_NUMBER(cpu_key_k_offset(key)));
+ else
+ sprintf(off_buf, "0x%Lx",
+ (unsigned long long)cpu_key_k_offset(key));
+ return off_buf;
}
-
-static char * le_offset (struct reiserfs_key * key)
+static char *le_offset(struct reiserfs_key *key)
{
- int version;
+ int version;
- version = le_key_version (key);
- if (le_key_k_type (version, key) == TYPE_DIRENTRY)
- sprintf (off_buf, "%Lu(%Lu)",
- (unsigned long long)GET_HASH_VALUE (le_key_k_offset (version, key)),
- (unsigned long long)GET_GENERATION_NUMBER (le_key_k_offset (version, key)));
- else
- sprintf (off_buf, "0x%Lx", (unsigned long long)le_key_k_offset (version, key));
- return off_buf;
+ version = le_key_version(key);
+ if (le_key_k_type(version, key) == TYPE_DIRENTRY)
+ sprintf(off_buf, "%Lu(%Lu)",
+ (unsigned long long)
+ GET_HASH_VALUE(le_key_k_offset(version, key)),
+ (unsigned long long)
+ GET_GENERATION_NUMBER(le_key_k_offset(version, key)));
+ else
+ sprintf(off_buf, "0x%Lx",
+ (unsigned long long)le_key_k_offset(version, key));
+ return off_buf;
}
-
-static char * cpu_type (struct cpu_key * key)
+static char *cpu_type(struct cpu_key *key)
{
- if (cpu_key_k_type (key) == TYPE_STAT_DATA)
- return "SD";
- if (cpu_key_k_type (key) == TYPE_DIRENTRY)
- return "DIR";
- if (cpu_key_k_type (key) == TYPE_DIRECT)
- return "DIRECT";
- if (cpu_key_k_type (key) == TYPE_INDIRECT)
- return "IND";
- return "UNKNOWN";
+ if (cpu_key_k_type(key) == TYPE_STAT_DATA)
+ return "SD";
+ if (cpu_key_k_type(key) == TYPE_DIRENTRY)
+ return "DIR";
+ if (cpu_key_k_type(key) == TYPE_DIRECT)
+ return "DIRECT";
+ if (cpu_key_k_type(key) == TYPE_INDIRECT)
+ return "IND";
+ return "UNKNOWN";
}
-
-static char * le_type (struct reiserfs_key * key)
+static char *le_type(struct reiserfs_key *key)
{
- int version;
-
- version = le_key_version (key);
+ int version;
- if (le_key_k_type (version, key) == TYPE_STAT_DATA)
- return "SD";
- if (le_key_k_type (version, key) == TYPE_DIRENTRY)
- return "DIR";
- if (le_key_k_type (version, key) == TYPE_DIRECT)
- return "DIRECT";
- if (le_key_k_type (version, key) == TYPE_INDIRECT)
- return "IND";
- return "UNKNOWN";
-}
+ version = le_key_version(key);
+ if (le_key_k_type(version, key) == TYPE_STAT_DATA)
+ return "SD";
+ if (le_key_k_type(version, key) == TYPE_DIRENTRY)
+ return "DIR";
+ if (le_key_k_type(version, key) == TYPE_DIRECT)
+ return "DIRECT";
+ if (le_key_k_type(version, key) == TYPE_INDIRECT)
+ return "IND";
+ return "UNKNOWN";
+}
/* %k */
-static void sprintf_le_key (char * buf, struct reiserfs_key * key)
+static void sprintf_le_key(char *buf, struct reiserfs_key *key)
{
- if (key)
- sprintf (buf, "[%d %d %s %s]", le32_to_cpu (key->k_dir_id),
- le32_to_cpu (key->k_objectid), le_offset (key), le_type (key));
- else
- sprintf (buf, "[NULL]");
+ if (key)
+ sprintf(buf, "[%d %d %s %s]", le32_to_cpu(key->k_dir_id),
+ le32_to_cpu(key->k_objectid), le_offset(key),
+ le_type(key));
+ else
+ sprintf(buf, "[NULL]");
}
-
/* %K */
-static void sprintf_cpu_key (char * buf, struct cpu_key * key)
+static void sprintf_cpu_key(char *buf, struct cpu_key *key)
{
- if (key)
- sprintf (buf, "[%d %d %s %s]", key->on_disk_key.k_dir_id,
- key->on_disk_key.k_objectid, reiserfs_cpu_offset (key),
- cpu_type (key));
- else
- sprintf (buf, "[NULL]");
+ if (key)
+ sprintf(buf, "[%d %d %s %s]", key->on_disk_key.k_dir_id,
+ key->on_disk_key.k_objectid, reiserfs_cpu_offset(key),
+ cpu_type(key));
+ else
+ sprintf(buf, "[NULL]");
}
-static void sprintf_de_head( char *buf, struct reiserfs_de_head *deh )
+static void sprintf_de_head(char *buf, struct reiserfs_de_head *deh)
{
- if( deh )
- sprintf( buf, "[offset=%d dir_id=%d objectid=%d location=%d state=%04x]", deh_offset(deh), deh_dir_id(deh),
- deh_objectid(deh), deh_location(deh), deh_state(deh) );
- else
- sprintf( buf, "[NULL]" );
+ if (deh)
+ sprintf(buf,
+ "[offset=%d dir_id=%d objectid=%d location=%d state=%04x]",
+ deh_offset(deh), deh_dir_id(deh), deh_objectid(deh),
+ deh_location(deh), deh_state(deh));
+ else
+ sprintf(buf, "[NULL]");
}
-static void sprintf_item_head (char * buf, struct item_head * ih)
+static void sprintf_item_head(char *buf, struct item_head *ih)
{
- if (ih) {
- strcpy (buf, (ih_version (ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*");
- sprintf_le_key (buf + strlen (buf), &(ih->ih_key));
- sprintf (buf + strlen (buf), ", item_len %d, item_location %d, "
- "free_space(entry_count) %d",
- ih_item_len(ih), ih_location(ih), ih_free_space (ih));
- } else
- sprintf (buf, "[NULL]");
+ if (ih) {
+ strcpy(buf,
+ (ih_version(ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*");
+ sprintf_le_key(buf + strlen(buf), &(ih->ih_key));
+ sprintf(buf + strlen(buf), ", item_len %d, item_location %d, "
+ "free_space(entry_count) %d",
+ ih_item_len(ih), ih_location(ih), ih_free_space(ih));
+ } else
+ sprintf(buf, "[NULL]");
}
-
-static void sprintf_direntry (char * buf, struct reiserfs_dir_entry * de)
+static void sprintf_direntry(char *buf, struct reiserfs_dir_entry *de)
{
- char name[20];
+ char name[20];
- memcpy (name, de->de_name, de->de_namelen > 19 ? 19 : de->de_namelen);
- name [de->de_namelen > 19 ? 19 : de->de_namelen] = 0;
- sprintf (buf, "\"%s\"==>[%d %d]", name, de->de_dir_id, de->de_objectid);
+ memcpy(name, de->de_name, de->de_namelen > 19 ? 19 : de->de_namelen);
+ name[de->de_namelen > 19 ? 19 : de->de_namelen] = 0;
+ sprintf(buf, "\"%s\"==>[%d %d]", name, de->de_dir_id, de->de_objectid);
}
-
-static void sprintf_block_head (char * buf, struct buffer_head * bh)
+static void sprintf_block_head(char *buf, struct buffer_head *bh)
{
- sprintf (buf, "level=%d, nr_items=%d, free_space=%d rdkey ",
- B_LEVEL (bh), B_NR_ITEMS (bh), B_FREE_SPACE (bh));
+ sprintf(buf, "level=%d, nr_items=%d, free_space=%d rdkey ",
+ B_LEVEL(bh), B_NR_ITEMS(bh), B_FREE_SPACE(bh));
}
-
-static void sprintf_buffer_head (char * buf, struct buffer_head * bh)
+static void sprintf_buffer_head(char *buf, struct buffer_head *bh)
{
- char b[BDEVNAME_SIZE];
+ char b[BDEVNAME_SIZE];
- sprintf (buf, "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
- bdevname (bh->b_bdev, b), bh->b_size,
- (unsigned long long)bh->b_blocknr,
- atomic_read (&(bh->b_count)),
- bh->b_state, bh->b_page,
- buffer_uptodate (bh) ? "UPTODATE" : "!UPTODATE",
- buffer_dirty (bh) ? "DIRTY" : "CLEAN",
- buffer_locked (bh) ? "LOCKED" : "UNLOCKED");
+ sprintf(buf,
+ "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)",
+ bdevname(bh->b_bdev, b), bh->b_size,
+ (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)),
+ bh->b_state, bh->b_page,
+ buffer_uptodate(bh) ? "UPTODATE" : "!UPTODATE",
+ buffer_dirty(bh) ? "DIRTY" : "CLEAN",
+ buffer_locked(bh) ? "LOCKED" : "UNLOCKED");
}
-
-static void sprintf_disk_child (char * buf, struct disk_child * dc)
+static void sprintf_disk_child(char *buf, struct disk_child *dc)
{
- sprintf (buf, "[dc_number=%d, dc_size=%u]", dc_block_number(dc), dc_size(dc));
+ sprintf(buf, "[dc_number=%d, dc_size=%u]", dc_block_number(dc),
+ dc_size(dc));
}
-
-static char * is_there_reiserfs_struct (char * fmt, int * what, int * skip)
+static char *is_there_reiserfs_struct(char *fmt, int *what, int *skip)
{
- char * k = fmt;
+ char *k = fmt;
- *skip = 0;
-
- while ((k = strchr (k, '%')) != NULL)
- {
- if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
- k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a' ) {
- *what = k[1];
- break;
- }
- (*skip) ++;
- k ++;
- }
- return k;
-}
+ *skip = 0;
+ while ((k = strchr(k, '%')) != NULL) {
+ if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
+ k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') {
+ *what = k[1];
+ break;
+ }
+ (*skip)++;
+ k++;
+ }
+ return k;
+}
/* debugging reiserfs we used to print out a lot of different
variables, like keys, item headers, buffer heads etc. Values of
@@ -191,61 +189,64 @@ static char * is_there_reiserfs_struct (char * fmt, int * what, int * skip)
key->k_offset, key->k_uniqueness);
*/
-
-static void
-prepare_error_buf( const char *fmt, va_list args )
-{
- char * fmt1 = fmt_buf;
- char * k;
- char * p = error_buf;
- int i, j, what, skip;
-
- strcpy (fmt1, fmt);
-
- while( (k = is_there_reiserfs_struct( fmt1, &what, &skip )) != NULL )
- {
- *k = 0;
-
- p += vsprintf (p, fmt1, args);
-
- for (i = 0; i < skip; i ++)
- j = va_arg (args, int);
-
- switch (what) {
- case 'k':
- sprintf_le_key (p, va_arg(args, struct reiserfs_key *));
- break;
- case 'K':
- sprintf_cpu_key (p, va_arg(args, struct cpu_key *));
- break;
- case 'h':
- sprintf_item_head (p, va_arg(args, struct item_head *));
- break;
- case 't':
- sprintf_direntry (p, va_arg(args, struct reiserfs_dir_entry *));
- break;
- case 'y':
- sprintf_disk_child (p, va_arg(args, struct disk_child *));
- break;
- case 'z':
- sprintf_block_head (p, va_arg(args, struct buffer_head *));
- break;
- case 'b':
- sprintf_buffer_head (p, va_arg(args, struct buffer_head *));
- break;
- case 'a':
- sprintf_de_head (p, va_arg(args, struct reiserfs_de_head *));
- break;
- }
-
- p += strlen (p);
- fmt1 = k + 2;
- }
- vsprintf (p, fmt1, args);
+static void prepare_error_buf(const char *fmt, va_list args)
+{
+ char *fmt1 = fmt_buf;
+ char *k;
+ char *p = error_buf;
+ int i, j, what, skip;
+
+ strcpy(fmt1, fmt);
+
+ while ((k = is_there_reiserfs_struct(fmt1, &what, &skip)) != NULL) {
+ *k = 0;
+
+ p += vsprintf(p, fmt1, args);
+
+ for (i = 0; i < skip; i++)
+ j = va_arg(args, int);
+
+ switch (what) {
+ case 'k':
+ sprintf_le_key(p, va_arg(args, struct reiserfs_key *));
+ break;
+ case 'K':
+ sprintf_cpu_key(p, va_arg(args, struct cpu_key *));
+ break;
+ case 'h':
+ sprintf_item_head(p, va_arg(args, struct item_head *));
+ break;
+ case 't':
+ sprintf_direntry(p,
+ va_arg(args,
+ struct reiserfs_dir_entry *));
+ break;
+ case 'y':
+ sprintf_disk_child(p,
+ va_arg(args, struct disk_child *));
+ break;
+ case 'z':
+ sprintf_block_head(p,
+ va_arg(args, struct buffer_head *));
+ break;
+ case 'b':
+ sprintf_buffer_head(p,
+ va_arg(args, struct buffer_head *));
+ break;
+ case 'a':
+ sprintf_de_head(p,
+ va_arg(args,
+ struct reiserfs_de_head *));
+ break;
+ }
+
+ p += strlen(p);
+ fmt1 = k + 2;
+ }
+ vsprintf(p, fmt1, args);
}
-
/* in addition to usual conversion specifiers this accepts reiserfs
specific conversion specifiers:
%k to print little endian key,
@@ -264,43 +265,43 @@ prepare_error_buf( const char *fmt, va_list args )
va_end( args );\
}
-void reiserfs_warning (struct super_block *sb, const char * fmt, ...)
+void reiserfs_warning(struct super_block *sb, const char *fmt, ...)
{
- do_reiserfs_warning(fmt);
- if (sb)
- printk (KERN_WARNING "ReiserFS: %s: warning: %s\n",
- reiserfs_bdevname (sb), error_buf);
- else
- printk (KERN_WARNING "ReiserFS: warning: %s\n", error_buf);
+ do_reiserfs_warning(fmt);
+ if (sb)
+ printk(KERN_WARNING "ReiserFS: %s: warning: %s\n",
+ reiserfs_bdevname(sb), error_buf);
+ else
+ printk(KERN_WARNING "ReiserFS: warning: %s\n", error_buf);
}
/* No newline.. reiserfs_info calls can be followed by printk's */
-void reiserfs_info (struct super_block *sb, const char * fmt, ...)
+void reiserfs_info(struct super_block *sb, const char *fmt, ...)
{
- do_reiserfs_warning(fmt);
- if (sb)
- printk (KERN_NOTICE "ReiserFS: %s: %s",
- reiserfs_bdevname (sb), error_buf);
- else
- printk (KERN_NOTICE "ReiserFS: %s", error_buf);
+ do_reiserfs_warning(fmt);
+ if (sb)
+ printk(KERN_NOTICE "ReiserFS: %s: %s",
+ reiserfs_bdevname(sb), error_buf);
+ else
+ printk(KERN_NOTICE "ReiserFS: %s", error_buf);
}
/* No newline.. reiserfs_printk calls can be followed by printk's */
-static void reiserfs_printk (const char * fmt, ...)
+static void reiserfs_printk(const char *fmt, ...)
{
- do_reiserfs_warning(fmt);
- printk (error_buf);
+ do_reiserfs_warning(fmt);
+ printk(error_buf);
}
-void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...)
+void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...)
{
#ifdef CONFIG_REISERFS_CHECK
- do_reiserfs_warning(fmt);
- if (s)
- printk (KERN_DEBUG "ReiserFS: %s: %s\n",
- reiserfs_bdevname (s), error_buf);
- else
- printk (KERN_DEBUG "ReiserFS: %s\n", error_buf);
+ do_reiserfs_warning(fmt);
+ if (s)
+ printk(KERN_DEBUG "ReiserFS: %s: %s\n",
+ reiserfs_bdevname(s), error_buf);
+ else
+ printk(KERN_DEBUG "ReiserFS: %s\n", error_buf);
#endif
}
@@ -349,379 +350,403 @@ void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...)
. */
-
#ifdef CONFIG_REISERFS_CHECK
-extern struct tree_balance * cur_tb;
+extern struct tree_balance *cur_tb;
#endif
-void reiserfs_panic (struct super_block * sb, const char * fmt, ...)
+void reiserfs_panic(struct super_block *sb, const char *fmt, ...)
{
- do_reiserfs_warning(fmt);
- printk (KERN_EMERG "REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname (sb), error_buf);
- BUG ();
+ do_reiserfs_warning(fmt);
+ printk(KERN_EMERG "REISERFS: panic (device %s): %s\n",
+ reiserfs_bdevname(sb), error_buf);
+ BUG();
- /* this is not actually called, but makes reiserfs_panic() "noreturn" */
- panic ("REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname (sb), error_buf);
+ /* this is not actually called, but makes reiserfs_panic() "noreturn" */
+ panic("REISERFS: panic (device %s): %s\n",
+ reiserfs_bdevname(sb), error_buf);
}
-void
-reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...)
+void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
{
- do_reiserfs_warning (fmt);
+ do_reiserfs_warning(fmt);
- if (reiserfs_error_panic (sb)) {
- panic (KERN_CRIT "REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname (sb), error_buf);
- }
+ if (reiserfs_error_panic(sb)) {
+ panic(KERN_CRIT "REISERFS: panic (device %s): %s\n",
+ reiserfs_bdevname(sb), error_buf);
+ }
- if (sb->s_flags & MS_RDONLY)
- return;
+ if (sb->s_flags & MS_RDONLY)
+ return;
- printk (KERN_CRIT "REISERFS: abort (device %s): %s\n",
- reiserfs_bdevname (sb), error_buf);
+ printk(KERN_CRIT "REISERFS: abort (device %s): %s\n",
+ reiserfs_bdevname(sb), error_buf);
- sb->s_flags |= MS_RDONLY;
- reiserfs_journal_abort (sb, errno);
+ sb->s_flags |= MS_RDONLY;
+ reiserfs_journal_abort(sb, errno);
}
/* this prints internal nodes (4 keys/items in line) (dc_number,
dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number,
dc_size)...*/
-static int print_internal (struct buffer_head * bh, int first, int last)
+static int print_internal(struct buffer_head *bh, int first, int last)
{
- struct reiserfs_key * key;
- struct disk_child * dc;
- int i;
- int from, to;
-
- if (!B_IS_KEYS_LEVEL (bh))
- return 1;
-
- check_internal (bh);
-
- if (first == -1) {
- from = 0;
- to = B_NR_ITEMS (bh);
- } else {
- from = first;
- to = last < B_NR_ITEMS (bh) ? last : B_NR_ITEMS (bh);
- }
-
- reiserfs_printk ("INTERNAL NODE (%ld) contains %z\n", bh->b_blocknr, bh);
-
- dc = B_N_CHILD (bh, from);
- reiserfs_printk ("PTR %d: %y ", from, dc);
-
- for (i = from, key = B_N_PDELIM_KEY (bh, from), dc ++; i < to; i ++, key ++, dc ++) {
- reiserfs_printk ("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
- if (i && i % 4 == 0)
- printk ("\n");
- }
- printk ("\n");
- return 0;
-}
+ struct reiserfs_key *key;
+ struct disk_child *dc;
+ int i;
+ int from, to;
+ if (!B_IS_KEYS_LEVEL(bh))
+ return 1;
+ check_internal(bh);
+ if (first == -1) {
+ from = 0;
+ to = B_NR_ITEMS(bh);
+ } else {
+ from = first;
+ to = last < B_NR_ITEMS(bh) ? last : B_NR_ITEMS(bh);
+ }
+ reiserfs_printk("INTERNAL NODE (%ld) contains %z\n", bh->b_blocknr, bh);
-static int print_leaf (struct buffer_head * bh, int print_mode, int first, int last)
-{
- struct block_head * blkh;
- struct item_head * ih;
- int i, nr;
- int from, to;
+ dc = B_N_CHILD(bh, from);
+ reiserfs_printk("PTR %d: %y ", from, dc);
- if (!B_IS_ITEMS_LEVEL (bh))
- return 1;
+ for (i = from, key = B_N_PDELIM_KEY(bh, from), dc++; i < to;
+ i++, key++, dc++) {
+ reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc);
+ if (i && i % 4 == 0)
+ printk("\n");
+ }
+ printk("\n");
+ return 0;
+}
- check_leaf (bh);
+static int print_leaf(struct buffer_head *bh, int print_mode, int first,
+ int last)
+{
+ struct block_head *blkh;
+ struct item_head *ih;
+ int i, nr;
+ int from, to;
- blkh = B_BLK_HEAD (bh);
- ih = B_N_PITEM_HEAD (bh,0);
- nr = blkh_nr_item(blkh);
+ if (!B_IS_ITEMS_LEVEL(bh))
+ return 1;
- printk ("\n===================================================================\n");
- reiserfs_printk ("LEAF NODE (%ld) contains %z\n", bh->b_blocknr, bh);
+ check_leaf(bh);
- if (!(print_mode & PRINT_LEAF_ITEMS)) {
- reiserfs_printk ("FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n",
- &(ih->ih_key), &((ih + nr - 1)->ih_key));
- return 0;
- }
+ blkh = B_BLK_HEAD(bh);
+ ih = B_N_PITEM_HEAD(bh, 0);
+ nr = blkh_nr_item(blkh);
- if (first < 0 || first > nr - 1)
- from = 0;
- else
- from = first;
+ printk
+ ("\n===================================================================\n");
+ reiserfs_printk("LEAF NODE (%ld) contains %z\n", bh->b_blocknr, bh);
- if (last < 0 || last > nr )
- to = nr;
- else
- to = last;
+ if (!(print_mode & PRINT_LEAF_ITEMS)) {
+ reiserfs_printk("FIRST ITEM_KEY: %k, LAST ITEM KEY: %k\n",
+ &(ih->ih_key), &((ih + nr - 1)->ih_key));
+ return 0;
+ }
- ih += from;
- printk ("-------------------------------------------------------------------------------\n");
- printk ("|##| type | key | ilen | free_space | version | loc |\n");
- for (i = from; i < to; i++, ih ++) {
- printk ("-------------------------------------------------------------------------------\n");
- reiserfs_printk ("|%2d| %h |\n", i, ih);
- if (print_mode & PRINT_LEAF_ITEMS)
- op_print_item (ih, B_I_PITEM (bh, ih));
- }
+ if (first < 0 || first > nr - 1)
+ from = 0;
+ else
+ from = first;
+
+ if (last < 0 || last > nr)
+ to = nr;
+ else
+ to = last;
+
+ ih += from;
+ printk
+ ("-------------------------------------------------------------------------------\n");
+ printk
+ ("|##| type | key | ilen | free_space | version | loc |\n");
+ for (i = from; i < to; i++, ih++) {
+ printk
+ ("-------------------------------------------------------------------------------\n");
+ reiserfs_printk("|%2d| %h |\n", i, ih);
+ if (print_mode & PRINT_LEAF_ITEMS)
+ op_print_item(ih, B_I_PITEM(bh, ih));
+ }
- printk ("===================================================================\n");
+ printk
+ ("===================================================================\n");
- return 0;
+ return 0;
}
-char * reiserfs_hashname(int code)
+char *reiserfs_hashname(int code)
{
- if ( code == YURA_HASH)
- return "rupasov";
- if ( code == TEA_HASH)
- return "tea";
- if ( code == R5_HASH)
- return "r5";
+ if (code == YURA_HASH)
+ return "rupasov";
+ if (code == TEA_HASH)
+ return "tea";
+ if (code == R5_HASH)
+ return "r5";
- return "unknown";
+ return "unknown";
}
/* return 1 if this is not super block */
-static int print_super_block (struct buffer_head * bh)
-{
- struct reiserfs_super_block * rs = (struct reiserfs_super_block *)(bh->b_data);
- int skipped, data_blocks;
- char *version;
- char b[BDEVNAME_SIZE];
-
- if (is_reiserfs_3_5(rs)) {
- version = "3.5";
- } else if (is_reiserfs_3_6(rs)) {
- version = "3.6";
- } else if (is_reiserfs_jr(rs)) {
- version = ((sb_version(rs) == REISERFS_VERSION_2) ?
- "3.6" : "3.5");
- } else {
- return 1;
- }
-
- printk ("%s\'s super block is in block %llu\n", bdevname (bh->b_bdev, b),
- (unsigned long long)bh->b_blocknr);
- printk ("Reiserfs version %s\n", version );
- printk ("Block count %u\n", sb_block_count(rs));
- printk ("Blocksize %d\n", sb_blocksize(rs));
- printk ("Free blocks %u\n", sb_free_blocks(rs));
- // FIXME: this would be confusing if
- // someone stores reiserfs super block in some data block ;)
+static int print_super_block(struct buffer_head *bh)
+{
+ struct reiserfs_super_block *rs =
+ (struct reiserfs_super_block *)(bh->b_data);
+ int skipped, data_blocks;
+ char *version;
+ char b[BDEVNAME_SIZE];
+
+ if (is_reiserfs_3_5(rs)) {
+ version = "3.5";
+ } else if (is_reiserfs_3_6(rs)) {
+ version = "3.6";
+ } else if (is_reiserfs_jr(rs)) {
+ version = ((sb_version(rs) == REISERFS_VERSION_2) ?
+ "3.6" : "3.5");
+ } else {
+ return 1;
+ }
+
+ printk("%s\'s super block is in block %llu\n", bdevname(bh->b_bdev, b),
+ (unsigned long long)bh->b_blocknr);
+ printk("Reiserfs version %s\n", version);
+ printk("Block count %u\n", sb_block_count(rs));
+ printk("Blocksize %d\n", sb_blocksize(rs));
+ printk("Free blocks %u\n", sb_free_blocks(rs));
+ // FIXME: this would be confusing if
+ // someone stores reiserfs super block in some data block ;)
// skipped = (bh->b_blocknr * bh->b_size) / sb_blocksize(rs);
- skipped = bh->b_blocknr;
- data_blocks = sb_block_count(rs) - skipped - 1 - sb_bmap_nr(rs) -
- (!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) + 1 : sb_reserved_for_journal(rs)) -
- sb_free_blocks(rs);
- printk ("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
- "1 super block, %d data blocks\n",
- skipped, sb_bmap_nr(rs), (!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) :
- sb_reserved_for_journal(rs)) , data_blocks);
- printk ("Root block %u\n", sb_root_block(rs));
- printk ("Journal block (first) %d\n", sb_jp_journal_1st_block(rs));
- printk ("Journal dev %d\n", sb_jp_journal_dev(rs));
- printk ("Journal orig size %d\n", sb_jp_journal_size(rs));
- printk ("FS state %d\n", sb_fs_state(rs));
- printk ("Hash function \"%s\"\n",
- reiserfs_hashname(sb_hash_function_code(rs)));
-
- printk ("Tree height %d\n", sb_tree_height(rs));
- return 0;
+ skipped = bh->b_blocknr;
+ data_blocks = sb_block_count(rs) - skipped - 1 - sb_bmap_nr(rs) -
+ (!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) +
+ 1 : sb_reserved_for_journal(rs)) - sb_free_blocks(rs);
+ printk
+ ("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d\n"
+ "1 super block, %d data blocks\n", skipped, sb_bmap_nr(rs),
+ (!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) :
+ sb_reserved_for_journal(rs)), data_blocks);
+ printk("Root block %u\n", sb_root_block(rs));
+ printk("Journal block (first) %d\n", sb_jp_journal_1st_block(rs));
+ printk("Journal dev %d\n", sb_jp_journal_dev(rs));
+ printk("Journal orig size %d\n", sb_jp_journal_size(rs));
+ printk("FS state %d\n", sb_fs_state(rs));
+ printk("Hash function \"%s\"\n",
+ reiserfs_hashname(sb_hash_function_code(rs)));
+
+ printk("Tree height %d\n", sb_tree_height(rs));
+ return 0;
}
-static int print_desc_block (struct buffer_head * bh)
+static int print_desc_block(struct buffer_head *bh)
{
- struct reiserfs_journal_desc * desc;
+ struct reiserfs_journal_desc *desc;
- if (memcmp(get_journal_desc_magic (bh), JOURNAL_DESC_MAGIC, 8))
- return 1;
+ if (memcmp(get_journal_desc_magic(bh), JOURNAL_DESC_MAGIC, 8))
+ return 1;
- desc = (struct reiserfs_journal_desc *)(bh->b_data);
- printk ("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)",
- (unsigned long long)bh->b_blocknr, get_desc_trans_id (desc), get_desc_mount_id (desc),
- get_desc_trans_len (desc));
+ desc = (struct reiserfs_journal_desc *)(bh->b_data);
+ printk("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)",
+ (unsigned long long)bh->b_blocknr, get_desc_trans_id(desc),
+ get_desc_mount_id(desc), get_desc_trans_len(desc));
- return 0;
+ return 0;
}
-
-void print_block (struct buffer_head * bh, ...)//int print_mode, int first, int last)
+void print_block(struct buffer_head *bh, ...) //int print_mode, int first, int last)
{
- va_list args;
- int mode, first, last;
+ va_list args;
+ int mode, first, last;
- va_start (args, bh);
+ va_start(args, bh);
- if ( ! bh ) {
- printk("print_block: buffer is NULL\n");
- return;
- }
+ if (!bh) {
+ printk("print_block: buffer is NULL\n");
+ return;
+ }
- mode = va_arg (args, int);
- first = va_arg (args, int);
- last = va_arg (args, int);
- if (print_leaf (bh, mode, first, last))
- if (print_internal (bh, first, last))
- if (print_super_block (bh))
- if (print_desc_block (bh))
- printk ("Block %llu contains unformatted data\n", (unsigned long long)bh->b_blocknr);
+ mode = va_arg(args, int);
+ first = va_arg(args, int);
+ last = va_arg(args, int);
+ if (print_leaf(bh, mode, first, last))
+ if (print_internal(bh, first, last))
+ if (print_super_block(bh))
+ if (print_desc_block(bh))
+ printk
+ ("Block %llu contains unformatted data\n",
+ (unsigned long long)bh->b_blocknr);
}
-
-
static char print_tb_buf[2048];
/* this stores initial state of tree balance in the print_tb_buf */
-void store_print_tb (struct tree_balance * tb)
-{
- int h = 0;
- int i;
- struct buffer_head * tbSh, * tbFh;
-
- if (!tb)
- return;
-
- sprintf (print_tb_buf, "\n"
- "BALANCING %d\n"
- "MODE=%c, ITEM_POS=%d POS_IN_ITEM=%d\n"
- "=====================================================================\n"
- "* h * S * L * R * F * FL * FR * CFL * CFR *\n",
- REISERFS_SB(tb->tb_sb)->s_do_balance,
- tb->tb_mode, PATH_LAST_POSITION (tb->tb_path), tb->tb_path->pos_in_item);
-
- for (h = 0; h < sizeof(tb->insert_size) / sizeof (tb->insert_size[0]); h ++) {
- if (PATH_H_PATH_OFFSET (tb->tb_path, h) <= tb->tb_path->path_length &&
- PATH_H_PATH_OFFSET (tb->tb_path, h) > ILLEGAL_PATH_ELEMENT_OFFSET) {
- tbSh = PATH_H_PBUFFER (tb->tb_path, h);
- tbFh = PATH_H_PPARENT (tb->tb_path, h);
- } else {
- tbSh = NULL;
- tbFh = NULL;
+void store_print_tb(struct tree_balance *tb)
+{
+ int h = 0;
+ int i;
+ struct buffer_head *tbSh, *tbFh;
+
+ if (!tb)
+ return;
+
+ sprintf(print_tb_buf, "\n"
+ "BALANCING %d\n"
+ "MODE=%c, ITEM_POS=%d POS_IN_ITEM=%d\n"
+ "=====================================================================\n"
+ "* h * S * L * R * F * FL * FR * CFL * CFR *\n",
+ REISERFS_SB(tb->tb_sb)->s_do_balance,
+ tb->tb_mode, PATH_LAST_POSITION(tb->tb_path),
+ tb->tb_path->pos_in_item);
+
+ for (h = 0; h < sizeof(tb->insert_size) / sizeof(tb->insert_size[0]);
+ h++) {
+ if (PATH_H_PATH_OFFSET(tb->tb_path, h) <=
+ tb->tb_path->path_length
+ && PATH_H_PATH_OFFSET(tb->tb_path,
+ h) > ILLEGAL_PATH_ELEMENT_OFFSET) {
+ tbSh = PATH_H_PBUFFER(tb->tb_path, h);
+ tbFh = PATH_H_PPARENT(tb->tb_path, h);
+ } else {
+ tbSh = NULL;
+ tbFh = NULL;
+ }
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "* %d * %3lld(%2d) * %3lld(%2d) * %3lld(%2d) * %5lld * %5lld * %5lld * %5lld * %5lld *\n",
+ h,
+ (tbSh) ? (long long)(tbSh->b_blocknr) : (-1LL),
+ (tbSh) ? atomic_read(&(tbSh->b_count)) : -1,
+ (tb->L[h]) ? (long long)(tb->L[h]->b_blocknr) : (-1LL),
+ (tb->L[h]) ? atomic_read(&(tb->L[h]->b_count)) : -1,
+ (tb->R[h]) ? (long long)(tb->R[h]->b_blocknr) : (-1LL),
+ (tb->R[h]) ? atomic_read(&(tb->R[h]->b_count)) : -1,
+ (tbFh) ? (long long)(tbFh->b_blocknr) : (-1LL),
+ (tb->FL[h]) ? (long long)(tb->FL[h]->
+ b_blocknr) : (-1LL),
+ (tb->FR[h]) ? (long long)(tb->FR[h]->
+ b_blocknr) : (-1LL),
+ (tb->CFL[h]) ? (long long)(tb->CFL[h]->
+ b_blocknr) : (-1LL),
+ (tb->CFR[h]) ? (long long)(tb->CFR[h]->
+ b_blocknr) : (-1LL));
}
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "* %d * %3lld(%2d) * %3lld(%2d) * %3lld(%2d) * %5lld * %5lld * %5lld * %5lld * %5lld *\n",
- h,
- (tbSh) ? (long long)(tbSh->b_blocknr):(-1LL),
- (tbSh) ? atomic_read (&(tbSh->b_count)) : -1,
- (tb->L[h]) ? (long long)(tb->L[h]->b_blocknr):(-1LL),
- (tb->L[h]) ? atomic_read (&(tb->L[h]->b_count)) : -1,
- (tb->R[h]) ? (long long)(tb->R[h]->b_blocknr):(-1LL),
- (tb->R[h]) ? atomic_read (&(tb->R[h]->b_count)) : -1,
- (tbFh) ? (long long)(tbFh->b_blocknr):(-1LL),
- (tb->FL[h]) ? (long long)(tb->FL[h]->b_blocknr):(-1LL),
- (tb->FR[h]) ? (long long)(tb->FR[h]->b_blocknr):(-1LL),
- (tb->CFL[h]) ? (long long)(tb->CFL[h]->b_blocknr):(-1LL),
- (tb->CFR[h]) ? (long long)(tb->CFR[h]->b_blocknr):(-1LL));
- }
-
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "=====================================================================\n"
- "* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n"
- "* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
- tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0],tb->rbytes, tb->blknum[0],
- tb->s0num, tb->s1num,tb->s1bytes, tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[0], tb->rkey[0]);
-
- /* this prints balance parameters for non-leaf levels */
- h = 0;
- do {
- h++;
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "* %d * %4d * %2d * * %2d * * %2d *\n",
- h, tb->insert_size[h], tb->lnum[h], tb->rnum[h], tb->blknum[h]);
- } while (tb->insert_size[h]);
-
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "=====================================================================\n"
- "FEB list: ");
-
- /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */
- h = 0;
- for (i = 0; i < sizeof (tb->FEB) / sizeof (tb->FEB[0]); i ++)
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "%p (%llu %d)%s", tb->FEB[i], tb->FEB[i] ? (unsigned long long)tb->FEB[i]->b_blocknr : 0ULL,
- tb->FEB[i] ? atomic_read (&(tb->FEB[i]->b_count)) : 0,
- (i == sizeof (tb->FEB) / sizeof (tb->FEB[0]) - 1) ? "\n" : ", ");
-
- sprintf (print_tb_buf + strlen (print_tb_buf),
- "======================== the end ====================================\n");
-}
-
-void print_cur_tb (char * mes)
-{
- printk ("%s\n%s", mes, print_tb_buf);
-}
-
-static void check_leaf_block_head (struct buffer_head * bh)
-{
- struct block_head * blkh;
- int nr;
-
- blkh = B_BLK_HEAD (bh);
- nr = blkh_nr_item(blkh);
- if ( nr > (bh->b_size - BLKH_SIZE) / IH_SIZE)
- reiserfs_panic (NULL, "vs-6010: check_leaf_block_head: invalid item number %z", bh);
- if ( blkh_free_space(blkh) >
- bh->b_size - BLKH_SIZE - IH_SIZE * nr )
- reiserfs_panic (NULL, "vs-6020: check_leaf_block_head: invalid free space %z", bh);
-
-}
-static void check_internal_block_head (struct buffer_head * bh)
-{
- struct block_head * blkh;
-
- blkh = B_BLK_HEAD (bh);
- if (!(B_LEVEL (bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL (bh) <= MAX_HEIGHT))
- reiserfs_panic (NULL, "vs-6025: check_internal_block_head: invalid level %z", bh);
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "=====================================================================\n"
+ "* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n"
+ "* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
+ tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0],
+ tb->rbytes, tb->blknum[0], tb->s0num, tb->s1num, tb->s1bytes,
+ tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[0],
+ tb->rkey[0]);
+
+ /* this prints balance parameters for non-leaf levels */
+ h = 0;
+ do {
+ h++;
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "* %d * %4d * %2d * * %2d * * %2d *\n",
+ h, tb->insert_size[h], tb->lnum[h], tb->rnum[h],
+ tb->blknum[h]);
+ } while (tb->insert_size[h]);
- if (B_NR_ITEMS (bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE)
- reiserfs_panic (NULL, "vs-6030: check_internal_block_head: invalid item number %z", bh);
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "=====================================================================\n"
+ "FEB list: ");
- if (B_FREE_SPACE (bh) !=
- bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS (bh) - DC_SIZE * (B_NR_ITEMS (bh) + 1))
- reiserfs_panic (NULL, "vs-6040: check_internal_block_head: invalid free space %z", bh);
+ /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */
+ h = 0;
+ for (i = 0; i < sizeof(tb->FEB) / sizeof(tb->FEB[0]); i++)
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "%p (%llu %d)%s", tb->FEB[i],
+ tb->FEB[i] ? (unsigned long long)tb->FEB[i]->
+ b_blocknr : 0ULL,
+ tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0,
+ (i ==
+ sizeof(tb->FEB) / sizeof(tb->FEB[0]) -
+ 1) ? "\n" : ", ");
+ sprintf(print_tb_buf + strlen(print_tb_buf),
+ "======================== the end ====================================\n");
}
+void print_cur_tb(char *mes)
+{
+ printk("%s\n%s", mes, print_tb_buf);
+}
-void check_leaf (struct buffer_head * bh)
+static void check_leaf_block_head(struct buffer_head *bh)
{
- int i;
- struct item_head * ih;
+ struct block_head *blkh;
+ int nr;
+
+ blkh = B_BLK_HEAD(bh);
+ nr = blkh_nr_item(blkh);
+ if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE)
+ reiserfs_panic(NULL,
+ "vs-6010: check_leaf_block_head: invalid item number %z",
+ bh);
+ if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr)
+ reiserfs_panic(NULL,
+ "vs-6020: check_leaf_block_head: invalid free space %z",
+ bh);
- if (!bh)
- return;
- check_leaf_block_head (bh);
- for (i = 0, ih = B_N_PITEM_HEAD (bh, 0); i < B_NR_ITEMS (bh); i ++, ih ++)
- op_check_item (ih, B_I_PITEM (bh, ih));
}
+static void check_internal_block_head(struct buffer_head *bh)
+{
+ struct block_head *blkh;
+
+ blkh = B_BLK_HEAD(bh);
+ if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT))
+ reiserfs_panic(NULL,
+ "vs-6025: check_internal_block_head: invalid level %z",
+ bh);
+
+ if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE)
+ reiserfs_panic(NULL,
+ "vs-6030: check_internal_block_head: invalid item number %z",
+ bh);
+
+ if (B_FREE_SPACE(bh) !=
+ bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) -
+ DC_SIZE * (B_NR_ITEMS(bh) + 1))
+ reiserfs_panic(NULL,
+ "vs-6040: check_internal_block_head: invalid free space %z",
+ bh);
+
+}
-void check_internal (struct buffer_head * bh)
+void check_leaf(struct buffer_head *bh)
{
- if (!bh)
- return;
- check_internal_block_head (bh);
+ int i;
+ struct item_head *ih;
+
+ if (!bh)
+ return;
+ check_leaf_block_head(bh);
+ for (i = 0, ih = B_N_PITEM_HEAD(bh, 0); i < B_NR_ITEMS(bh); i++, ih++)
+ op_check_item(ih, B_I_PITEM(bh, ih));
}
+void check_internal(struct buffer_head *bh)
+{
+ if (!bh)
+ return;
+ check_internal_block_head(bh);
+}
-void print_statistics (struct super_block * s)
+void print_statistics(struct super_block *s)
{
- /*
- printk ("reiserfs_put_super: session statistics: balances %d, fix_nodes %d, \
-bmap with search %d, without %d, dir2ind %d, ind2dir %d\n",
- REISERFS_SB(s)->s_do_balance, REISERFS_SB(s)->s_fix_nodes,
- REISERFS_SB(s)->s_bmaps, REISERFS_SB(s)->s_bmaps_without_search,
- REISERFS_SB(s)->s_direct2indirect, REISERFS_SB(s)->s_indirect2direct);
- */
+ /*
+ printk ("reiserfs_put_super: session statistics: balances %d, fix_nodes %d, \
+ bmap with search %d, without %d, dir2ind %d, ind2dir %d\n",
+ REISERFS_SB(s)->s_do_balance, REISERFS_SB(s)->s_fix_nodes,
+ REISERFS_SB(s)->s_bmaps, REISERFS_SB(s)->s_bmaps_without_search,
+ REISERFS_SB(s)->s_direct2indirect, REISERFS_SB(s)->s_indirect2direct);
+ */
}
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index e242ebc7f6f..fc2f43c75df 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -33,28 +33,27 @@
static int show_version(struct seq_file *m, struct super_block *sb)
{
char *format;
-
- if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6) ) {
+
+ if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
format = "3.6";
- } else if ( REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5) ) {
+ } else if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_5)) {
format = "3.5";
} else {
format = "unknown";
}
- seq_printf(m, "%s format\twith checks %s\n",
- format,
+ seq_printf(m, "%s format\twith checks %s\n", format,
#if defined( CONFIG_REISERFS_CHECK )
- "on"
+ "on"
#else
- "off"
+ "off"
#endif
- );
+ );
return 0;
}
-int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset,
- int count, int *eof, void *data )
+int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
+ int count, int *eof, void *data)
{
*start = buffer;
*eof = 1;
@@ -79,87 +78,68 @@ int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset,
#define DJF( x ) le32_to_cpu( rs -> x )
#define DJV( x ) le32_to_cpu( s_v1 -> x )
-#define DJP( x ) le32_to_cpu( jp -> x )
+#define DJP( x ) le32_to_cpu( jp -> x )
#define JF( x ) ( r -> s_journal -> x )
static int show_super(struct seq_file *m, struct super_block *sb)
{
struct reiserfs_sb_info *r = REISERFS_SB(sb);
-
- seq_printf(m, "state: \t%s\n"
- "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
- "gen. counter: \t%i\n"
- "s_kmallocs: \t%i\n"
- "s_disk_reads: \t%i\n"
- "s_disk_writes: \t%i\n"
- "s_fix_nodes: \t%i\n"
- "s_do_balance: \t%i\n"
- "s_unneeded_left_neighbor: \t%i\n"
- "s_good_search_by_key_reada: \t%i\n"
- "s_bmaps: \t%i\n"
- "s_bmaps_without_search: \t%i\n"
- "s_direct2indirect: \t%i\n"
- "s_indirect2direct: \t%i\n"
- "\n"
- "max_hash_collisions: \t%i\n"
-
- "breads: \t%lu\n"
- "bread_misses: \t%lu\n"
-
- "search_by_key: \t%lu\n"
- "search_by_key_fs_changed: \t%lu\n"
- "search_by_key_restarted: \t%lu\n"
-
- "insert_item_restarted: \t%lu\n"
- "paste_into_item_restarted: \t%lu\n"
- "cut_from_item_restarted: \t%lu\n"
- "delete_solid_item_restarted: \t%lu\n"
- "delete_item_restarted: \t%lu\n"
-
- "leaked_oid: \t%lu\n"
- "leaves_removable: \t%lu\n",
-
- SF( s_mount_state ) == REISERFS_VALID_FS ?
- "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
- reiserfs_r5_hash( sb ) ? "FORCE_R5 " : "",
- reiserfs_rupasov_hash( sb ) ? "FORCE_RUPASOV " : "",
- reiserfs_tea_hash( sb ) ? "FORCE_TEA " : "",
- reiserfs_hash_detect( sb ) ? "DETECT_HASH " : "",
- reiserfs_no_border( sb ) ? "NO_BORDER " : "BORDER ",
- reiserfs_no_unhashed_relocation( sb ) ? "NO_UNHASHED_RELOCATION " : "",
- reiserfs_hashed_relocation( sb ) ? "UNHASHED_RELOCATION " : "",
- reiserfs_test4( sb ) ? "TEST4 " : "",
- have_large_tails( sb ) ? "TAILS " : have_small_tails(sb)?"SMALL_TAILS ":"NO_TAILS ",
- replay_only( sb ) ? "REPLAY_ONLY " : "",
- convert_reiserfs( sb ) ? "CONV " : "",
-
- atomic_read( &r -> s_generation_counter ),
- SF( s_kmallocs ),
- SF( s_disk_reads ),
- SF( s_disk_writes ),
- SF( s_fix_nodes ),
- SF( s_do_balance ),
- SF( s_unneeded_left_neighbor ),
- SF( s_good_search_by_key_reada ),
- SF( s_bmaps ),
- SF( s_bmaps_without_search ),
- SF( s_direct2indirect ),
- SF( s_indirect2direct ),
- SFP( max_hash_collisions ),
- SFP( breads ),
- SFP( bread_miss ),
- SFP( search_by_key ),
- SFP( search_by_key_fs_changed ),
- SFP( search_by_key_restarted ),
-
- SFP( insert_item_restarted ),
- SFP( paste_into_item_restarted ),
- SFP( cut_from_item_restarted ),
- SFP( delete_solid_item_restarted ),
- SFP( delete_item_restarted ),
-
- SFP( leaked_oid ),
- SFP( leaves_removable ) );
+
+ seq_printf(m, "state: \t%s\n"
+ "mount options: \t%s%s%s%s%s%s%s%s%s%s%s\n"
+ "gen. counter: \t%i\n"
+ "s_kmallocs: \t%i\n"
+ "s_disk_reads: \t%i\n"
+ "s_disk_writes: \t%i\n"
+ "s_fix_nodes: \t%i\n"
+ "s_do_balance: \t%i\n"
+ "s_unneeded_left_neighbor: \t%i\n"
+ "s_good_search_by_key_reada: \t%i\n"
+ "s_bmaps: \t%i\n"
+ "s_bmaps_without_search: \t%i\n"
+ "s_direct2indirect: \t%i\n"
+ "s_indirect2direct: \t%i\n"
+ "\n"
+ "max_hash_collisions: \t%i\n"
+ "breads: \t%lu\n"
+ "bread_misses: \t%lu\n"
+ "search_by_key: \t%lu\n"
+ "search_by_key_fs_changed: \t%lu\n"
+ "search_by_key_restarted: \t%lu\n"
+ "insert_item_restarted: \t%lu\n"
+ "paste_into_item_restarted: \t%lu\n"
+ "cut_from_item_restarted: \t%lu\n"
+ "delete_solid_item_restarted: \t%lu\n"
+ "delete_item_restarted: \t%lu\n"
+ "leaked_oid: \t%lu\n"
+ "leaves_removable: \t%lu\n",
+ SF(s_mount_state) == REISERFS_VALID_FS ?
+ "REISERFS_VALID_FS" : "REISERFS_ERROR_FS",
+ reiserfs_r5_hash(sb) ? "FORCE_R5 " : "",
+ reiserfs_rupasov_hash(sb) ? "FORCE_RUPASOV " : "",
+ reiserfs_tea_hash(sb) ? "FORCE_TEA " : "",
+ reiserfs_hash_detect(sb) ? "DETECT_HASH " : "",
+ reiserfs_no_border(sb) ? "NO_BORDER " : "BORDER ",
+ reiserfs_no_unhashed_relocation(sb) ?
+ "NO_UNHASHED_RELOCATION " : "",
+ reiserfs_hashed_relocation(sb) ? "UNHASHED_RELOCATION " : "",
+ reiserfs_test4(sb) ? "TEST4 " : "",
+ have_large_tails(sb) ? "TAILS " : have_small_tails(sb) ?
+ "SMALL_TAILS " : "NO_TAILS ",
+ replay_only(sb) ? "REPLAY_ONLY " : "",
+ convert_reiserfs(sb) ? "CONV " : "",
+ atomic_read(&r->s_generation_counter), SF(s_kmallocs),
+ SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
+ SF(s_do_balance), SF(s_unneeded_left_neighbor),
+ SF(s_good_search_by_key_reada), SF(s_bmaps),
+ SF(s_bmaps_without_search), SF(s_direct2indirect),
+ SF(s_indirect2direct), SFP(max_hash_collisions), SFP(breads),
+ SFP(bread_miss), SFP(search_by_key),
+ SFP(search_by_key_fs_changed), SFP(search_by_key_restarted),
+ SFP(insert_item_restarted), SFP(paste_into_item_restarted),
+ SFP(cut_from_item_restarted),
+ SFP(delete_solid_item_restarted), SFP(delete_item_restarted),
+ SFP(leaked_oid), SFP(leaves_removable));
return 0;
}
@@ -169,61 +149,55 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
struct reiserfs_sb_info *r = REISERFS_SB(sb);
int level;
- seq_printf(m, "level\t"
- " balances"
- " [sbk: reads"
- " fs_changed"
- " restarted]"
- " free space"
- " items"
- " can_remove"
- " lnum"
- " rnum"
- " lbytes"
- " rbytes"
- " get_neig"
- " get_neig_res"
- " need_l_neig"
- " need_r_neig"
- "\n"
-
- );
-
- for( level = 0 ; level < MAX_HEIGHT ; ++ level ) {
- seq_printf(m, "%i\t"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12li"
- " %12li"
- " %12li"
- " %12li"
- " %12lu"
- " %12lu"
- " %12lu"
- " %12lu"
- "\n",
- level,
- SFPL( balance_at ),
- SFPL( sbk_read_at ),
- SFPL( sbk_fs_changed ),
- SFPL( sbk_restarted ),
- SFPL( free_at ),
- SFPL( items_at ),
- SFPL( can_node_be_removed ),
- SFPL( lnum ),
- SFPL( rnum ),
- SFPL( lbytes ),
- SFPL( rbytes ),
- SFPL( get_neighbors ),
- SFPL( get_neighbors_restart ),
- SFPL( need_l_neighbor ),
- SFPL( need_r_neighbor )
- );
+ seq_printf(m, "level\t"
+ " balances"
+ " [sbk: reads"
+ " fs_changed"
+ " restarted]"
+ " free space"
+ " items"
+ " can_remove"
+ " lnum"
+ " rnum"
+ " lbytes"
+ " rbytes"
+ " get_neig"
+ " get_neig_res" " need_l_neig" " need_r_neig" "\n");
+
+ for (level = 0; level < MAX_HEIGHT; ++level) {
+ seq_printf(m, "%i\t"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12li"
+ " %12li"
+ " %12li"
+ " %12li"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ " %12lu"
+ "\n",
+ level,
+ SFPL(balance_at),
+ SFPL(sbk_read_at),
+ SFPL(sbk_fs_changed),
+ SFPL(sbk_restarted),
+ SFPL(free_at),
+ SFPL(items_at),
+ SFPL(can_node_be_removed),
+ SFPL(lnum),
+ SFPL(rnum),
+ SFPL(lbytes),
+ SFPL(rbytes),
+ SFPL(get_neighbors),
+ SFPL(get_neighbors_restart),
+ SFPL(need_l_neighbor), SFPL(need_r_neighbor)
+ );
}
return 0;
}
@@ -232,31 +206,30 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
{
struct reiserfs_sb_info *r = REISERFS_SB(sb);
- seq_printf(m, "free_block: %lu\n"
- " scan_bitmap:"
- " wait"
- " bmap"
- " retry"
- " stolen"
- " journal_hint"
- "journal_nohint"
- "\n"
- " %14lu"
- " %14lu"
- " %14lu"
- " %14lu"
- " %14lu"
- " %14lu"
- " %14lu"
- "\n",
- SFP( free_block ),
- SFPF( call ),
- SFPF( wait ),
- SFPF( bmap ),
- SFPF( retry ),
- SFPF( stolen ),
- SFPF( in_journal_hint ),
- SFPF( in_journal_nohint ) );
+ seq_printf(m, "free_block: %lu\n"
+ " scan_bitmap:"
+ " wait"
+ " bmap"
+ " retry"
+ " stolen"
+ " journal_hint"
+ "journal_nohint"
+ "\n"
+ " %14lu"
+ " %14lu"
+ " %14lu"
+ " %14lu"
+ " %14lu"
+ " %14lu"
+ " %14lu"
+ "\n",
+ SFP(free_block),
+ SFPF(call),
+ SFPF(wait),
+ SFPF(bmap),
+ SFPF(retry),
+ SFPF(stolen),
+ SFPF(in_journal_hint), SFPF(in_journal_nohint));
return 0;
}
@@ -264,46 +237,42 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
{
struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
- struct reiserfs_super_block *rs = sb_info -> s_rs;
- int hash_code = DFL( s_hash_function_code );
- __u32 flags = DJF( s_flags );
-
- seq_printf(m, "block_count: \t%i\n"
- "free_blocks: \t%i\n"
- "root_block: \t%i\n"
- "blocksize: \t%i\n"
- "oid_maxsize: \t%i\n"
- "oid_cursize: \t%i\n"
- "umount_state: \t%i\n"
- "magic: \t%10.10s\n"
- "fs_state: \t%i\n"
- "hash: \t%s\n"
- "tree_height: \t%i\n"
- "bmap_nr: \t%i\n"
- "version: \t%i\n"
- "flags: \t%x[%s]\n"
- "reserved_for_journal: \t%i\n",
-
- DFL( s_block_count ),
- DFL( s_free_blocks ),
- DFL( s_root_block ),
- DF( s_blocksize ),
- DF( s_oid_maxsize ),
- DF( s_oid_cursize ),
- DF( s_umount_state ),
- rs -> s_v1.s_magic,
- DF( s_fs_state ),
- hash_code == TEA_HASH ? "tea" :
- ( hash_code == YURA_HASH ) ? "rupasov" :
- ( hash_code == R5_HASH ) ? "r5" :
- ( hash_code == UNSET_HASH ) ? "unset" : "unknown",
- DF( s_tree_height ),
- DF( s_bmap_nr ),
- DF( s_version ),
- flags,
- ( flags & reiserfs_attrs_cleared )
- ? "attrs_cleared" : "",
- DF (s_reserved_for_journal));
+ struct reiserfs_super_block *rs = sb_info->s_rs;
+ int hash_code = DFL(s_hash_function_code);
+ __u32 flags = DJF(s_flags);
+
+ seq_printf(m, "block_count: \t%i\n"
+ "free_blocks: \t%i\n"
+ "root_block: \t%i\n"
+ "blocksize: \t%i\n"
+ "oid_maxsize: \t%i\n"
+ "oid_cursize: \t%i\n"
+ "umount_state: \t%i\n"
+ "magic: \t%10.10s\n"
+ "fs_state: \t%i\n"
+ "hash: \t%s\n"
+ "tree_height: \t%i\n"
+ "bmap_nr: \t%i\n"
+ "version: \t%i\n"
+ "flags: \t%x[%s]\n"
+ "reserved_for_journal: \t%i\n",
+ DFL(s_block_count),
+ DFL(s_free_blocks),
+ DFL(s_root_block),
+ DF(s_blocksize),
+ DF(s_oid_maxsize),
+ DF(s_oid_cursize),
+ DF(s_umount_state),
+ rs->s_v1.s_magic,
+ DF(s_fs_state),
+ hash_code == TEA_HASH ? "tea" :
+ (hash_code == YURA_HASH) ? "rupasov" :
+ (hash_code == R5_HASH) ? "r5" :
+ (hash_code == UNSET_HASH) ? "unset" : "unknown",
+ DF(s_tree_height),
+ DF(s_bmap_nr),
+ DF(s_version), flags, (flags & reiserfs_attrs_cleared)
+ ? "attrs_cleared" : "", DF(s_reserved_for_journal));
return 0;
}
@@ -311,131 +280,122 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
static int show_oidmap(struct seq_file *m, struct super_block *sb)
{
struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
- struct reiserfs_super_block *rs = sb_info -> s_rs;
- unsigned int mapsize = le16_to_cpu( rs -> s_v1.s_oid_cursize );
+ struct reiserfs_super_block *rs = sb_info->s_rs;
+ unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
unsigned long total_used = 0;
int i;
- for( i = 0 ; i < mapsize ; ++i ) {
+ for (i = 0; i < mapsize; ++i) {
__u32 right;
- right = ( i == mapsize - 1 ) ? MAX_KEY_OBJECTID : MAP( i + 1 );
+ right = (i == mapsize - 1) ? MAX_KEY_OBJECTID : MAP(i + 1);
seq_printf(m, "%s: [ %x .. %x )\n",
- ( i & 1 ) ? "free" : "used", MAP( i ), right );
- if( ! ( i & 1 ) ) {
- total_used += right - MAP( i );
+ (i & 1) ? "free" : "used", MAP(i), right);
+ if (!(i & 1)) {
+ total_used += right - MAP(i);
}
}
#if defined( REISERFS_USE_OIDMAPF )
- if( sb_info -> oidmap.use_file && ( sb_info -> oidmap.mapf != NULL ) ) {
+ if (sb_info->oidmap.use_file && (sb_info->oidmap.mapf != NULL)) {
loff_t size = sb_info->oidmap.mapf->f_dentry->d_inode->i_size;
- total_used += size / sizeof( reiserfs_oidinterval_d_t );
+ total_used += size / sizeof(reiserfs_oidinterval_d_t);
}
#endif
- seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
- mapsize,
- mapsize, le16_to_cpu( rs -> s_v1.s_oid_maxsize ),
- total_used);
+ seq_printf(m, "total: \t%i [%i/%i] used: %lu [exact]\n",
+ mapsize,
+ mapsize, le16_to_cpu(rs->s_v1.s_oid_maxsize), total_used);
return 0;
}
static int show_journal(struct seq_file *m, struct super_block *sb)
{
struct reiserfs_sb_info *r = REISERFS_SB(sb);
- struct reiserfs_super_block *rs = r -> s_rs;
+ struct reiserfs_super_block *rs = r->s_rs;
struct journal_params *jp = &rs->s_v1.s_journal;
char b[BDEVNAME_SIZE];
-
-
- seq_printf(m, /* on-disk fields */
- "jp_journal_1st_block: \t%i\n"
- "jp_journal_dev: \t%s[%x]\n"
- "jp_journal_size: \t%i\n"
- "jp_journal_trans_max: \t%i\n"
- "jp_journal_magic: \t%i\n"
- "jp_journal_max_batch: \t%i\n"
- "jp_journal_max_commit_age: \t%i\n"
- "jp_journal_max_trans_age: \t%i\n"
- /* incore fields */
- "j_1st_reserved_block: \t%i\n"
- "j_state: \t%li\n"
- "j_trans_id: \t%lu\n"
- "j_mount_id: \t%lu\n"
- "j_start: \t%lu\n"
- "j_len: \t%lu\n"
- "j_len_alloc: \t%lu\n"
- "j_wcount: \t%i\n"
- "j_bcount: \t%lu\n"
- "j_first_unflushed_offset: \t%lu\n"
- "j_last_flush_trans_id: \t%lu\n"
- "j_trans_start_time: \t%li\n"
- "j_list_bitmap_index: \t%i\n"
- "j_must_wait: \t%i\n"
- "j_next_full_flush: \t%i\n"
- "j_next_async_flush: \t%i\n"
- "j_cnode_used: \t%i\n"
- "j_cnode_free: \t%i\n"
- "\n"
- /* reiserfs_proc_info_data_t.journal fields */
- "in_journal: \t%12lu\n"
- "in_journal_bitmap: \t%12lu\n"
- "in_journal_reusable: \t%12lu\n"
- "lock_journal: \t%12lu\n"
- "lock_journal_wait: \t%12lu\n"
- "journal_begin: \t%12lu\n"
- "journal_relock_writers: \t%12lu\n"
- "journal_relock_wcount: \t%12lu\n"
- "mark_dirty: \t%12lu\n"
- "mark_dirty_already: \t%12lu\n"
- "mark_dirty_notjournal: \t%12lu\n"
- "restore_prepared: \t%12lu\n"
- "prepare: \t%12lu\n"
- "prepare_retry: \t%12lu\n",
-
- DJP( jp_journal_1st_block ),
- bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
- DJP( jp_journal_dev ),
- DJP( jp_journal_size ),
- DJP( jp_journal_trans_max ),
- DJP( jp_journal_magic ),
- DJP( jp_journal_max_batch ),
- SB_JOURNAL(sb)->j_max_commit_age,
- DJP( jp_journal_max_trans_age ),
-
- JF( j_1st_reserved_block ),
- JF( j_state ),
- JF( j_trans_id ),
- JF( j_mount_id ),
- JF( j_start ),
- JF( j_len ),
- JF( j_len_alloc ),
- atomic_read( & r -> s_journal -> j_wcount ),
- JF( j_bcount ),
- JF( j_first_unflushed_offset ),
- JF( j_last_flush_trans_id ),
- JF( j_trans_start_time ),
- JF( j_list_bitmap_index ),
- JF( j_must_wait ),
- JF( j_next_full_flush ),
- JF( j_next_async_flush ),
- JF( j_cnode_used ),
- JF( j_cnode_free ),
-
- SFPJ( in_journal ),
- SFPJ( in_journal_bitmap ),
- SFPJ( in_journal_reusable ),
- SFPJ( lock_journal ),
- SFPJ( lock_journal_wait ),
- SFPJ( journal_being ),
- SFPJ( journal_relock_writers ),
- SFPJ( journal_relock_wcount ),
- SFPJ( mark_dirty ),
- SFPJ( mark_dirty_already ),
- SFPJ( mark_dirty_notjournal ),
- SFPJ( restore_prepared ),
- SFPJ( prepare ),
- SFPJ( prepare_retry )
- );
+
+ seq_printf(m, /* on-disk fields */
+ "jp_journal_1st_block: \t%i\n"
+ "jp_journal_dev: \t%s[%x]\n"
+ "jp_journal_size: \t%i\n"
+ "jp_journal_trans_max: \t%i\n"
+ "jp_journal_magic: \t%i\n"
+ "jp_journal_max_batch: \t%i\n"
+ "jp_journal_max_commit_age: \t%i\n"
+ "jp_journal_max_trans_age: \t%i\n"
+ /* incore fields */
+ "j_1st_reserved_block: \t%i\n"
+ "j_state: \t%li\n"
+ "j_trans_id: \t%lu\n"
+ "j_mount_id: \t%lu\n"
+ "j_start: \t%lu\n"
+ "j_len: \t%lu\n"
+ "j_len_alloc: \t%lu\n"
+ "j_wcount: \t%i\n"
+ "j_bcount: \t%lu\n"
+ "j_first_unflushed_offset: \t%lu\n"
+ "j_last_flush_trans_id: \t%lu\n"
+ "j_trans_start_time: \t%li\n"
+ "j_list_bitmap_index: \t%i\n"
+ "j_must_wait: \t%i\n"
+ "j_next_full_flush: \t%i\n"
+ "j_next_async_flush: \t%i\n"
+ "j_cnode_used: \t%i\n" "j_cnode_free: \t%i\n" "\n"
+ /* reiserfs_proc_info_data_t.journal fields */
+ "in_journal: \t%12lu\n"
+ "in_journal_bitmap: \t%12lu\n"
+ "in_journal_reusable: \t%12lu\n"
+ "lock_journal: \t%12lu\n"
+ "lock_journal_wait: \t%12lu\n"
+ "journal_begin: \t%12lu\n"
+ "journal_relock_writers: \t%12lu\n"
+ "journal_relock_wcount: \t%12lu\n"
+ "mark_dirty: \t%12lu\n"
+ "mark_dirty_already: \t%12lu\n"
+ "mark_dirty_notjournal: \t%12lu\n"
+ "restore_prepared: \t%12lu\n"
+ "prepare: \t%12lu\n"
+ "prepare_retry: \t%12lu\n",
+ DJP(jp_journal_1st_block),
+ bdevname(SB_JOURNAL(sb)->j_dev_bd, b),
+ DJP(jp_journal_dev),
+ DJP(jp_journal_size),
+ DJP(jp_journal_trans_max),
+ DJP(jp_journal_magic),
+ DJP(jp_journal_max_batch),
+ SB_JOURNAL(sb)->j_max_commit_age,
+ DJP(jp_journal_max_trans_age),
+ JF(j_1st_reserved_block),
+ JF(j_state),
+ JF(j_trans_id),
+ JF(j_mount_id),
+ JF(j_start),
+ JF(j_len),
+ JF(j_len_alloc),
+ atomic_read(&r->s_journal->j_wcount),
+ JF(j_bcount),
+ JF(j_first_unflushed_offset),
+ JF(j_last_flush_trans_id),
+ JF(j_trans_start_time),
+ JF(j_list_bitmap_index),
+ JF(j_must_wait),
+ JF(j_next_full_flush),
+ JF(j_next_async_flush),
+ JF(j_cnode_used),
+ JF(j_cnode_free),
+ SFPJ(in_journal),
+ SFPJ(in_journal_bitmap),
+ SFPJ(in_journal_reusable),
+ SFPJ(lock_journal),
+ SFPJ(lock_journal_wait),
+ SFPJ(journal_being),
+ SFPJ(journal_relock_writers),
+ SFPJ(journal_relock_wcount),
+ SFPJ(mark_dirty),
+ SFPJ(mark_dirty_already),
+ SFPJ(mark_dirty_notjournal),
+ SFPJ(restore_prepared), SFPJ(prepare), SFPJ(prepare_retry)
+ );
return 0;
}
@@ -450,7 +410,7 @@ static int set_sb(struct super_block *sb, void *data)
return -ENOENT;
}
-static void *r_start(struct seq_file *m, loff_t *pos)
+static void *r_start(struct seq_file *m, loff_t * pos)
{
struct proc_dir_entry *de = m->private;
struct super_block *s = de->parent->data;
@@ -472,7 +432,7 @@ static void *r_start(struct seq_file *m, loff_t *pos)
return s;
}
-static void *r_next(struct seq_file *m, void *v, loff_t *pos)
+static void *r_next(struct seq_file *m, void *v, loff_t * pos)
{
++*pos;
if (v)
@@ -489,7 +449,7 @@ static void r_stop(struct seq_file *m, void *v)
static int r_show(struct seq_file *m, void *v)
{
struct proc_dir_entry *de = m->private;
- int (*show)(struct seq_file *, struct super_block *) = de->data;
+ int (*show) (struct seq_file *, struct super_block *) = de->data;
return show(m, v);
}
@@ -512,17 +472,17 @@ static int r_open(struct inode *inode, struct file *file)
}
static struct file_operations r_file_operations = {
- .open = r_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
+ .open = r_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
};
static struct proc_dir_entry *proc_info_root = NULL;
static const char proc_info_root_name[] = "fs/reiserfs";
static void add_file(struct super_block *sb, char *name,
- int (*func)(struct seq_file *, struct super_block *))
+ int (*func) (struct seq_file *, struct super_block *))
{
struct proc_dir_entry *de;
de = create_proc_entry(name, 0, REISERFS_SB(sb)->procdir);
@@ -532,11 +492,12 @@ static void add_file(struct super_block *sb, char *name,
}
}
-int reiserfs_proc_info_init( struct super_block *sb )
+int reiserfs_proc_info_init(struct super_block *sb)
{
- spin_lock_init( & __PINFO( sb ).lock );
- REISERFS_SB(sb)->procdir = proc_mkdir(reiserfs_bdevname (sb), proc_info_root);
- if( REISERFS_SB(sb)->procdir ) {
+ spin_lock_init(&__PINFO(sb).lock);
+ REISERFS_SB(sb)->procdir =
+ proc_mkdir(reiserfs_bdevname(sb), proc_info_root);
+ if (REISERFS_SB(sb)->procdir) {
REISERFS_SB(sb)->procdir->owner = THIS_MODULE;
REISERFS_SB(sb)->procdir->data = sb;
add_file(sb, "version", show_version);
@@ -549,11 +510,11 @@ int reiserfs_proc_info_init( struct super_block *sb )
return 0;
}
reiserfs_warning(sb, "reiserfs: cannot create /proc/%s/%s",
- proc_info_root_name, reiserfs_bdevname (sb) );
+ proc_info_root_name, reiserfs_bdevname(sb));
return 1;
}
-int reiserfs_proc_info_done( struct super_block *sb )
+int reiserfs_proc_info_done(struct super_block *sb)
{
struct proc_dir_entry *de = REISERFS_SB(sb)->procdir;
if (de) {
@@ -565,48 +526,48 @@ int reiserfs_proc_info_done( struct super_block *sb )
remove_proc_entry("super", de);
remove_proc_entry("version", de);
}
- spin_lock( & __PINFO( sb ).lock );
- __PINFO( sb ).exiting = 1;
- spin_unlock( & __PINFO( sb ).lock );
- if ( proc_info_root ) {
- remove_proc_entry( reiserfs_bdevname (sb), proc_info_root );
+ spin_lock(&__PINFO(sb).lock);
+ __PINFO(sb).exiting = 1;
+ spin_unlock(&__PINFO(sb).lock);
+ if (proc_info_root) {
+ remove_proc_entry(reiserfs_bdevname(sb), proc_info_root);
REISERFS_SB(sb)->procdir = NULL;
}
return 0;
}
-struct proc_dir_entry *reiserfs_proc_register_global( char *name,
- read_proc_t *func )
+struct proc_dir_entry *reiserfs_proc_register_global(char *name,
+ read_proc_t * func)
{
- return ( proc_info_root ) ? create_proc_read_entry( name, 0,
- proc_info_root,
- func, NULL ) : NULL;
+ return (proc_info_root) ? create_proc_read_entry(name, 0,
+ proc_info_root,
+ func, NULL) : NULL;
}
-void reiserfs_proc_unregister_global( const char *name )
+void reiserfs_proc_unregister_global(const char *name)
{
- remove_proc_entry( name, proc_info_root );
+ remove_proc_entry(name, proc_info_root);
}
-int reiserfs_proc_info_global_init( void )
+int reiserfs_proc_info_global_init(void)
{
- if( proc_info_root == NULL ) {
+ if (proc_info_root == NULL) {
proc_info_root = proc_mkdir(proc_info_root_name, NULL);
- if( proc_info_root ) {
- proc_info_root -> owner = THIS_MODULE;
+ if (proc_info_root) {
+ proc_info_root->owner = THIS_MODULE;
} else {
- reiserfs_warning (NULL,
- "reiserfs: cannot create /proc/%s",
- proc_info_root_name );
+ reiserfs_warning(NULL,
+ "reiserfs: cannot create /proc/%s",
+ proc_info_root_name);
return 1;
}
}
return 0;
}
-int reiserfs_proc_info_global_done( void )
+int reiserfs_proc_info_global_done(void)
{
- if ( proc_info_root != NULL ) {
+ if (proc_info_root != NULL) {
proc_info_root = NULL;
remove_proc_entry(proc_info_root_name, NULL);
}
@@ -616,22 +577,40 @@ int reiserfs_proc_info_global_done( void )
/* REISERFS_PROC_INFO */
#else
-int reiserfs_proc_info_init( struct super_block *sb ) { return 0; }
-int reiserfs_proc_info_done( struct super_block *sb ) { return 0; }
+int reiserfs_proc_info_init(struct super_block *sb)
+{
+ return 0;
+}
+int reiserfs_proc_info_done(struct super_block *sb)
+{
+ return 0;
+}
-struct proc_dir_entry *reiserfs_proc_register_global( char *name,
- read_proc_t *func )
-{ return NULL; }
+struct proc_dir_entry *reiserfs_proc_register_global(char *name,
+ read_proc_t * func)
+{
+ return NULL;
+}
-void reiserfs_proc_unregister_global( const char *name ) {;}
+void reiserfs_proc_unregister_global(const char *name)
+{;
+}
-int reiserfs_proc_info_global_init( void ) { return 0; }
-int reiserfs_proc_info_global_done( void ) { return 0; }
+int reiserfs_proc_info_global_init(void)
+{
+ return 0;
+}
+int reiserfs_proc_info_global_done(void)
+{
+ return 0;
+}
-int reiserfs_global_version_in_proc( char *buffer, char **start,
- off_t offset,
- int count, int *eof, void *data )
-{ return 0; }
+int reiserfs_global_version_in_proc(char *buffer, char **start,
+ off_t offset,
+ int count, int *eof, void *data)
+{
+ return 0;
+}
/* REISERFS_PROC_INFO */
#endif
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
index 170012078b7..39cc7f47f5d 100644
--- a/fs/reiserfs/resize.c
+++ b/fs/reiserfs/resize.c
@@ -1,7 +1,7 @@
/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*/
-
+
/*
* Written by Alexander Zarochentcev.
*
@@ -17,23 +17,23 @@
#include <linux/reiserfs_fs_sb.h>
#include <linux/buffer_head.h>
-int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
+int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
{
- int err = 0;
- struct reiserfs_super_block * sb;
- struct reiserfs_bitmap_info *bitmap;
+ int err = 0;
+ struct reiserfs_super_block *sb;
+ struct reiserfs_bitmap_info *bitmap;
struct reiserfs_bitmap_info *old_bitmap = SB_AP_BITMAP(s);
- struct buffer_head * bh;
+ struct buffer_head *bh;
struct reiserfs_transaction_handle th;
unsigned int bmap_nr_new, bmap_nr;
unsigned int block_r_new, block_r;
-
- struct reiserfs_list_bitmap * jb;
+
+ struct reiserfs_list_bitmap *jb;
struct reiserfs_list_bitmap jbitmap[JOURNAL_NUM_BITMAPS];
-
+
unsigned long int block_count, free_blocks;
int i;
- int copy_size ;
+ int copy_size;
sb = SB_DISK_SUPER_BLOCK(s);
@@ -47,136 +47,145 @@ int reiserfs_resize (struct super_block * s, unsigned long block_count_new)
if (!bh) {
printk("reiserfs_resize: can\'t read last block\n");
return -EINVAL;
- }
+ }
bforget(bh);
/* old disk layout detection; those partitions can be mounted, but
* cannot be resized */
- if (SB_BUFFER_WITH_SB(s)->b_blocknr * SB_BUFFER_WITH_SB(s)->b_size
- != REISERFS_DISK_OFFSET_IN_BYTES ) {
- printk("reiserfs_resize: unable to resize a reiserfs without distributed bitmap (fs version < 3.5.12)\n");
+ if (SB_BUFFER_WITH_SB(s)->b_blocknr * SB_BUFFER_WITH_SB(s)->b_size
+ != REISERFS_DISK_OFFSET_IN_BYTES) {
+ printk
+ ("reiserfs_resize: unable to resize a reiserfs without distributed bitmap (fs version < 3.5.12)\n");
return -ENOTSUPP;
}
-
+
/* count used bits in last bitmap block */
- block_r = SB_BLOCK_COUNT(s) -
- (SB_BMAP_NR(s) - 1) * s->s_blocksize * 8;
-
+ block_r = SB_BLOCK_COUNT(s) - (SB_BMAP_NR(s) - 1) * s->s_blocksize * 8;
+
/* count bitmap blocks in new fs */
- bmap_nr_new = block_count_new / ( s->s_blocksize * 8 );
+ bmap_nr_new = block_count_new / (s->s_blocksize * 8);
block_r_new = block_count_new - bmap_nr_new * s->s_blocksize * 8;
- if (block_r_new)
+ if (block_r_new)
bmap_nr_new++;
else
block_r_new = s->s_blocksize * 8;
/* save old values */
block_count = SB_BLOCK_COUNT(s);
- bmap_nr = SB_BMAP_NR(s);
+ bmap_nr = SB_BMAP_NR(s);
/* resizing of reiserfs bitmaps (journal and real), if needed */
- if (bmap_nr_new > bmap_nr) {
- /* reallocate journal bitmaps */
- if (reiserfs_allocate_list_bitmaps(s, jbitmap, bmap_nr_new) < 0) {
- printk("reiserfs_resize: unable to allocate memory for journal bitmaps\n");
- unlock_super(s) ;
- return -ENOMEM ;
- }
- /* the new journal bitmaps are zero filled, now we copy in the bitmap
- ** node pointers from the old journal bitmap structs, and then
- ** transfer the new data structures into the journal struct.
- **
- ** using the copy_size var below allows this code to work for
- ** both shrinking and expanding the FS.
- */
- copy_size = bmap_nr_new < bmap_nr ? bmap_nr_new : bmap_nr ;
- copy_size = copy_size * sizeof(struct reiserfs_list_bitmap_node *) ;
- for (i = 0 ; i < JOURNAL_NUM_BITMAPS ; i++) {
- struct reiserfs_bitmap_node **node_tmp ;
- jb = SB_JOURNAL(s)->j_list_bitmap + i ;
- memcpy(jbitmap[i].bitmaps, jb->bitmaps, copy_size) ;
-
- /* just in case vfree schedules on us, copy the new
- ** pointer into the journal struct before freeing the
- ** old one
- */
- node_tmp = jb->bitmaps ;
- jb->bitmaps = jbitmap[i].bitmaps ;
- vfree(node_tmp) ;
- }
-
- /* allocate additional bitmap blocks, reallocate array of bitmap
- * block pointers */
- bitmap = vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
- if (!bitmap) {
- /* Journal bitmaps are still supersized, but the memory isn't
- * leaked, so I guess it's ok */
- printk("reiserfs_resize: unable to allocate memory.\n");
- return -ENOMEM;
- }
- memset (bitmap, 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
- for (i = 0; i < bmap_nr; i++)
- bitmap[i] = old_bitmap[i];
-
- /* This doesn't go through the journal, but it doesn't have to.
- * The changes are still atomic: We're synced up when the journal
- * transaction begins, and the new bitmaps don't matter if the
- * transaction fails. */
- for (i = bmap_nr; i < bmap_nr_new; i++) {
- bitmap[i].bh = sb_getblk(s, i * s->s_blocksize * 8);
- memset(bitmap[i].bh->b_data, 0, sb_blocksize(sb));
- reiserfs_test_and_set_le_bit(0, bitmap[i].bh->b_data);
-
- set_buffer_uptodate(bitmap[i].bh);
- mark_buffer_dirty(bitmap[i].bh) ;
- sync_dirty_buffer(bitmap[i].bh);
- // update bitmap_info stuff
- bitmap[i].first_zero_hint=1;
- bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
- }
- /* free old bitmap blocks array */
- SB_AP_BITMAP(s) = bitmap;
- vfree (old_bitmap);
+ if (bmap_nr_new > bmap_nr) {
+ /* reallocate journal bitmaps */
+ if (reiserfs_allocate_list_bitmaps(s, jbitmap, bmap_nr_new) < 0) {
+ printk
+ ("reiserfs_resize: unable to allocate memory for journal bitmaps\n");
+ unlock_super(s);
+ return -ENOMEM;
+ }
+ /* the new journal bitmaps are zero filled, now we copy in the bitmap
+ ** node pointers from the old journal bitmap structs, and then
+ ** transfer the new data structures into the journal struct.
+ **
+ ** using the copy_size var below allows this code to work for
+ ** both shrinking and expanding the FS.
+ */
+ copy_size = bmap_nr_new < bmap_nr ? bmap_nr_new : bmap_nr;
+ copy_size =
+ copy_size * sizeof(struct reiserfs_list_bitmap_node *);
+ for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
+ struct reiserfs_bitmap_node **node_tmp;
+ jb = SB_JOURNAL(s)->j_list_bitmap + i;
+ memcpy(jbitmap[i].bitmaps, jb->bitmaps, copy_size);
+
+ /* just in case vfree schedules on us, copy the new
+ ** pointer into the journal struct before freeing the
+ ** old one
+ */
+ node_tmp = jb->bitmaps;
+ jb->bitmaps = jbitmap[i].bitmaps;
+ vfree(node_tmp);
+ }
+
+ /* allocate additional bitmap blocks, reallocate array of bitmap
+ * block pointers */
+ bitmap =
+ vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
+ if (!bitmap) {
+ /* Journal bitmaps are still supersized, but the memory isn't
+ * leaked, so I guess it's ok */
+ printk("reiserfs_resize: unable to allocate memory.\n");
+ return -ENOMEM;
+ }
+ memset(bitmap, 0,
+ sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
+ for (i = 0; i < bmap_nr; i++)
+ bitmap[i] = old_bitmap[i];
+
+ /* This doesn't go through the journal, but it doesn't have to.
+ * The changes are still atomic: We're synced up when the journal
+ * transaction begins, and the new bitmaps don't matter if the
+ * transaction fails. */
+ for (i = bmap_nr; i < bmap_nr_new; i++) {
+ bitmap[i].bh = sb_getblk(s, i * s->s_blocksize * 8);
+ memset(bitmap[i].bh->b_data, 0, sb_blocksize(sb));
+ reiserfs_test_and_set_le_bit(0, bitmap[i].bh->b_data);
+
+ set_buffer_uptodate(bitmap[i].bh);
+ mark_buffer_dirty(bitmap[i].bh);
+ sync_dirty_buffer(bitmap[i].bh);
+ // update bitmap_info stuff
+ bitmap[i].first_zero_hint = 1;
+ bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
+ }
+ /* free old bitmap blocks array */
+ SB_AP_BITMAP(s) = bitmap;
+ vfree(old_bitmap);
}
-
+
/* begin transaction, if there was an error, it's fine. Yes, we have
* incorrect bitmaps now, but none of it is ever going to touch the
* disk anyway. */
err = journal_begin(&th, s, 10);
if (err)
- return err;
+ return err;
/* correct last bitmap blocks in old and new disk layout */
reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr - 1].bh, 1);
for (i = block_r; i < s->s_blocksize * 8; i++)
- reiserfs_test_and_clear_le_bit(i,
- SB_AP_BITMAP(s)[bmap_nr - 1].bh->b_data);
+ reiserfs_test_and_clear_le_bit(i,
+ SB_AP_BITMAP(s)[bmap_nr -
+ 1].bh->b_data);
SB_AP_BITMAP(s)[bmap_nr - 1].free_count += s->s_blocksize * 8 - block_r;
- if ( !SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint)
- SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint = block_r;
+ if (!SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint)
+ SB_AP_BITMAP(s)[bmap_nr - 1].first_zero_hint = block_r;
journal_mark_dirty(&th, s, SB_AP_BITMAP(s)[bmap_nr - 1].bh);
reiserfs_prepare_for_journal(s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh, 1);
for (i = block_r_new; i < s->s_blocksize * 8; i++)
- reiserfs_test_and_set_le_bit(i,
- SB_AP_BITMAP(s)[bmap_nr_new - 1].bh->b_data);
+ reiserfs_test_and_set_le_bit(i,
+ SB_AP_BITMAP(s)[bmap_nr_new -
+ 1].bh->b_data);
journal_mark_dirty(&th, s, SB_AP_BITMAP(s)[bmap_nr_new - 1].bh);
-
- SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count -= s->s_blocksize * 8 - block_r_new;
+
+ SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count -=
+ s->s_blocksize * 8 - block_r_new;
/* Extreme case where last bitmap is the only valid block in itself. */
- if ( !SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count )
- SB_AP_BITMAP(s)[bmap_nr_new - 1].first_zero_hint = 0;
- /* update super */
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
+ if (!SB_AP_BITMAP(s)[bmap_nr_new - 1].free_count)
+ SB_AP_BITMAP(s)[bmap_nr_new - 1].first_zero_hint = 0;
+ /* update super */
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
free_blocks = SB_FREE_BLOCKS(s);
- PUT_SB_FREE_BLOCKS(s, free_blocks + (block_count_new - block_count - (bmap_nr_new - bmap_nr)));
+ PUT_SB_FREE_BLOCKS(s,
+ free_blocks + (block_count_new - block_count -
+ (bmap_nr_new - bmap_nr)));
PUT_SB_BLOCK_COUNT(s, block_count_new);
PUT_SB_BMAP_NR(s, bmap_nr_new);
s->s_dirt = 1;
journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
-
+
SB_JOURNAL(s)->j_must_wait = 1;
return journal_end(&th, s, 10);
}
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 63158491e15..e2d08d7bcff 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -59,46 +59,45 @@
#include <linux/quotaops.h>
/* Does the buffer contain a disk block which is in the tree. */
-inline int B_IS_IN_TREE (const struct buffer_head * p_s_bh)
+inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
{
- RFALSE( B_LEVEL (p_s_bh) > MAX_HEIGHT,
- "PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
+ RFALSE(B_LEVEL(p_s_bh) > MAX_HEIGHT,
+ "PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
- return ( B_LEVEL (p_s_bh) != FREE_LEVEL );
+ return (B_LEVEL(p_s_bh) != FREE_LEVEL);
}
//
// to gets item head in le form
//
-inline void copy_item_head(struct item_head * p_v_to,
- const struct item_head * p_v_from)
+inline void copy_item_head(struct item_head *p_v_to,
+ const struct item_head *p_v_from)
{
- memcpy (p_v_to, p_v_from, IH_SIZE);
+ memcpy(p_v_to, p_v_from, IH_SIZE);
}
-
/* k1 is pointer to on-disk structure which is stored in little-endian
form. k2 is pointer to cpu variable. For key of items of the same
object this returns 0.
Returns: -1 if key1 < key2
0 if key1 == key2
1 if key1 > key2 */
-inline int comp_short_keys (const struct reiserfs_key * le_key,
- const struct cpu_key * cpu_key)
+inline int comp_short_keys(const struct reiserfs_key *le_key,
+ const struct cpu_key *cpu_key)
{
- __u32 n;
- n = le32_to_cpu(le_key->k_dir_id);
- if (n < cpu_key->on_disk_key.k_dir_id)
- return -1;
- if (n > cpu_key->on_disk_key.k_dir_id)
- return 1;
- n = le32_to_cpu(le_key->k_objectid);
- if (n < cpu_key->on_disk_key.k_objectid)
- return -1;
- if (n > cpu_key->on_disk_key.k_objectid)
- return 1;
- return 0;
+ __u32 n;
+ n = le32_to_cpu(le_key->k_dir_id);
+ if (n < cpu_key->on_disk_key.k_dir_id)
+ return -1;
+ if (n > cpu_key->on_disk_key.k_dir_id)
+ return 1;
+ n = le32_to_cpu(le_key->k_objectid);
+ if (n < cpu_key->on_disk_key.k_objectid)
+ return -1;
+ if (n > cpu_key->on_disk_key.k_objectid)
+ return 1;
+ return 0;
}
/* k1 is pointer to on-disk structure which is stored in little-endian
@@ -106,68 +105,72 @@ inline int comp_short_keys (const struct reiserfs_key * le_key,
Compare keys using all 4 key fields.
Returns: -1 if key1 < key2 0
if key1 = key2 1 if key1 > key2 */
-static inline int comp_keys (const struct reiserfs_key * le_key, const struct cpu_key * cpu_key)
+static inline int comp_keys(const struct reiserfs_key *le_key,
+ const struct cpu_key *cpu_key)
{
- int retval;
-
- retval = comp_short_keys (le_key, cpu_key);
- if (retval)
- return retval;
- if (le_key_k_offset (le_key_version(le_key), le_key) < cpu_key_k_offset (cpu_key))
- return -1;
- if (le_key_k_offset (le_key_version(le_key), le_key) > cpu_key_k_offset (cpu_key))
- return 1;
-
- if (cpu_key->key_length == 3)
- return 0;
-
- /* this part is needed only when tail conversion is in progress */
- if (le_key_k_type (le_key_version(le_key), le_key) < cpu_key_k_type (cpu_key))
- return -1;
+ int retval;
+
+ retval = comp_short_keys(le_key, cpu_key);
+ if (retval)
+ return retval;
+ if (le_key_k_offset(le_key_version(le_key), le_key) <
+ cpu_key_k_offset(cpu_key))
+ return -1;
+ if (le_key_k_offset(le_key_version(le_key), le_key) >
+ cpu_key_k_offset(cpu_key))
+ return 1;
+
+ if (cpu_key->key_length == 3)
+ return 0;
+
+ /* this part is needed only when tail conversion is in progress */
+ if (le_key_k_type(le_key_version(le_key), le_key) <
+ cpu_key_k_type(cpu_key))
+ return -1;
+
+ if (le_key_k_type(le_key_version(le_key), le_key) >
+ cpu_key_k_type(cpu_key))
+ return 1;
- if (le_key_k_type (le_key_version(le_key), le_key) > cpu_key_k_type (cpu_key))
- return 1;
-
- return 0;
+ return 0;
}
-
-inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct reiserfs_key * key2)
+inline int comp_short_le_keys(const struct reiserfs_key *key1,
+ const struct reiserfs_key *key2)
{
- __u32 * p_s_1_u32, * p_s_2_u32;
- int n_key_length = REISERFS_SHORT_KEY_LEN;
-
- p_s_1_u32 = (__u32 *)key1;
- p_s_2_u32 = (__u32 *)key2;
- for( ; n_key_length--; ++p_s_1_u32, ++p_s_2_u32 ) {
- if ( le32_to_cpu (*p_s_1_u32) < le32_to_cpu (*p_s_2_u32) )
- return -1;
- if ( le32_to_cpu (*p_s_1_u32) > le32_to_cpu (*p_s_2_u32) )
- return 1;
- }
- return 0;
+ __u32 *p_s_1_u32, *p_s_2_u32;
+ int n_key_length = REISERFS_SHORT_KEY_LEN;
+
+ p_s_1_u32 = (__u32 *) key1;
+ p_s_2_u32 = (__u32 *) key2;
+ for (; n_key_length--; ++p_s_1_u32, ++p_s_2_u32) {
+ if (le32_to_cpu(*p_s_1_u32) < le32_to_cpu(*p_s_2_u32))
+ return -1;
+ if (le32_to_cpu(*p_s_1_u32) > le32_to_cpu(*p_s_2_u32))
+ return 1;
+ }
+ return 0;
}
-inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from)
+inline void le_key2cpu_key(struct cpu_key *to, const struct reiserfs_key *from)
{
- int version;
- to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id);
- to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid);
-
- // find out version of the key
- version = le_key_version (from);
- to->version = version;
- to->on_disk_key.k_offset = le_key_k_offset(version, from);
- to->on_disk_key.k_type = le_key_k_type(version, from);
+ int version;
+ to->on_disk_key.k_dir_id = le32_to_cpu(from->k_dir_id);
+ to->on_disk_key.k_objectid = le32_to_cpu(from->k_objectid);
+
+ // find out version of the key
+ version = le_key_version(from);
+ to->version = version;
+ to->on_disk_key.k_offset = le_key_k_offset(version, from);
+ to->on_disk_key.k_type = le_key_k_type(version, from);
}
-
-
// this does not say which one is bigger, it only returns 1 if keys
// are not equal, 0 otherwise
-inline int comp_le_keys (const struct reiserfs_key * k1, const struct reiserfs_key * k2)
+inline int comp_le_keys(const struct reiserfs_key *k1,
+ const struct reiserfs_key *k2)
{
- return memcmp (k1, k2, sizeof (struct reiserfs_key));
+ return memcmp(k1, k2, sizeof(struct reiserfs_key));
}
/**************************************************************************
@@ -184,373 +187,396 @@ inline int comp_le_keys (const struct reiserfs_key * k1, const struct reiserfs_k
there are no possible items, and we have not found it. With each examination we
cut the number of possible items it could be by one more than half rounded down,
or we find it. */
-static inline int bin_search (
- const void * p_v_key, /* Key to search for. */
- const void * p_v_base,/* First item in the array. */
- int p_n_num, /* Number of items in the array. */
- int p_n_width, /* Item size in the array.
- searched. Lest the reader be
- confused, note that this is crafted
- as a general function, and when it
- is applied specifically to the array
- of item headers in a node, p_n_width
- is actually the item header size not
- the item size. */
- int * p_n_pos /* Number of the searched for element. */
- ) {
- int n_rbound, n_lbound, n_j;
-
- for ( n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0))/2; n_lbound <= n_rbound; n_j = (n_rbound + n_lbound)/2 )
- switch( comp_keys((struct reiserfs_key *)((char * )p_v_base + n_j * p_n_width), (struct cpu_key *)p_v_key) ) {
- case -1: n_lbound = n_j + 1; continue;
- case 1: n_rbound = n_j - 1; continue;
- case 0: *p_n_pos = n_j; return ITEM_FOUND; /* Key found in the array. */
- }
-
- /* bin_search did not find given key, it returns position of key,
- that is minimal and greater than the given one. */
- *p_n_pos = n_lbound;
- return ITEM_NOT_FOUND;
+static inline int bin_search(const void *p_v_key, /* Key to search for. */
+ const void *p_v_base, /* First item in the array. */
+ int p_n_num, /* Number of items in the array. */
+ int p_n_width, /* Item size in the array.
+ searched. Lest the reader be
+ confused, note that this is crafted
+ as a general function, and when it
+ is applied specifically to the array
+ of item headers in a node, p_n_width
+ is actually the item header size not
+ the item size. */
+ int *p_n_pos /* Number of the searched for element. */
+ )
+{
+ int n_rbound, n_lbound, n_j;
+
+ for (n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0)) / 2;
+ n_lbound <= n_rbound; n_j = (n_rbound + n_lbound) / 2)
+ switch (comp_keys
+ ((struct reiserfs_key *)((char *)p_v_base +
+ n_j * p_n_width),
+ (struct cpu_key *)p_v_key)) {
+ case -1:
+ n_lbound = n_j + 1;
+ continue;
+ case 1:
+ n_rbound = n_j - 1;
+ continue;
+ case 0:
+ *p_n_pos = n_j;
+ return ITEM_FOUND; /* Key found in the array. */
+ }
+
+ /* bin_search did not find given key, it returns position of key,
+ that is minimal and greater than the given one. */
+ *p_n_pos = n_lbound;
+ return ITEM_NOT_FOUND;
}
#ifdef CONFIG_REISERFS_CHECK
-extern struct tree_balance * cur_tb;
+extern struct tree_balance *cur_tb;
#endif
-
-
/* Minimal possible key. It is never in the tree. */
-const struct reiserfs_key MIN_KEY = {0, 0, {{0, 0},}};
+const struct reiserfs_key MIN_KEY = { 0, 0, {{0, 0},} };
/* Maximal possible key. It is never in the tree. */
-static const struct reiserfs_key MAX_KEY = {
+static const struct reiserfs_key MAX_KEY = {
__constant_cpu_to_le32(0xffffffff),
__constant_cpu_to_le32(0xffffffff),
{{__constant_cpu_to_le32(0xffffffff),
- __constant_cpu_to_le32(0xffffffff)},}
+ __constant_cpu_to_le32(0xffffffff)},}
};
-
/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
of the path, and going upwards. We must check the path's validity at each step. If the key is not in
the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
case we return a special key, either MIN_KEY or MAX_KEY. */
-static inline const struct reiserfs_key * get_lkey (
- const struct path * p_s_chk_path,
- const struct super_block * p_s_sb
- ) {
- int n_position, n_path_offset = p_s_chk_path->path_length;
- struct buffer_head * p_s_parent;
-
- RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
- "PAP-5010: invalid offset in the path");
-
- /* While not higher in path than first element. */
- while ( n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET ) {
-
- RFALSE( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
- "PAP-5020: parent is not uptodate");
-
- /* Parent at the path is not in the tree now. */
- if ( ! B_IS_IN_TREE(p_s_parent = PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
- return &MAX_KEY;
- /* Check whether position in the parent is correct. */
- if ( (n_position = PATH_OFFSET_POSITION(p_s_chk_path, n_path_offset)) > B_NR_ITEMS(p_s_parent) )
- return &MAX_KEY;
- /* Check whether parent at the path really points to the child. */
- if ( B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset + 1)->b_blocknr )
- return &MAX_KEY;
- /* Return delimiting key if position in the parent is not equal to zero. */
- if ( n_position )
- return B_N_PDELIM_KEY(p_s_parent, n_position - 1);
- }
- /* Return MIN_KEY if we are in the root of the buffer tree. */
- if ( PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
- SB_ROOT_BLOCK (p_s_sb) )
- return &MIN_KEY;
- return &MAX_KEY;
+static inline const struct reiserfs_key *get_lkey(const struct path
+ *p_s_chk_path,
+ const struct super_block
+ *p_s_sb)
+{
+ int n_position, n_path_offset = p_s_chk_path->path_length;
+ struct buffer_head *p_s_parent;
+
+ RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ "PAP-5010: invalid offset in the path");
+
+ /* While not higher in path than first element. */
+ while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+
+ RFALSE(!buffer_uptodate
+ (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ "PAP-5020: parent is not uptodate");
+
+ /* Parent at the path is not in the tree now. */
+ if (!B_IS_IN_TREE
+ (p_s_parent =
+ PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+ return &MAX_KEY;
+ /* Check whether position in the parent is correct. */
+ if ((n_position =
+ PATH_OFFSET_POSITION(p_s_chk_path,
+ n_path_offset)) >
+ B_NR_ITEMS(p_s_parent))
+ return &MAX_KEY;
+ /* Check whether parent at the path really points to the child. */
+ if (B_N_CHILD_NUM(p_s_parent, n_position) !=
+ PATH_OFFSET_PBUFFER(p_s_chk_path,
+ n_path_offset + 1)->b_blocknr)
+ return &MAX_KEY;
+ /* Return delimiting key if position in the parent is not equal to zero. */
+ if (n_position)
+ return B_N_PDELIM_KEY(p_s_parent, n_position - 1);
+ }
+ /* Return MIN_KEY if we are in the root of the buffer tree. */
+ if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+ b_blocknr == SB_ROOT_BLOCK(p_s_sb))
+ return &MIN_KEY;
+ return &MAX_KEY;
}
-
/* Get delimiting key of the buffer at the path and its right neighbor. */
-inline const struct reiserfs_key * get_rkey (
- const struct path * p_s_chk_path,
- const struct super_block * p_s_sb
- ) {
- int n_position,
- n_path_offset = p_s_chk_path->path_length;
- struct buffer_head * p_s_parent;
-
- RFALSE( n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
- "PAP-5030: invalid offset in the path");
-
- while ( n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET ) {
-
- RFALSE( ! buffer_uptodate(PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
- "PAP-5040: parent is not uptodate");
-
- /* Parent at the path is not in the tree now. */
- if ( ! B_IS_IN_TREE(p_s_parent = PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)) )
- return &MIN_KEY;
- /* Check whether position in the parent is correct. */
- if ( (n_position = PATH_OFFSET_POSITION(p_s_chk_path, n_path_offset)) > B_NR_ITEMS(p_s_parent) )
- return &MIN_KEY;
- /* Check whether parent at the path really points to the child. */
- if ( B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset + 1)->b_blocknr )
- return &MIN_KEY;
- /* Return delimiting key if position in the parent is not the last one. */
- if ( n_position != B_NR_ITEMS(p_s_parent) )
- return B_N_PDELIM_KEY(p_s_parent, n_position);
- }
- /* Return MAX_KEY if we are in the root of the buffer tree. */
- if ( PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
- SB_ROOT_BLOCK (p_s_sb) )
- return &MAX_KEY;
- return &MIN_KEY;
+inline const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
+ const struct super_block *p_s_sb)
+{
+ int n_position, n_path_offset = p_s_chk_path->path_length;
+ struct buffer_head *p_s_parent;
+
+ RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ "PAP-5030: invalid offset in the path");
+
+ while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+
+ RFALSE(!buffer_uptodate
+ (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ "PAP-5040: parent is not uptodate");
+
+ /* Parent at the path is not in the tree now. */
+ if (!B_IS_IN_TREE
+ (p_s_parent =
+ PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+ return &MIN_KEY;
+ /* Check whether position in the parent is correct. */
+ if ((n_position =
+ PATH_OFFSET_POSITION(p_s_chk_path,
+ n_path_offset)) >
+ B_NR_ITEMS(p_s_parent))
+ return &MIN_KEY;
+ /* Check whether parent at the path really points to the child. */
+ if (B_N_CHILD_NUM(p_s_parent, n_position) !=
+ PATH_OFFSET_PBUFFER(p_s_chk_path,
+ n_path_offset + 1)->b_blocknr)
+ return &MIN_KEY;
+ /* Return delimiting key if position in the parent is not the last one. */
+ if (n_position != B_NR_ITEMS(p_s_parent))
+ return B_N_PDELIM_KEY(p_s_parent, n_position);
+ }
+ /* Return MAX_KEY if we are in the root of the buffer tree. */
+ if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+ b_blocknr == SB_ROOT_BLOCK(p_s_sb))
+ return &MAX_KEY;
+ return &MIN_KEY;
}
-
/* Check whether a key is contained in the tree rooted from a buffer at a path. */
/* This works by looking at the left and right delimiting keys for the buffer in the last path_element in
the path. These delimiting keys are stored at least one level above that buffer in the tree. If the
buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in
this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */
-static inline int key_in_buffer (
- struct path * p_s_chk_path, /* Path which should be checked. */
- const struct cpu_key * p_s_key, /* Key which should be checked. */
- struct super_block * p_s_sb /* Super block pointer. */
- ) {
-
- RFALSE( ! p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET ||
- p_s_chk_path->path_length > MAX_HEIGHT,
- "PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)",
- p_s_key, p_s_chk_path->path_length);
- RFALSE( !PATH_PLAST_BUFFER(p_s_chk_path)->b_bdev,
- "PAP-5060: device must not be NODEV");
-
- if ( comp_keys(get_lkey(p_s_chk_path, p_s_sb), p_s_key) == 1 )
- /* left delimiting key is bigger, that the key we look for */
- return 0;
- // if ( comp_keys(p_s_key, get_rkey(p_s_chk_path, p_s_sb)) != -1 )
- if ( comp_keys(get_rkey(p_s_chk_path, p_s_sb), p_s_key) != 1 )
- /* p_s_key must be less than right delimitiing key */
- return 0;
- return 1;
-}
-
+static inline int key_in_buffer(struct path *p_s_chk_path, /* Path which should be checked. */
+ const struct cpu_key *p_s_key, /* Key which should be checked. */
+ struct super_block *p_s_sb /* Super block pointer. */
+ )
+{
-inline void decrement_bcount(
- struct buffer_head * p_s_bh
- ) {
- if ( p_s_bh ) {
- if ( atomic_read (&(p_s_bh->b_count)) ) {
- put_bh(p_s_bh) ;
- return;
- }
- reiserfs_panic(NULL, "PAP-5070: decrement_bcount: trying to free free buffer %b", p_s_bh);
- }
+ RFALSE(!p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET
+ || p_s_chk_path->path_length > MAX_HEIGHT,
+ "PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)",
+ p_s_key, p_s_chk_path->path_length);
+ RFALSE(!PATH_PLAST_BUFFER(p_s_chk_path)->b_bdev,
+ "PAP-5060: device must not be NODEV");
+
+ if (comp_keys(get_lkey(p_s_chk_path, p_s_sb), p_s_key) == 1)
+ /* left delimiting key is bigger, that the key we look for */
+ return 0;
+ // if ( comp_keys(p_s_key, get_rkey(p_s_chk_path, p_s_sb)) != -1 )
+ if (comp_keys(get_rkey(p_s_chk_path, p_s_sb), p_s_key) != 1)
+ /* p_s_key must be less than right delimitiing key */
+ return 0;
+ return 1;
}
+inline void decrement_bcount(struct buffer_head *p_s_bh)
+{
+ if (p_s_bh) {
+ if (atomic_read(&(p_s_bh->b_count))) {
+ put_bh(p_s_bh);
+ return;
+ }
+ reiserfs_panic(NULL,
+ "PAP-5070: decrement_bcount: trying to free free buffer %b",
+ p_s_bh);
+ }
+}
/* Decrement b_count field of the all buffers in the path. */
-void decrement_counters_in_path (
- struct path * p_s_search_path
- ) {
- int n_path_offset = p_s_search_path->path_length;
-
- RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
- n_path_offset > EXTENDED_MAX_HEIGHT - 1,
- "PAP-5080: invalid path offset of %d", n_path_offset);
-
- while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET ) {
- struct buffer_head * bh;
-
- bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
- decrement_bcount (bh);
- }
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
-}
+void decrement_counters_in_path(struct path *p_s_search_path)
+{
+ int n_path_offset = p_s_search_path->path_length;
+
+ RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
+ n_path_offset > EXTENDED_MAX_HEIGHT - 1,
+ "PAP-5080: invalid path offset of %d", n_path_offset);
+ while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
+ struct buffer_head *bh;
-int reiserfs_check_path(struct path *p) {
- RFALSE( p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
- "path not properly relsed") ;
- return 0 ;
+ bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
+ decrement_bcount(bh);
+ }
+ p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
+int reiserfs_check_path(struct path *p)
+{
+ RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
+ "path not properly relsed");
+ return 0;
+}
/* Release all buffers in the path. Restore dirty bits clean
** when preparing the buffer for the log
**
** only called from fix_nodes()
*/
-void pathrelse_and_restore (
- struct super_block *s,
- struct path * p_s_search_path
- ) {
- int n_path_offset = p_s_search_path->path_length;
-
- RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
- "clm-4000: invalid path offset");
-
- while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET ) {
- reiserfs_restore_prepared_buffer(s, PATH_OFFSET_PBUFFER(p_s_search_path,
- n_path_offset));
- brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
- }
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path)
+{
+ int n_path_offset = p_s_search_path->path_length;
+
+ RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ "clm-4000: invalid path offset");
+
+ while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
+ reiserfs_restore_prepared_buffer(s,
+ PATH_OFFSET_PBUFFER
+ (p_s_search_path,
+ n_path_offset));
+ brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
+ }
+ p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
/* Release all buffers in the path. */
-void pathrelse (
- struct path * p_s_search_path
- ) {
- int n_path_offset = p_s_search_path->path_length;
-
- RFALSE( n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
- "PAP-5090: invalid path offset");
-
- while ( n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET )
- brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
-
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
-}
+void pathrelse(struct path *p_s_search_path)
+{
+ int n_path_offset = p_s_search_path->path_length;
+ RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ "PAP-5090: invalid path offset");
+ while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
+ brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
-static int is_leaf (char * buf, int blocksize, struct buffer_head * bh)
-{
- struct block_head * blkh;
- struct item_head * ih;
- int used_space;
- int prev_location;
- int i;
- int nr;
-
- blkh = (struct block_head *)buf;
- if ( blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) {
- reiserfs_warning (NULL, "is_leaf: this should be caught earlier");
- return 0;
- }
+ p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+}
- nr = blkh_nr_item(blkh);
- if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) {
- /* item number is too big or too small */
- reiserfs_warning (NULL, "is_leaf: nr_item seems wrong: %z", bh);
- return 0;
- }
- ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
- used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location (ih));
- if (used_space != blocksize - blkh_free_space(blkh)) {
- /* free space does not match to calculated amount of use space */
- reiserfs_warning (NULL, "is_leaf: free space seems wrong: %z", bh);
- return 0;
- }
-
- // FIXME: it is_leaf will hit performance too much - we may have
- // return 1 here
-
- /* check tables of item heads */
- ih = (struct item_head *)(buf + BLKH_SIZE);
- prev_location = blocksize;
- for (i = 0; i < nr; i ++, ih ++) {
- if ( le_ih_k_type(ih) == TYPE_ANY) {
- reiserfs_warning (NULL, "is_leaf: wrong item type for item %h",ih);
- return 0;
+static int is_leaf(char *buf, int blocksize, struct buffer_head *bh)
+{
+ struct block_head *blkh;
+ struct item_head *ih;
+ int used_space;
+ int prev_location;
+ int i;
+ int nr;
+
+ blkh = (struct block_head *)buf;
+ if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) {
+ reiserfs_warning(NULL,
+ "is_leaf: this should be caught earlier");
+ return 0;
}
- if (ih_location (ih) >= blocksize || ih_location (ih) < IH_SIZE * nr) {
- reiserfs_warning (NULL, "is_leaf: item location seems wrong: %h", ih);
- return 0;
+
+ nr = blkh_nr_item(blkh);
+ if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) {
+ /* item number is too big or too small */
+ reiserfs_warning(NULL, "is_leaf: nr_item seems wrong: %z", bh);
+ return 0;
}
- if (ih_item_len (ih) < 1 || ih_item_len (ih) > MAX_ITEM_LEN (blocksize)) {
- reiserfs_warning (NULL, "is_leaf: item length seems wrong: %h", ih);
- return 0;
+ ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
+ used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih));
+ if (used_space != blocksize - blkh_free_space(blkh)) {
+ /* free space does not match to calculated amount of use space */
+ reiserfs_warning(NULL, "is_leaf: free space seems wrong: %z",
+ bh);
+ return 0;
}
- if (prev_location - ih_location (ih) != ih_item_len (ih)) {
- reiserfs_warning (NULL, "is_leaf: item location seems wrong (second one): %h", ih);
- return 0;
+ // FIXME: it is_leaf will hit performance too much - we may have
+ // return 1 here
+
+ /* check tables of item heads */
+ ih = (struct item_head *)(buf + BLKH_SIZE);
+ prev_location = blocksize;
+ for (i = 0; i < nr; i++, ih++) {
+ if (le_ih_k_type(ih) == TYPE_ANY) {
+ reiserfs_warning(NULL,
+ "is_leaf: wrong item type for item %h",
+ ih);
+ return 0;
+ }
+ if (ih_location(ih) >= blocksize
+ || ih_location(ih) < IH_SIZE * nr) {
+ reiserfs_warning(NULL,
+ "is_leaf: item location seems wrong: %h",
+ ih);
+ return 0;
+ }
+ if (ih_item_len(ih) < 1
+ || ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) {
+ reiserfs_warning(NULL,
+ "is_leaf: item length seems wrong: %h",
+ ih);
+ return 0;
+ }
+ if (prev_location - ih_location(ih) != ih_item_len(ih)) {
+ reiserfs_warning(NULL,
+ "is_leaf: item location seems wrong (second one): %h",
+ ih);
+ return 0;
+ }
+ prev_location = ih_location(ih);
}
- prev_location = ih_location (ih);
- }
- // one may imagine much more checks
- return 1;
+ // one may imagine much more checks
+ return 1;
}
-
/* returns 1 if buf looks like an internal node, 0 otherwise */
-static int is_internal (char * buf, int blocksize, struct buffer_head * bh)
+static int is_internal(char *buf, int blocksize, struct buffer_head *bh)
{
- struct block_head * blkh;
- int nr;
- int used_space;
-
- blkh = (struct block_head *)buf;
- nr = blkh_level(blkh);
- if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
- /* this level is not possible for internal nodes */
- reiserfs_warning (NULL, "is_internal: this should be caught earlier");
- return 0;
- }
-
- nr = blkh_nr_item(blkh);
- if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
- /* for internal which is not root we might check min number of keys */
- reiserfs_warning (NULL, "is_internal: number of key seems wrong: %z", bh);
- return 0;
- }
+ struct block_head *blkh;
+ int nr;
+ int used_space;
+
+ blkh = (struct block_head *)buf;
+ nr = blkh_level(blkh);
+ if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
+ /* this level is not possible for internal nodes */
+ reiserfs_warning(NULL,
+ "is_internal: this should be caught earlier");
+ return 0;
+ }
- used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
- if (used_space != blocksize - blkh_free_space(blkh)) {
- reiserfs_warning (NULL, "is_internal: free space seems wrong: %z", bh);
- return 0;
- }
+ nr = blkh_nr_item(blkh);
+ if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
+ /* for internal which is not root we might check min number of keys */
+ reiserfs_warning(NULL,
+ "is_internal: number of key seems wrong: %z",
+ bh);
+ return 0;
+ }
- // one may imagine much more checks
- return 1;
+ used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
+ if (used_space != blocksize - blkh_free_space(blkh)) {
+ reiserfs_warning(NULL,
+ "is_internal: free space seems wrong: %z", bh);
+ return 0;
+ }
+ // one may imagine much more checks
+ return 1;
}
-
// make sure that bh contains formatted node of reiserfs tree of
// 'level'-th level
-static int is_tree_node (struct buffer_head * bh, int level)
+static int is_tree_node(struct buffer_head *bh, int level)
{
- if (B_LEVEL (bh) != level) {
- reiserfs_warning (NULL, "is_tree_node: node level %d does not match to the expected one %d",
- B_LEVEL (bh), level);
- return 0;
- }
- if (level == DISK_LEAF_NODE_LEVEL)
- return is_leaf (bh->b_data, bh->b_size, bh);
+ if (B_LEVEL(bh) != level) {
+ reiserfs_warning(NULL,
+ "is_tree_node: node level %d does not match to the expected one %d",
+ B_LEVEL(bh), level);
+ return 0;
+ }
+ if (level == DISK_LEAF_NODE_LEVEL)
+ return is_leaf(bh->b_data, bh->b_size, bh);
- return is_internal (bh->b_data, bh->b_size, bh);
+ return is_internal(bh->b_data, bh->b_size, bh);
}
-
-
#define SEARCH_BY_KEY_READA 16
/* The function is NOT SCHEDULE-SAFE! */
-static void search_by_key_reada (struct super_block * s,
- struct buffer_head **bh,
- unsigned long *b, int num)
+static void search_by_key_reada(struct super_block *s,
+ struct buffer_head **bh,
+ unsigned long *b, int num)
{
- int i,j;
-
- for (i = 0 ; i < num ; i++) {
- bh[i] = sb_getblk (s, b[i]);
- }
- for (j = 0 ; j < i ; j++) {
- /*
- * note, this needs attention if we are getting rid of the BKL
- * you have to make sure the prepared bit isn't set on this buffer
- */
- if (!buffer_uptodate(bh[j]))
- ll_rw_block(READA, 1, bh + j);
- brelse(bh[j]);
- }
+ int i, j;
+
+ for (i = 0; i < num; i++) {
+ bh[i] = sb_getblk(s, b[i]);
+ }
+ for (j = 0; j < i; j++) {
+ /*
+ * note, this needs attention if we are getting rid of the BKL
+ * you have to make sure the prepared bit isn't set on this buffer
+ */
+ if (!buffer_uptodate(bh[j]))
+ ll_rw_block(READA, 1, bh + j);
+ brelse(bh[j]);
+ }
}
/**************************************************************************
@@ -576,194 +602,200 @@ static void search_by_key_reada (struct super_block * s,
correctness of the top of the path but need not be checked for the
correctness of the bottom of the path */
/* The function is NOT SCHEDULE-SAFE! */
-int search_by_key (struct super_block * p_s_sb,
- const struct cpu_key * p_s_key, /* Key to search. */
- struct path * p_s_search_path, /* This structure was
- allocated and initialized
- by the calling
- function. It is filled up
- by this function. */
- int n_stop_level /* How far down the tree to search. To
- stop at leaf level - set to
- DISK_LEAF_NODE_LEVEL */
- ) {
- int n_block_number;
- int expected_level;
- struct buffer_head * p_s_bh;
- struct path_element * p_s_last_element;
- int n_node_level, n_retval;
- int right_neighbor_of_leaf_node;
- int fs_gen;
- struct buffer_head *reada_bh[SEARCH_BY_KEY_READA];
- unsigned long reada_blocks[SEARCH_BY_KEY_READA];
- int reada_count = 0;
+int search_by_key(struct super_block *p_s_sb, const struct cpu_key *p_s_key, /* Key to search. */
+ struct path *p_s_search_path, /* This structure was
+ allocated and initialized
+ by the calling
+ function. It is filled up
+ by this function. */
+ int n_stop_level /* How far down the tree to search. To
+ stop at leaf level - set to
+ DISK_LEAF_NODE_LEVEL */
+ )
+{
+ int n_block_number;
+ int expected_level;
+ struct buffer_head *p_s_bh;
+ struct path_element *p_s_last_element;
+ int n_node_level, n_retval;
+ int right_neighbor_of_leaf_node;
+ int fs_gen;
+ struct buffer_head *reada_bh[SEARCH_BY_KEY_READA];
+ unsigned long reada_blocks[SEARCH_BY_KEY_READA];
+ int reada_count = 0;
#ifdef CONFIG_REISERFS_CHECK
- int n_repeat_counter = 0;
+ int n_repeat_counter = 0;
#endif
-
- PROC_INFO_INC( p_s_sb, search_by_key );
-
- /* As we add each node to a path we increase its count. This means that
- we must be careful to release all nodes in a path before we either
- discard the path struct or re-use the path struct, as we do here. */
- decrement_counters_in_path(p_s_search_path);
+ PROC_INFO_INC(p_s_sb, search_by_key);
+
+ /* As we add each node to a path we increase its count. This means that
+ we must be careful to release all nodes in a path before we either
+ discard the path struct or re-use the path struct, as we do here. */
- right_neighbor_of_leaf_node = 0;
+ decrement_counters_in_path(p_s_search_path);
- /* With each iteration of this loop we search through the items in the
- current node, and calculate the next current node(next path element)
- for the next iteration of this loop.. */
- n_block_number = SB_ROOT_BLOCK (p_s_sb);
- expected_level = -1;
- while ( 1 ) {
+ right_neighbor_of_leaf_node = 0;
+
+ /* With each iteration of this loop we search through the items in the
+ current node, and calculate the next current node(next path element)
+ for the next iteration of this loop.. */
+ n_block_number = SB_ROOT_BLOCK(p_s_sb);
+ expected_level = -1;
+ while (1) {
#ifdef CONFIG_REISERFS_CHECK
- if ( !(++n_repeat_counter % 50000) )
- reiserfs_warning (p_s_sb, "PAP-5100: search_by_key: %s:"
- "there were %d iterations of while loop "
- "looking for key %K",
- current->comm, n_repeat_counter, p_s_key);
+ if (!(++n_repeat_counter % 50000))
+ reiserfs_warning(p_s_sb, "PAP-5100: search_by_key: %s:"
+ "there were %d iterations of while loop "
+ "looking for key %K",
+ current->comm, n_repeat_counter,
+ p_s_key);
#endif
- /* prep path to have another element added to it. */
- p_s_last_element = PATH_OFFSET_PELEMENT(p_s_search_path, ++p_s_search_path->path_length);
- fs_gen = get_generation (p_s_sb);
-
- /* Read the next tree node, and set the last element in the path to
- have a pointer to it. */
- if ((p_s_bh = p_s_last_element->pe_buffer =
- sb_getblk(p_s_sb, n_block_number)) ) {
- if (!buffer_uptodate(p_s_bh) && reada_count > 1) {
- search_by_key_reada (p_s_sb, reada_bh,
- reada_blocks, reada_count);
- }
- ll_rw_block(READ, 1, &p_s_bh);
- wait_on_buffer(p_s_bh);
- if (!buffer_uptodate(p_s_bh))
- goto io_error;
- } else {
-io_error:
- p_s_search_path->path_length --;
- pathrelse(p_s_search_path);
- return IO_ERROR;
- }
- reada_count = 0;
- if (expected_level == -1)
- expected_level = SB_TREE_HEIGHT (p_s_sb);
- expected_level --;
-
- /* It is possible that schedule occurred. We must check whether the key
- to search is still in the tree rooted from the current buffer. If
- not then repeat search from the root. */
- if ( fs_changed (fs_gen, p_s_sb) &&
- (!B_IS_IN_TREE (p_s_bh) ||
- B_LEVEL(p_s_bh) != expected_level ||
- !key_in_buffer(p_s_search_path, p_s_key, p_s_sb))) {
- PROC_INFO_INC( p_s_sb, search_by_key_fs_changed );
- PROC_INFO_INC( p_s_sb, search_by_key_restarted );
- PROC_INFO_INC( p_s_sb, sbk_restarted[ expected_level - 1 ] );
- decrement_counters_in_path(p_s_search_path);
-
- /* Get the root block number so that we can repeat the search
- starting from the root. */
- n_block_number = SB_ROOT_BLOCK (p_s_sb);
- expected_level = -1;
- right_neighbor_of_leaf_node = 0;
-
- /* repeat search from the root */
- continue;
- }
+ /* prep path to have another element added to it. */
+ p_s_last_element =
+ PATH_OFFSET_PELEMENT(p_s_search_path,
+ ++p_s_search_path->path_length);
+ fs_gen = get_generation(p_s_sb);
+
+ /* Read the next tree node, and set the last element in the path to
+ have a pointer to it. */
+ if ((p_s_bh = p_s_last_element->pe_buffer =
+ sb_getblk(p_s_sb, n_block_number))) {
+ if (!buffer_uptodate(p_s_bh) && reada_count > 1) {
+ search_by_key_reada(p_s_sb, reada_bh,
+ reada_blocks, reada_count);
+ }
+ ll_rw_block(READ, 1, &p_s_bh);
+ wait_on_buffer(p_s_bh);
+ if (!buffer_uptodate(p_s_bh))
+ goto io_error;
+ } else {
+ io_error:
+ p_s_search_path->path_length--;
+ pathrelse(p_s_search_path);
+ return IO_ERROR;
+ }
+ reada_count = 0;
+ if (expected_level == -1)
+ expected_level = SB_TREE_HEIGHT(p_s_sb);
+ expected_level--;
+
+ /* It is possible that schedule occurred. We must check whether the key
+ to search is still in the tree rooted from the current buffer. If
+ not then repeat search from the root. */
+ if (fs_changed(fs_gen, p_s_sb) &&
+ (!B_IS_IN_TREE(p_s_bh) ||
+ B_LEVEL(p_s_bh) != expected_level ||
+ !key_in_buffer(p_s_search_path, p_s_key, p_s_sb))) {
+ PROC_INFO_INC(p_s_sb, search_by_key_fs_changed);
+ PROC_INFO_INC(p_s_sb, search_by_key_restarted);
+ PROC_INFO_INC(p_s_sb,
+ sbk_restarted[expected_level - 1]);
+ decrement_counters_in_path(p_s_search_path);
+
+ /* Get the root block number so that we can repeat the search
+ starting from the root. */
+ n_block_number = SB_ROOT_BLOCK(p_s_sb);
+ expected_level = -1;
+ right_neighbor_of_leaf_node = 0;
+
+ /* repeat search from the root */
+ continue;
+ }
- /* only check that the key is in the buffer if p_s_key is not
- equal to the MAX_KEY. Latter case is only possible in
- "finish_unfinished()" processing during mount. */
- RFALSE( comp_keys( &MAX_KEY, p_s_key ) &&
- ! key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
- "PAP-5130: key is not in the buffer");
+ /* only check that the key is in the buffer if p_s_key is not
+ equal to the MAX_KEY. Latter case is only possible in
+ "finish_unfinished()" processing during mount. */
+ RFALSE(comp_keys(&MAX_KEY, p_s_key) &&
+ !key_in_buffer(p_s_search_path, p_s_key, p_s_sb),
+ "PAP-5130: key is not in the buffer");
#ifdef CONFIG_REISERFS_CHECK
- if ( cur_tb ) {
- print_cur_tb ("5140");
- reiserfs_panic(p_s_sb, "PAP-5140: search_by_key: schedule occurred in do_balance!");
- }
+ if (cur_tb) {
+ print_cur_tb("5140");
+ reiserfs_panic(p_s_sb,
+ "PAP-5140: search_by_key: schedule occurred in do_balance!");
+ }
#endif
- // make sure, that the node contents look like a node of
- // certain level
- if (!is_tree_node (p_s_bh, expected_level)) {
- reiserfs_warning (p_s_sb, "vs-5150: search_by_key: "
- "invalid format found in block %ld. Fsck?",
- p_s_bh->b_blocknr);
- pathrelse (p_s_search_path);
- return IO_ERROR;
- }
-
- /* ok, we have acquired next formatted node in the tree */
- n_node_level = B_LEVEL (p_s_bh);
-
- PROC_INFO_BH_STAT( p_s_sb, p_s_bh, n_node_level - 1 );
-
- RFALSE( n_node_level < n_stop_level,
- "vs-5152: tree level (%d) is less than stop level (%d)",
- n_node_level, n_stop_level);
-
- n_retval = bin_search( p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
- B_NR_ITEMS(p_s_bh),
- ( n_node_level == DISK_LEAF_NODE_LEVEL ) ? IH_SIZE : KEY_SIZE,
- &(p_s_last_element->pe_position));
- if (n_node_level == n_stop_level) {
- return n_retval;
- }
+ // make sure, that the node contents look like a node of
+ // certain level
+ if (!is_tree_node(p_s_bh, expected_level)) {
+ reiserfs_warning(p_s_sb, "vs-5150: search_by_key: "
+ "invalid format found in block %ld. Fsck?",
+ p_s_bh->b_blocknr);
+ pathrelse(p_s_search_path);
+ return IO_ERROR;
+ }
- /* we are not in the stop level */
- if (n_retval == ITEM_FOUND)
- /* item has been found, so we choose the pointer which is to the right of the found one */
- p_s_last_element->pe_position++;
+ /* ok, we have acquired next formatted node in the tree */
+ n_node_level = B_LEVEL(p_s_bh);
- /* if item was not found we choose the position which is to
- the left of the found item. This requires no code,
- bin_search did it already.*/
+ PROC_INFO_BH_STAT(p_s_sb, p_s_bh, n_node_level - 1);
- /* So we have chosen a position in the current node which is
- an internal node. Now we calculate child block number by
- position in the node. */
- n_block_number = B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position);
+ RFALSE(n_node_level < n_stop_level,
+ "vs-5152: tree level (%d) is less than stop level (%d)",
+ n_node_level, n_stop_level);
- /* if we are going to read leaf nodes, try for read ahead as well */
- if ((p_s_search_path->reada & PATH_READA) &&
- n_node_level == DISK_LEAF_NODE_LEVEL + 1)
- {
- int pos = p_s_last_element->pe_position;
- int limit = B_NR_ITEMS(p_s_bh);
- struct reiserfs_key *le_key;
-
- if (p_s_search_path->reada & PATH_READA_BACK)
- limit = 0;
- while(reada_count < SEARCH_BY_KEY_READA) {
- if (pos == limit)
- break;
- reada_blocks[reada_count++] = B_N_CHILD_NUM(p_s_bh, pos);
- if (p_s_search_path->reada & PATH_READA_BACK)
- pos--;
- else
- pos++;
+ n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
+ B_NR_ITEMS(p_s_bh),
+ (n_node_level ==
+ DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
+ KEY_SIZE,
+ &(p_s_last_element->pe_position));
+ if (n_node_level == n_stop_level) {
+ return n_retval;
+ }
- /*
- * check to make sure we're in the same object
- */
- le_key = B_N_PDELIM_KEY(p_s_bh, pos);
- if (le32_to_cpu(le_key->k_objectid) !=
- p_s_key->on_disk_key.k_objectid)
- {
- break;
+ /* we are not in the stop level */
+ if (n_retval == ITEM_FOUND)
+ /* item has been found, so we choose the pointer which is to the right of the found one */
+ p_s_last_element->pe_position++;
+
+ /* if item was not found we choose the position which is to
+ the left of the found item. This requires no code,
+ bin_search did it already. */
+
+ /* So we have chosen a position in the current node which is
+ an internal node. Now we calculate child block number by
+ position in the node. */
+ n_block_number =
+ B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position);
+
+ /* if we are going to read leaf nodes, try for read ahead as well */
+ if ((p_s_search_path->reada & PATH_READA) &&
+ n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
+ int pos = p_s_last_element->pe_position;
+ int limit = B_NR_ITEMS(p_s_bh);
+ struct reiserfs_key *le_key;
+
+ if (p_s_search_path->reada & PATH_READA_BACK)
+ limit = 0;
+ while (reada_count < SEARCH_BY_KEY_READA) {
+ if (pos == limit)
+ break;
+ reada_blocks[reada_count++] =
+ B_N_CHILD_NUM(p_s_bh, pos);
+ if (p_s_search_path->reada & PATH_READA_BACK)
+ pos--;
+ else
+ pos++;
+
+ /*
+ * check to make sure we're in the same object
+ */
+ le_key = B_N_PDELIM_KEY(p_s_bh, pos);
+ if (le32_to_cpu(le_key->k_objectid) !=
+ p_s_key->on_disk_key.k_objectid) {
+ break;
+ }
+ }
}
- }
- }
- }
+ }
}
-
/* Form the path to an item and position in this item which contains
file byte defined by p_s_key. If there is no such item
corresponding to the key, we point the path to the item with
@@ -780,94 +812,97 @@ io_error:
units of directory entries. */
/* The function is NOT SCHEDULE-SAFE! */
-int search_for_position_by_key (struct super_block * p_s_sb, /* Pointer to the super block. */
- const struct cpu_key * p_cpu_key, /* Key to search (cpu variable) */
- struct path * p_s_search_path /* Filled up by this function. */
- ) {
- struct item_head * p_le_ih; /* pointer to on-disk structure */
- int n_blk_size;
- loff_t item_offset, offset;
- struct reiserfs_dir_entry de;
- int retval;
-
- /* If searching for directory entry. */
- if ( is_direntry_cpu_key (p_cpu_key) )
- return search_by_entry_key (p_s_sb, p_cpu_key, p_s_search_path, &de);
-
- /* If not searching for directory entry. */
-
- /* If item is found. */
- retval = search_item (p_s_sb, p_cpu_key, p_s_search_path);
- if (retval == IO_ERROR)
- return retval;
- if ( retval == ITEM_FOUND ) {
-
- RFALSE( ! ih_item_len(
- B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
- PATH_LAST_POSITION(p_s_search_path))),
- "PAP-5165: item length equals zero");
+int search_for_position_by_key(struct super_block *p_s_sb, /* Pointer to the super block. */
+ const struct cpu_key *p_cpu_key, /* Key to search (cpu variable) */
+ struct path *p_s_search_path /* Filled up by this function. */
+ )
+{
+ struct item_head *p_le_ih; /* pointer to on-disk structure */
+ int n_blk_size;
+ loff_t item_offset, offset;
+ struct reiserfs_dir_entry de;
+ int retval;
+
+ /* If searching for directory entry. */
+ if (is_direntry_cpu_key(p_cpu_key))
+ return search_by_entry_key(p_s_sb, p_cpu_key, p_s_search_path,
+ &de);
+
+ /* If not searching for directory entry. */
+
+ /* If item is found. */
+ retval = search_item(p_s_sb, p_cpu_key, p_s_search_path);
+ if (retval == IO_ERROR)
+ return retval;
+ if (retval == ITEM_FOUND) {
- pos_in_item(p_s_search_path) = 0;
- return POSITION_FOUND;
- }
+ RFALSE(!ih_item_len
+ (B_N_PITEM_HEAD
+ (PATH_PLAST_BUFFER(p_s_search_path),
+ PATH_LAST_POSITION(p_s_search_path))),
+ "PAP-5165: item length equals zero");
- RFALSE( ! PATH_LAST_POSITION(p_s_search_path),
- "PAP-5170: position equals zero");
+ pos_in_item(p_s_search_path) = 0;
+ return POSITION_FOUND;
+ }
- /* Item is not found. Set path to the previous item. */
- p_le_ih = B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path), --PATH_LAST_POSITION(p_s_search_path));
- n_blk_size = p_s_sb->s_blocksize;
+ RFALSE(!PATH_LAST_POSITION(p_s_search_path),
+ "PAP-5170: position equals zero");
- if (comp_short_keys (&(p_le_ih->ih_key), p_cpu_key)) {
- return FILE_NOT_FOUND;
- }
+ /* Item is not found. Set path to the previous item. */
+ p_le_ih =
+ B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
+ --PATH_LAST_POSITION(p_s_search_path));
+ n_blk_size = p_s_sb->s_blocksize;
- // FIXME: quite ugly this far
+ if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) {
+ return FILE_NOT_FOUND;
+ }
+ // FIXME: quite ugly this far
- item_offset = le_ih_k_offset (p_le_ih);
- offset = cpu_key_k_offset (p_cpu_key);
+ item_offset = le_ih_k_offset(p_le_ih);
+ offset = cpu_key_k_offset(p_cpu_key);
- /* Needed byte is contained in the item pointed to by the path.*/
- if (item_offset <= offset &&
- item_offset + op_bytes_number (p_le_ih, n_blk_size) > offset) {
- pos_in_item (p_s_search_path) = offset - item_offset;
- if ( is_indirect_le_ih(p_le_ih) ) {
- pos_in_item (p_s_search_path) /= n_blk_size;
+ /* Needed byte is contained in the item pointed to by the path. */
+ if (item_offset <= offset &&
+ item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) {
+ pos_in_item(p_s_search_path) = offset - item_offset;
+ if (is_indirect_le_ih(p_le_ih)) {
+ pos_in_item(p_s_search_path) /= n_blk_size;
+ }
+ return POSITION_FOUND;
}
- return POSITION_FOUND;
- }
-
- /* Needed byte is not contained in the item pointed to by the
- path. Set pos_in_item out of the item. */
- if ( is_indirect_le_ih (p_le_ih) )
- pos_in_item (p_s_search_path) = ih_item_len(p_le_ih) / UNFM_P_SIZE;
- else
- pos_in_item (p_s_search_path) = ih_item_len( p_le_ih );
-
- return POSITION_NOT_FOUND;
-}
+ /* Needed byte is not contained in the item pointed to by the
+ path. Set pos_in_item out of the item. */
+ if (is_indirect_le_ih(p_le_ih))
+ pos_in_item(p_s_search_path) =
+ ih_item_len(p_le_ih) / UNFM_P_SIZE;
+ else
+ pos_in_item(p_s_search_path) = ih_item_len(p_le_ih);
+
+ return POSITION_NOT_FOUND;
+}
/* Compare given item and item pointed to by the path. */
-int comp_items (const struct item_head * stored_ih, const struct path * p_s_path)
+int comp_items(const struct item_head *stored_ih, const struct path *p_s_path)
{
- struct buffer_head * p_s_bh;
- struct item_head * ih;
+ struct buffer_head *p_s_bh;
+ struct item_head *ih;
- /* Last buffer at the path is not in the tree. */
- if ( ! B_IS_IN_TREE(p_s_bh = PATH_PLAST_BUFFER(p_s_path)) )
- return 1;
+ /* Last buffer at the path is not in the tree. */
+ if (!B_IS_IN_TREE(p_s_bh = PATH_PLAST_BUFFER(p_s_path)))
+ return 1;
- /* Last path position is invalid. */
- if ( PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(p_s_bh) )
- return 1;
+ /* Last path position is invalid. */
+ if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(p_s_bh))
+ return 1;
- /* we need only to know, whether it is the same item */
- ih = get_ih (p_s_path);
- return memcmp (stored_ih, ih, IH_SIZE);
+ /* we need only to know, whether it is the same item */
+ ih = get_ih(p_s_path);
+ return memcmp(stored_ih, ih, IH_SIZE);
}
-
/* unformatted nodes are not logged anymore, ever. This is safe
** now
*/
@@ -876,461 +911,466 @@ int comp_items (const struct item_head * stored_ih, const struct path * p_s_path
// block can not be forgotten as it is in I/O or held by someone
#define block_in_use(bh) (buffer_locked(bh) || (held_by_others(bh)))
-
-
// prepare for delete or cut of direct item
-static inline int prepare_for_direct_item (struct path * path,
- struct item_head * le_ih,
- struct inode * inode,
- loff_t new_file_length,
- int * cut_size)
+static inline int prepare_for_direct_item(struct path *path,
+ struct item_head *le_ih,
+ struct inode *inode,
+ loff_t new_file_length, int *cut_size)
{
- loff_t round_len;
-
-
- if ( new_file_length == max_reiserfs_offset (inode) ) {
- /* item has to be deleted */
- *cut_size = -(IH_SIZE + ih_item_len(le_ih));
- return M_DELETE;
- }
-
- // new file gets truncated
- if (get_inode_item_key_version (inode) == KEY_FORMAT_3_6) {
- //
- round_len = ROUND_UP (new_file_length);
- /* this was n_new_file_length < le_ih ... */
- if ( round_len < le_ih_k_offset (le_ih) ) {
- *cut_size = -(IH_SIZE + ih_item_len(le_ih));
- return M_DELETE; /* Delete this item. */
+ loff_t round_len;
+
+ if (new_file_length == max_reiserfs_offset(inode)) {
+ /* item has to be deleted */
+ *cut_size = -(IH_SIZE + ih_item_len(le_ih));
+ return M_DELETE;
+ }
+ // new file gets truncated
+ if (get_inode_item_key_version(inode) == KEY_FORMAT_3_6) {
+ //
+ round_len = ROUND_UP(new_file_length);
+ /* this was n_new_file_length < le_ih ... */
+ if (round_len < le_ih_k_offset(le_ih)) {
+ *cut_size = -(IH_SIZE + ih_item_len(le_ih));
+ return M_DELETE; /* Delete this item. */
+ }
+ /* Calculate first position and size for cutting from item. */
+ pos_in_item(path) = round_len - (le_ih_k_offset(le_ih) - 1);
+ *cut_size = -(ih_item_len(le_ih) - pos_in_item(path));
+
+ return M_CUT; /* Cut from this item. */
+ }
+
+ // old file: items may have any length
+
+ if (new_file_length < le_ih_k_offset(le_ih)) {
+ *cut_size = -(IH_SIZE + ih_item_len(le_ih));
+ return M_DELETE; /* Delete this item. */
}
/* Calculate first position and size for cutting from item. */
- pos_in_item (path) = round_len - (le_ih_k_offset (le_ih) - 1);
- *cut_size = -(ih_item_len(le_ih) - pos_in_item(path));
-
- return M_CUT; /* Cut from this item. */
- }
-
-
- // old file: items may have any length
-
- if ( new_file_length < le_ih_k_offset (le_ih) ) {
- *cut_size = -(IH_SIZE + ih_item_len(le_ih));
- return M_DELETE; /* Delete this item. */
- }
- /* Calculate first position and size for cutting from item. */
- *cut_size = -(ih_item_len(le_ih) -
- (pos_in_item (path) = new_file_length + 1 - le_ih_k_offset (le_ih)));
- return M_CUT; /* Cut from this item. */
+ *cut_size = -(ih_item_len(le_ih) -
+ (pos_in_item(path) =
+ new_file_length + 1 - le_ih_k_offset(le_ih)));
+ return M_CUT; /* Cut from this item. */
}
-
-static inline int prepare_for_direntry_item (struct path * path,
- struct item_head * le_ih,
- struct inode * inode,
- loff_t new_file_length,
- int * cut_size)
+static inline int prepare_for_direntry_item(struct path *path,
+ struct item_head *le_ih,
+ struct inode *inode,
+ loff_t new_file_length,
+ int *cut_size)
{
- if (le_ih_k_offset (le_ih) == DOT_OFFSET &&
- new_file_length == max_reiserfs_offset (inode)) {
- RFALSE( ih_entry_count (le_ih) != 2,
- "PAP-5220: incorrect empty directory item (%h)", le_ih);
- *cut_size = -(IH_SIZE + ih_item_len(le_ih));
- return M_DELETE; /* Delete the directory item containing "." and ".." entry. */
- }
-
- if ( ih_entry_count (le_ih) == 1 ) {
- /* Delete the directory item such as there is one record only
- in this item*/
- *cut_size = -(IH_SIZE + ih_item_len(le_ih));
- return M_DELETE;
- }
-
- /* Cut one record from the directory item. */
- *cut_size = -(DEH_SIZE + entry_length (get_last_bh (path), le_ih, pos_in_item (path)));
- return M_CUT;
-}
+ if (le_ih_k_offset(le_ih) == DOT_OFFSET &&
+ new_file_length == max_reiserfs_offset(inode)) {
+ RFALSE(ih_entry_count(le_ih) != 2,
+ "PAP-5220: incorrect empty directory item (%h)", le_ih);
+ *cut_size = -(IH_SIZE + ih_item_len(le_ih));
+ return M_DELETE; /* Delete the directory item containing "." and ".." entry. */
+ }
+ if (ih_entry_count(le_ih) == 1) {
+ /* Delete the directory item such as there is one record only
+ in this item */
+ *cut_size = -(IH_SIZE + ih_item_len(le_ih));
+ return M_DELETE;
+ }
+
+ /* Cut one record from the directory item. */
+ *cut_size =
+ -(DEH_SIZE +
+ entry_length(get_last_bh(path), le_ih, pos_in_item(path)));
+ return M_CUT;
+}
/* If the path points to a directory or direct item, calculate mode and the size cut, for balance.
If the path points to an indirect item, remove some number of its unformatted nodes.
In case of file truncate calculate whether this item must be deleted/truncated or last
unformatted node of this item will be converted to a direct item.
This function returns a determination of what balance mode the calling function should employ. */
-static char prepare_for_delete_or_cut(
- struct reiserfs_transaction_handle *th,
- struct inode * inode,
- struct path * p_s_path,
- const struct cpu_key * p_s_item_key,
- int * p_n_removed, /* Number of unformatted nodes which were removed
- from end of the file. */
- int * p_n_cut_size,
- unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */
- ) {
- struct super_block * p_s_sb = inode->i_sb;
- struct item_head * p_le_ih = PATH_PITEM_HEAD(p_s_path);
- struct buffer_head * p_s_bh = PATH_PLAST_BUFFER(p_s_path);
-
- BUG_ON (!th->t_trans_id);
-
- /* Stat_data item. */
- if ( is_statdata_le_ih (p_le_ih) ) {
-
- RFALSE( n_new_file_length != max_reiserfs_offset (inode),
- "PAP-5210: mode must be M_DELETE");
-
- *p_n_cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
- return M_DELETE;
- }
-
-
- /* Directory item. */
- if ( is_direntry_le_ih (p_le_ih) )
- return prepare_for_direntry_item (p_s_path, p_le_ih, inode, n_new_file_length, p_n_cut_size);
-
- /* Direct item. */
- if ( is_direct_le_ih (p_le_ih) )
- return prepare_for_direct_item (p_s_path, p_le_ih, inode, n_new_file_length, p_n_cut_size);
-
-
- /* Case of an indirect item. */
- {
- int n_unfm_number, /* Number of the item unformatted nodes. */
- n_counter,
- n_blk_size;
- __le32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */
- __u32 tmp;
- struct item_head s_ih; /* Item header. */
- char c_mode; /* Returned mode of the balance. */
- int need_research;
+static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed, /* Number of unformatted nodes which were removed
+ from end of the file. */
+ int *p_n_cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */
+ )
+{
+ struct super_block *p_s_sb = inode->i_sb;
+ struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_path);
+ struct buffer_head *p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+ BUG_ON(!th->t_trans_id);
- n_blk_size = p_s_sb->s_blocksize;
+ /* Stat_data item. */
+ if (is_statdata_le_ih(p_le_ih)) {
- /* Search for the needed object indirect item until there are no unformatted nodes to be removed. */
- do {
- need_research = 0;
- p_s_bh = PATH_PLAST_BUFFER(p_s_path);
- /* Copy indirect item header to a temp variable. */
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
- /* Calculate number of unformatted nodes in this item. */
- n_unfm_number = I_UNFM_NUM(&s_ih);
-
- RFALSE( ! is_indirect_le_ih(&s_ih) || ! n_unfm_number ||
- pos_in_item (p_s_path) + 1 != n_unfm_number,
- "PAP-5240: invalid item %h "
- "n_unfm_number = %d *p_n_pos_in_item = %d",
- &s_ih, n_unfm_number, pos_in_item (p_s_path));
-
- /* Calculate balance mode and position in the item to remove unformatted nodes. */
- if ( n_new_file_length == max_reiserfs_offset (inode) ) {/* Case of delete. */
- pos_in_item (p_s_path) = 0;
- *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih));
- c_mode = M_DELETE;
- }
- else { /* Case of truncate. */
- if ( n_new_file_length < le_ih_k_offset (&s_ih) ) {
- pos_in_item (p_s_path) = 0;
- *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih));
- c_mode = M_DELETE; /* Delete this item. */
- }
- else {
- /* indirect item must be truncated starting from *p_n_pos_in_item-th position */
- pos_in_item (p_s_path) = (n_new_file_length + n_blk_size - le_ih_k_offset (&s_ih) ) >> p_s_sb->s_blocksize_bits;
-
- RFALSE( pos_in_item (p_s_path) > n_unfm_number,
- "PAP-5250: invalid position in the item");
-
- /* Either convert last unformatted node of indirect item to direct item or increase
- its free space. */
- if ( pos_in_item (p_s_path) == n_unfm_number ) {
- *p_n_cut_size = 0; /* Nothing to cut. */
- return M_CONVERT; /* Maybe convert last unformatted node to the direct item. */
- }
- /* Calculate size to cut. */
- *p_n_cut_size = -(ih_item_len(&s_ih) - pos_in_item(p_s_path) * UNFM_P_SIZE);
-
- c_mode = M_CUT; /* Cut from this indirect item. */
- }
- }
-
- RFALSE( n_unfm_number <= pos_in_item (p_s_path),
- "PAP-5260: invalid position in the indirect item");
-
- /* pointers to be cut */
- n_unfm_number -= pos_in_item (p_s_path);
- /* Set pointer to the last unformatted node pointer that is to be cut. */
- p_n_unfm_pointer = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1 - *p_n_removed;
-
-
- /* We go through the unformatted nodes pointers of the indirect
- item and look for the unformatted nodes in the cache. If we
- found some of them we free it, zero corresponding indirect item
- entry and log buffer containing that indirect item. For this we
- need to prepare last path element for logging. If some
- unformatted node has b_count > 1 we must not free this
- unformatted node since it is in use. */
- reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
- // note: path could be changed, first line in for loop takes care
- // of it
-
- for (n_counter = *p_n_removed;
- n_counter < n_unfm_number; n_counter++, p_n_unfm_pointer-- ) {
-
- cond_resched();
- if (item_moved (&s_ih, p_s_path)) {
- need_research = 1 ;
- break;
- }
- RFALSE( p_n_unfm_pointer < (__le32 *)B_I_PITEM(p_s_bh, &s_ih) ||
- p_n_unfm_pointer > (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1,
- "vs-5265: pointer out of range");
+ RFALSE(n_new_file_length != max_reiserfs_offset(inode),
+ "PAP-5210: mode must be M_DELETE");
- /* Hole, nothing to remove. */
- if ( ! get_block_num(p_n_unfm_pointer,0) ) {
- (*p_n_removed)++;
- continue;
- }
+ *p_n_cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
+ return M_DELETE;
+ }
- (*p_n_removed)++;
+ /* Directory item. */
+ if (is_direntry_le_ih(p_le_ih))
+ return prepare_for_direntry_item(p_s_path, p_le_ih, inode,
+ n_new_file_length,
+ p_n_cut_size);
- tmp = get_block_num(p_n_unfm_pointer,0);
- put_block_num(p_n_unfm_pointer, 0, 0);
- journal_mark_dirty (th, p_s_sb, p_s_bh);
- reiserfs_free_block(th, inode, tmp, 1);
- if ( item_moved (&s_ih, p_s_path) ) {
- need_research = 1;
- break ;
- }
- }
-
- /* a trick. If the buffer has been logged, this
- ** will do nothing. If we've broken the loop without
- ** logging it, it will restore the buffer
- **
- */
- reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
-
- /* This loop can be optimized. */
- } while ( (*p_n_removed < n_unfm_number || need_research) &&
- search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND );
-
- RFALSE( *p_n_removed < n_unfm_number,
- "PAP-5310: indirect item is not found");
- RFALSE( item_moved (&s_ih, p_s_path),
- "after while, comp failed, retry") ;
-
- if (c_mode == M_CUT)
- pos_in_item (p_s_path) *= UNFM_P_SIZE;
- return c_mode;
- }
+ /* Direct item. */
+ if (is_direct_le_ih(p_le_ih))
+ return prepare_for_direct_item(p_s_path, p_le_ih, inode,
+ n_new_file_length, p_n_cut_size);
+
+ /* Case of an indirect item. */
+ {
+ int n_unfm_number, /* Number of the item unformatted nodes. */
+ n_counter, n_blk_size;
+ __le32 *p_n_unfm_pointer; /* Pointer to the unformatted node number. */
+ __u32 tmp;
+ struct item_head s_ih; /* Item header. */
+ char c_mode; /* Returned mode of the balance. */
+ int need_research;
+
+ n_blk_size = p_s_sb->s_blocksize;
+
+ /* Search for the needed object indirect item until there are no unformatted nodes to be removed. */
+ do {
+ need_research = 0;
+ p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+ /* Copy indirect item header to a temp variable. */
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ /* Calculate number of unformatted nodes in this item. */
+ n_unfm_number = I_UNFM_NUM(&s_ih);
+
+ RFALSE(!is_indirect_le_ih(&s_ih) || !n_unfm_number ||
+ pos_in_item(p_s_path) + 1 != n_unfm_number,
+ "PAP-5240: invalid item %h "
+ "n_unfm_number = %d *p_n_pos_in_item = %d",
+ &s_ih, n_unfm_number, pos_in_item(p_s_path));
+
+ /* Calculate balance mode and position in the item to remove unformatted nodes. */
+ if (n_new_file_length == max_reiserfs_offset(inode)) { /* Case of delete. */
+ pos_in_item(p_s_path) = 0;
+ *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih));
+ c_mode = M_DELETE;
+ } else { /* Case of truncate. */
+ if (n_new_file_length < le_ih_k_offset(&s_ih)) {
+ pos_in_item(p_s_path) = 0;
+ *p_n_cut_size =
+ -(IH_SIZE + ih_item_len(&s_ih));
+ c_mode = M_DELETE; /* Delete this item. */
+ } else {
+ /* indirect item must be truncated starting from *p_n_pos_in_item-th position */
+ pos_in_item(p_s_path) =
+ (n_new_file_length + n_blk_size -
+ le_ih_k_offset(&s_ih)) >> p_s_sb->
+ s_blocksize_bits;
+
+ RFALSE(pos_in_item(p_s_path) >
+ n_unfm_number,
+ "PAP-5250: invalid position in the item");
+
+ /* Either convert last unformatted node of indirect item to direct item or increase
+ its free space. */
+ if (pos_in_item(p_s_path) ==
+ n_unfm_number) {
+ *p_n_cut_size = 0; /* Nothing to cut. */
+ return M_CONVERT; /* Maybe convert last unformatted node to the direct item. */
+ }
+ /* Calculate size to cut. */
+ *p_n_cut_size =
+ -(ih_item_len(&s_ih) -
+ pos_in_item(p_s_path) *
+ UNFM_P_SIZE);
+
+ c_mode = M_CUT; /* Cut from this indirect item. */
+ }
+ }
+
+ RFALSE(n_unfm_number <= pos_in_item(p_s_path),
+ "PAP-5260: invalid position in the indirect item");
+
+ /* pointers to be cut */
+ n_unfm_number -= pos_in_item(p_s_path);
+ /* Set pointer to the last unformatted node pointer that is to be cut. */
+ p_n_unfm_pointer =
+ (__le32 *) B_I_PITEM(p_s_bh,
+ &s_ih) + I_UNFM_NUM(&s_ih) -
+ 1 - *p_n_removed;
+
+ /* We go through the unformatted nodes pointers of the indirect
+ item and look for the unformatted nodes in the cache. If we
+ found some of them we free it, zero corresponding indirect item
+ entry and log buffer containing that indirect item. For this we
+ need to prepare last path element for logging. If some
+ unformatted node has b_count > 1 we must not free this
+ unformatted node since it is in use. */
+ reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
+ // note: path could be changed, first line in for loop takes care
+ // of it
+
+ for (n_counter = *p_n_removed;
+ n_counter < n_unfm_number;
+ n_counter++, p_n_unfm_pointer--) {
+
+ cond_resched();
+ if (item_moved(&s_ih, p_s_path)) {
+ need_research = 1;
+ break;
+ }
+ RFALSE(p_n_unfm_pointer <
+ (__le32 *) B_I_PITEM(p_s_bh, &s_ih)
+ || p_n_unfm_pointer >
+ (__le32 *) B_I_PITEM(p_s_bh,
+ &s_ih) +
+ I_UNFM_NUM(&s_ih) - 1,
+ "vs-5265: pointer out of range");
+
+ /* Hole, nothing to remove. */
+ if (!get_block_num(p_n_unfm_pointer, 0)) {
+ (*p_n_removed)++;
+ continue;
+ }
+
+ (*p_n_removed)++;
+
+ tmp = get_block_num(p_n_unfm_pointer, 0);
+ put_block_num(p_n_unfm_pointer, 0, 0);
+ journal_mark_dirty(th, p_s_sb, p_s_bh);
+ reiserfs_free_block(th, inode, tmp, 1);
+ if (item_moved(&s_ih, p_s_path)) {
+ need_research = 1;
+ break;
+ }
+ }
+
+ /* a trick. If the buffer has been logged, this
+ ** will do nothing. If we've broken the loop without
+ ** logging it, it will restore the buffer
+ **
+ */
+ reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
+
+ /* This loop can be optimized. */
+ } while ((*p_n_removed < n_unfm_number || need_research) &&
+ search_for_position_by_key(p_s_sb, p_s_item_key,
+ p_s_path) ==
+ POSITION_FOUND);
+
+ RFALSE(*p_n_removed < n_unfm_number,
+ "PAP-5310: indirect item is not found");
+ RFALSE(item_moved(&s_ih, p_s_path),
+ "after while, comp failed, retry");
+
+ if (c_mode == M_CUT)
+ pos_in_item(p_s_path) *= UNFM_P_SIZE;
+ return c_mode;
+ }
}
/* Calculate number of bytes which will be deleted or cut during balance */
-static int calc_deleted_bytes_number(
- struct tree_balance * p_s_tb,
- char c_mode
- ) {
- int n_del_size;
- struct item_head * p_le_ih = PATH_PITEM_HEAD(p_s_tb->tb_path);
-
- if ( is_statdata_le_ih (p_le_ih) )
- return 0;
+static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode)
+{
+ int n_del_size;
+ struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_tb->tb_path);
+
+ if (is_statdata_le_ih(p_le_ih))
+ return 0;
+
+ n_del_size =
+ (c_mode ==
+ M_DELETE) ? ih_item_len(p_le_ih) : -p_s_tb->insert_size[0];
+ if (is_direntry_le_ih(p_le_ih)) {
+ // return EMPTY_DIR_SIZE; /* We delete emty directoris only. */
+ // we can't use EMPTY_DIR_SIZE, as old format dirs have a different
+ // empty size. ick. FIXME, is this right?
+ //
+ return n_del_size;
+ }
- n_del_size = ( c_mode == M_DELETE ) ? ih_item_len(p_le_ih) : -p_s_tb->insert_size[0];
- if ( is_direntry_le_ih (p_le_ih) ) {
- // return EMPTY_DIR_SIZE; /* We delete emty directoris only. */
- // we can't use EMPTY_DIR_SIZE, as old format dirs have a different
- // empty size. ick. FIXME, is this right?
- //
- return n_del_size ;
- }
-
- if ( is_indirect_le_ih (p_le_ih) )
- n_del_size = (n_del_size/UNFM_P_SIZE)*
- (PATH_PLAST_BUFFER(p_s_tb->tb_path)->b_size);// - get_ih_free_space (p_le_ih);
- return n_del_size;
+ if (is_indirect_le_ih(p_le_ih))
+ n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(p_s_tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
+ return n_del_size;
}
-static void init_tb_struct(
- struct reiserfs_transaction_handle *th,
- struct tree_balance * p_s_tb,
- struct super_block * p_s_sb,
- struct path * p_s_path,
- int n_size
- ) {
-
- BUG_ON (!th->t_trans_id);
-
- memset (p_s_tb,'\0',sizeof(struct tree_balance));
- p_s_tb->transaction_handle = th ;
- p_s_tb->tb_sb = p_s_sb;
- p_s_tb->tb_path = p_s_path;
- PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
- PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
- p_s_tb->insert_size[0] = n_size;
-}
+static void init_tb_struct(struct reiserfs_transaction_handle *th,
+ struct tree_balance *p_s_tb,
+ struct super_block *p_s_sb,
+ struct path *p_s_path, int n_size)
+{
+ BUG_ON(!th->t_trans_id);
+ memset(p_s_tb, '\0', sizeof(struct tree_balance));
+ p_s_tb->transaction_handle = th;
+ p_s_tb->tb_sb = p_s_sb;
+ p_s_tb->tb_path = p_s_path;
+ PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
+ PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
+ p_s_tb->insert_size[0] = n_size;
+}
-void padd_item (char * item, int total_length, int length)
+void padd_item(char *item, int total_length, int length)
{
- int i;
+ int i;
- for (i = total_length; i > length; )
- item [--i] = 0;
+ for (i = total_length; i > length;)
+ item[--i] = 0;
}
#ifdef REISERQUOTA_DEBUG
char key2type(struct reiserfs_key *ih)
{
- if (is_direntry_le_key(2, ih))
- return 'd';
- if (is_direct_le_key(2, ih))
- return 'D';
- if (is_indirect_le_key(2, ih))
- return 'i';
- if (is_statdata_le_key(2, ih))
- return 's';
- return 'u';
+ if (is_direntry_le_key(2, ih))
+ return 'd';
+ if (is_direct_le_key(2, ih))
+ return 'D';
+ if (is_indirect_le_key(2, ih))
+ return 'i';
+ if (is_statdata_le_key(2, ih))
+ return 's';
+ return 'u';
}
char head2type(struct item_head *ih)
{
- if (is_direntry_le_ih(ih))
- return 'd';
- if (is_direct_le_ih(ih))
- return 'D';
- if (is_indirect_le_ih(ih))
- return 'i';
- if (is_statdata_le_ih(ih))
- return 's';
- return 'u';
+ if (is_direntry_le_ih(ih))
+ return 'd';
+ if (is_direct_le_ih(ih))
+ return 'D';
+ if (is_indirect_le_ih(ih))
+ return 'i';
+ if (is_statdata_le_ih(ih))
+ return 's';
+ return 'u';
}
#endif
/* Delete object item. */
-int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
- struct path * p_s_path, /* Path to the deleted item. */
- const struct cpu_key * p_s_item_key, /* Key to search for the deleted item. */
- struct inode * p_s_inode,/* inode is here just to update i_blocks and quotas */
- struct buffer_head * p_s_un_bh) /* NULL or unformatted node pointer. */
-{
- struct super_block * p_s_sb = p_s_inode->i_sb;
- struct tree_balance s_del_balance;
- struct item_head s_ih;
- struct item_head *q_ih;
- int quota_cut_bytes;
- int n_ret_value,
- n_del_size,
- n_removed;
+int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct path *p_s_path, /* Path to the deleted item. */
+ const struct cpu_key *p_s_item_key, /* Key to search for the deleted item. */
+ struct inode *p_s_inode, /* inode is here just to update i_blocks and quotas */
+ struct buffer_head *p_s_un_bh)
+{ /* NULL or unformatted node pointer. */
+ struct super_block *p_s_sb = p_s_inode->i_sb;
+ struct tree_balance s_del_balance;
+ struct item_head s_ih;
+ struct item_head *q_ih;
+ int quota_cut_bytes;
+ int n_ret_value, n_del_size, n_removed;
#ifdef CONFIG_REISERFS_CHECK
- char c_mode;
- int n_iter = 0;
+ char c_mode;
+ int n_iter = 0;
#endif
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- init_tb_struct(th, &s_del_balance, p_s_sb, p_s_path, 0/*size is unknown*/);
+ init_tb_struct(th, &s_del_balance, p_s_sb, p_s_path,
+ 0 /*size is unknown */ );
- while ( 1 ) {
- n_removed = 0;
+ while (1) {
+ n_removed = 0;
#ifdef CONFIG_REISERFS_CHECK
- n_iter++;
- c_mode =
+ n_iter++;
+ c_mode =
#endif
- prepare_for_delete_or_cut(th, p_s_inode, p_s_path, p_s_item_key, &n_removed, &n_del_size, max_reiserfs_offset (p_s_inode));
-
- RFALSE( c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
-
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
- s_del_balance.insert_size[0] = n_del_size;
-
- n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
- if ( n_ret_value != REPEAT_SEARCH )
- break;
-
- PROC_INFO_INC( p_s_sb, delete_item_restarted );
+ prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
+ p_s_item_key, &n_removed,
+ &n_del_size,
+ max_reiserfs_offset(p_s_inode));
+
+ RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
+
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ s_del_balance.insert_size[0] = n_del_size;
+
+ n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
+ if (n_ret_value != REPEAT_SEARCH)
+ break;
+
+ PROC_INFO_INC(p_s_sb, delete_item_restarted);
+
+ // file system changed, repeat search
+ n_ret_value =
+ search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
+ if (n_ret_value == IO_ERROR)
+ break;
+ if (n_ret_value == FILE_NOT_FOUND) {
+ reiserfs_warning(p_s_sb,
+ "vs-5340: reiserfs_delete_item: "
+ "no items of the file %K found",
+ p_s_item_key);
+ break;
+ }
+ } /* while (1) */
- // file system changed, repeat search
- n_ret_value = search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
- if (n_ret_value == IO_ERROR)
- break;
- if (n_ret_value == FILE_NOT_FOUND) {
- reiserfs_warning (p_s_sb, "vs-5340: reiserfs_delete_item: "
- "no items of the file %K found", p_s_item_key);
- break;
+ if (n_ret_value != CARRY_ON) {
+ unfix_nodes(&s_del_balance);
+ return 0;
+ }
+ // reiserfs_delete_item returns item length when success
+ n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
+ q_ih = get_ih(p_s_path);
+ quota_cut_bytes = ih_item_len(q_ih);
+
+ /* hack so the quota code doesn't have to guess if the file
+ ** has a tail. On tail insert, we allocate quota for 1 unformatted node.
+ ** We test the offset because the tail might have been
+ ** split into multiple items, and we only want to decrement for
+ ** the unfm node once
+ */
+ if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(q_ih)) {
+ if ((le_ih_k_offset(q_ih) & (p_s_sb->s_blocksize - 1)) == 1) {
+ quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE;
+ } else {
+ quota_cut_bytes = 0;
+ }
}
- } /* while (1) */
- if ( n_ret_value != CARRY_ON ) {
- unfix_nodes(&s_del_balance);
- return 0;
- }
-
- // reiserfs_delete_item returns item length when success
- n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
- q_ih = get_ih(p_s_path) ;
- quota_cut_bytes = ih_item_len(q_ih) ;
-
- /* hack so the quota code doesn't have to guess if the file
- ** has a tail. On tail insert, we allocate quota for 1 unformatted node.
- ** We test the offset because the tail might have been
- ** split into multiple items, and we only want to decrement for
- ** the unfm node once
- */
- if (!S_ISLNK (p_s_inode->i_mode) && is_direct_le_ih(q_ih)) {
- if ((le_ih_k_offset(q_ih) & (p_s_sb->s_blocksize - 1)) == 1) {
- quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE;
- } else {
- quota_cut_bytes = 0 ;
+ if (p_s_un_bh) {
+ int off;
+ char *data;
+
+ /* We are in direct2indirect conversion, so move tail contents
+ to the unformatted node */
+ /* note, we do the copy before preparing the buffer because we
+ ** don't care about the contents of the unformatted node yet.
+ ** the only thing we really care about is the direct item's data
+ ** is in the unformatted node.
+ **
+ ** Otherwise, we would have to call reiserfs_prepare_for_journal on
+ ** the unformatted node, which might schedule, meaning we'd have to
+ ** loop all the way back up to the start of the while loop.
+ **
+ ** The unformatted node must be dirtied later on. We can't be
+ ** sure here if the entire tail has been deleted yet.
+ **
+ ** p_s_un_bh is from the page cache (all unformatted nodes are
+ ** from the page cache) and might be a highmem page. So, we
+ ** can't use p_s_un_bh->b_data.
+ ** -clm
+ */
+
+ data = kmap_atomic(p_s_un_bh->b_page, KM_USER0);
+ off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
+ memcpy(data + off,
+ B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih),
+ n_ret_value);
+ kunmap_atomic(data, KM_USER0);
}
- }
-
- if ( p_s_un_bh ) {
- int off;
- char *data ;
-
- /* We are in direct2indirect conversion, so move tail contents
- to the unformatted node */
- /* note, we do the copy before preparing the buffer because we
- ** don't care about the contents of the unformatted node yet.
- ** the only thing we really care about is the direct item's data
- ** is in the unformatted node.
- **
- ** Otherwise, we would have to call reiserfs_prepare_for_journal on
- ** the unformatted node, which might schedule, meaning we'd have to
- ** loop all the way back up to the start of the while loop.
- **
- ** The unformatted node must be dirtied later on. We can't be
- ** sure here if the entire tail has been deleted yet.
- **
- ** p_s_un_bh is from the page cache (all unformatted nodes are
- ** from the page cache) and might be a highmem page. So, we
- ** can't use p_s_un_bh->b_data.
- ** -clm
- */
-
- data = kmap_atomic(p_s_un_bh->b_page, KM_USER0);
- off = ((le_ih_k_offset (&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
- memcpy(data + off,
- B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih), n_ret_value);
- kunmap_atomic(data, KM_USER0);
- }
- /* Perform balancing after all resources have been collected at once. */
- do_balance(&s_del_balance, NULL, NULL, M_DELETE);
+ /* Perform balancing after all resources have been collected at once. */
+ do_balance(&s_del_balance, NULL, NULL, M_DELETE);
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (p_s_sb, REISERFS_DEBUG_CODE, "reiserquota delete_item(): freeing %u, id=%u type=%c", quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
+ reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE,
+ "reiserquota delete_item(): freeing %u, id=%u type=%c",
+ quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
#endif
- DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
+ DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
- /* Return deleted body length */
- return n_ret_value;
+ /* Return deleted body length */
+ return n_ret_value;
}
-
/* Summary Of Mechanisms For Handling Collisions Between Processes:
deletion of the body of the object is performed by iput(), with the
@@ -1347,727 +1387,804 @@ int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
- Hans
*/
-
/* this deletes item which never gets split */
-void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
- struct inode *inode,
- struct reiserfs_key * key)
+void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
+ struct inode *inode, struct reiserfs_key *key)
{
- struct tree_balance tb;
- INITIALIZE_PATH (path);
- int item_len = 0;
- int tb_init = 0 ;
- struct cpu_key cpu_key;
- int retval;
- int quota_cut_bytes = 0;
-
- BUG_ON (!th->t_trans_id);
-
- le_key2cpu_key (&cpu_key, key);
-
- while (1) {
- retval = search_item (th->t_super, &cpu_key, &path);
- if (retval == IO_ERROR) {
- reiserfs_warning (th->t_super,
- "vs-5350: reiserfs_delete_solid_item: "
- "i/o failure occurred trying to delete %K",
- &cpu_key);
- break;
- }
- if (retval != ITEM_FOUND) {
- pathrelse (&path);
- // No need for a warning, if there is just no free space to insert '..' item into the newly-created subdir
- if ( !( (unsigned long long) GET_HASH_VALUE (le_key_k_offset (le_key_version (key), key)) == 0 && \
- (unsigned long long) GET_GENERATION_NUMBER (le_key_k_offset (le_key_version (key), key)) == 1 ) )
- reiserfs_warning (th->t_super, "vs-5355: reiserfs_delete_solid_item: %k not found", key);
- break;
- }
- if (!tb_init) {
- tb_init = 1 ;
- item_len = ih_item_len( PATH_PITEM_HEAD(&path) );
- init_tb_struct (th, &tb, th->t_super, &path, - (IH_SIZE + item_len));
- }
- quota_cut_bytes = ih_item_len(PATH_PITEM_HEAD(&path)) ;
+ struct tree_balance tb;
+ INITIALIZE_PATH(path);
+ int item_len = 0;
+ int tb_init = 0;
+ struct cpu_key cpu_key;
+ int retval;
+ int quota_cut_bytes = 0;
+
+ BUG_ON(!th->t_trans_id);
+
+ le_key2cpu_key(&cpu_key, key);
+
+ while (1) {
+ retval = search_item(th->t_super, &cpu_key, &path);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(th->t_super,
+ "vs-5350: reiserfs_delete_solid_item: "
+ "i/o failure occurred trying to delete %K",
+ &cpu_key);
+ break;
+ }
+ if (retval != ITEM_FOUND) {
+ pathrelse(&path);
+ // No need for a warning, if there is just no free space to insert '..' item into the newly-created subdir
+ if (!
+ ((unsigned long long)
+ GET_HASH_VALUE(le_key_k_offset
+ (le_key_version(key), key)) == 0
+ && (unsigned long long)
+ GET_GENERATION_NUMBER(le_key_k_offset
+ (le_key_version(key),
+ key)) == 1))
+ reiserfs_warning(th->t_super,
+ "vs-5355: reiserfs_delete_solid_item: %k not found",
+ key);
+ break;
+ }
+ if (!tb_init) {
+ tb_init = 1;
+ item_len = ih_item_len(PATH_PITEM_HEAD(&path));
+ init_tb_struct(th, &tb, th->t_super, &path,
+ -(IH_SIZE + item_len));
+ }
+ quota_cut_bytes = ih_item_len(PATH_PITEM_HEAD(&path));
- retval = fix_nodes (M_DELETE, &tb, NULL, NULL);
- if (retval == REPEAT_SEARCH) {
- PROC_INFO_INC( th -> t_super, delete_solid_item_restarted );
- continue;
- }
+ retval = fix_nodes(M_DELETE, &tb, NULL, NULL);
+ if (retval == REPEAT_SEARCH) {
+ PROC_INFO_INC(th->t_super, delete_solid_item_restarted);
+ continue;
+ }
- if (retval == CARRY_ON) {
- do_balance (&tb, NULL, NULL, M_DELETE);
- if (inode) { /* Should we count quota for item? (we don't count quotas for save-links) */
+ if (retval == CARRY_ON) {
+ do_balance(&tb, NULL, NULL, M_DELETE);
+ if (inode) { /* Should we count quota for item? (we don't count quotas for save-links) */
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (th->t_super, REISERFS_DEBUG_CODE, "reiserquota delete_solid_item(): freeing %u id=%u type=%c", quota_cut_bytes, inode->i_uid, key2type(key));
+ reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
+ "reiserquota delete_solid_item(): freeing %u id=%u type=%c",
+ quota_cut_bytes, inode->i_uid,
+ key2type(key));
#endif
- DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
- }
- break;
+ DQUOT_FREE_SPACE_NODIRTY(inode,
+ quota_cut_bytes);
+ }
+ break;
+ }
+ // IO_ERROR, NO_DISK_SPACE, etc
+ reiserfs_warning(th->t_super,
+ "vs-5360: reiserfs_delete_solid_item: "
+ "could not delete %K due to fix_nodes failure",
+ &cpu_key);
+ unfix_nodes(&tb);
+ break;
}
- // IO_ERROR, NO_DISK_SPACE, etc
- reiserfs_warning (th->t_super, "vs-5360: reiserfs_delete_solid_item: "
- "could not delete %K due to fix_nodes failure", &cpu_key);
- unfix_nodes (&tb);
- break;
- }
-
- reiserfs_check_path(&path) ;
+ reiserfs_check_path(&path);
}
-
-int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * inode)
+int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
+ struct inode *inode)
{
- int err;
- inode->i_size = 0;
- BUG_ON (!th->t_trans_id);
-
- /* for directory this deletes item containing "." and ".." */
- err = reiserfs_do_truncate (th, inode, NULL, 0/*no timestamp updates*/);
- if (err)
- return err;
-
+ int err;
+ inode->i_size = 0;
+ BUG_ON(!th->t_trans_id);
+
+ /* for directory this deletes item containing "." and ".." */
+ err =
+ reiserfs_do_truncate(th, inode, NULL, 0 /*no timestamp updates */ );
+ if (err)
+ return err;
+
#if defined( USE_INODE_GENERATION_COUNTER )
- if( !old_format_only ( th -> t_super ) )
- {
- __le32 *inode_generation;
-
- inode_generation =
- &REISERFS_SB(th -> t_super) -> s_rs -> s_inode_generation;
- *inode_generation = cpu_to_le32( le32_to_cpu( *inode_generation ) + 1 );
- }
+ if (!old_format_only(th->t_super)) {
+ __le32 *inode_generation;
+
+ inode_generation =
+ &REISERFS_SB(th->t_super)->s_rs->s_inode_generation;
+ *inode_generation =
+ cpu_to_le32(le32_to_cpu(*inode_generation) + 1);
+ }
/* USE_INODE_GENERATION_COUNTER */
#endif
- reiserfs_delete_solid_item (th, inode, INODE_PKEY (inode));
+ reiserfs_delete_solid_item(th, inode, INODE_PKEY(inode));
- return err;
+ return err;
}
-static void
-unmap_buffers(struct page *page, loff_t pos) {
- struct buffer_head *bh ;
- struct buffer_head *head ;
- struct buffer_head *next ;
- unsigned long tail_index ;
- unsigned long cur_index ;
-
- if (page) {
- if (page_has_buffers(page)) {
- tail_index = pos & (PAGE_CACHE_SIZE - 1) ;
- cur_index = 0 ;
- head = page_buffers(page) ;
- bh = head ;
- do {
- next = bh->b_this_page ;
-
- /* we want to unmap the buffers that contain the tail, and
- ** all the buffers after it (since the tail must be at the
- ** end of the file). We don't want to unmap file data
- ** before the tail, since it might be dirty and waiting to
- ** reach disk
- */
- cur_index += bh->b_size ;
- if (cur_index > tail_index) {
- reiserfs_unmap_buffer(bh) ;
+static void unmap_buffers(struct page *page, loff_t pos)
+{
+ struct buffer_head *bh;
+ struct buffer_head *head;
+ struct buffer_head *next;
+ unsigned long tail_index;
+ unsigned long cur_index;
+
+ if (page) {
+ if (page_has_buffers(page)) {
+ tail_index = pos & (PAGE_CACHE_SIZE - 1);
+ cur_index = 0;
+ head = page_buffers(page);
+ bh = head;
+ do {
+ next = bh->b_this_page;
+
+ /* we want to unmap the buffers that contain the tail, and
+ ** all the buffers after it (since the tail must be at the
+ ** end of the file). We don't want to unmap file data
+ ** before the tail, since it might be dirty and waiting to
+ ** reach disk
+ */
+ cur_index += bh->b_size;
+ if (cur_index > tail_index) {
+ reiserfs_unmap_buffer(bh);
+ }
+ bh = next;
+ } while (bh != head);
+ if (PAGE_SIZE == bh->b_size) {
+ clear_page_dirty(page);
+ }
}
- bh = next ;
- } while (bh != head) ;
- if ( PAGE_SIZE == bh->b_size ) {
- clear_page_dirty(page);
- }
}
- }
}
-static int maybe_indirect_to_direct (struct reiserfs_transaction_handle *th,
- struct inode * p_s_inode,
- struct page *page,
- struct path * p_s_path,
- const struct cpu_key * p_s_item_key,
- loff_t n_new_file_size,
- char * p_c_mode
- ) {
- struct super_block * p_s_sb = p_s_inode->i_sb;
- int n_block_size = p_s_sb->s_blocksize;
- int cut_bytes;
- BUG_ON (!th->t_trans_id);
-
- if (n_new_file_size != p_s_inode->i_size)
- BUG ();
-
- /* the page being sent in could be NULL if there was an i/o error
- ** reading in the last block. The user will hit problems trying to
- ** read the file, but for now we just skip the indirect2direct
- */
- if (atomic_read(&p_s_inode->i_count) > 1 ||
- !tail_has_to_be_packed (p_s_inode) ||
- !page || (REISERFS_I(p_s_inode)->i_flags & i_nopack_mask)) {
- // leave tail in an unformatted node
- *p_c_mode = M_SKIP_BALANCING;
- cut_bytes = n_block_size - (n_new_file_size & (n_block_size - 1));
- pathrelse(p_s_path);
- return cut_bytes;
- }
- /* Permorm the conversion to a direct_item. */
- /*return indirect_to_direct (p_s_inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode);*/
- return indirect2direct (th, p_s_inode, page, p_s_path, p_s_item_key, n_new_file_size, p_c_mode);
-}
+static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
+ struct inode *p_s_inode,
+ struct page *page,
+ struct path *p_s_path,
+ const struct cpu_key *p_s_item_key,
+ loff_t n_new_file_size, char *p_c_mode)
+{
+ struct super_block *p_s_sb = p_s_inode->i_sb;
+ int n_block_size = p_s_sb->s_blocksize;
+ int cut_bytes;
+ BUG_ON(!th->t_trans_id);
+
+ if (n_new_file_size != p_s_inode->i_size)
+ BUG();
+ /* the page being sent in could be NULL if there was an i/o error
+ ** reading in the last block. The user will hit problems trying to
+ ** read the file, but for now we just skip the indirect2direct
+ */
+ if (atomic_read(&p_s_inode->i_count) > 1 ||
+ !tail_has_to_be_packed(p_s_inode) ||
+ !page || (REISERFS_I(p_s_inode)->i_flags & i_nopack_mask)) {
+ // leave tail in an unformatted node
+ *p_c_mode = M_SKIP_BALANCING;
+ cut_bytes =
+ n_block_size - (n_new_file_size & (n_block_size - 1));
+ pathrelse(p_s_path);
+ return cut_bytes;
+ }
+ /* Permorm the conversion to a direct_item. */
+ /*return indirect_to_direct (p_s_inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode); */
+ return indirect2direct(th, p_s_inode, page, p_s_path, p_s_item_key,
+ n_new_file_size, p_c_mode);
+}
/* we did indirect_to_direct conversion. And we have inserted direct
item successesfully, but there were no disk space to cut unfm
pointer being converted. Therefore we have to delete inserted
direct item(s) */
-static void indirect_to_direct_roll_back (struct reiserfs_transaction_handle *th, struct inode * inode, struct path * path)
+static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th,
+ struct inode *inode, struct path *path)
{
- struct cpu_key tail_key;
- int tail_len;
- int removed;
- BUG_ON (!th->t_trans_id);
-
- make_cpu_key (&tail_key, inode, inode->i_size + 1, TYPE_DIRECT, 4);// !!!!
- tail_key.key_length = 4;
-
- tail_len = (cpu_key_k_offset (&tail_key) & (inode->i_sb->s_blocksize - 1)) - 1;
- while (tail_len) {
- /* look for the last byte of the tail */
- if (search_for_position_by_key (inode->i_sb, &tail_key, path) == POSITION_NOT_FOUND)
- reiserfs_panic (inode->i_sb, "vs-5615: indirect_to_direct_roll_back: found invalid item");
- RFALSE( path->pos_in_item != ih_item_len(PATH_PITEM_HEAD (path)) - 1,
- "vs-5616: appended bytes found");
- PATH_LAST_POSITION (path) --;
-
- removed = reiserfs_delete_item (th, path, &tail_key, inode, NULL/*unbh not needed*/);
- RFALSE( removed <= 0 || removed > tail_len,
- "vs-5617: there was tail %d bytes, removed item length %d bytes",
- tail_len, removed);
- tail_len -= removed;
- set_cpu_key_k_offset (&tail_key, cpu_key_k_offset (&tail_key) - removed);
- }
- reiserfs_warning (inode->i_sb, "indirect_to_direct_roll_back: indirect_to_direct conversion has been rolled back due to lack of disk space");
- //mark_file_without_tail (inode);
- mark_inode_dirty (inode);
+ struct cpu_key tail_key;
+ int tail_len;
+ int removed;
+ BUG_ON(!th->t_trans_id);
+
+ make_cpu_key(&tail_key, inode, inode->i_size + 1, TYPE_DIRECT, 4); // !!!!
+ tail_key.key_length = 4;
+
+ tail_len =
+ (cpu_key_k_offset(&tail_key) & (inode->i_sb->s_blocksize - 1)) - 1;
+ while (tail_len) {
+ /* look for the last byte of the tail */
+ if (search_for_position_by_key(inode->i_sb, &tail_key, path) ==
+ POSITION_NOT_FOUND)
+ reiserfs_panic(inode->i_sb,
+ "vs-5615: indirect_to_direct_roll_back: found invalid item");
+ RFALSE(path->pos_in_item !=
+ ih_item_len(PATH_PITEM_HEAD(path)) - 1,
+ "vs-5616: appended bytes found");
+ PATH_LAST_POSITION(path)--;
+
+ removed =
+ reiserfs_delete_item(th, path, &tail_key, inode,
+ NULL /*unbh not needed */ );
+ RFALSE(removed <= 0
+ || removed > tail_len,
+ "vs-5617: there was tail %d bytes, removed item length %d bytes",
+ tail_len, removed);
+ tail_len -= removed;
+ set_cpu_key_k_offset(&tail_key,
+ cpu_key_k_offset(&tail_key) - removed);
+ }
+ reiserfs_warning(inode->i_sb,
+ "indirect_to_direct_roll_back: indirect_to_direct conversion has been rolled back due to lack of disk space");
+ //mark_file_without_tail (inode);
+ mark_inode_dirty(inode);
}
-
/* (Truncate or cut entry) or delete object item. Returns < 0 on failure */
-int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
- struct path * p_s_path,
- struct cpu_key * p_s_item_key,
- struct inode * p_s_inode,
- struct page *page,
- loff_t n_new_file_size)
+int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
+ struct path *p_s_path,
+ struct cpu_key *p_s_item_key,
+ struct inode *p_s_inode,
+ struct page *page, loff_t n_new_file_size)
{
- struct super_block * p_s_sb = p_s_inode->i_sb;
- /* Every function which is going to call do_balance must first
- create a tree_balance structure. Then it must fill up this
- structure by using the init_tb_struct and fix_nodes functions.
- After that we can make tree balancing. */
- struct tree_balance s_cut_balance;
- struct item_head *p_le_ih;
- int n_cut_size = 0, /* Amount to be cut. */
- n_ret_value = CARRY_ON,
- n_removed = 0, /* Number of the removed unformatted nodes. */
- n_is_inode_locked = 0;
- char c_mode; /* Mode of the balance. */
- int retval2 = -1;
- int quota_cut_bytes;
- loff_t tail_pos = 0;
-
- BUG_ON (!th->t_trans_id);
-
- init_tb_struct(th, &s_cut_balance, p_s_inode->i_sb, p_s_path, n_cut_size);
-
-
- /* Repeat this loop until we either cut the item without needing
- to balance, or we fix_nodes without schedule occurring */
- while ( 1 ) {
- /* Determine the balance mode, position of the first byte to
- be cut, and size to be cut. In case of the indirect item
- free unformatted nodes which are pointed to by the cut
- pointers. */
-
- c_mode = prepare_for_delete_or_cut(th, p_s_inode, p_s_path, p_s_item_key, &n_removed,
- &n_cut_size, n_new_file_size);
- if ( c_mode == M_CONVERT ) {
- /* convert last unformatted node to direct item or leave
- tail in the unformatted node */
- RFALSE( n_ret_value != CARRY_ON, "PAP-5570: can not convert twice");
-
- n_ret_value = maybe_indirect_to_direct (th, p_s_inode, page, p_s_path, p_s_item_key,
- n_new_file_size, &c_mode);
- if ( c_mode == M_SKIP_BALANCING )
- /* tail has been left in the unformatted node */
- return n_ret_value;
-
- n_is_inode_locked = 1;
-
- /* removing of last unformatted node will change value we
- have to return to truncate. Save it */
- retval2 = n_ret_value;
- /*retval2 = p_s_sb->s_blocksize - (n_new_file_size & (p_s_sb->s_blocksize - 1));*/
-
- /* So, we have performed the first part of the conversion:
- inserting the new direct item. Now we are removing the
- last unformatted node pointer. Set key to search for
- it. */
- set_cpu_key_k_type (p_s_item_key, TYPE_INDIRECT);
- p_s_item_key->key_length = 4;
- n_new_file_size -= (n_new_file_size & (p_s_sb->s_blocksize - 1));
- tail_pos = n_new_file_size;
- set_cpu_key_k_offset (p_s_item_key, n_new_file_size + 1);
- if ( search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_NOT_FOUND ){
- print_block (PATH_PLAST_BUFFER (p_s_path), 3, PATH_LAST_POSITION (p_s_path) - 1, PATH_LAST_POSITION (p_s_path) + 1);
- reiserfs_panic(p_s_sb, "PAP-5580: reiserfs_cut_from_item: item to convert does not exist (%K)", p_s_item_key);
- }
- continue;
- }
- if (n_cut_size == 0) {
- pathrelse (p_s_path);
- return 0;
- }
+ struct super_block *p_s_sb = p_s_inode->i_sb;
+ /* Every function which is going to call do_balance must first
+ create a tree_balance structure. Then it must fill up this
+ structure by using the init_tb_struct and fix_nodes functions.
+ After that we can make tree balancing. */
+ struct tree_balance s_cut_balance;
+ struct item_head *p_le_ih;
+ int n_cut_size = 0, /* Amount to be cut. */
+ n_ret_value = CARRY_ON, n_removed = 0, /* Number of the removed unformatted nodes. */
+ n_is_inode_locked = 0;
+ char c_mode; /* Mode of the balance. */
+ int retval2 = -1;
+ int quota_cut_bytes;
+ loff_t tail_pos = 0;
+
+ BUG_ON(!th->t_trans_id);
+
+ init_tb_struct(th, &s_cut_balance, p_s_inode->i_sb, p_s_path,
+ n_cut_size);
+
+ /* Repeat this loop until we either cut the item without needing
+ to balance, or we fix_nodes without schedule occurring */
+ while (1) {
+ /* Determine the balance mode, position of the first byte to
+ be cut, and size to be cut. In case of the indirect item
+ free unformatted nodes which are pointed to by the cut
+ pointers. */
+
+ c_mode =
+ prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
+ p_s_item_key, &n_removed,
+ &n_cut_size, n_new_file_size);
+ if (c_mode == M_CONVERT) {
+ /* convert last unformatted node to direct item or leave
+ tail in the unformatted node */
+ RFALSE(n_ret_value != CARRY_ON,
+ "PAP-5570: can not convert twice");
+
+ n_ret_value =
+ maybe_indirect_to_direct(th, p_s_inode, page,
+ p_s_path, p_s_item_key,
+ n_new_file_size, &c_mode);
+ if (c_mode == M_SKIP_BALANCING)
+ /* tail has been left in the unformatted node */
+ return n_ret_value;
+
+ n_is_inode_locked = 1;
+
+ /* removing of last unformatted node will change value we
+ have to return to truncate. Save it */
+ retval2 = n_ret_value;
+ /*retval2 = p_s_sb->s_blocksize - (n_new_file_size & (p_s_sb->s_blocksize - 1)); */
+
+ /* So, we have performed the first part of the conversion:
+ inserting the new direct item. Now we are removing the
+ last unformatted node pointer. Set key to search for
+ it. */
+ set_cpu_key_k_type(p_s_item_key, TYPE_INDIRECT);
+ p_s_item_key->key_length = 4;
+ n_new_file_size -=
+ (n_new_file_size & (p_s_sb->s_blocksize - 1));
+ tail_pos = n_new_file_size;
+ set_cpu_key_k_offset(p_s_item_key, n_new_file_size + 1);
+ if (search_for_position_by_key
+ (p_s_sb, p_s_item_key,
+ p_s_path) == POSITION_NOT_FOUND) {
+ print_block(PATH_PLAST_BUFFER(p_s_path), 3,
+ PATH_LAST_POSITION(p_s_path) - 1,
+ PATH_LAST_POSITION(p_s_path) + 1);
+ reiserfs_panic(p_s_sb,
+ "PAP-5580: reiserfs_cut_from_item: item to convert does not exist (%K)",
+ p_s_item_key);
+ }
+ continue;
+ }
+ if (n_cut_size == 0) {
+ pathrelse(p_s_path);
+ return 0;
+ }
+
+ s_cut_balance.insert_size[0] = n_cut_size;
+
+ n_ret_value = fix_nodes(c_mode, &s_cut_balance, NULL, NULL);
+ if (n_ret_value != REPEAT_SEARCH)
+ break;
+
+ PROC_INFO_INC(p_s_sb, cut_from_item_restarted);
+
+ n_ret_value =
+ search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
+ if (n_ret_value == POSITION_FOUND)
+ continue;
- s_cut_balance.insert_size[0] = n_cut_size;
-
- n_ret_value = fix_nodes(c_mode, &s_cut_balance, NULL, NULL);
- if ( n_ret_value != REPEAT_SEARCH )
- break;
-
- PROC_INFO_INC( p_s_sb, cut_from_item_restarted );
-
- n_ret_value = search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path);
- if (n_ret_value == POSITION_FOUND)
- continue;
-
- reiserfs_warning (p_s_sb, "PAP-5610: reiserfs_cut_from_item: item %K not found", p_s_item_key);
- unfix_nodes (&s_cut_balance);
- return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
- } /* while */
-
- // check fix_nodes results (IO_ERROR or NO_DISK_SPACE)
- if ( n_ret_value != CARRY_ON ) {
- if ( n_is_inode_locked ) {
- // FIXME: this seems to be not needed: we are always able
- // to cut item
- indirect_to_direct_roll_back (th, p_s_inode, p_s_path);
+ reiserfs_warning(p_s_sb,
+ "PAP-5610: reiserfs_cut_from_item: item %K not found",
+ p_s_item_key);
+ unfix_nodes(&s_cut_balance);
+ return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
+ } /* while */
+
+ // check fix_nodes results (IO_ERROR or NO_DISK_SPACE)
+ if (n_ret_value != CARRY_ON) {
+ if (n_is_inode_locked) {
+ // FIXME: this seems to be not needed: we are always able
+ // to cut item
+ indirect_to_direct_roll_back(th, p_s_inode, p_s_path);
+ }
+ if (n_ret_value == NO_DISK_SPACE)
+ reiserfs_warning(p_s_sb, "NO_DISK_SPACE");
+ unfix_nodes(&s_cut_balance);
+ return -EIO;
}
- if (n_ret_value == NO_DISK_SPACE)
- reiserfs_warning (p_s_sb, "NO_DISK_SPACE");
- unfix_nodes (&s_cut_balance);
- return -EIO;
- }
-
- /* go ahead and perform balancing */
-
- RFALSE( c_mode == M_PASTE || c_mode == M_INSERT, "invalid mode");
-
- /* Calculate number of bytes that need to be cut from the item. */
- quota_cut_bytes = ( c_mode == M_DELETE ) ? ih_item_len(get_ih(p_s_path)) : -s_cut_balance.insert_size[0];
- if (retval2 == -1)
- n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode);
- else
- n_ret_value = retval2;
-
-
- /* For direct items, we only change the quota when deleting the last
- ** item.
- */
- p_le_ih = PATH_PITEM_HEAD (s_cut_balance.tb_path);
- if (!S_ISLNK (p_s_inode->i_mode) && is_direct_le_ih(p_le_ih)) {
- if (c_mode == M_DELETE &&
- (le_ih_k_offset (p_le_ih) & (p_s_sb->s_blocksize - 1)) == 1 ) {
- // FIXME: this is to keep 3.5 happy
- REISERFS_I(p_s_inode)->i_first_direct_byte = U32_MAX;
- quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE ;
- } else {
- quota_cut_bytes = 0 ;
+
+ /* go ahead and perform balancing */
+
+ RFALSE(c_mode == M_PASTE || c_mode == M_INSERT, "invalid mode");
+
+ /* Calculate number of bytes that need to be cut from the item. */
+ quota_cut_bytes =
+ (c_mode ==
+ M_DELETE) ? ih_item_len(get_ih(p_s_path)) : -s_cut_balance.
+ insert_size[0];
+ if (retval2 == -1)
+ n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode);
+ else
+ n_ret_value = retval2;
+
+ /* For direct items, we only change the quota when deleting the last
+ ** item.
+ */
+ p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path);
+ if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(p_le_ih)) {
+ if (c_mode == M_DELETE &&
+ (le_ih_k_offset(p_le_ih) & (p_s_sb->s_blocksize - 1)) ==
+ 1) {
+ // FIXME: this is to keep 3.5 happy
+ REISERFS_I(p_s_inode)->i_first_direct_byte = U32_MAX;
+ quota_cut_bytes = p_s_sb->s_blocksize + UNFM_P_SIZE;
+ } else {
+ quota_cut_bytes = 0;
+ }
}
- }
#ifdef CONFIG_REISERFS_CHECK
- if (n_is_inode_locked) {
- struct item_head * le_ih = PATH_PITEM_HEAD (s_cut_balance.tb_path);
- /* we are going to complete indirect2direct conversion. Make
- sure, that we exactly remove last unformatted node pointer
- of the item */
- if (!is_indirect_le_ih (le_ih))
- reiserfs_panic (p_s_sb, "vs-5652: reiserfs_cut_from_item: "
- "item must be indirect %h", le_ih);
-
- if (c_mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
- reiserfs_panic (p_s_sb, "vs-5653: reiserfs_cut_from_item: "
- "completing indirect2direct conversion indirect item %h "
- "being deleted must be of 4 byte long", le_ih);
-
- if (c_mode == M_CUT && s_cut_balance.insert_size[0] != -UNFM_P_SIZE) {
- reiserfs_panic (p_s_sb, "vs-5654: reiserfs_cut_from_item: "
- "can not complete indirect2direct conversion of %h (CUT, insert_size==%d)",
- le_ih, s_cut_balance.insert_size[0]);
+ if (n_is_inode_locked) {
+ struct item_head *le_ih =
+ PATH_PITEM_HEAD(s_cut_balance.tb_path);
+ /* we are going to complete indirect2direct conversion. Make
+ sure, that we exactly remove last unformatted node pointer
+ of the item */
+ if (!is_indirect_le_ih(le_ih))
+ reiserfs_panic(p_s_sb,
+ "vs-5652: reiserfs_cut_from_item: "
+ "item must be indirect %h", le_ih);
+
+ if (c_mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
+ reiserfs_panic(p_s_sb,
+ "vs-5653: reiserfs_cut_from_item: "
+ "completing indirect2direct conversion indirect item %h "
+ "being deleted must be of 4 byte long",
+ le_ih);
+
+ if (c_mode == M_CUT
+ && s_cut_balance.insert_size[0] != -UNFM_P_SIZE) {
+ reiserfs_panic(p_s_sb,
+ "vs-5654: reiserfs_cut_from_item: "
+ "can not complete indirect2direct conversion of %h (CUT, insert_size==%d)",
+ le_ih, s_cut_balance.insert_size[0]);
+ }
+ /* it would be useful to make sure, that right neighboring
+ item is direct item of this file */
}
- /* it would be useful to make sure, that right neighboring
- item is direct item of this file */
- }
#endif
-
- do_balance(&s_cut_balance, NULL, NULL, c_mode);
- if ( n_is_inode_locked ) {
- /* we've done an indirect->direct conversion. when the data block
- ** was freed, it was removed from the list of blocks that must
- ** be flushed before the transaction commits, make sure to
- ** unmap and invalidate it
- */
- unmap_buffers(page, tail_pos);
- REISERFS_I(p_s_inode)->i_flags &= ~i_pack_on_close_mask ;
- }
+
+ do_balance(&s_cut_balance, NULL, NULL, c_mode);
+ if (n_is_inode_locked) {
+ /* we've done an indirect->direct conversion. when the data block
+ ** was freed, it was removed from the list of blocks that must
+ ** be flushed before the transaction commits, make sure to
+ ** unmap and invalidate it
+ */
+ unmap_buffers(page, tail_pos);
+ REISERFS_I(p_s_inode)->i_flags &= ~i_pack_on_close_mask;
+ }
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (p_s_inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota cut_from_item(): freeing %u id=%u type=%c", quota_cut_bytes, p_s_inode->i_uid, '?');
+ reiserfs_debug(p_s_inode->i_sb, REISERFS_DEBUG_CODE,
+ "reiserquota cut_from_item(): freeing %u id=%u type=%c",
+ quota_cut_bytes, p_s_inode->i_uid, '?');
#endif
- DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
- return n_ret_value;
+ DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
+ return n_ret_value;
}
-static void truncate_directory (struct reiserfs_transaction_handle *th, struct inode * inode)
+static void truncate_directory(struct reiserfs_transaction_handle *th,
+ struct inode *inode)
{
- BUG_ON (!th->t_trans_id);
- if (inode->i_nlink)
- reiserfs_warning (inode->i_sb,
- "vs-5655: truncate_directory: link count != 0");
-
- set_le_key_k_offset (KEY_FORMAT_3_5, INODE_PKEY (inode), DOT_OFFSET);
- set_le_key_k_type (KEY_FORMAT_3_5, INODE_PKEY (inode), TYPE_DIRENTRY);
- reiserfs_delete_solid_item (th, inode, INODE_PKEY (inode));
- reiserfs_update_sd(th, inode) ;
- set_le_key_k_offset (KEY_FORMAT_3_5, INODE_PKEY (inode), SD_OFFSET);
- set_le_key_k_type (KEY_FORMAT_3_5, INODE_PKEY (inode), TYPE_STAT_DATA);
+ BUG_ON(!th->t_trans_id);
+ if (inode->i_nlink)
+ reiserfs_warning(inode->i_sb,
+ "vs-5655: truncate_directory: link count != 0");
+
+ set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET);
+ set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY);
+ reiserfs_delete_solid_item(th, inode, INODE_PKEY(inode));
+ reiserfs_update_sd(th, inode);
+ set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), SD_OFFSET);
+ set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_STAT_DATA);
}
+/* Truncate file to the new size. Note, this must be called with a transaction
+ already started */
+int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, /* ->i_size contains new
+ size */
+ struct page *page, /* up to date for last block */
+ int update_timestamps /* when it is called by
+ file_release to convert
+ the tail - no timestamps
+ should be updated */
+ )
+{
+ INITIALIZE_PATH(s_search_path); /* Path to the current object item. */
+ struct item_head *p_le_ih; /* Pointer to an item header. */
+ struct cpu_key s_item_key; /* Key to search for a previous file item. */
+ loff_t n_file_size, /* Old file size. */
+ n_new_file_size; /* New file size. */
+ int n_deleted; /* Number of deleted or truncated bytes. */
+ int retval;
+ int err = 0;
+
+ BUG_ON(!th->t_trans_id);
+ if (!
+ (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode)
+ || S_ISLNK(p_s_inode->i_mode)))
+ return 0;
+
+ if (S_ISDIR(p_s_inode->i_mode)) {
+ // deletion of directory - no need to update timestamps
+ truncate_directory(th, p_s_inode);
+ return 0;
+ }
+ /* Get new file size. */
+ n_new_file_size = p_s_inode->i_size;
+ // FIXME: note, that key type is unimportant here
+ make_cpu_key(&s_item_key, p_s_inode, max_reiserfs_offset(p_s_inode),
+ TYPE_DIRECT, 3);
-/* Truncate file to the new size. Note, this must be called with a transaction
- already started */
-int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
- struct inode * p_s_inode, /* ->i_size contains new
- size */
- struct page *page, /* up to date for last block */
- int update_timestamps /* when it is called by
- file_release to convert
- the tail - no timestamps
- should be updated */
- ) {
- INITIALIZE_PATH (s_search_path); /* Path to the current object item. */
- struct item_head * p_le_ih; /* Pointer to an item header. */
- struct cpu_key s_item_key; /* Key to search for a previous file item. */
- loff_t n_file_size, /* Old file size. */
- n_new_file_size;/* New file size. */
- int n_deleted; /* Number of deleted or truncated bytes. */
- int retval;
- int err = 0;
-
- BUG_ON (!th->t_trans_id);
- if ( ! (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode) || S_ISLNK(p_s_inode->i_mode)) )
- return 0;
+ retval =
+ search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+ &s_search_path);
+ if (retval == IO_ERROR) {
+ reiserfs_warning(p_s_inode->i_sb,
+ "vs-5657: reiserfs_do_truncate: "
+ "i/o failure occurred trying to truncate %K",
+ &s_item_key);
+ err = -EIO;
+ goto out;
+ }
+ if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
+ reiserfs_warning(p_s_inode->i_sb,
+ "PAP-5660: reiserfs_do_truncate: "
+ "wrong result %d of search for %K", retval,
+ &s_item_key);
+
+ err = -EIO;
+ goto out;
+ }
- if (S_ISDIR(p_s_inode->i_mode)) {
- // deletion of directory - no need to update timestamps
- truncate_directory (th, p_s_inode);
- return 0;
- }
-
- /* Get new file size. */
- n_new_file_size = p_s_inode->i_size;
-
- // FIXME: note, that key type is unimportant here
- make_cpu_key (&s_item_key, p_s_inode, max_reiserfs_offset (p_s_inode), TYPE_DIRECT, 3);
-
- retval = search_for_position_by_key(p_s_inode->i_sb, &s_item_key, &s_search_path);
- if (retval == IO_ERROR) {
- reiserfs_warning (p_s_inode->i_sb, "vs-5657: reiserfs_do_truncate: "
- "i/o failure occurred trying to truncate %K", &s_item_key);
- err = -EIO;
- goto out;
- }
- if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
- reiserfs_warning (p_s_inode->i_sb, "PAP-5660: reiserfs_do_truncate: "
- "wrong result %d of search for %K", retval, &s_item_key);
-
- err = -EIO;
- goto out;
- }
-
- s_search_path.pos_in_item --;
-
- /* Get real file size (total length of all file items) */
- p_le_ih = PATH_PITEM_HEAD(&s_search_path);
- if ( is_statdata_le_ih (p_le_ih) )
- n_file_size = 0;
- else {
- loff_t offset = le_ih_k_offset (p_le_ih);
- int bytes = op_bytes_number (p_le_ih,p_s_inode->i_sb->s_blocksize);
-
- /* this may mismatch with real file size: if last direct item
- had no padding zeros and last unformatted node had no free
- space, this file would have this file size */
- n_file_size = offset + bytes - 1;
- }
- /*
- * are we doing a full truncate or delete, if so
- * kick in the reada code
- */
- if (n_new_file_size == 0)
- s_search_path.reada = PATH_READA | PATH_READA_BACK;
-
- if ( n_file_size == 0 || n_file_size < n_new_file_size ) {
- goto update_and_out ;
- }
-
- /* Update key to search for the last file item. */
- set_cpu_key_k_offset (&s_item_key, n_file_size);
-
- do {
- /* Cut or delete file item. */
- n_deleted = reiserfs_cut_from_item(th, &s_search_path, &s_item_key, p_s_inode, page, n_new_file_size);
- if (n_deleted < 0) {
- reiserfs_warning (p_s_inode->i_sb, "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
- reiserfs_check_path(&s_search_path) ;
- return 0;
+ s_search_path.pos_in_item--;
+
+ /* Get real file size (total length of all file items) */
+ p_le_ih = PATH_PITEM_HEAD(&s_search_path);
+ if (is_statdata_le_ih(p_le_ih))
+ n_file_size = 0;
+ else {
+ loff_t offset = le_ih_k_offset(p_le_ih);
+ int bytes =
+ op_bytes_number(p_le_ih, p_s_inode->i_sb->s_blocksize);
+
+ /* this may mismatch with real file size: if last direct item
+ had no padding zeros and last unformatted node had no free
+ space, this file would have this file size */
+ n_file_size = offset + bytes - 1;
+ }
+ /*
+ * are we doing a full truncate or delete, if so
+ * kick in the reada code
+ */
+ if (n_new_file_size == 0)
+ s_search_path.reada = PATH_READA | PATH_READA_BACK;
+
+ if (n_file_size == 0 || n_file_size < n_new_file_size) {
+ goto update_and_out;
}
- RFALSE( n_deleted > n_file_size,
- "PAP-5670: reiserfs_cut_from_item: too many bytes deleted: deleted %d, file_size %lu, item_key %K",
- n_deleted, n_file_size, &s_item_key);
+ /* Update key to search for the last file item. */
+ set_cpu_key_k_offset(&s_item_key, n_file_size);
+
+ do {
+ /* Cut or delete file item. */
+ n_deleted =
+ reiserfs_cut_from_item(th, &s_search_path, &s_item_key,
+ p_s_inode, page, n_new_file_size);
+ if (n_deleted < 0) {
+ reiserfs_warning(p_s_inode->i_sb,
+ "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
+ reiserfs_check_path(&s_search_path);
+ return 0;
+ }
- /* Change key to search the last file item. */
- n_file_size -= n_deleted;
+ RFALSE(n_deleted > n_file_size,
+ "PAP-5670: reiserfs_cut_from_item: too many bytes deleted: deleted %d, file_size %lu, item_key %K",
+ n_deleted, n_file_size, &s_item_key);
- set_cpu_key_k_offset (&s_item_key, n_file_size);
+ /* Change key to search the last file item. */
+ n_file_size -= n_deleted;
- /* While there are bytes to truncate and previous file item is presented in the tree. */
+ set_cpu_key_k_offset(&s_item_key, n_file_size);
- /*
- ** This loop could take a really long time, and could log
- ** many more blocks than a transaction can hold. So, we do a polite
- ** journal end here, and if the transaction needs ending, we make
- ** sure the file is consistent before ending the current trans
- ** and starting a new one
- */
- if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
- int orig_len_alloc = th->t_blocks_allocated ;
- decrement_counters_in_path(&s_search_path) ;
-
- if (update_timestamps) {
- p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME_SEC;
- }
- reiserfs_update_sd(th, p_s_inode) ;
-
- err = journal_end(th, p_s_inode->i_sb, orig_len_alloc) ;
- if (err)
- goto out;
- err = journal_begin (th, p_s_inode->i_sb,
- JOURNAL_PER_BALANCE_CNT * 6);
- if (err)
- goto out;
- reiserfs_update_inode_transaction(p_s_inode) ;
+ /* While there are bytes to truncate and previous file item is presented in the tree. */
+
+ /*
+ ** This loop could take a really long time, and could log
+ ** many more blocks than a transaction can hold. So, we do a polite
+ ** journal end here, and if the transaction needs ending, we make
+ ** sure the file is consistent before ending the current trans
+ ** and starting a new one
+ */
+ if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
+ int orig_len_alloc = th->t_blocks_allocated;
+ decrement_counters_in_path(&s_search_path);
+
+ if (update_timestamps) {
+ p_s_inode->i_mtime = p_s_inode->i_ctime =
+ CURRENT_TIME_SEC;
+ }
+ reiserfs_update_sd(th, p_s_inode);
+
+ err = journal_end(th, p_s_inode->i_sb, orig_len_alloc);
+ if (err)
+ goto out;
+ err = journal_begin(th, p_s_inode->i_sb,
+ JOURNAL_PER_BALANCE_CNT * 6);
+ if (err)
+ goto out;
+ reiserfs_update_inode_transaction(p_s_inode);
+ }
+ } while (n_file_size > ROUND_UP(n_new_file_size) &&
+ search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+ &s_search_path) == POSITION_FOUND);
+
+ RFALSE(n_file_size > ROUND_UP(n_new_file_size),
+ "PAP-5680: truncate did not finish: new_file_size %Ld, current %Ld, oid %d",
+ n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
+
+ update_and_out:
+ if (update_timestamps) {
+ // this is truncate, not file closing
+ p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME_SEC;
}
- } while ( n_file_size > ROUND_UP (n_new_file_size) &&
- search_for_position_by_key(p_s_inode->i_sb, &s_item_key, &s_search_path) == POSITION_FOUND ) ;
-
- RFALSE( n_file_size > ROUND_UP (n_new_file_size),
- "PAP-5680: truncate did not finish: new_file_size %Ld, current %Ld, oid %d",
- n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
-
-update_and_out:
- if (update_timestamps) {
- // this is truncate, not file closing
- p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME_SEC;
- }
- reiserfs_update_sd (th, p_s_inode);
-
-out:
- pathrelse(&s_search_path) ;
- return err;
-}
+ reiserfs_update_sd(th, p_s_inode);
+ out:
+ pathrelse(&s_search_path);
+ return err;
+}
#ifdef CONFIG_REISERFS_CHECK
// this makes sure, that we __append__, not overwrite or add holes
-static void check_research_for_paste (struct path * path,
- const struct cpu_key * p_s_key)
+static void check_research_for_paste(struct path *path,
+ const struct cpu_key *p_s_key)
{
- struct item_head * found_ih = get_ih (path);
-
- if (is_direct_le_ih (found_ih)) {
- if (le_ih_k_offset (found_ih) + op_bytes_number (found_ih, get_last_bh (path)->b_size) !=
- cpu_key_k_offset (p_s_key) ||
- op_bytes_number (found_ih, get_last_bh (path)->b_size) != pos_in_item (path))
- reiserfs_panic (NULL, "PAP-5720: check_research_for_paste: "
- "found direct item %h or position (%d) does not match to key %K",
- found_ih, pos_in_item (path), p_s_key);
- }
- if (is_indirect_le_ih (found_ih)) {
- if (le_ih_k_offset (found_ih) + op_bytes_number (found_ih, get_last_bh (path)->b_size) != cpu_key_k_offset (p_s_key) ||
- I_UNFM_NUM (found_ih) != pos_in_item (path) ||
- get_ih_free_space (found_ih) != 0)
- reiserfs_panic (NULL, "PAP-5730: check_research_for_paste: "
- "found indirect item (%h) or position (%d) does not match to key (%K)",
- found_ih, pos_in_item (path), p_s_key);
- }
+ struct item_head *found_ih = get_ih(path);
+
+ if (is_direct_le_ih(found_ih)) {
+ if (le_ih_k_offset(found_ih) +
+ op_bytes_number(found_ih,
+ get_last_bh(path)->b_size) !=
+ cpu_key_k_offset(p_s_key)
+ || op_bytes_number(found_ih,
+ get_last_bh(path)->b_size) !=
+ pos_in_item(path))
+ reiserfs_panic(NULL,
+ "PAP-5720: check_research_for_paste: "
+ "found direct item %h or position (%d) does not match to key %K",
+ found_ih, pos_in_item(path), p_s_key);
+ }
+ if (is_indirect_le_ih(found_ih)) {
+ if (le_ih_k_offset(found_ih) +
+ op_bytes_number(found_ih,
+ get_last_bh(path)->b_size) !=
+ cpu_key_k_offset(p_s_key)
+ || I_UNFM_NUM(found_ih) != pos_in_item(path)
+ || get_ih_free_space(found_ih) != 0)
+ reiserfs_panic(NULL,
+ "PAP-5730: check_research_for_paste: "
+ "found indirect item (%h) or position (%d) does not match to key (%K)",
+ found_ih, pos_in_item(path), p_s_key);
+ }
}
-#endif /* config reiserfs check */
-
+#endif /* config reiserfs check */
/* Paste bytes to the existing item. Returns bytes number pasted into the item. */
-int reiserfs_paste_into_item (struct reiserfs_transaction_handle *th,
- struct path * p_s_search_path, /* Path to the pasted item. */
- const struct cpu_key * p_s_key, /* Key to search for the needed item.*/
- struct inode * inode, /* Inode item belongs to */
- const char * p_c_body, /* Pointer to the bytes to paste. */
- int n_pasted_size) /* Size of pasted bytes. */
-{
- struct tree_balance s_paste_balance;
- int retval;
- int fs_gen;
+int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct path *p_s_search_path, /* Path to the pasted item. */
+ const struct cpu_key *p_s_key, /* Key to search for the needed item. */
+ struct inode *inode, /* Inode item belongs to */
+ const char *p_c_body, /* Pointer to the bytes to paste. */
+ int n_pasted_size)
+{ /* Size of pasted bytes. */
+ struct tree_balance s_paste_balance;
+ int retval;
+ int fs_gen;
+
+ BUG_ON(!th->t_trans_id);
- BUG_ON (!th->t_trans_id);
-
- fs_gen = get_generation(inode->i_sb) ;
+ fs_gen = get_generation(inode->i_sb);
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota paste_into_item(): allocating %u id=%u type=%c", n_pasted_size, inode->i_uid, key2type(&(p_s_key->on_disk_key)));
+ reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
+ "reiserquota paste_into_item(): allocating %u id=%u type=%c",
+ n_pasted_size, inode->i_uid,
+ key2type(&(p_s_key->on_disk_key)));
#endif
- if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) {
- pathrelse(p_s_search_path);
- return -EDQUOT;
- }
- init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path, n_pasted_size);
+ if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) {
+ pathrelse(p_s_search_path);
+ return -EDQUOT;
+ }
+ init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
+ n_pasted_size);
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- s_paste_balance.key = p_s_key->on_disk_key;
+ s_paste_balance.key = p_s_key->on_disk_key;
#endif
- /* DQUOT_* can schedule, must check before the fix_nodes */
- if (fs_changed(fs_gen, inode->i_sb)) {
- goto search_again;
- }
-
- while ((retval = fix_nodes(M_PASTE, &s_paste_balance, NULL, p_c_body)) ==
-REPEAT_SEARCH ) {
-search_again:
- /* file system changed while we were in the fix_nodes */
- PROC_INFO_INC( th -> t_super, paste_into_item_restarted );
- retval = search_for_position_by_key (th->t_super, p_s_key, p_s_search_path);
- if (retval == IO_ERROR) {
- retval = -EIO ;
- goto error_out ;
+ /* DQUOT_* can schedule, must check before the fix_nodes */
+ if (fs_changed(fs_gen, inode->i_sb)) {
+ goto search_again;
}
- if (retval == POSITION_FOUND) {
- reiserfs_warning (inode->i_sb, "PAP-5710: reiserfs_paste_into_item: entry or pasted byte (%K) exists", p_s_key);
- retval = -EEXIST ;
- goto error_out ;
- }
-
+
+ while ((retval =
+ fix_nodes(M_PASTE, &s_paste_balance, NULL,
+ p_c_body)) == REPEAT_SEARCH) {
+ search_again:
+ /* file system changed while we were in the fix_nodes */
+ PROC_INFO_INC(th->t_super, paste_into_item_restarted);
+ retval =
+ search_for_position_by_key(th->t_super, p_s_key,
+ p_s_search_path);
+ if (retval == IO_ERROR) {
+ retval = -EIO;
+ goto error_out;
+ }
+ if (retval == POSITION_FOUND) {
+ reiserfs_warning(inode->i_sb,
+ "PAP-5710: reiserfs_paste_into_item: entry or pasted byte (%K) exists",
+ p_s_key);
+ retval = -EEXIST;
+ goto error_out;
+ }
#ifdef CONFIG_REISERFS_CHECK
- check_research_for_paste (p_s_search_path, p_s_key);
+ check_research_for_paste(p_s_search_path, p_s_key);
#endif
- }
+ }
- /* Perform balancing after all resources are collected by fix_nodes, and
- accessing them will not risk triggering schedule. */
- if ( retval == CARRY_ON ) {
- do_balance(&s_paste_balance, NULL/*ih*/, p_c_body, M_PASTE);
- return 0;
- }
- retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
-error_out:
- /* this also releases the path */
- unfix_nodes(&s_paste_balance);
+ /* Perform balancing after all resources are collected by fix_nodes, and
+ accessing them will not risk triggering schedule. */
+ if (retval == CARRY_ON) {
+ do_balance(&s_paste_balance, NULL /*ih */ , p_c_body, M_PASTE);
+ return 0;
+ }
+ retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
+ error_out:
+ /* this also releases the path */
+ unfix_nodes(&s_paste_balance);
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota paste_into_item(): freeing %u id=%u type=%c", n_pasted_size, inode->i_uid, key2type(&(p_s_key->on_disk_key)));
+ reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
+ "reiserquota paste_into_item(): freeing %u id=%u type=%c",
+ n_pasted_size, inode->i_uid,
+ key2type(&(p_s_key->on_disk_key)));
#endif
- DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
- return retval ;
+ DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
+ return retval;
}
-
/* Insert new item into the buffer at the path. */
-int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
- struct path * p_s_path, /* Path to the inserteded item. */
- const struct cpu_key * key,
- struct item_head * p_s_ih, /* Pointer to the item header to insert.*/
- struct inode * inode,
- const char * p_c_body) /* Pointer to the bytes to insert. */
-{
- struct tree_balance s_ins_balance;
- int retval;
- int fs_gen = 0 ;
- int quota_bytes = 0 ;
-
- BUG_ON (!th->t_trans_id);
-
- if (inode) { /* Do we count quotas for item? */
- fs_gen = get_generation(inode->i_sb);
- quota_bytes = ih_item_len(p_s_ih);
-
- /* hack so the quota code doesn't have to guess if the file has
- ** a tail, links are always tails, so there's no guessing needed
- */
- if (!S_ISLNK (inode->i_mode) && is_direct_le_ih(p_s_ih)) {
- quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE ;
- }
+int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct path *p_s_path, /* Path to the inserteded item. */
+ const struct cpu_key *key, struct item_head *p_s_ih, /* Pointer to the item header to insert. */
+ struct inode *inode, const char *p_c_body)
+{ /* Pointer to the bytes to insert. */
+ struct tree_balance s_ins_balance;
+ int retval;
+ int fs_gen = 0;
+ int quota_bytes = 0;
+
+ BUG_ON(!th->t_trans_id);
+
+ if (inode) { /* Do we count quotas for item? */
+ fs_gen = get_generation(inode->i_sb);
+ quota_bytes = ih_item_len(p_s_ih);
+
+ /* hack so the quota code doesn't have to guess if the file has
+ ** a tail, links are always tails, so there's no guessing needed
+ */
+ if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_s_ih)) {
+ quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE;
+ }
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (inode->i_sb, REISERFS_DEBUG_CODE, "reiserquota insert_item(): allocating %u id=%u type=%c", quota_bytes, inode->i_uid, head2type(p_s_ih));
+ reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
+ "reiserquota insert_item(): allocating %u id=%u type=%c",
+ quota_bytes, inode->i_uid, head2type(p_s_ih));
#endif
- /* We can't dirty inode here. It would be immediately written but
- * appropriate stat item isn't inserted yet... */
- if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) {
- pathrelse(p_s_path);
- return -EDQUOT;
+ /* We can't dirty inode here. It would be immediately written but
+ * appropriate stat item isn't inserted yet... */
+ if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) {
+ pathrelse(p_s_path);
+ return -EDQUOT;
+ }
}
- }
- init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path, IH_SIZE + ih_item_len(p_s_ih));
+ init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
+ IH_SIZE + ih_item_len(p_s_ih));
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- s_ins_balance.key = key->on_disk_key;
+ s_ins_balance.key = key->on_disk_key;
#endif
- /* DQUOT_* can schedule, must check to be sure calling fix_nodes is safe */
- if (inode && fs_changed(fs_gen, inode->i_sb)) {
- goto search_again;
- }
-
- while ( (retval = fix_nodes(M_INSERT, &s_ins_balance, p_s_ih, p_c_body)) == REPEAT_SEARCH) {
-search_again:
- /* file system changed while we were in the fix_nodes */
- PROC_INFO_INC( th -> t_super, insert_item_restarted );
- retval = search_item (th->t_super, key, p_s_path);
- if (retval == IO_ERROR) {
- retval = -EIO;
- goto error_out ;
+ /* DQUOT_* can schedule, must check to be sure calling fix_nodes is safe */
+ if (inode && fs_changed(fs_gen, inode->i_sb)) {
+ goto search_again;
}
- if (retval == ITEM_FOUND) {
- reiserfs_warning (th->t_super, "PAP-5760: reiserfs_insert_item: "
- "key %K already exists in the tree", key);
- retval = -EEXIST ;
- goto error_out;
+
+ while ((retval =
+ fix_nodes(M_INSERT, &s_ins_balance, p_s_ih,
+ p_c_body)) == REPEAT_SEARCH) {
+ search_again:
+ /* file system changed while we were in the fix_nodes */
+ PROC_INFO_INC(th->t_super, insert_item_restarted);
+ retval = search_item(th->t_super, key, p_s_path);
+ if (retval == IO_ERROR) {
+ retval = -EIO;
+ goto error_out;
+ }
+ if (retval == ITEM_FOUND) {
+ reiserfs_warning(th->t_super,
+ "PAP-5760: reiserfs_insert_item: "
+ "key %K already exists in the tree",
+ key);
+ retval = -EEXIST;
+ goto error_out;
+ }
}
- }
- /* make balancing after all resources will be collected at a time */
- if ( retval == CARRY_ON ) {
- do_balance (&s_ins_balance, p_s_ih, p_c_body, M_INSERT);
- return 0;
- }
+ /* make balancing after all resources will be collected at a time */
+ if (retval == CARRY_ON) {
+ do_balance(&s_ins_balance, p_s_ih, p_c_body, M_INSERT);
+ return 0;
+ }
- retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
-error_out:
- /* also releases the path */
- unfix_nodes(&s_ins_balance);
+ retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
+ error_out:
+ /* also releases the path */
+ unfix_nodes(&s_ins_balance);
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug (th->t_super, REISERFS_DEBUG_CODE, "reiserquota insert_item(): freeing %u id=%u type=%c", quota_bytes, inode->i_uid, head2type(p_s_ih));
+ reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
+ "reiserquota insert_item(): freeing %u id=%u type=%c",
+ quota_bytes, inode->i_uid, head2type(p_s_ih));
#endif
- if (inode)
- DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes) ;
- return retval;
+ if (inode)
+ DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
+ return retval;
}
-
-
-
-
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 4b80ab95d33..6951c35755b 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -35,83 +35,81 @@ static const char reiserfs_3_5_magic_string[] = REISERFS_SUPER_MAGIC_STRING;
static const char reiserfs_3_6_magic_string[] = REISER2FS_SUPER_MAGIC_STRING;
static const char reiserfs_jr_magic_string[] = REISER2FS_JR_SUPER_MAGIC_STRING;
-int is_reiserfs_3_5 (struct reiserfs_super_block * rs)
+int is_reiserfs_3_5(struct reiserfs_super_block *rs)
{
- return !strncmp (rs->s_v1.s_magic, reiserfs_3_5_magic_string,
- strlen (reiserfs_3_5_magic_string));
+ return !strncmp(rs->s_v1.s_magic, reiserfs_3_5_magic_string,
+ strlen(reiserfs_3_5_magic_string));
}
-
-int is_reiserfs_3_6 (struct reiserfs_super_block * rs)
+int is_reiserfs_3_6(struct reiserfs_super_block *rs)
{
- return !strncmp (rs->s_v1.s_magic, reiserfs_3_6_magic_string,
- strlen (reiserfs_3_6_magic_string));
+ return !strncmp(rs->s_v1.s_magic, reiserfs_3_6_magic_string,
+ strlen(reiserfs_3_6_magic_string));
}
-
-int is_reiserfs_jr (struct reiserfs_super_block * rs)
+int is_reiserfs_jr(struct reiserfs_super_block *rs)
{
- return !strncmp (rs->s_v1.s_magic, reiserfs_jr_magic_string,
- strlen (reiserfs_jr_magic_string));
+ return !strncmp(rs->s_v1.s_magic, reiserfs_jr_magic_string,
+ strlen(reiserfs_jr_magic_string));
}
-
-static int is_any_reiserfs_magic_string (struct reiserfs_super_block * rs)
+static int is_any_reiserfs_magic_string(struct reiserfs_super_block *rs)
{
- return (is_reiserfs_3_5 (rs) || is_reiserfs_3_6 (rs) ||
- is_reiserfs_jr (rs));
+ return (is_reiserfs_3_5(rs) || is_reiserfs_3_6(rs) ||
+ is_reiserfs_jr(rs));
}
-static int reiserfs_remount (struct super_block * s, int * flags, char * data);
-static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf);
+static int reiserfs_remount(struct super_block *s, int *flags, char *data);
+static int reiserfs_statfs(struct super_block *s, struct kstatfs *buf);
-static int reiserfs_sync_fs (struct super_block * s, int wait)
+static int reiserfs_sync_fs(struct super_block *s, int wait)
{
- if (!(s->s_flags & MS_RDONLY)) {
- struct reiserfs_transaction_handle th;
- reiserfs_write_lock(s);
- if (!journal_begin(&th, s, 1))
- if (!journal_end_sync(&th, s, 1))
- reiserfs_flush_old_commits(s);
- s->s_dirt = 0; /* Even if it's not true.
- * We'll loop forever in sync_supers otherwise */
- reiserfs_write_unlock(s);
- } else {
- s->s_dirt = 0;
- }
- return 0;
+ if (!(s->s_flags & MS_RDONLY)) {
+ struct reiserfs_transaction_handle th;
+ reiserfs_write_lock(s);
+ if (!journal_begin(&th, s, 1))
+ if (!journal_end_sync(&th, s, 1))
+ reiserfs_flush_old_commits(s);
+ s->s_dirt = 0; /* Even if it's not true.
+ * We'll loop forever in sync_supers otherwise */
+ reiserfs_write_unlock(s);
+ } else {
+ s->s_dirt = 0;
+ }
+ return 0;
}
static void reiserfs_write_super(struct super_block *s)
{
- reiserfs_sync_fs(s, 1);
+ reiserfs_sync_fs(s, 1);
}
-static void reiserfs_write_super_lockfs (struct super_block * s)
+static void reiserfs_write_super_lockfs(struct super_block *s)
{
- struct reiserfs_transaction_handle th ;
- reiserfs_write_lock(s);
- if (!(s->s_flags & MS_RDONLY)) {
- int err = journal_begin(&th, s, 1) ;
- if (err) {
- reiserfs_block_writes(&th) ;
- } else {
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
- journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
- reiserfs_block_writes(&th) ;
- journal_end_sync(&th, s, 1) ;
- }
- }
- s->s_dirt = 0;
- reiserfs_write_unlock(s);
+ struct reiserfs_transaction_handle th;
+ reiserfs_write_lock(s);
+ if (!(s->s_flags & MS_RDONLY)) {
+ int err = journal_begin(&th, s, 1);
+ if (err) {
+ reiserfs_block_writes(&th);
+ } else {
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
+ 1);
+ journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+ reiserfs_block_writes(&th);
+ journal_end_sync(&th, s, 1);
+ }
+ }
+ s->s_dirt = 0;
+ reiserfs_write_unlock(s);
}
-static void reiserfs_unlockfs(struct super_block *s) {
- reiserfs_allow_writes(s) ;
+static void reiserfs_unlockfs(struct super_block *s)
+{
+ reiserfs_allow_writes(s);
}
-extern const struct in_core_key MAX_IN_CORE_KEY;
-
+extern const struct in_core_key MAX_IN_CORE_KEY;
/* this is used to delete "save link" when there are no items of a
file it points to. It can either happen if unlink is completed but
@@ -120,364 +118,387 @@ extern const struct in_core_key MAX_IN_CORE_KEY;
protecting unlink is bigger that a key lf "save link" which
protects truncate), so there left no items to make truncate
completion on */
-static int remove_save_link_only (struct super_block * s, struct reiserfs_key * key, int oid_free)
+static int remove_save_link_only(struct super_block *s,
+ struct reiserfs_key *key, int oid_free)
{
- struct reiserfs_transaction_handle th;
- int err;
-
- /* we are going to do one balancing */
- err = journal_begin (&th, s, JOURNAL_PER_BALANCE_CNT);
- if (err)
- return err;
-
- reiserfs_delete_solid_item (&th, NULL, key);
- if (oid_free)
- /* removals are protected by direct items */
- reiserfs_release_objectid (&th, le32_to_cpu (key->k_objectid));
-
- return journal_end (&th, s, JOURNAL_PER_BALANCE_CNT);
+ struct reiserfs_transaction_handle th;
+ int err;
+
+ /* we are going to do one balancing */
+ err = journal_begin(&th, s, JOURNAL_PER_BALANCE_CNT);
+ if (err)
+ return err;
+
+ reiserfs_delete_solid_item(&th, NULL, key);
+ if (oid_free)
+ /* removals are protected by direct items */
+ reiserfs_release_objectid(&th, le32_to_cpu(key->k_objectid));
+
+ return journal_end(&th, s, JOURNAL_PER_BALANCE_CNT);
}
-
+
#ifdef CONFIG_QUOTA
static int reiserfs_quota_on_mount(struct super_block *, int);
#endif
-
+
/* look for uncompleted unlinks and truncates and complete them */
-static int finish_unfinished (struct super_block * s)
+static int finish_unfinished(struct super_block *s)
{
- INITIALIZE_PATH (path);
- struct cpu_key max_cpu_key, obj_key;
- struct reiserfs_key save_link_key;
- int retval = 0;
- struct item_head * ih;
- struct buffer_head * bh;
- int item_pos;
- char * item;
- int done;
- struct inode * inode;
- int truncate;
+ INITIALIZE_PATH(path);
+ struct cpu_key max_cpu_key, obj_key;
+ struct reiserfs_key save_link_key;
+ int retval = 0;
+ struct item_head *ih;
+ struct buffer_head *bh;
+ int item_pos;
+ char *item;
+ int done;
+ struct inode *inode;
+ int truncate;
#ifdef CONFIG_QUOTA
- int i;
- int ms_active_set;
+ int i;
+ int ms_active_set;
#endif
-
-
- /* compose key to look for "save" links */
- max_cpu_key.version = KEY_FORMAT_3_5;
- max_cpu_key.on_disk_key.k_dir_id = ~0U;
- max_cpu_key.on_disk_key.k_objectid = ~0U;
- set_cpu_key_k_offset (&max_cpu_key, ~0U);
- max_cpu_key.key_length = 3;
+
+ /* compose key to look for "save" links */
+ max_cpu_key.version = KEY_FORMAT_3_5;
+ max_cpu_key.on_disk_key.k_dir_id = ~0U;
+ max_cpu_key.on_disk_key.k_objectid = ~0U;
+ set_cpu_key_k_offset(&max_cpu_key, ~0U);
+ max_cpu_key.key_length = 3;
#ifdef CONFIG_QUOTA
- /* Needed for iput() to work correctly and not trash data */
- if (s->s_flags & MS_ACTIVE) {
- ms_active_set = 0;
- } else {
- ms_active_set = 1;
- s->s_flags |= MS_ACTIVE;
- }
- /* Turn on quotas so that they are updated correctly */
- for (i = 0; i < MAXQUOTAS; i++) {
- if (REISERFS_SB(s)->s_qf_names[i]) {
- int ret = reiserfs_quota_on_mount(s, i);
- if (ret < 0)
- reiserfs_warning(s, "reiserfs: cannot turn on journalled quota: error %d", ret);
- }
- }
+ /* Needed for iput() to work correctly and not trash data */
+ if (s->s_flags & MS_ACTIVE) {
+ ms_active_set = 0;
+ } else {
+ ms_active_set = 1;
+ s->s_flags |= MS_ACTIVE;
+ }
+ /* Turn on quotas so that they are updated correctly */
+ for (i = 0; i < MAXQUOTAS; i++) {
+ if (REISERFS_SB(s)->s_qf_names[i]) {
+ int ret = reiserfs_quota_on_mount(s, i);
+ if (ret < 0)
+ reiserfs_warning(s,
+ "reiserfs: cannot turn on journalled quota: error %d",
+ ret);
+ }
+ }
#endif
-
- done = 0;
- REISERFS_SB(s)->s_is_unlinked_ok = 1;
- while (!retval) {
- retval = search_item (s, &max_cpu_key, &path);
- if (retval != ITEM_NOT_FOUND) {
- reiserfs_warning (s, "vs-2140: finish_unfinished: search_by_key returned %d",
- retval);
- break;
- }
-
- bh = get_last_bh (&path);
- item_pos = get_item_pos (&path);
- if (item_pos != B_NR_ITEMS (bh)) {
- reiserfs_warning (s, "vs-2060: finish_unfinished: wrong position found");
- break;
- }
- item_pos --;
- ih = B_N_PITEM_HEAD (bh, item_pos);
-
- if (le32_to_cpu (ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
- /* there are no "save" links anymore */
- break;
-
- save_link_key = ih->ih_key;
- if (is_indirect_le_ih (ih))
- truncate = 1;
- else
- truncate = 0;
-
- /* reiserfs_iget needs k_dirid and k_objectid only */
- item = B_I_PITEM (bh, ih);
- obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__le32 *)item);
- obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid);
- obj_key.on_disk_key.k_offset = 0;
- obj_key.on_disk_key.k_type = 0;
-
- pathrelse (&path);
-
- inode = reiserfs_iget (s, &obj_key);
- if (!inode) {
- /* the unlink almost completed, it just did not manage to remove
- "save" link and release objectid */
- reiserfs_warning (s, "vs-2180: finish_unfinished: iget failed for %K",
- &obj_key);
- retval = remove_save_link_only (s, &save_link_key, 1);
- continue;
- }
-
- if (!truncate && inode->i_nlink) {
- /* file is not unlinked */
- reiserfs_warning (s, "vs-2185: finish_unfinished: file %K is not unlinked",
- &obj_key);
- retval = remove_save_link_only (s, &save_link_key, 0);
- continue;
- }
- DQUOT_INIT(inode);
-
- if (truncate && S_ISDIR (inode->i_mode) ) {
- /* We got a truncate request for a dir which is impossible.
- The only imaginable way is to execute unfinished truncate request
- then boot into old kernel, remove the file and create dir with
- the same key. */
- reiserfs_warning(s, "green-2101: impossible truncate on a directory %k. Please report", INODE_PKEY (inode));
- retval = remove_save_link_only (s, &save_link_key, 0);
- truncate = 0;
- iput (inode);
- continue;
- }
-
- if (truncate) {
- REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
- /* not completed truncate found. New size was committed together
- with "save" link */
- reiserfs_info (s, "Truncating %k to %Ld ..",
- INODE_PKEY (inode), inode->i_size);
- reiserfs_truncate_file (inode, 0/*don't update modification time*/);
- retval = remove_save_link (inode, truncate);
- } else {
- REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
- /* not completed unlink (rmdir) found */
- reiserfs_info (s, "Removing %k..", INODE_PKEY (inode));
- /* removal gets completed in iput */
- retval = 0;
- }
-
- iput (inode);
- printk ("done\n");
- done ++;
- }
- REISERFS_SB(s)->s_is_unlinked_ok = 0;
-
+
+ done = 0;
+ REISERFS_SB(s)->s_is_unlinked_ok = 1;
+ while (!retval) {
+ retval = search_item(s, &max_cpu_key, &path);
+ if (retval != ITEM_NOT_FOUND) {
+ reiserfs_warning(s,
+ "vs-2140: finish_unfinished: search_by_key returned %d",
+ retval);
+ break;
+ }
+
+ bh = get_last_bh(&path);
+ item_pos = get_item_pos(&path);
+ if (item_pos != B_NR_ITEMS(bh)) {
+ reiserfs_warning(s,
+ "vs-2060: finish_unfinished: wrong position found");
+ break;
+ }
+ item_pos--;
+ ih = B_N_PITEM_HEAD(bh, item_pos);
+
+ if (le32_to_cpu(ih->ih_key.k_dir_id) != MAX_KEY_OBJECTID)
+ /* there are no "save" links anymore */
+ break;
+
+ save_link_key = ih->ih_key;
+ if (is_indirect_le_ih(ih))
+ truncate = 1;
+ else
+ truncate = 0;
+
+ /* reiserfs_iget needs k_dirid and k_objectid only */
+ item = B_I_PITEM(bh, ih);
+ obj_key.on_disk_key.k_dir_id = le32_to_cpu(*(__le32 *) item);
+ obj_key.on_disk_key.k_objectid =
+ le32_to_cpu(ih->ih_key.k_objectid);
+ obj_key.on_disk_key.k_offset = 0;
+ obj_key.on_disk_key.k_type = 0;
+
+ pathrelse(&path);
+
+ inode = reiserfs_iget(s, &obj_key);
+ if (!inode) {
+ /* the unlink almost completed, it just did not manage to remove
+ "save" link and release objectid */
+ reiserfs_warning(s,
+ "vs-2180: finish_unfinished: iget failed for %K",
+ &obj_key);
+ retval = remove_save_link_only(s, &save_link_key, 1);
+ continue;
+ }
+
+ if (!truncate && inode->i_nlink) {
+ /* file is not unlinked */
+ reiserfs_warning(s,
+ "vs-2185: finish_unfinished: file %K is not unlinked",
+ &obj_key);
+ retval = remove_save_link_only(s, &save_link_key, 0);
+ continue;
+ }
+ DQUOT_INIT(inode);
+
+ if (truncate && S_ISDIR(inode->i_mode)) {
+ /* We got a truncate request for a dir which is impossible.
+ The only imaginable way is to execute unfinished truncate request
+ then boot into old kernel, remove the file and create dir with
+ the same key. */
+ reiserfs_warning(s,
+ "green-2101: impossible truncate on a directory %k. Please report",
+ INODE_PKEY(inode));
+ retval = remove_save_link_only(s, &save_link_key, 0);
+ truncate = 0;
+ iput(inode);
+ continue;
+ }
+
+ if (truncate) {
+ REISERFS_I(inode)->i_flags |=
+ i_link_saved_truncate_mask;
+ /* not completed truncate found. New size was committed together
+ with "save" link */
+ reiserfs_info(s, "Truncating %k to %Ld ..",
+ INODE_PKEY(inode), inode->i_size);
+ reiserfs_truncate_file(inode,
+ 0
+ /*don't update modification time */
+ );
+ retval = remove_save_link(inode, truncate);
+ } else {
+ REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
+ /* not completed unlink (rmdir) found */
+ reiserfs_info(s, "Removing %k..", INODE_PKEY(inode));
+ /* removal gets completed in iput */
+ retval = 0;
+ }
+
+ iput(inode);
+ printk("done\n");
+ done++;
+ }
+ REISERFS_SB(s)->s_is_unlinked_ok = 0;
+
#ifdef CONFIG_QUOTA
- /* Turn quotas off */
- for (i = 0; i < MAXQUOTAS; i++) {
- if (sb_dqopt(s)->files[i])
- vfs_quota_off_mount(s, i);
- }
- if (ms_active_set)
- /* Restore the flag back */
- s->s_flags &= ~MS_ACTIVE;
+ /* Turn quotas off */
+ for (i = 0; i < MAXQUOTAS; i++) {
+ if (sb_dqopt(s)->files[i])
+ vfs_quota_off_mount(s, i);
+ }
+ if (ms_active_set)
+ /* Restore the flag back */
+ s->s_flags &= ~MS_ACTIVE;
#endif
- pathrelse (&path);
- if (done)
- reiserfs_info (s, "There were %d uncompleted unlinks/truncates. "
- "Completed\n", done);
- return retval;
+ pathrelse(&path);
+ if (done)
+ reiserfs_info(s, "There were %d uncompleted unlinks/truncates. "
+ "Completed\n", done);
+ return retval;
}
-
+
/* to protect file being unlinked from getting lost we "safe" link files
being unlinked. This link will be deleted in the same transaction with last
item of file. mounting the filesytem we scan all these links and remove
files which almost got lost */
-void add_save_link (struct reiserfs_transaction_handle * th,
- struct inode * inode, int truncate)
+void add_save_link(struct reiserfs_transaction_handle *th,
+ struct inode *inode, int truncate)
{
- INITIALIZE_PATH (path);
- int retval;
- struct cpu_key key;
- struct item_head ih;
- __le32 link;
-
- BUG_ON (!th->t_trans_id);
-
- /* file can only get one "save link" of each kind */
- RFALSE( truncate &&
- ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ),
- "saved link already exists for truncated inode %lx",
- ( long ) inode -> i_ino );
- RFALSE( !truncate &&
- ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ),
- "saved link already exists for unlinked inode %lx",
- ( long ) inode -> i_ino );
-
- /* setup key of "save" link */
- key.version = KEY_FORMAT_3_5;
- key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
- key.on_disk_key.k_objectid = inode->i_ino;
- if (!truncate) {
- /* unlink, rmdir, rename */
- set_cpu_key_k_offset (&key, 1 + inode->i_sb->s_blocksize);
- set_cpu_key_k_type (&key, TYPE_DIRECT);
-
- /* item head of "safe" link */
- make_le_item_head (&ih, &key, key.version, 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
- 4/*length*/, 0xffff/*free space*/);
- } else {
- /* truncate */
- if (S_ISDIR (inode->i_mode))
- reiserfs_warning(inode->i_sb, "green-2102: Adding a truncate savelink for a directory %k! Please report", INODE_PKEY(inode));
- set_cpu_key_k_offset (&key, 1);
- set_cpu_key_k_type (&key, TYPE_INDIRECT);
-
- /* item head of "safe" link */
- make_le_item_head (&ih, &key, key.version, 1, TYPE_INDIRECT,
- 4/*length*/, 0/*free space*/);
- }
- key.key_length = 3;
-
- /* look for its place in the tree */
- retval = search_item (inode->i_sb, &key, &path);
- if (retval != ITEM_NOT_FOUND) {
- if ( retval != -ENOSPC )
- reiserfs_warning (inode->i_sb, "vs-2100: add_save_link:"
- "search_by_key (%K) returned %d", &key, retval);
- pathrelse (&path);
- return;
- }
-
- /* body of "save" link */
- link = INODE_PKEY (inode)->k_dir_id;
-
- /* put "save" link inot tree, don't charge quota to anyone */
- retval = reiserfs_insert_item (th, &path, &key, &ih, NULL, (char *)&link);
- if (retval) {
- if (retval != -ENOSPC)
- reiserfs_warning (inode->i_sb, "vs-2120: add_save_link: insert_item returned %d",
- retval);
- } else {
- if( truncate )
- REISERFS_I(inode) -> i_flags |= i_link_saved_truncate_mask;
- else
- REISERFS_I(inode) -> i_flags |= i_link_saved_unlink_mask;
- }
-}
+ INITIALIZE_PATH(path);
+ int retval;
+ struct cpu_key key;
+ struct item_head ih;
+ __le32 link;
+
+ BUG_ON(!th->t_trans_id);
+
+ /* file can only get one "save link" of each kind */
+ RFALSE(truncate &&
+ (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask),
+ "saved link already exists for truncated inode %lx",
+ (long)inode->i_ino);
+ RFALSE(!truncate &&
+ (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask),
+ "saved link already exists for unlinked inode %lx",
+ (long)inode->i_ino);
+
+ /* setup key of "save" link */
+ key.version = KEY_FORMAT_3_5;
+ key.on_disk_key.k_dir_id = MAX_KEY_OBJECTID;
+ key.on_disk_key.k_objectid = inode->i_ino;
+ if (!truncate) {
+ /* unlink, rmdir, rename */
+ set_cpu_key_k_offset(&key, 1 + inode->i_sb->s_blocksize);
+ set_cpu_key_k_type(&key, TYPE_DIRECT);
+
+ /* item head of "safe" link */
+ make_le_item_head(&ih, &key, key.version,
+ 1 + inode->i_sb->s_blocksize, TYPE_DIRECT,
+ 4 /*length */ , 0xffff /*free space */ );
+ } else {
+ /* truncate */
+ if (S_ISDIR(inode->i_mode))
+ reiserfs_warning(inode->i_sb,
+ "green-2102: Adding a truncate savelink for a directory %k! Please report",
+ INODE_PKEY(inode));
+ set_cpu_key_k_offset(&key, 1);
+ set_cpu_key_k_type(&key, TYPE_INDIRECT);
+
+ /* item head of "safe" link */
+ make_le_item_head(&ih, &key, key.version, 1, TYPE_INDIRECT,
+ 4 /*length */ , 0 /*free space */ );
+ }
+ key.key_length = 3;
+
+ /* look for its place in the tree */
+ retval = search_item(inode->i_sb, &key, &path);
+ if (retval != ITEM_NOT_FOUND) {
+ if (retval != -ENOSPC)
+ reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:"
+ "search_by_key (%K) returned %d", &key,
+ retval);
+ pathrelse(&path);
+ return;
+ }
+ /* body of "save" link */
+ link = INODE_PKEY(inode)->k_dir_id;
+
+ /* put "save" link inot tree, don't charge quota to anyone */
+ retval =
+ reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
+ if (retval) {
+ if (retval != -ENOSPC)
+ reiserfs_warning(inode->i_sb,
+ "vs-2120: add_save_link: insert_item returned %d",
+ retval);
+ } else {
+ if (truncate)
+ REISERFS_I(inode)->i_flags |=
+ i_link_saved_truncate_mask;
+ else
+ REISERFS_I(inode)->i_flags |= i_link_saved_unlink_mask;
+ }
+}
/* this opens transaction unlike add_save_link */
-int remove_save_link (struct inode * inode, int truncate)
+int remove_save_link(struct inode *inode, int truncate)
{
- struct reiserfs_transaction_handle th;
- struct reiserfs_key key;
- int err;
-
- /* we are going to do one balancing only */
- err = journal_begin (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
- if (err)
- return err;
-
- /* setup key of "save" link */
- key.k_dir_id = cpu_to_le32 (MAX_KEY_OBJECTID);
- key.k_objectid = INODE_PKEY (inode)->k_objectid;
- if (!truncate) {
- /* unlink, rmdir, rename */
- set_le_key_k_offset (KEY_FORMAT_3_5, &key,
- 1 + inode->i_sb->s_blocksize);
- set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_DIRECT);
- } else {
- /* truncate */
- set_le_key_k_offset (KEY_FORMAT_3_5, &key, 1);
- set_le_key_k_type (KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
- }
-
- if( ( truncate &&
- ( REISERFS_I(inode) -> i_flags & i_link_saved_truncate_mask ) ) ||
- ( !truncate &&
- ( REISERFS_I(inode) -> i_flags & i_link_saved_unlink_mask ) ) )
- /* don't take quota bytes from anywhere */
- reiserfs_delete_solid_item (&th, NULL, &key);
- if (!truncate) {
- reiserfs_release_objectid (&th, inode->i_ino);
- REISERFS_I(inode) -> i_flags &= ~i_link_saved_unlink_mask;
- } else
- REISERFS_I(inode) -> i_flags &= ~i_link_saved_truncate_mask;
-
- return journal_end (&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
-}
+ struct reiserfs_transaction_handle th;
+ struct reiserfs_key key;
+ int err;
+
+ /* we are going to do one balancing only */
+ err = journal_begin(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+ if (err)
+ return err;
+
+ /* setup key of "save" link */
+ key.k_dir_id = cpu_to_le32(MAX_KEY_OBJECTID);
+ key.k_objectid = INODE_PKEY(inode)->k_objectid;
+ if (!truncate) {
+ /* unlink, rmdir, rename */
+ set_le_key_k_offset(KEY_FORMAT_3_5, &key,
+ 1 + inode->i_sb->s_blocksize);
+ set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_DIRECT);
+ } else {
+ /* truncate */
+ set_le_key_k_offset(KEY_FORMAT_3_5, &key, 1);
+ set_le_key_k_type(KEY_FORMAT_3_5, &key, TYPE_INDIRECT);
+ }
+ if ((truncate &&
+ (REISERFS_I(inode)->i_flags & i_link_saved_truncate_mask)) ||
+ (!truncate &&
+ (REISERFS_I(inode)->i_flags & i_link_saved_unlink_mask)))
+ /* don't take quota bytes from anywhere */
+ reiserfs_delete_solid_item(&th, NULL, &key);
+ if (!truncate) {
+ reiserfs_release_objectid(&th, inode->i_ino);
+ REISERFS_I(inode)->i_flags &= ~i_link_saved_unlink_mask;
+ } else
+ REISERFS_I(inode)->i_flags &= ~i_link_saved_truncate_mask;
+
+ return journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT);
+}
-static void reiserfs_put_super (struct super_block * s)
+static void reiserfs_put_super(struct super_block *s)
{
- int i;
- struct reiserfs_transaction_handle th ;
- th.t_trans_id = 0;
-
- if (REISERFS_SB(s)->xattr_root) {
- d_invalidate (REISERFS_SB(s)->xattr_root);
- dput (REISERFS_SB(s)->xattr_root);
- }
-
- if (REISERFS_SB(s)->priv_root) {
- d_invalidate (REISERFS_SB(s)->priv_root);
- dput (REISERFS_SB(s)->priv_root);
- }
-
- /* change file system state to current state if it was mounted with read-write permissions */
- if (!(s->s_flags & MS_RDONLY)) {
- if (!journal_begin(&th, s, 10)) {
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
- set_sb_umount_state( SB_DISK_SUPER_BLOCK(s), REISERFS_SB(s)->s_mount_state );
- journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
- }
- }
-
- /* note, journal_release checks for readonly mount, and can decide not
- ** to do a journal_end
- */
- journal_release(&th, s) ;
-
- for (i = 0; i < SB_BMAP_NR (s); i ++)
- brelse (SB_AP_BITMAP (s)[i].bh);
-
- vfree (SB_AP_BITMAP (s));
-
- brelse (SB_BUFFER_WITH_SB (s));
-
- print_statistics (s);
-
- if (REISERFS_SB(s)->s_kmallocs != 0) {
- reiserfs_warning (s, "vs-2004: reiserfs_put_super: allocated memory left %d",
- REISERFS_SB(s)->s_kmallocs);
- }
-
- if (REISERFS_SB(s)->reserved_blocks != 0) {
- reiserfs_warning (s, "green-2005: reiserfs_put_super: reserved blocks left %d",
- REISERFS_SB(s)->reserved_blocks);
- }
-
- reiserfs_proc_info_done( s );
-
- kfree(s->s_fs_info);
- s->s_fs_info = NULL;
-
- return;
+ int i;
+ struct reiserfs_transaction_handle th;
+ th.t_trans_id = 0;
+
+ if (REISERFS_SB(s)->xattr_root) {
+ d_invalidate(REISERFS_SB(s)->xattr_root);
+ dput(REISERFS_SB(s)->xattr_root);
+ }
+
+ if (REISERFS_SB(s)->priv_root) {
+ d_invalidate(REISERFS_SB(s)->priv_root);
+ dput(REISERFS_SB(s)->priv_root);
+ }
+
+ /* change file system state to current state if it was mounted with read-write permissions */
+ if (!(s->s_flags & MS_RDONLY)) {
+ if (!journal_begin(&th, s, 10)) {
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s),
+ 1);
+ set_sb_umount_state(SB_DISK_SUPER_BLOCK(s),
+ REISERFS_SB(s)->s_mount_state);
+ journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+ }
+ }
+
+ /* note, journal_release checks for readonly mount, and can decide not
+ ** to do a journal_end
+ */
+ journal_release(&th, s);
+
+ for (i = 0; i < SB_BMAP_NR(s); i++)
+ brelse(SB_AP_BITMAP(s)[i].bh);
+
+ vfree(SB_AP_BITMAP(s));
+
+ brelse(SB_BUFFER_WITH_SB(s));
+
+ print_statistics(s);
+
+ if (REISERFS_SB(s)->s_kmallocs != 0) {
+ reiserfs_warning(s,
+ "vs-2004: reiserfs_put_super: allocated memory left %d",
+ REISERFS_SB(s)->s_kmallocs);
+ }
+
+ if (REISERFS_SB(s)->reserved_blocks != 0) {
+ reiserfs_warning(s,
+ "green-2005: reiserfs_put_super: reserved blocks left %d",
+ REISERFS_SB(s)->reserved_blocks);
+ }
+
+ reiserfs_proc_info_done(s);
+
+ kfree(s->s_fs_info);
+ s->s_fs_info = NULL;
+
+ return;
}
-static kmem_cache_t * reiserfs_inode_cachep;
+static kmem_cache_t *reiserfs_inode_cachep;
static struct inode *reiserfs_alloc_inode(struct super_block *sb)
{
struct reiserfs_inode_info *ei;
- ei = (struct reiserfs_inode_info *)kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
+ ei = (struct reiserfs_inode_info *)
+ kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL);
if (!ei)
return NULL;
return &ei->vfs_inode;
@@ -488,25 +509,26 @@ static void reiserfs_destroy_inode(struct inode *inode)
kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
}
-static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
+static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
{
- struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *) foo;
+ struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
- if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) {
- INIT_LIST_HEAD(&ei->i_prealloc_list) ;
+ INIT_LIST_HEAD(&ei->i_prealloc_list);
inode_init_once(&ei->vfs_inode);
ei->i_acl_access = NULL;
ei->i_acl_default = NULL;
}
}
-
+
static int init_inodecache(void)
{
reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
- sizeof(struct reiserfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
- init_once, NULL);
+ sizeof(struct
+ reiserfs_inode_info),
+ 0, SLAB_RECLAIM_ACCOUNT,
+ init_once, NULL);
if (reiserfs_inode_cachep == NULL)
return -ENOMEM;
return 0;
@@ -515,72 +537,76 @@ static int init_inodecache(void)
static void destroy_inodecache(void)
{
if (kmem_cache_destroy(reiserfs_inode_cachep))
- reiserfs_warning (NULL, "reiserfs_inode_cache: not all structures were freed");
+ reiserfs_warning(NULL,
+ "reiserfs_inode_cache: not all structures were freed");
}
/* we don't mark inodes dirty, we just log them */
-static void reiserfs_dirty_inode (struct inode * inode) {
- struct reiserfs_transaction_handle th ;
-
- int err = 0;
- if (inode->i_sb->s_flags & MS_RDONLY) {
- reiserfs_warning(inode->i_sb, "clm-6006: writing inode %lu on readonly FS",
- inode->i_ino) ;
- return ;
- }
- reiserfs_write_lock(inode->i_sb);
-
- /* this is really only used for atime updates, so they don't have
- ** to be included in O_SYNC or fsync
- */
- err = journal_begin(&th, inode->i_sb, 1) ;
- if (err) {
- reiserfs_write_unlock (inode->i_sb);
- return;
- }
- reiserfs_update_sd (&th, inode);
- journal_end(&th, inode->i_sb, 1) ;
- reiserfs_write_unlock(inode->i_sb);
+static void reiserfs_dirty_inode(struct inode *inode)
+{
+ struct reiserfs_transaction_handle th;
+
+ int err = 0;
+ if (inode->i_sb->s_flags & MS_RDONLY) {
+ reiserfs_warning(inode->i_sb,
+ "clm-6006: writing inode %lu on readonly FS",
+ inode->i_ino);
+ return;
+ }
+ reiserfs_write_lock(inode->i_sb);
+
+ /* this is really only used for atime updates, so they don't have
+ ** to be included in O_SYNC or fsync
+ */
+ err = journal_begin(&th, inode->i_sb, 1);
+ if (err) {
+ reiserfs_write_unlock(inode->i_sb);
+ return;
+ }
+ reiserfs_update_sd(&th, inode);
+ journal_end(&th, inode->i_sb, 1);
+ reiserfs_write_unlock(inode->i_sb);
}
-static void reiserfs_clear_inode (struct inode *inode)
+static void reiserfs_clear_inode(struct inode *inode)
{
- struct posix_acl *acl;
+ struct posix_acl *acl;
- acl = REISERFS_I(inode)->i_acl_access;
- if (acl && !IS_ERR (acl))
- posix_acl_release (acl);
- REISERFS_I(inode)->i_acl_access = NULL;
+ acl = REISERFS_I(inode)->i_acl_access;
+ if (acl && !IS_ERR(acl))
+ posix_acl_release(acl);
+ REISERFS_I(inode)->i_acl_access = NULL;
- acl = REISERFS_I(inode)->i_acl_default;
- if (acl && !IS_ERR (acl))
- posix_acl_release (acl);
- REISERFS_I(inode)->i_acl_default = NULL;
+ acl = REISERFS_I(inode)->i_acl_default;
+ if (acl && !IS_ERR(acl))
+ posix_acl_release(acl);
+ REISERFS_I(inode)->i_acl_default = NULL;
}
#ifdef CONFIG_QUOTA
-static ssize_t reiserfs_quota_write(struct super_block *, int, const char *, size_t, loff_t);
-static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t, loff_t);
+static ssize_t reiserfs_quota_write(struct super_block *, int, const char *,
+ size_t, loff_t);
+static ssize_t reiserfs_quota_read(struct super_block *, int, char *, size_t,
+ loff_t);
#endif
-static struct super_operations reiserfs_sops =
-{
- .alloc_inode = reiserfs_alloc_inode,
- .destroy_inode = reiserfs_destroy_inode,
- .write_inode = reiserfs_write_inode,
- .dirty_inode = reiserfs_dirty_inode,
- .delete_inode = reiserfs_delete_inode,
- .clear_inode = reiserfs_clear_inode,
- .put_super = reiserfs_put_super,
- .write_super = reiserfs_write_super,
- .sync_fs = reiserfs_sync_fs,
- .write_super_lockfs = reiserfs_write_super_lockfs,
- .unlockfs = reiserfs_unlockfs,
- .statfs = reiserfs_statfs,
- .remount_fs = reiserfs_remount,
+static struct super_operations reiserfs_sops = {
+ .alloc_inode = reiserfs_alloc_inode,
+ .destroy_inode = reiserfs_destroy_inode,
+ .write_inode = reiserfs_write_inode,
+ .dirty_inode = reiserfs_dirty_inode,
+ .delete_inode = reiserfs_delete_inode,
+ .clear_inode = reiserfs_clear_inode,
+ .put_super = reiserfs_put_super,
+ .write_super = reiserfs_write_super,
+ .sync_fs = reiserfs_sync_fs,
+ .write_super_lockfs = reiserfs_write_super_lockfs,
+ .unlockfs = reiserfs_unlockfs,
+ .statfs = reiserfs_statfs,
+ .remount_fs = reiserfs_remount,
#ifdef CONFIG_QUOTA
- .quota_read = reiserfs_quota_read,
- .quota_write = reiserfs_quota_write,
+ .quota_read = reiserfs_quota_read,
+ .quota_write = reiserfs_quota_write,
#endif
};
@@ -596,50 +622,48 @@ static int reiserfs_mark_dquot_dirty(struct dquot *);
static int reiserfs_write_info(struct super_block *, int);
static int reiserfs_quota_on(struct super_block *, int, int, char *);
-static struct dquot_operations reiserfs_quota_operations =
-{
- .initialize = reiserfs_dquot_initialize,
- .drop = reiserfs_dquot_drop,
- .alloc_space = dquot_alloc_space,
- .alloc_inode = dquot_alloc_inode,
- .free_space = dquot_free_space,
- .free_inode = dquot_free_inode,
- .transfer = dquot_transfer,
- .write_dquot = reiserfs_write_dquot,
- .acquire_dquot = reiserfs_acquire_dquot,
- .release_dquot = reiserfs_release_dquot,
- .mark_dirty = reiserfs_mark_dquot_dirty,
- .write_info = reiserfs_write_info,
+static struct dquot_operations reiserfs_quota_operations = {
+ .initialize = reiserfs_dquot_initialize,
+ .drop = reiserfs_dquot_drop,
+ .alloc_space = dquot_alloc_space,
+ .alloc_inode = dquot_alloc_inode,
+ .free_space = dquot_free_space,
+ .free_inode = dquot_free_inode,
+ .transfer = dquot_transfer,
+ .write_dquot = reiserfs_write_dquot,
+ .acquire_dquot = reiserfs_acquire_dquot,
+ .release_dquot = reiserfs_release_dquot,
+ .mark_dirty = reiserfs_mark_dquot_dirty,
+ .write_info = reiserfs_write_info,
};
-static struct quotactl_ops reiserfs_qctl_operations =
-{
- .quota_on = reiserfs_quota_on,
- .quota_off = vfs_quota_off,
- .quota_sync = vfs_quota_sync,
- .get_info = vfs_get_dqinfo,
- .set_info = vfs_set_dqinfo,
- .get_dqblk = vfs_get_dqblk,
- .set_dqblk = vfs_set_dqblk,
+static struct quotactl_ops reiserfs_qctl_operations = {
+ .quota_on = reiserfs_quota_on,
+ .quota_off = vfs_quota_off,
+ .quota_sync = vfs_quota_sync,
+ .get_info = vfs_get_dqinfo,
+ .set_info = vfs_set_dqinfo,
+ .get_dqblk = vfs_get_dqblk,
+ .set_dqblk = vfs_set_dqblk,
};
#endif
static struct export_operations reiserfs_export_ops = {
- .encode_fh = reiserfs_encode_fh,
- .decode_fh = reiserfs_decode_fh,
- .get_parent = reiserfs_get_parent,
- .get_dentry = reiserfs_get_dentry,
-} ;
+ .encode_fh = reiserfs_encode_fh,
+ .decode_fh = reiserfs_decode_fh,
+ .get_parent = reiserfs_get_parent,
+ .get_dentry = reiserfs_get_dentry,
+};
/* this struct is used in reiserfs_getopt () for containing the value for those
mount options that have values rather than being toggles. */
typedef struct {
- char * value;
- int setmask; /* bitmask which is to set on mount_options bitmask when this
- value is found, 0 is no bits are to be changed. */
- int clrmask; /* bitmask which is to clear on mount_options bitmask when this
- value is found, 0 is no bits are to be changed. This is
- applied BEFORE setmask */
+ char *value;
+ int setmask; /* bitmask which is to set on mount_options bitmask when this
+ value is found, 0 is no bits are to be changed. */
+ int clrmask; /* bitmask which is to clear on mount_options bitmask when this
+ value is found, 0 is no bits are to be changed. This is
+ applied BEFORE setmask */
} arg_desc_t;
/* Set this bit in arg_required to allow empty arguments */
@@ -648,67 +672,70 @@ typedef struct {
/* this struct is used in reiserfs_getopt() for describing the set of reiserfs
mount options */
typedef struct {
- char * option_name;
- int arg_required; /* 0 if argument is not required, not 0 otherwise */
- const arg_desc_t * values; /* list of values accepted by an option */
- int setmask; /* bitmask which is to set on mount_options bitmask when this
- value is found, 0 is no bits are to be changed. */
- int clrmask; /* bitmask which is to clear on mount_options bitmask when this
- value is found, 0 is no bits are to be changed. This is
- applied BEFORE setmask */
+ char *option_name;
+ int arg_required; /* 0 if argument is not required, not 0 otherwise */
+ const arg_desc_t *values; /* list of values accepted by an option */
+ int setmask; /* bitmask which is to set on mount_options bitmask when this
+ value is found, 0 is no bits are to be changed. */
+ int clrmask; /* bitmask which is to clear on mount_options bitmask when this
+ value is found, 0 is no bits are to be changed. This is
+ applied BEFORE setmask */
} opt_desc_t;
/* possible values for -o data= */
static const arg_desc_t logging_mode[] = {
- {"ordered", 1<<REISERFS_DATA_ORDERED, (1<<REISERFS_DATA_LOG|1<<REISERFS_DATA_WRITEBACK)},
- {"journal", 1<<REISERFS_DATA_LOG, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_WRITEBACK)},
- {"writeback", 1<<REISERFS_DATA_WRITEBACK, (1<<REISERFS_DATA_ORDERED|1<<REISERFS_DATA_LOG)},
- {NULL, 0}
+ {"ordered", 1 << REISERFS_DATA_ORDERED,
+ (1 << REISERFS_DATA_LOG | 1 << REISERFS_DATA_WRITEBACK)},
+ {"journal", 1 << REISERFS_DATA_LOG,
+ (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)},
+ {"writeback", 1 << REISERFS_DATA_WRITEBACK,
+ (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)},
+ {NULL, 0}
};
/* possible values for -o barrier= */
static const arg_desc_t barrier_mode[] = {
- {"none", 1<<REISERFS_BARRIER_NONE, 1<<REISERFS_BARRIER_FLUSH},
- {"flush", 1<<REISERFS_BARRIER_FLUSH, 1<<REISERFS_BARRIER_NONE},
- {NULL, 0}
+ {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH},
+ {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE},
+ {NULL, 0}
};
/* possible values for "-o block-allocator=" and bits which are to be set in
s_mount_opt of reiserfs specific part of in-core super block */
static const arg_desc_t balloc[] = {
- {"noborder", 1<<REISERFS_NO_BORDER, 0},
- {"border", 0, 1<<REISERFS_NO_BORDER},
- {"no_unhashed_relocation", 1<<REISERFS_NO_UNHASHED_RELOCATION, 0},
- {"hashed_relocation", 1<<REISERFS_HASHED_RELOCATION, 0},
- {"test4", 1<<REISERFS_TEST4, 0},
- {"notest4", 0, 1<<REISERFS_TEST4},
- {NULL, 0, 0}
+ {"noborder", 1 << REISERFS_NO_BORDER, 0},
+ {"border", 0, 1 << REISERFS_NO_BORDER},
+ {"no_unhashed_relocation", 1 << REISERFS_NO_UNHASHED_RELOCATION, 0},
+ {"hashed_relocation", 1 << REISERFS_HASHED_RELOCATION, 0},
+ {"test4", 1 << REISERFS_TEST4, 0},
+ {"notest4", 0, 1 << REISERFS_TEST4},
+ {NULL, 0, 0}
};
static const arg_desc_t tails[] = {
- {"on", 1<<REISERFS_LARGETAIL, 1<<REISERFS_SMALLTAIL},
- {"off", 0, (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
- {"small", 1<<REISERFS_SMALLTAIL, 1<<REISERFS_LARGETAIL},
- {NULL, 0, 0}
+ {"on", 1 << REISERFS_LARGETAIL, 1 << REISERFS_SMALLTAIL},
+ {"off", 0, (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
+ {"small", 1 << REISERFS_SMALLTAIL, 1 << REISERFS_LARGETAIL},
+ {NULL, 0, 0}
};
static const arg_desc_t error_actions[] = {
- {"panic", 1 << REISERFS_ERROR_PANIC,
- (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
- {"ro-remount", 1 << REISERFS_ERROR_RO,
- (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
+ {"panic", 1 << REISERFS_ERROR_PANIC,
+ (1 << REISERFS_ERROR_RO | 1 << REISERFS_ERROR_CONTINUE)},
+ {"ro-remount", 1 << REISERFS_ERROR_RO,
+ (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_CONTINUE)},
#ifdef REISERFS_JOURNAL_ERROR_ALLOWS_NO_LOG
- {"continue", 1 << REISERFS_ERROR_CONTINUE,
- (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
+ {"continue", 1 << REISERFS_ERROR_CONTINUE,
+ (1 << REISERFS_ERROR_PANIC | 1 << REISERFS_ERROR_RO)},
#endif
- {NULL, 0, 0},
+ {NULL, 0, 0},
};
-int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
- There might be broken applications that are
- confused by this. Use nolargeio mount option
- to get usual i/o size = PAGE_SIZE.
- */
+int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
+ There might be broken applications that are
+ confused by this. Use nolargeio mount option
+ to get usual i/o size = PAGE_SIZE.
+ */
/* proceed only one option from a list *cur - string containing of mount options
opts - array of options which are accepted
@@ -716,486 +743,530 @@ int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 12
in the input - pointer to the argument is stored here
bit_flags - if option requires to set a certain bit - it is set here
return -1 if unknown option is found, opt->arg_required otherwise */
-static int reiserfs_getopt ( struct super_block * s, char ** cur, opt_desc_t * opts, char ** opt_arg,
- unsigned long * bit_flags)
+static int reiserfs_getopt(struct super_block *s, char **cur, opt_desc_t * opts,
+ char **opt_arg, unsigned long *bit_flags)
{
- char * p;
- /* foo=bar,
- ^ ^ ^
- | | +-- option_end
- | +-- arg_start
- +-- option_start
- */
- const opt_desc_t * opt;
- const arg_desc_t * arg;
-
-
- p = *cur;
-
- /* assume argument cannot contain commas */
- *cur = strchr (p, ',');
- if (*cur) {
- *(*cur) = '\0';
- (*cur) ++;
- }
-
- if ( !strncmp (p, "alloc=", 6) ) {
- /* Ugly special case, probably we should redo options parser so that
- it can understand several arguments for some options, also so that
- it can fill several bitfields with option values. */
- if ( reiserfs_parse_alloc_options( s, p + 6) ) {
- return -1;
- } else {
- return 0;
- }
- }
-
-
- /* for every option in the list */
- for (opt = opts; opt->option_name; opt ++) {
- if (!strncmp (p, opt->option_name, strlen (opt->option_name))) {
- if (bit_flags) {
- if (opt->clrmask == (1 << REISERFS_UNSUPPORTED_OPT))
- reiserfs_warning (s, "%s not supported.", p);
- else
- *bit_flags &= ~opt->clrmask;
- if (opt->setmask == (1 << REISERFS_UNSUPPORTED_OPT))
- reiserfs_warning (s, "%s not supported.", p);
- else
- *bit_flags |= opt->setmask;
- }
- break;
- }
- }
- if (!opt->option_name) {
- reiserfs_warning (s, "unknown mount option \"%s\"", p);
- return -1;
- }
-
- p += strlen (opt->option_name);
- switch (*p) {
- case '=':
- if (!opt->arg_required) {
- reiserfs_warning (s, "the option \"%s\" does not require an argument",
- opt->option_name);
- return -1;
- }
- break;
-
- case 0:
- if (opt->arg_required) {
- reiserfs_warning (s, "the option \"%s\" requires an argument", opt->option_name);
- return -1;
- }
- break;
- default:
- reiserfs_warning (s, "head of option \"%s\" is only correct", opt->option_name);
- return -1;
- }
-
- /* move to the argument, or to next option if argument is not required */
- p ++;
-
- if ( opt->arg_required && !(opt->arg_required & (1<<REISERFS_OPT_ALLOWEMPTY)) && !strlen (p) ) {
- /* this catches "option=," if not allowed */
- reiserfs_warning (s, "empty argument for \"%s\"", opt->option_name);
+ char *p;
+ /* foo=bar,
+ ^ ^ ^
+ | | +-- option_end
+ | +-- arg_start
+ +-- option_start
+ */
+ const opt_desc_t *opt;
+ const arg_desc_t *arg;
+
+ p = *cur;
+
+ /* assume argument cannot contain commas */
+ *cur = strchr(p, ',');
+ if (*cur) {
+ *(*cur) = '\0';
+ (*cur)++;
+ }
+
+ if (!strncmp(p, "alloc=", 6)) {
+ /* Ugly special case, probably we should redo options parser so that
+ it can understand several arguments for some options, also so that
+ it can fill several bitfields with option values. */
+ if (reiserfs_parse_alloc_options(s, p + 6)) {
+ return -1;
+ } else {
+ return 0;
+ }
+ }
+
+ /* for every option in the list */
+ for (opt = opts; opt->option_name; opt++) {
+ if (!strncmp(p, opt->option_name, strlen(opt->option_name))) {
+ if (bit_flags) {
+ if (opt->clrmask ==
+ (1 << REISERFS_UNSUPPORTED_OPT))
+ reiserfs_warning(s, "%s not supported.",
+ p);
+ else
+ *bit_flags &= ~opt->clrmask;
+ if (opt->setmask ==
+ (1 << REISERFS_UNSUPPORTED_OPT))
+ reiserfs_warning(s, "%s not supported.",
+ p);
+ else
+ *bit_flags |= opt->setmask;
+ }
+ break;
+ }
+ }
+ if (!opt->option_name) {
+ reiserfs_warning(s, "unknown mount option \"%s\"", p);
+ return -1;
+ }
+
+ p += strlen(opt->option_name);
+ switch (*p) {
+ case '=':
+ if (!opt->arg_required) {
+ reiserfs_warning(s,
+ "the option \"%s\" does not require an argument",
+ opt->option_name);
+ return -1;
+ }
+ break;
+
+ case 0:
+ if (opt->arg_required) {
+ reiserfs_warning(s,
+ "the option \"%s\" requires an argument",
+ opt->option_name);
+ return -1;
+ }
+ break;
+ default:
+ reiserfs_warning(s, "head of option \"%s\" is only correct",
+ opt->option_name);
+ return -1;
+ }
+
+ /* move to the argument, or to next option if argument is not required */
+ p++;
+
+ if (opt->arg_required
+ && !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY))
+ && !strlen(p)) {
+ /* this catches "option=," if not allowed */
+ reiserfs_warning(s, "empty argument for \"%s\"",
+ opt->option_name);
+ return -1;
+ }
+
+ if (!opt->values) {
+ /* *=NULLopt_arg contains pointer to argument */
+ *opt_arg = p;
+ return opt->arg_required & ~(1 << REISERFS_OPT_ALLOWEMPTY);
+ }
+
+ /* values possible for this option are listed in opt->values */
+ for (arg = opt->values; arg->value; arg++) {
+ if (!strcmp(p, arg->value)) {
+ if (bit_flags) {
+ *bit_flags &= ~arg->clrmask;
+ *bit_flags |= arg->setmask;
+ }
+ return opt->arg_required;
+ }
+ }
+
+ reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p,
+ opt->option_name);
return -1;
- }
-
- if (!opt->values) {
- /* *=NULLopt_arg contains pointer to argument */
- *opt_arg = p;
- return opt->arg_required & ~(1<<REISERFS_OPT_ALLOWEMPTY);
- }
-
- /* values possible for this option are listed in opt->values */
- for (arg = opt->values; arg->value; arg ++) {
- if (!strcmp (p, arg->value)) {
- if (bit_flags) {
- *bit_flags &= ~arg->clrmask;
- *bit_flags |= arg->setmask;
- }
- return opt->arg_required;
- }
- }
-
- reiserfs_warning (s, "bad value \"%s\" for option \"%s\"", p, opt->option_name);
- return -1;
}
/* returns 0 if something is wrong in option string, 1 - otherwise */
-static int reiserfs_parse_options (struct super_block * s, char * options, /* string given via mount's -o */
- unsigned long * mount_options,
- /* after the parsing phase, contains the
- collection of bitflags defining what
- mount options were selected. */
- unsigned long * blocks, /* strtol-ed from NNN of resize=NNN */
- char ** jdev_name,
- unsigned int * commit_max_age)
+static int reiserfs_parse_options(struct super_block *s, char *options, /* string given via mount's -o */
+ unsigned long *mount_options,
+ /* after the parsing phase, contains the
+ collection of bitflags defining what
+ mount options were selected. */
+ unsigned long *blocks, /* strtol-ed from NNN of resize=NNN */
+ char **jdev_name,
+ unsigned int *commit_max_age)
{
- int c;
- char * arg = NULL;
- char * pos;
- opt_desc_t opts[] = {
- /* Compatibility stuff, so that -o notail for old setups still work */
- {"tails", .arg_required = 't', .values = tails},
- {"notail", .clrmask = (1<<REISERFS_LARGETAIL)|(1<<REISERFS_SMALLTAIL)},
- {"conv", .setmask = 1<<REISERFS_CONVERT},
- {"attrs", .setmask = 1<<REISERFS_ATTRS},
- {"noattrs", .clrmask = 1<<REISERFS_ATTRS},
+ int c;
+ char *arg = NULL;
+ char *pos;
+ opt_desc_t opts[] = {
+ /* Compatibility stuff, so that -o notail for old setups still work */
+ {"tails",.arg_required = 't',.values = tails},
+ {"notail",.clrmask =
+ (1 << REISERFS_LARGETAIL) | (1 << REISERFS_SMALLTAIL)},
+ {"conv",.setmask = 1 << REISERFS_CONVERT},
+ {"attrs",.setmask = 1 << REISERFS_ATTRS},
+ {"noattrs",.clrmask = 1 << REISERFS_ATTRS},
#ifdef CONFIG_REISERFS_FS_XATTR
- {"user_xattr", .setmask = 1<<REISERFS_XATTRS_USER},
- {"nouser_xattr",.clrmask = 1<<REISERFS_XATTRS_USER},
+ {"user_xattr",.setmask = 1 << REISERFS_XATTRS_USER},
+ {"nouser_xattr",.clrmask = 1 << REISERFS_XATTRS_USER},
#else
- {"user_xattr", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
- {"nouser_xattr",.clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
+ {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
+ {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
#endif
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
- {"acl", .setmask = 1<<REISERFS_POSIXACL},
- {"noacl", .clrmask = 1<<REISERFS_POSIXACL},
+ {"acl",.setmask = 1 << REISERFS_POSIXACL},
+ {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
#else
- {"acl", .setmask = 1<<REISERFS_UNSUPPORTED_OPT},
- {"noacl", .clrmask = 1<<REISERFS_UNSUPPORTED_OPT},
+ {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
+ {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
#endif
- {"nolog",}, /* This is unsupported */
- {"replayonly", .setmask = 1<<REPLAYONLY},
- {"block-allocator", .arg_required = 'a', .values = balloc},
- {"data", .arg_required = 'd', .values = logging_mode},
- {"barrier", .arg_required = 'b', .values = barrier_mode},
- {"resize", .arg_required = 'r', .values = NULL},
- {"jdev", .arg_required = 'j', .values = NULL},
- {"nolargeio", .arg_required = 'w', .values = NULL},
- {"commit", .arg_required = 'c', .values = NULL},
- {"usrquota", .setmask = 1<<REISERFS_QUOTA},
- {"grpquota", .setmask = 1<<REISERFS_QUOTA},
- {"noquota", .clrmask = 1<<REISERFS_QUOTA},
- {"errors", .arg_required = 'e', .values = error_actions},
- {"usrjquota", .arg_required = 'u'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
- {"grpjquota", .arg_required = 'g'|(1<<REISERFS_OPT_ALLOWEMPTY), .values = NULL},
- {"jqfmt", .arg_required = 'f', .values = NULL},
- {NULL,}
- };
-
- *blocks = 0;
- if (!options || !*options)
- /* use default configuration: create tails, journaling on, no
- conversion to newest format */
- return 1;
-
- for (pos = options; pos; ) {
- c = reiserfs_getopt (s, &pos, opts, &arg, mount_options);
- if (c == -1)
- /* wrong option is given */
- return 0;
-
- if (c == 'r') {
- char * p;
-
- p = NULL;
- /* "resize=NNN" or "resize=auto" */
-
- if (!strcmp(arg, "auto")) {
- /* From JFS code, to auto-get the size.*/
- *blocks = s->s_bdev->bd_inode->i_size >> s->s_blocksize_bits;
- } else {
- *blocks = simple_strtoul (arg, &p, 0);
- if (*p != '\0') {
- /* NNN does not look like a number */
- reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
+ {"nolog",}, /* This is unsupported */
+ {"replayonly",.setmask = 1 << REPLAYONLY},
+ {"block-allocator",.arg_required = 'a',.values = balloc},
+ {"data",.arg_required = 'd',.values = logging_mode},
+ {"barrier",.arg_required = 'b',.values = barrier_mode},
+ {"resize",.arg_required = 'r',.values = NULL},
+ {"jdev",.arg_required = 'j',.values = NULL},
+ {"nolargeio",.arg_required = 'w',.values = NULL},
+ {"commit",.arg_required = 'c',.values = NULL},
+ {"usrquota",.setmask = 1 << REISERFS_QUOTA},
+ {"grpquota",.setmask = 1 << REISERFS_QUOTA},
+ {"noquota",.clrmask = 1 << REISERFS_QUOTA},
+ {"errors",.arg_required = 'e',.values = error_actions},
+ {"usrjquota",.arg_required =
+ 'u' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
+ {"grpjquota",.arg_required =
+ 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
+ {"jqfmt",.arg_required = 'f',.values = NULL},
+ {NULL,}
+ };
+
+ *blocks = 0;
+ if (!options || !*options)
+ /* use default configuration: create tails, journaling on, no
+ conversion to newest format */
+ return 1;
+
+ for (pos = options; pos;) {
+ c = reiserfs_getopt(s, &pos, opts, &arg, mount_options);
+ if (c == -1)
+ /* wrong option is given */
return 0;
- }
- }
- }
- if ( c == 'c' ) {
- char *p = NULL;
- unsigned long val = simple_strtoul (arg, &p, 0);
- /* commit=NNN (time in seconds) */
- if ( *p != '\0' || val >= (unsigned int)-1) {
- reiserfs_warning (s, "reiserfs_parse_options: bad value %s", arg);
- return 0;
+ if (c == 'r') {
+ char *p;
+
+ p = NULL;
+ /* "resize=NNN" or "resize=auto" */
+
+ if (!strcmp(arg, "auto")) {
+ /* From JFS code, to auto-get the size. */
+ *blocks =
+ s->s_bdev->bd_inode->i_size >> s->
+ s_blocksize_bits;
+ } else {
+ *blocks = simple_strtoul(arg, &p, 0);
+ if (*p != '\0') {
+ /* NNN does not look like a number */
+ reiserfs_warning(s,
+ "reiserfs_parse_options: bad value %s",
+ arg);
+ return 0;
+ }
+ }
}
- *commit_max_age = (unsigned int)val;
- }
- if ( c == 'w' ) {
- char *p=NULL;
- int val = simple_strtoul (arg, &p, 0);
-
- if ( *p != '\0') {
- reiserfs_warning (s, "reiserfs_parse_options: non-numeric value %s for nolargeio option", arg);
- return 0;
+ if (c == 'c') {
+ char *p = NULL;
+ unsigned long val = simple_strtoul(arg, &p, 0);
+ /* commit=NNN (time in seconds) */
+ if (*p != '\0' || val >= (unsigned int)-1) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: bad value %s",
+ arg);
+ return 0;
+ }
+ *commit_max_age = (unsigned int)val;
}
- if ( val )
- reiserfs_default_io_size = PAGE_SIZE;
- else
- reiserfs_default_io_size = 128 * 1024;
- }
- if (c == 'j') {
- if (arg && *arg && jdev_name) {
- if ( *jdev_name ) { //Hm, already assigned?
- reiserfs_warning (s, "reiserfs_parse_options: journal device was already specified to be %s", *jdev_name);
- return 0;
+ if (c == 'w') {
+ char *p = NULL;
+ int val = simple_strtoul(arg, &p, 0);
+
+ if (*p != '\0') {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: non-numeric value %s for nolargeio option",
+ arg);
+ return 0;
+ }
+ if (val)
+ reiserfs_default_io_size = PAGE_SIZE;
+ else
+ reiserfs_default_io_size = 128 * 1024;
}
- *jdev_name = arg;
- }
- }
-#ifdef CONFIG_QUOTA
- if (c == 'u' || c == 'g') {
- int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
-
- if (sb_any_quota_enabled(s)) {
- reiserfs_warning(s, "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
- return 0;
- }
- if (*arg) { /* Some filename specified? */
- if (REISERFS_SB(s)->s_qf_names[qtype] && strcmp(REISERFS_SB(s)->s_qf_names[qtype], arg)) {
- reiserfs_warning(s, "reiserfs_parse_options: %s quota file already specified.", QTYPE2NAME(qtype));
- return 0;
+ if (c == 'j') {
+ if (arg && *arg && jdev_name) {
+ if (*jdev_name) { //Hm, already assigned?
+ reiserfs_warning(s,
+ "reiserfs_parse_options: journal device was already specified to be %s",
+ *jdev_name);
+ return 0;
+ }
+ *jdev_name = arg;
+ }
}
- if (strchr(arg, '/')) {
- reiserfs_warning(s, "reiserfs_parse_options: quotafile must be on filesystem root.");
- return 0;
+#ifdef CONFIG_QUOTA
+ if (c == 'u' || c == 'g') {
+ int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
+
+ if (sb_any_quota_enabled(s)) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
+ return 0;
+ }
+ if (*arg) { /* Some filename specified? */
+ if (REISERFS_SB(s)->s_qf_names[qtype]
+ && strcmp(REISERFS_SB(s)->s_qf_names[qtype],
+ arg)) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: %s quota file already specified.",
+ QTYPE2NAME(qtype));
+ return 0;
+ }
+ if (strchr(arg, '/')) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: quotafile must be on filesystem root.");
+ return 0;
+ }
+ REISERFS_SB(s)->s_qf_names[qtype] =
+ kmalloc(strlen(arg) + 1, GFP_KERNEL);
+ if (!REISERFS_SB(s)->s_qf_names[qtype]) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: not enough memory for storing quotafile name.");
+ return 0;
+ }
+ strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
+ *mount_options |= 1 << REISERFS_QUOTA;
+ } else {
+ if (REISERFS_SB(s)->s_qf_names[qtype]) {
+ kfree(REISERFS_SB(s)->
+ s_qf_names[qtype]);
+ REISERFS_SB(s)->s_qf_names[qtype] =
+ NULL;
+ }
+ }
}
- REISERFS_SB(s)->s_qf_names[qtype] = kmalloc(strlen(arg)+1, GFP_KERNEL);
- if (!REISERFS_SB(s)->s_qf_names[qtype]) {
- reiserfs_warning(s, "reiserfs_parse_options: not enough memory for storing quotafile name.");
- return 0;
+ if (c == 'f') {
+ if (!strcmp(arg, "vfsold"))
+ REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
+ else if (!strcmp(arg, "vfsv0"))
+ REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
+ else {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: unknown quota format specified.");
+ return 0;
+ }
}
- strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
- *mount_options |= 1<<REISERFS_QUOTA;
- }
- else {
- if (REISERFS_SB(s)->s_qf_names[qtype]) {
- kfree(REISERFS_SB(s)->s_qf_names[qtype]);
- REISERFS_SB(s)->s_qf_names[qtype] = NULL;
+#else
+ if (c == 'u' || c == 'g' || c == 'f') {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: journalled quota options not supported.");
+ return 0;
}
- }
- }
- if (c == 'f') {
- if (!strcmp(arg, "vfsold"))
- REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_OLD;
- else if (!strcmp(arg, "vfsv0"))
- REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
- else {
- reiserfs_warning(s, "reiserfs_parse_options: unknown quota format specified.");
+#endif
+ }
+
+#ifdef CONFIG_QUOTA
+ if (!REISERFS_SB(s)->s_jquota_fmt
+ && (REISERFS_SB(s)->s_qf_names[USRQUOTA]
+ || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: journalled quota format not specified.");
return 0;
- }
}
-#else
- if (c == 'u' || c == 'g' || c == 'f') {
- reiserfs_warning(s, "reiserfs_parse_options: journalled quota options not supported.");
- return 0;
+ /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
+ if (!(*mount_options & (1 << REISERFS_QUOTA))
+ && sb_any_quota_enabled(s)) {
+ reiserfs_warning(s,
+ "reiserfs_parse_options: quota options must be present when quota is turned on.");
+ return 0;
}
#endif
- }
-
-#ifdef CONFIG_QUOTA
- if (!REISERFS_SB(s)->s_jquota_fmt && (REISERFS_SB(s)->s_qf_names[USRQUOTA] || REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
- reiserfs_warning(s, "reiserfs_parse_options: journalled quota format not specified.");
- return 0;
- }
- /* This checking is not precise wrt the quota type but for our purposes it is sufficient */
- if (!(*mount_options & (1<<REISERFS_QUOTA)) && sb_any_quota_enabled(s)) {
- reiserfs_warning(s, "reiserfs_parse_options: quota options must be present when quota is turned on.");
- return 0;
- }
-#endif
- return 1;
+ return 1;
}
-static void switch_data_mode(struct super_block *s, unsigned long mode) {
- REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
- (1 << REISERFS_DATA_ORDERED) |
- (1 << REISERFS_DATA_WRITEBACK));
- REISERFS_SB(s)->s_mount_opt |= (1 << mode);
+static void switch_data_mode(struct super_block *s, unsigned long mode)
+{
+ REISERFS_SB(s)->s_mount_opt &= ~((1 << REISERFS_DATA_LOG) |
+ (1 << REISERFS_DATA_ORDERED) |
+ (1 << REISERFS_DATA_WRITEBACK));
+ REISERFS_SB(s)->s_mount_opt |= (1 << mode);
}
static void handle_data_mode(struct super_block *s, unsigned long mount_options)
{
- if (mount_options & (1 << REISERFS_DATA_LOG)) {
- if (!reiserfs_data_log(s)) {
- switch_data_mode(s, REISERFS_DATA_LOG);
- reiserfs_info (s, "switching to journaled data mode\n");
- }
- } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
- if (!reiserfs_data_ordered(s)) {
- switch_data_mode(s, REISERFS_DATA_ORDERED);
- reiserfs_info (s, "switching to ordered data mode\n");
- }
- } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
- if (!reiserfs_data_writeback(s)) {
- switch_data_mode(s, REISERFS_DATA_WRITEBACK);
- reiserfs_info (s, "switching to writeback data mode\n");
- }
- }
+ if (mount_options & (1 << REISERFS_DATA_LOG)) {
+ if (!reiserfs_data_log(s)) {
+ switch_data_mode(s, REISERFS_DATA_LOG);
+ reiserfs_info(s, "switching to journaled data mode\n");
+ }
+ } else if (mount_options & (1 << REISERFS_DATA_ORDERED)) {
+ if (!reiserfs_data_ordered(s)) {
+ switch_data_mode(s, REISERFS_DATA_ORDERED);
+ reiserfs_info(s, "switching to ordered data mode\n");
+ }
+ } else if (mount_options & (1 << REISERFS_DATA_WRITEBACK)) {
+ if (!reiserfs_data_writeback(s)) {
+ switch_data_mode(s, REISERFS_DATA_WRITEBACK);
+ reiserfs_info(s, "switching to writeback data mode\n");
+ }
+ }
}
-static void handle_barrier_mode(struct super_block *s, unsigned long bits) {
- int flush = (1 << REISERFS_BARRIER_FLUSH);
- int none = (1 << REISERFS_BARRIER_NONE);
- int all_barrier = flush | none;
-
- if (bits & all_barrier) {
- REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
- if (bits & flush) {
- REISERFS_SB(s)->s_mount_opt |= flush;
- printk("reiserfs: enabling write barrier flush mode\n");
- } else if (bits & none) {
- REISERFS_SB(s)->s_mount_opt |= none;
- printk("reiserfs: write barriers turned off\n");
- }
- }
+static void handle_barrier_mode(struct super_block *s, unsigned long bits)
+{
+ int flush = (1 << REISERFS_BARRIER_FLUSH);
+ int none = (1 << REISERFS_BARRIER_NONE);
+ int all_barrier = flush | none;
+
+ if (bits & all_barrier) {
+ REISERFS_SB(s)->s_mount_opt &= ~all_barrier;
+ if (bits & flush) {
+ REISERFS_SB(s)->s_mount_opt |= flush;
+ printk("reiserfs: enabling write barrier flush mode\n");
+ } else if (bits & none) {
+ REISERFS_SB(s)->s_mount_opt |= none;
+ printk("reiserfs: write barriers turned off\n");
+ }
+ }
}
-static void handle_attrs( struct super_block *s )
+static void handle_attrs(struct super_block *s)
{
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
+ struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
- if( reiserfs_attrs( s ) ) {
- if( old_format_only(s) ) {
- reiserfs_warning(s, "reiserfs: cannot support attributes on 3.5.x disk format" );
- REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
+ if (reiserfs_attrs(s)) {
+ if (old_format_only(s)) {
+ reiserfs_warning(s,
+ "reiserfs: cannot support attributes on 3.5.x disk format");
+ REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
return;
}
- if( !( le32_to_cpu( rs -> s_flags ) & reiserfs_attrs_cleared ) ) {
- reiserfs_warning(s, "reiserfs: cannot support attributes until flag is set in super-block" );
- REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS );
+ if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) {
+ reiserfs_warning(s,
+ "reiserfs: cannot support attributes until flag is set in super-block");
+ REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
}
- } else if (le32_to_cpu( rs -> s_flags ) & reiserfs_attrs_cleared) {
+ } else if (le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared) {
REISERFS_SB(s)->s_mount_opt |= REISERFS_ATTRS;
}
}
-static int reiserfs_remount (struct super_block * s, int * mount_flags, char * arg)
+static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
{
- struct reiserfs_super_block * rs;
- struct reiserfs_transaction_handle th ;
- unsigned long blocks;
- unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
- unsigned long safe_mask = 0;
- unsigned int commit_max_age = (unsigned int)-1;
- struct reiserfs_journal *journal = SB_JOURNAL(s);
- int err;
+ struct reiserfs_super_block *rs;
+ struct reiserfs_transaction_handle th;
+ unsigned long blocks;
+ unsigned long mount_options = REISERFS_SB(s)->s_mount_opt;
+ unsigned long safe_mask = 0;
+ unsigned int commit_max_age = (unsigned int)-1;
+ struct reiserfs_journal *journal = SB_JOURNAL(s);
+ int err;
#ifdef CONFIG_QUOTA
- int i;
+ int i;
#endif
- rs = SB_DISK_SUPER_BLOCK (s);
+ rs = SB_DISK_SUPER_BLOCK(s);
- if (!reiserfs_parse_options(s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
+ if (!reiserfs_parse_options
+ (s, arg, &mount_options, &blocks, NULL, &commit_max_age)) {
#ifdef CONFIG_QUOTA
- for (i = 0; i < MAXQUOTAS; i++)
- if (REISERFS_SB(s)->s_qf_names[i]) {
- kfree(REISERFS_SB(s)->s_qf_names[i]);
- REISERFS_SB(s)->s_qf_names[i] = NULL;
- }
+ for (i = 0; i < MAXQUOTAS; i++)
+ if (REISERFS_SB(s)->s_qf_names[i]) {
+ kfree(REISERFS_SB(s)->s_qf_names[i]);
+ REISERFS_SB(s)->s_qf_names[i] = NULL;
+ }
#endif
- return -EINVAL;
- }
-
- handle_attrs(s);
-
- /* Add options that are safe here */
- safe_mask |= 1 << REISERFS_SMALLTAIL;
- safe_mask |= 1 << REISERFS_LARGETAIL;
- safe_mask |= 1 << REISERFS_NO_BORDER;
- safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
- safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
- safe_mask |= 1 << REISERFS_TEST4;
- safe_mask |= 1 << REISERFS_ATTRS;
- safe_mask |= 1 << REISERFS_XATTRS_USER;
- safe_mask |= 1 << REISERFS_POSIXACL;
- safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
- safe_mask |= 1 << REISERFS_BARRIER_NONE;
- safe_mask |= 1 << REISERFS_ERROR_RO;
- safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
- safe_mask |= 1 << REISERFS_ERROR_PANIC;
- safe_mask |= 1 << REISERFS_QUOTA;
-
- /* Update the bitmask, taking care to keep
- * the bits we're not allowed to change here */
- REISERFS_SB(s)->s_mount_opt = (REISERFS_SB(s)->s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
-
- if(commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
- journal->j_max_commit_age = commit_max_age;
- journal->j_max_trans_age = commit_max_age;
- }
- else if(commit_max_age == 0)
- {
- /* 0 means restore defaults. */
- journal->j_max_commit_age = journal->j_default_max_commit_age;
- journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
- }
-
- if(blocks) {
- int rc = reiserfs_resize(s, blocks);
- if (rc != 0)
- return rc;
- }
-
- if (*mount_flags & MS_RDONLY) {
- reiserfs_xattr_init (s, *mount_flags);
- /* remount read-only */
- if (s->s_flags & MS_RDONLY)
- /* it is read-only already */
- return 0;
- /* try to remount file system with read-only permissions */
- if (sb_umount_state(rs) == REISERFS_VALID_FS || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
- return 0;
- }
-
- err = journal_begin(&th, s, 10) ;
- if (err)
- return err;
-
- /* Mounting a rw partition read-only. */
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
- set_sb_umount_state( rs, REISERFS_SB(s)->s_mount_state );
- journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
- } else {
- /* remount read-write */
- if (!(s->s_flags & MS_RDONLY)) {
- reiserfs_xattr_init (s, *mount_flags);
- return 0; /* We are read-write already */
- }
-
- if (reiserfs_is_journal_aborted (journal))
- return journal->j_errno;
-
- handle_data_mode(s, mount_options);
- handle_barrier_mode(s, mount_options);
- REISERFS_SB(s)->s_mount_state = sb_umount_state(rs) ;
- s->s_flags &= ~MS_RDONLY ; /* now it is safe to call journal_begin */
- err = journal_begin(&th, s, 10) ;
- if (err)
- return err;
-
- /* Mount a partition which is read-only, read-write */
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
- REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
- s->s_flags &= ~MS_RDONLY;
- set_sb_umount_state( rs, REISERFS_ERROR_FS );
- /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
- journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
- REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS ;
- }
- /* this will force a full flush of all journal lists */
- SB_JOURNAL(s)->j_must_wait = 1 ;
- err = journal_end(&th, s, 10) ;
- if (err)
- return err;
- s->s_dirt = 0;
-
- if (!( *mount_flags & MS_RDONLY ) ) {
- finish_unfinished( s );
- reiserfs_xattr_init (s, *mount_flags);
- }
-
- return 0;
+ return -EINVAL;
+ }
+
+ handle_attrs(s);
+
+ /* Add options that are safe here */
+ safe_mask |= 1 << REISERFS_SMALLTAIL;
+ safe_mask |= 1 << REISERFS_LARGETAIL;
+ safe_mask |= 1 << REISERFS_NO_BORDER;
+ safe_mask |= 1 << REISERFS_NO_UNHASHED_RELOCATION;
+ safe_mask |= 1 << REISERFS_HASHED_RELOCATION;
+ safe_mask |= 1 << REISERFS_TEST4;
+ safe_mask |= 1 << REISERFS_ATTRS;
+ safe_mask |= 1 << REISERFS_XATTRS_USER;
+ safe_mask |= 1 << REISERFS_POSIXACL;
+ safe_mask |= 1 << REISERFS_BARRIER_FLUSH;
+ safe_mask |= 1 << REISERFS_BARRIER_NONE;
+ safe_mask |= 1 << REISERFS_ERROR_RO;
+ safe_mask |= 1 << REISERFS_ERROR_CONTINUE;
+ safe_mask |= 1 << REISERFS_ERROR_PANIC;
+ safe_mask |= 1 << REISERFS_QUOTA;
+
+ /* Update the bitmask, taking care to keep
+ * the bits we're not allowed to change here */
+ REISERFS_SB(s)->s_mount_opt =
+ (REISERFS_SB(s)->
+ s_mount_opt & ~safe_mask) | (mount_options & safe_mask);
+
+ if (commit_max_age != 0 && commit_max_age != (unsigned int)-1) {
+ journal->j_max_commit_age = commit_max_age;
+ journal->j_max_trans_age = commit_max_age;
+ } else if (commit_max_age == 0) {
+ /* 0 means restore defaults. */
+ journal->j_max_commit_age = journal->j_default_max_commit_age;
+ journal->j_max_trans_age = JOURNAL_MAX_TRANS_AGE;
+ }
+
+ if (blocks) {
+ int rc = reiserfs_resize(s, blocks);
+ if (rc != 0)
+ return rc;
+ }
+
+ if (*mount_flags & MS_RDONLY) {
+ reiserfs_xattr_init(s, *mount_flags);
+ /* remount read-only */
+ if (s->s_flags & MS_RDONLY)
+ /* it is read-only already */
+ return 0;
+ /* try to remount file system with read-only permissions */
+ if (sb_umount_state(rs) == REISERFS_VALID_FS
+ || REISERFS_SB(s)->s_mount_state != REISERFS_VALID_FS) {
+ return 0;
+ }
+
+ err = journal_begin(&th, s, 10);
+ if (err)
+ return err;
+
+ /* Mounting a rw partition read-only. */
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+ set_sb_umount_state(rs, REISERFS_SB(s)->s_mount_state);
+ journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+ } else {
+ /* remount read-write */
+ if (!(s->s_flags & MS_RDONLY)) {
+ reiserfs_xattr_init(s, *mount_flags);
+ return 0; /* We are read-write already */
+ }
+
+ if (reiserfs_is_journal_aborted(journal))
+ return journal->j_errno;
+
+ handle_data_mode(s, mount_options);
+ handle_barrier_mode(s, mount_options);
+ REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
+ s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
+ err = journal_begin(&th, s, 10);
+ if (err)
+ return err;
+
+ /* Mount a partition which is read-only, read-write */
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+ REISERFS_SB(s)->s_mount_state = sb_umount_state(rs);
+ s->s_flags &= ~MS_RDONLY;
+ set_sb_umount_state(rs, REISERFS_ERROR_FS);
+ /* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */
+ journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+ REISERFS_SB(s)->s_mount_state = REISERFS_VALID_FS;
+ }
+ /* this will force a full flush of all journal lists */
+ SB_JOURNAL(s)->j_must_wait = 1;
+ err = journal_end(&th, s, 10);
+ if (err)
+ return err;
+ s->s_dirt = 0;
+
+ if (!(*mount_flags & MS_RDONLY)) {
+ finish_unfinished(s);
+ reiserfs_xattr_init(s, *mount_flags);
+ }
+
+ return 0;
}
/* load_bitmap_info_data - Sets up the reiserfs_bitmap_info structure from disk.
@@ -1214,761 +1285,829 @@ static int reiserfs_remount (struct super_block * s, int * mount_flags, char * a
* free blocks at all.
*/
-static void load_bitmap_info_data (struct super_block *sb,
- struct reiserfs_bitmap_info *bi)
+static void load_bitmap_info_data(struct super_block *sb,
+ struct reiserfs_bitmap_info *bi)
{
- unsigned long *cur = (unsigned long *)bi->bh->b_data;
-
- while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
-
- /* No need to scan if all 0's or all 1's.
- * Since we're only counting 0's, we can simply ignore all 1's */
- if (*cur == 0) {
- if (bi->first_zero_hint == 0) {
- bi->first_zero_hint = ((char *)cur - bi->bh->b_data) << 3;
- }
- bi->free_count += sizeof(unsigned long)*8;
- } else if (*cur != ~0L) {
- int b;
- for (b = 0; b < sizeof(unsigned long)*8; b++) {
- if (!reiserfs_test_le_bit (b, cur)) {
- bi->free_count ++;
- if (bi->first_zero_hint == 0)
- bi->first_zero_hint =
- (((char *)cur - bi->bh->b_data) << 3) + b;
- }
+ unsigned long *cur = (unsigned long *)bi->bh->b_data;
+
+ while ((char *)cur < (bi->bh->b_data + sb->s_blocksize)) {
+
+ /* No need to scan if all 0's or all 1's.
+ * Since we're only counting 0's, we can simply ignore all 1's */
+ if (*cur == 0) {
+ if (bi->first_zero_hint == 0) {
+ bi->first_zero_hint =
+ ((char *)cur - bi->bh->b_data) << 3;
+ }
+ bi->free_count += sizeof(unsigned long) * 8;
+ } else if (*cur != ~0L) {
+ int b;
+ for (b = 0; b < sizeof(unsigned long) * 8; b++) {
+ if (!reiserfs_test_le_bit(b, cur)) {
+ bi->free_count++;
+ if (bi->first_zero_hint == 0)
+ bi->first_zero_hint =
+ (((char *)cur -
+ bi->bh->b_data) << 3) + b;
+ }
+ }
}
- }
- cur ++;
- }
+ cur++;
+ }
#ifdef CONFIG_REISERFS_CHECK
// This outputs a lot of unneded info on big FSes
// reiserfs_warning ("bitmap loaded from block %d: %d free blocks",
-// bi->bh->b_blocknr, bi->free_count);
+// bi->bh->b_blocknr, bi->free_count);
#endif
}
-
-static int read_bitmaps (struct super_block * s)
+
+static int read_bitmaps(struct super_block *s)
{
- int i, bmap_nr;
+ int i, bmap_nr;
+
+ SB_AP_BITMAP(s) =
+ vmalloc(sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
+ if (SB_AP_BITMAP(s) == 0)
+ return 1;
+ memset(SB_AP_BITMAP(s), 0,
+ sizeof(struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
+ for (i = 0, bmap_nr =
+ REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
+ i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
+ SB_AP_BITMAP(s)[i].bh = sb_getblk(s, bmap_nr);
+ if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
+ ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
+ }
+ for (i = 0; i < SB_BMAP_NR(s); i++) {
+ wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
+ if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
+ reiserfs_warning(s, "sh-2029: reiserfs read_bitmaps: "
+ "bitmap block (#%lu) reading failed",
+ SB_AP_BITMAP(s)[i].bh->b_blocknr);
+ for (i = 0; i < SB_BMAP_NR(s); i++)
+ brelse(SB_AP_BITMAP(s)[i].bh);
+ vfree(SB_AP_BITMAP(s));
+ SB_AP_BITMAP(s) = NULL;
+ return 1;
+ }
+ load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
+ }
+ return 0;
+}
- SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
- if (SB_AP_BITMAP (s) == 0)
- return 1;
- memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_bitmap_info) * SB_BMAP_NR(s));
- for (i = 0, bmap_nr = REISERFS_DISK_OFFSET_IN_BYTES / s->s_blocksize + 1;
- i < SB_BMAP_NR(s); i++, bmap_nr = s->s_blocksize * 8 * i) {
- SB_AP_BITMAP (s)[i].bh = sb_getblk(s, bmap_nr);
- if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh))
- ll_rw_block(READ, 1, &SB_AP_BITMAP(s)[i].bh);
- }
- for (i = 0; i < SB_BMAP_NR(s); i++) {
- wait_on_buffer(SB_AP_BITMAP (s)[i].bh);
- if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
- reiserfs_warning(s,"sh-2029: reiserfs read_bitmaps: "
- "bitmap block (#%lu) reading failed",
- SB_AP_BITMAP(s)[i].bh->b_blocknr);
- for (i = 0; i < SB_BMAP_NR(s); i++)
- brelse(SB_AP_BITMAP(s)[i].bh);
- vfree(SB_AP_BITMAP(s));
- SB_AP_BITMAP(s) = NULL;
- return 1;
+static int read_old_bitmaps(struct super_block *s)
+{
+ int i;
+ struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
+ int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
+
+ /* read true bitmap */
+ SB_AP_BITMAP(s) =
+ vmalloc(sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
+ if (SB_AP_BITMAP(s) == 0)
+ return 1;
+
+ memset(SB_AP_BITMAP(s), 0,
+ sizeof(struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
+
+ for (i = 0; i < sb_bmap_nr(rs); i++) {
+ SB_AP_BITMAP(s)[i].bh = sb_bread(s, bmp1 + i);
+ if (!SB_AP_BITMAP(s)[i].bh)
+ return 1;
+ load_bitmap_info_data(s, SB_AP_BITMAP(s) + i);
}
- load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
- }
- return 0;
+
+ return 0;
}
-static int read_old_bitmaps (struct super_block * s)
+static int read_super_block(struct super_block *s, int offset)
{
- int i ;
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK(s);
- int bmp1 = (REISERFS_OLD_DISK_OFFSET_IN_BYTES / s->s_blocksize) + 1; /* first of bitmap blocks */
+ struct buffer_head *bh;
+ struct reiserfs_super_block *rs;
+ int fs_blocksize;
- /* read true bitmap */
- SB_AP_BITMAP (s) = vmalloc (sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
- if (SB_AP_BITMAP (s) == 0)
- return 1;
+ bh = sb_bread(s, offset / s->s_blocksize);
+ if (!bh) {
+ reiserfs_warning(s, "sh-2006: read_super_block: "
+ "bread failed (dev %s, block %lu, size %lu)",
+ reiserfs_bdevname(s), offset / s->s_blocksize,
+ s->s_blocksize);
+ return 1;
+ }
- memset (SB_AP_BITMAP (s), 0, sizeof (struct reiserfs_buffer_info *) * sb_bmap_nr(rs));
+ rs = (struct reiserfs_super_block *)bh->b_data;
+ if (!is_any_reiserfs_magic_string(rs)) {
+ brelse(bh);
+ return 1;
+ }
+ //
+ // ok, reiserfs signature (old or new) found in at the given offset
+ //
+ fs_blocksize = sb_blocksize(rs);
+ brelse(bh);
+ sb_set_blocksize(s, fs_blocksize);
- for (i = 0; i < sb_bmap_nr(rs); i ++) {
- SB_AP_BITMAP (s)[i].bh = sb_bread (s, bmp1 + i);
- if (!SB_AP_BITMAP (s)[i].bh)
- return 1;
- load_bitmap_info_data (s, SB_AP_BITMAP (s) + i);
- }
+ bh = sb_bread(s, offset / s->s_blocksize);
+ if (!bh) {
+ reiserfs_warning(s, "sh-2007: read_super_block: "
+ "bread failed (dev %s, block %lu, size %lu)\n",
+ reiserfs_bdevname(s), offset / s->s_blocksize,
+ s->s_blocksize);
+ return 1;
+ }
- return 0;
-}
+ rs = (struct reiserfs_super_block *)bh->b_data;
+ if (sb_blocksize(rs) != s->s_blocksize) {
+ reiserfs_warning(s, "sh-2011: read_super_block: "
+ "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
+ reiserfs_bdevname(s),
+ (unsigned long long)bh->b_blocknr,
+ s->s_blocksize);
+ brelse(bh);
+ return 1;
+ }
-static int read_super_block (struct super_block * s, int offset)
-{
- struct buffer_head * bh;
- struct reiserfs_super_block * rs;
- int fs_blocksize;
-
-
- bh = sb_bread (s, offset / s->s_blocksize);
- if (!bh) {
- reiserfs_warning (s, "sh-2006: read_super_block: "
- "bread failed (dev %s, block %lu, size %lu)",
- reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
- return 1;
- }
-
- rs = (struct reiserfs_super_block *)bh->b_data;
- if (!is_any_reiserfs_magic_string (rs)) {
- brelse (bh);
- return 1;
- }
-
- //
- // ok, reiserfs signature (old or new) found in at the given offset
- //
- fs_blocksize = sb_blocksize(rs);
- brelse (bh);
- sb_set_blocksize (s, fs_blocksize);
-
- bh = sb_bread (s, offset / s->s_blocksize);
- if (!bh) {
- reiserfs_warning (s, "sh-2007: read_super_block: "
- "bread failed (dev %s, block %lu, size %lu)\n",
- reiserfs_bdevname (s), offset / s->s_blocksize, s->s_blocksize);
- return 1;
- }
-
- rs = (struct reiserfs_super_block *)bh->b_data;
- if (sb_blocksize(rs) != s->s_blocksize) {
- reiserfs_warning (s, "sh-2011: read_super_block: "
- "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
- reiserfs_bdevname (s), (unsigned long long)bh->b_blocknr, s->s_blocksize);
- brelse (bh);
- return 1;
- }
-
- if ( rs->s_v1.s_root_block == cpu_to_le32(-1) ) {
- brelse(bh) ;
- reiserfs_warning (s, "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
- "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
- "get newer reiserfsprogs package");
- return 1;
- }
-
- SB_BUFFER_WITH_SB (s) = bh;
- SB_DISK_SUPER_BLOCK (s) = rs;
-
- if (is_reiserfs_jr (rs)) {
- /* magic is of non-standard journal filesystem, look at s_version to
- find which format is in use */
- if (sb_version(rs) == REISERFS_VERSION_2)
- reiserfs_warning (s, "read_super_block: found reiserfs format \"3.6\""
- " with non-standard journal");
- else if (sb_version(rs) == REISERFS_VERSION_1)
- reiserfs_warning (s, "read_super_block: found reiserfs format \"3.5\""
- " with non-standard journal");
- else {
- reiserfs_warning (s, "sh-2012: read_super_block: found unknown "
- "format \"%u\" of reiserfs with non-standard magic",
- sb_version(rs));
- return 1;
+ if (rs->s_v1.s_root_block == cpu_to_le32(-1)) {
+ brelse(bh);
+ reiserfs_warning(s,
+ "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
+ "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
+ "get newer reiserfsprogs package");
+ return 1;
}
- }
- else
- /* s_version of standard format may contain incorrect information,
- so we just look at the magic string */
- reiserfs_info (s, "found reiserfs format \"%s\" with standard journal\n",
- is_reiserfs_3_5 (rs) ? "3.5" : "3.6");
- s->s_op = &reiserfs_sops;
- s->s_export_op = &reiserfs_export_ops;
+ SB_BUFFER_WITH_SB(s) = bh;
+ SB_DISK_SUPER_BLOCK(s) = rs;
+
+ if (is_reiserfs_jr(rs)) {
+ /* magic is of non-standard journal filesystem, look at s_version to
+ find which format is in use */
+ if (sb_version(rs) == REISERFS_VERSION_2)
+ reiserfs_warning(s,
+ "read_super_block: found reiserfs format \"3.6\""
+ " with non-standard journal");
+ else if (sb_version(rs) == REISERFS_VERSION_1)
+ reiserfs_warning(s,
+ "read_super_block: found reiserfs format \"3.5\""
+ " with non-standard journal");
+ else {
+ reiserfs_warning(s,
+ "sh-2012: read_super_block: found unknown "
+ "format \"%u\" of reiserfs with non-standard magic",
+ sb_version(rs));
+ return 1;
+ }
+ } else
+ /* s_version of standard format may contain incorrect information,
+ so we just look at the magic string */
+ reiserfs_info(s,
+ "found reiserfs format \"%s\" with standard journal\n",
+ is_reiserfs_3_5(rs) ? "3.5" : "3.6");
+
+ s->s_op = &reiserfs_sops;
+ s->s_export_op = &reiserfs_export_ops;
#ifdef CONFIG_QUOTA
- s->s_qcop = &reiserfs_qctl_operations;
- s->dq_op = &reiserfs_quota_operations;
+ s->s_qcop = &reiserfs_qctl_operations;
+ s->dq_op = &reiserfs_quota_operations;
#endif
- /* new format is limited by the 32 bit wide i_blocks field, want to
- ** be one full block below that.
- */
- s->s_maxbytes = (512LL << 32) - s->s_blocksize ;
- return 0;
+ /* new format is limited by the 32 bit wide i_blocks field, want to
+ ** be one full block below that.
+ */
+ s->s_maxbytes = (512LL << 32) - s->s_blocksize;
+ return 0;
}
-
-
/* after journal replay, reread all bitmap and super blocks */
-static int reread_meta_blocks(struct super_block *s) {
- int i ;
- ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s))) ;
- wait_on_buffer(SB_BUFFER_WITH_SB(s)) ;
- if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
- reiserfs_warning (s, "reread_meta_blocks, error reading the super") ;
- return 1 ;
- }
-
- for (i = 0; i < SB_BMAP_NR(s) ; i++) {
- ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh)) ;
- wait_on_buffer(SB_AP_BITMAP(s)[i].bh) ;
- if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
- reiserfs_warning (s, "reread_meta_blocks, error reading bitmap block number %d at %llu",
- i, (unsigned long long)SB_AP_BITMAP(s)[i].bh->b_blocknr) ;
- return 1 ;
- }
- }
- return 0 ;
+static int reread_meta_blocks(struct super_block *s)
+{
+ int i;
+ ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
+ wait_on_buffer(SB_BUFFER_WITH_SB(s));
+ if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
+ reiserfs_warning(s,
+ "reread_meta_blocks, error reading the super");
+ return 1;
+ }
-}
+ for (i = 0; i < SB_BMAP_NR(s); i++) {
+ ll_rw_block(READ, 1, &(SB_AP_BITMAP(s)[i].bh));
+ wait_on_buffer(SB_AP_BITMAP(s)[i].bh);
+ if (!buffer_uptodate(SB_AP_BITMAP(s)[i].bh)) {
+ reiserfs_warning(s,
+ "reread_meta_blocks, error reading bitmap block number %d at %llu",
+ i,
+ (unsigned long long)SB_AP_BITMAP(s)[i].
+ bh->b_blocknr);
+ return 1;
+ }
+ }
+ return 0;
+}
/////////////////////////////////////////////////////
// hash detection stuff
-
// if root directory is empty - we set default - Yura's - hash and
// warn about it
// FIXME: we look for only one name in a directory. If tea and yura
// bith have the same value - we ask user to send report to the
// mailing list
-static __u32 find_hash_out (struct super_block * s)
+static __u32 find_hash_out(struct super_block *s)
{
- int retval;
- struct inode * inode;
- struct cpu_key key;
- INITIALIZE_PATH (path);
- struct reiserfs_dir_entry de;
- __u32 hash = DEFAULT_HASH;
-
- inode = s->s_root->d_inode;
-
- do { // Some serious "goto"-hater was there ;)
- u32 teahash, r5hash, yurahash;
-
- make_cpu_key (&key, inode, ~0, TYPE_DIRENTRY, 3);
- retval = search_by_entry_key (s, &key, &path, &de);
- if (retval == IO_ERROR) {
- pathrelse (&path);
- return UNSET_HASH ;
- }
- if (retval == NAME_NOT_FOUND)
- de.de_entry_num --;
- set_de_name_and_namelen (&de);
- if (deh_offset( &(de.de_deh[de.de_entry_num]) ) == DOT_DOT_OFFSET) {
- /* allow override in this case */
- if (reiserfs_rupasov_hash(s)) {
- hash = YURA_HASH ;
- }
- reiserfs_warning(s,"FS seems to be empty, autodetect "
- "is using the default hash");
- break;
- }
- r5hash=GET_HASH_VALUE (r5_hash (de.de_name, de.de_namelen));
- teahash=GET_HASH_VALUE (keyed_hash (de.de_name, de.de_namelen));
- yurahash=GET_HASH_VALUE (yura_hash (de.de_name, de.de_namelen));
- if ( ( (teahash == r5hash) && (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash) ) ||
- ( (teahash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ||
- ( (r5hash == yurahash) && (yurahash == GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])))) ) ) {
- reiserfs_warning(s,"Unable to automatically detect hash function. "
- "Please mount with -o hash={tea,rupasov,r5}",
- reiserfs_bdevname (s));
- hash = UNSET_HASH;
- break;
- }
- if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == yurahash)
- hash = YURA_HASH;
- else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == teahash)
- hash = TEA_HASH;
- else if (GET_HASH_VALUE( deh_offset(&(de.de_deh[de.de_entry_num])) ) == r5hash)
- hash = R5_HASH;
- else {
- reiserfs_warning (s,"Unrecognised hash function");
- hash = UNSET_HASH;
- }
- } while (0);
-
- pathrelse (&path);
- return hash;
+ int retval;
+ struct inode *inode;
+ struct cpu_key key;
+ INITIALIZE_PATH(path);
+ struct reiserfs_dir_entry de;
+ __u32 hash = DEFAULT_HASH;
+
+ inode = s->s_root->d_inode;
+
+ do { // Some serious "goto"-hater was there ;)
+ u32 teahash, r5hash, yurahash;
+
+ make_cpu_key(&key, inode, ~0, TYPE_DIRENTRY, 3);
+ retval = search_by_entry_key(s, &key, &path, &de);
+ if (retval == IO_ERROR) {
+ pathrelse(&path);
+ return UNSET_HASH;
+ }
+ if (retval == NAME_NOT_FOUND)
+ de.de_entry_num--;
+ set_de_name_and_namelen(&de);
+ if (deh_offset(&(de.de_deh[de.de_entry_num])) == DOT_DOT_OFFSET) {
+ /* allow override in this case */
+ if (reiserfs_rupasov_hash(s)) {
+ hash = YURA_HASH;
+ }
+ reiserfs_warning(s, "FS seems to be empty, autodetect "
+ "is using the default hash");
+ break;
+ }
+ r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
+ teahash = GET_HASH_VALUE(keyed_hash(de.de_name, de.de_namelen));
+ yurahash = GET_HASH_VALUE(yura_hash(de.de_name, de.de_namelen));
+ if (((teahash == r5hash)
+ &&
+ (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num])))
+ == r5hash)) || ((teahash == yurahash)
+ && (yurahash ==
+ GET_HASH_VALUE(deh_offset
+ (&
+ (de.
+ de_deh[de.
+ de_entry_num])))))
+ || ((r5hash == yurahash)
+ && (yurahash ==
+ GET_HASH_VALUE(deh_offset
+ (&(de.de_deh[de.de_entry_num])))))) {
+ reiserfs_warning(s,
+ "Unable to automatically detect hash function. "
+ "Please mount with -o hash={tea,rupasov,r5}",
+ reiserfs_bdevname(s));
+ hash = UNSET_HASH;
+ break;
+ }
+ if (GET_HASH_VALUE(deh_offset(&(de.de_deh[de.de_entry_num]))) ==
+ yurahash)
+ hash = YURA_HASH;
+ else if (GET_HASH_VALUE
+ (deh_offset(&(de.de_deh[de.de_entry_num]))) == teahash)
+ hash = TEA_HASH;
+ else if (GET_HASH_VALUE
+ (deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
+ hash = R5_HASH;
+ else {
+ reiserfs_warning(s, "Unrecognised hash function");
+ hash = UNSET_HASH;
+ }
+ } while (0);
+
+ pathrelse(&path);
+ return hash;
}
// finds out which hash names are sorted with
-static int what_hash (struct super_block * s)
+static int what_hash(struct super_block *s)
{
- __u32 code;
-
- code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
-
- /* reiserfs_hash_detect() == true if any of the hash mount options
- ** were used. We must check them to make sure the user isn't
- ** using a bad hash value
- */
- if (code == UNSET_HASH || reiserfs_hash_detect(s))
- code = find_hash_out (s);
-
- if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
- /* detection has found the hash, and we must check against the
- ** mount options
- */
- if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
- reiserfs_warning (s, "Error, %s hash detected, "
- "unable to force rupasov hash", reiserfs_hashname(code)) ;
- code = UNSET_HASH ;
- } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
- reiserfs_warning (s, "Error, %s hash detected, "
- "unable to force tea hash", reiserfs_hashname(code)) ;
- code = UNSET_HASH ;
- } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
- reiserfs_warning (s, "Error, %s hash detected, "
- "unable to force r5 hash", reiserfs_hashname(code)) ;
- code = UNSET_HASH ;
- }
- } else {
- /* find_hash_out was not called or could not determine the hash */
- if (reiserfs_rupasov_hash(s)) {
- code = YURA_HASH ;
- } else if (reiserfs_tea_hash(s)) {
- code = TEA_HASH ;
- } else if (reiserfs_r5_hash(s)) {
- code = R5_HASH ;
- }
- }
-
- /* if we are mounted RW, and we have a new valid hash code, update
- ** the super
- */
- if (code != UNSET_HASH &&
- !(s->s_flags & MS_RDONLY) &&
- code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
- set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
- }
- return code;
+ __u32 code;
+
+ code = sb_hash_function_code(SB_DISK_SUPER_BLOCK(s));
+
+ /* reiserfs_hash_detect() == true if any of the hash mount options
+ ** were used. We must check them to make sure the user isn't
+ ** using a bad hash value
+ */
+ if (code == UNSET_HASH || reiserfs_hash_detect(s))
+ code = find_hash_out(s);
+
+ if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
+ /* detection has found the hash, and we must check against the
+ ** mount options
+ */
+ if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
+ reiserfs_warning(s, "Error, %s hash detected, "
+ "unable to force rupasov hash",
+ reiserfs_hashname(code));
+ code = UNSET_HASH;
+ } else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
+ reiserfs_warning(s, "Error, %s hash detected, "
+ "unable to force tea hash",
+ reiserfs_hashname(code));
+ code = UNSET_HASH;
+ } else if (reiserfs_r5_hash(s) && code != R5_HASH) {
+ reiserfs_warning(s, "Error, %s hash detected, "
+ "unable to force r5 hash",
+ reiserfs_hashname(code));
+ code = UNSET_HASH;
+ }
+ } else {
+ /* find_hash_out was not called or could not determine the hash */
+ if (reiserfs_rupasov_hash(s)) {
+ code = YURA_HASH;
+ } else if (reiserfs_tea_hash(s)) {
+ code = TEA_HASH;
+ } else if (reiserfs_r5_hash(s)) {
+ code = R5_HASH;
+ }
+ }
+
+ /* if we are mounted RW, and we have a new valid hash code, update
+ ** the super
+ */
+ if (code != UNSET_HASH &&
+ !(s->s_flags & MS_RDONLY) &&
+ code != sb_hash_function_code(SB_DISK_SUPER_BLOCK(s))) {
+ set_sb_hash_function_code(SB_DISK_SUPER_BLOCK(s), code);
+ }
+ return code;
}
// return pointer to appropriate function
-static hashf_t hash_function (struct super_block * s)
+static hashf_t hash_function(struct super_block *s)
{
- switch (what_hash (s)) {
- case TEA_HASH:
- reiserfs_info (s, "Using tea hash to sort names\n");
- return keyed_hash;
- case YURA_HASH:
- reiserfs_info (s, "Using rupasov hash to sort names\n");
- return yura_hash;
- case R5_HASH:
- reiserfs_info (s, "Using r5 hash to sort names\n");
- return r5_hash;
- }
- return NULL;
+ switch (what_hash(s)) {
+ case TEA_HASH:
+ reiserfs_info(s, "Using tea hash to sort names\n");
+ return keyed_hash;
+ case YURA_HASH:
+ reiserfs_info(s, "Using rupasov hash to sort names\n");
+ return yura_hash;
+ case R5_HASH:
+ reiserfs_info(s, "Using r5 hash to sort names\n");
+ return r5_hash;
+ }
+ return NULL;
}
// this is used to set up correct value for old partitions
-static int function2code (hashf_t func)
+static int function2code(hashf_t func)
{
- if (func == keyed_hash)
- return TEA_HASH;
- if (func == yura_hash)
- return YURA_HASH;
- if (func == r5_hash)
- return R5_HASH;
+ if (func == keyed_hash)
+ return TEA_HASH;
+ if (func == yura_hash)
+ return YURA_HASH;
+ if (func == r5_hash)
+ return R5_HASH;
- BUG() ; // should never happen
+ BUG(); // should never happen
- return 0;
+ return 0;
}
#define SWARN(silent, s, ...) \
if (!(silent)) \
reiserfs_warning (s, __VA_ARGS__)
-static int reiserfs_fill_super (struct super_block * s, void * data, int silent)
+static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
{
- struct inode *root_inode;
- int j;
- struct reiserfs_transaction_handle th ;
- int old_format = 0;
- unsigned long blocks;
- unsigned int commit_max_age = 0;
- int jinit_done = 0 ;
- struct reiserfs_iget_args args ;
- struct reiserfs_super_block * rs;
- char *jdev_name;
- struct reiserfs_sb_info *sbi;
- int errval = -EINVAL;
-
- sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
- if (!sbi) {
- errval = -ENOMEM;
- goto error;
- }
- s->s_fs_info = sbi;
- memset (sbi, 0, sizeof (struct reiserfs_sb_info));
- /* Set default values for options: non-aggressive tails, RO on errors */
- REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
- REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
- /* no preallocation minimum, be smart in
- reiserfs_file_write instead */
- REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
- /* Preallocate by 16 blocks (17-1) at once */
- REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
- /* Initialize the rwsem for xattr dir */
- init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
-
- /* setup default block allocator options */
- reiserfs_init_alloc_options(s);
-
- jdev_name = NULL;
- if (reiserfs_parse_options (s, (char *) data, &(sbi->s_mount_opt), &blocks, &jdev_name, &commit_max_age) == 0) {
- goto error;
- }
-
- if (blocks) {
- SWARN (silent, s, "jmacd-7: reiserfs_fill_super: resize option "
- "for remount only");
- goto error;
- }
-
- /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
- if (!read_super_block (s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
- old_format = 1;
- /* try new format (64-th 1k block), which can contain reiserfs super block */
- else if (read_super_block (s, REISERFS_DISK_OFFSET_IN_BYTES)) {
- SWARN(silent, s, "sh-2021: reiserfs_fill_super: can not find reiserfs on %s", reiserfs_bdevname (s));
- goto error;
- }
-
- rs = SB_DISK_SUPER_BLOCK (s);
- /* Let's do basic sanity check to verify that underlying device is not
- smaller than the filesystem. If the check fails then abort and scream,
- because bad stuff will happen otherwise. */
- if ( s->s_bdev && s->s_bdev->bd_inode && i_size_read(s->s_bdev->bd_inode) < sb_block_count(rs)*sb_blocksize(rs)) {
- SWARN (silent, s, "Filesystem on %s cannot be mounted because it is bigger than the device", reiserfs_bdevname(s));
- SWARN(silent, s, "You may need to run fsck or increase size of your LVM partition");
- SWARN(silent, s, "Or may be you forgot to reboot after fdisk when it told you to");
- goto error;
- }
-
- sbi->s_mount_state = SB_REISERFS_STATE(s);
- sbi->s_mount_state = REISERFS_VALID_FS ;
-
- if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
- SWARN(silent, s, "jmacd-8: reiserfs_fill_super: unable to read bitmap");
- goto error;
- }
+ struct inode *root_inode;
+ int j;
+ struct reiserfs_transaction_handle th;
+ int old_format = 0;
+ unsigned long blocks;
+ unsigned int commit_max_age = 0;
+ int jinit_done = 0;
+ struct reiserfs_iget_args args;
+ struct reiserfs_super_block *rs;
+ char *jdev_name;
+ struct reiserfs_sb_info *sbi;
+ int errval = -EINVAL;
+
+ sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
+ if (!sbi) {
+ errval = -ENOMEM;
+ goto error;
+ }
+ s->s_fs_info = sbi;
+ memset(sbi, 0, sizeof(struct reiserfs_sb_info));
+ /* Set default values for options: non-aggressive tails, RO on errors */
+ REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
+ REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
+ /* no preallocation minimum, be smart in
+ reiserfs_file_write instead */
+ REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
+ /* Preallocate by 16 blocks (17-1) at once */
+ REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
+ /* Initialize the rwsem for xattr dir */
+ init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
+
+ /* setup default block allocator options */
+ reiserfs_init_alloc_options(s);
+
+ jdev_name = NULL;
+ if (reiserfs_parse_options
+ (s, (char *)data, &(sbi->s_mount_opt), &blocks, &jdev_name,
+ &commit_max_age) == 0) {
+ goto error;
+ }
+
+ if (blocks) {
+ SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option "
+ "for remount only");
+ goto error;
+ }
+
+ /* try old format (undistributed bitmap, super block in 8-th 1k block of a device) */
+ if (!read_super_block(s, REISERFS_OLD_DISK_OFFSET_IN_BYTES))
+ old_format = 1;
+ /* try new format (64-th 1k block), which can contain reiserfs super block */
+ else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
+ SWARN(silent, s,
+ "sh-2021: reiserfs_fill_super: can not find reiserfs on %s",
+ reiserfs_bdevname(s));
+ goto error;
+ }
+
+ rs = SB_DISK_SUPER_BLOCK(s);
+ /* Let's do basic sanity check to verify that underlying device is not
+ smaller than the filesystem. If the check fails then abort and scream,
+ because bad stuff will happen otherwise. */
+ if (s->s_bdev && s->s_bdev->bd_inode
+ && i_size_read(s->s_bdev->bd_inode) <
+ sb_block_count(rs) * sb_blocksize(rs)) {
+ SWARN(silent, s,
+ "Filesystem on %s cannot be mounted because it is bigger than the device",
+ reiserfs_bdevname(s));
+ SWARN(silent, s,
+ "You may need to run fsck or increase size of your LVM partition");
+ SWARN(silent, s,
+ "Or may be you forgot to reboot after fdisk when it told you to");
+ goto error;
+ }
+
+ sbi->s_mount_state = SB_REISERFS_STATE(s);
+ sbi->s_mount_state = REISERFS_VALID_FS;
+
+ if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) {
+ SWARN(silent, s,
+ "jmacd-8: reiserfs_fill_super: unable to read bitmap");
+ goto error;
+ }
#ifdef CONFIG_REISERFS_CHECK
- SWARN (silent, s, "CONFIG_REISERFS_CHECK is set ON");
- SWARN (silent, s, "- it is slow mode for debugging.");
+ SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
+ SWARN(silent, s, "- it is slow mode for debugging.");
#endif
- /* make data=ordered the default */
- if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
- !reiserfs_data_writeback(s))
- {
- REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
- }
-
- if (reiserfs_data_log(s)) {
- reiserfs_info (s, "using journaled data mode\n");
- } else if (reiserfs_data_ordered(s)) {
- reiserfs_info (s, "using ordered data mode\n");
- } else {
- reiserfs_info (s, "using writeback data mode\n");
- }
- if (reiserfs_barrier_flush(s)) {
- printk("reiserfs: using flush barriers\n");
- }
-
- // set_device_ro(s->s_dev, 1) ;
- if( journal_init(s, jdev_name, old_format, commit_max_age) ) {
- SWARN(silent, s, "sh-2022: reiserfs_fill_super: unable to initialize journal space") ;
- goto error ;
- } else {
- jinit_done = 1 ; /* once this is set, journal_release must be called
- ** if we error out of the mount
- */
- }
- if (reread_meta_blocks(s)) {
- SWARN(silent, s, "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init") ;
- goto error ;
- }
-
- if (replay_only (s))
- goto error;
-
- if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
- SWARN(silent, s, "clm-7000: Detected readonly device, marking FS readonly") ;
- s->s_flags |= MS_RDONLY ;
- }
- args.objectid = REISERFS_ROOT_OBJECTID ;
- args.dirid = REISERFS_ROOT_PARENT_OBJECTID ;
- root_inode = iget5_locked (s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor, reiserfs_init_locked_inode, (void *)(&args));
- if (!root_inode) {
- SWARN(silent, s, "jmacd-10: reiserfs_fill_super: get root inode failed");
- goto error;
- }
-
- if (root_inode->i_state & I_NEW) {
- reiserfs_read_locked_inode(root_inode, &args);
- unlock_new_inode(root_inode);
- }
-
- s->s_root = d_alloc_root(root_inode);
- if (!s->s_root) {
- iput(root_inode);
- goto error;
- }
-
- // define and initialize hash function
- sbi->s_hash_function = hash_function (s);
- if (sbi->s_hash_function == NULL) {
- dput(s->s_root) ;
- s->s_root = NULL ;
- goto error ;
- }
-
- if (is_reiserfs_3_5 (rs) || (is_reiserfs_jr (rs) && SB_VERSION (s) == REISERFS_VERSION_1))
- set_bit(REISERFS_3_5, &(sbi->s_properties));
- else
- set_bit(REISERFS_3_6, &(sbi->s_properties));
-
- if (!(s->s_flags & MS_RDONLY)) {
-
- errval = journal_begin(&th, s, 1) ;
- if (errval) {
- dput (s->s_root);
- s->s_root = NULL;
- goto error;
- }
- reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ;
-
- set_sb_umount_state( rs, REISERFS_ERROR_FS );
- set_sb_fs_state (rs, 0);
-
- if (old_format_only(s)) {
- /* filesystem of format 3.5 either with standard or non-standard
- journal */
- if (convert_reiserfs (s)) {
- /* and -o conv is given */
- if(!silent)
- reiserfs_info (s,"converting 3.5 filesystem to the 3.6 format") ;
-
- if (is_reiserfs_3_5 (rs))
- /* put magic string of 3.6 format. 2.2 will not be able to
- mount this filesystem anymore */
- memcpy (rs->s_v1.s_magic, reiserfs_3_6_magic_string,
- sizeof (reiserfs_3_6_magic_string));
-
- set_sb_version(rs,REISERFS_VERSION_2);
- reiserfs_convert_objectid_map_v1(s) ;
- set_bit(REISERFS_3_6, &(sbi->s_properties));
- clear_bit(REISERFS_3_5, &(sbi->s_properties));
- } else if (!silent){
- reiserfs_info (s, "using 3.5.x disk format\n") ;
- }
- }
-
- journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
- errval = journal_end(&th, s, 1) ;
- if (errval) {
- dput (s->s_root);
- s->s_root = NULL;
- goto error;
- }
-
- if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
- dput (s->s_root);
- s->s_root = NULL;
- goto error;
- }
-
- /* look for files which were to be removed in previous session */
- finish_unfinished (s);
- } else {
- if ( old_format_only(s) && !silent) {
- reiserfs_info (s, "using 3.5.x disk format\n") ;
- }
-
- if ((errval = reiserfs_xattr_init (s, s->s_flags))) {
- dput (s->s_root);
- s->s_root = NULL;
- goto error;
- }
- }
- // mark hash in super block: it could be unset. overwrite should be ok
- set_sb_hash_function_code( rs, function2code(sbi->s_hash_function ) );
-
- handle_attrs( s );
-
- reiserfs_proc_info_init( s );
-
- init_waitqueue_head (&(sbi->s_wait));
- spin_lock_init(&sbi->bitmap_lock);
-
- return (0);
-
- error:
- if (jinit_done) { /* kill the commit thread, free journal ram */
- journal_release_error(NULL, s) ;
- }
- if (SB_DISK_SUPER_BLOCK (s)) {
- for (j = 0; j < SB_BMAP_NR (s); j ++) {
- if (SB_AP_BITMAP (s))
- brelse (SB_AP_BITMAP (s)[j].bh);
- }
- if (SB_AP_BITMAP (s))
- vfree (SB_AP_BITMAP (s));
- }
- if (SB_BUFFER_WITH_SB (s))
- brelse(SB_BUFFER_WITH_SB (s));
+ /* make data=ordered the default */
+ if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) &&
+ !reiserfs_data_writeback(s)) {
+ REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED);
+ }
+
+ if (reiserfs_data_log(s)) {
+ reiserfs_info(s, "using journaled data mode\n");
+ } else if (reiserfs_data_ordered(s)) {
+ reiserfs_info(s, "using ordered data mode\n");
+ } else {
+ reiserfs_info(s, "using writeback data mode\n");
+ }
+ if (reiserfs_barrier_flush(s)) {
+ printk("reiserfs: using flush barriers\n");
+ }
+ // set_device_ro(s->s_dev, 1) ;
+ if (journal_init(s, jdev_name, old_format, commit_max_age)) {
+ SWARN(silent, s,
+ "sh-2022: reiserfs_fill_super: unable to initialize journal space");
+ goto error;
+ } else {
+ jinit_done = 1; /* once this is set, journal_release must be called
+ ** if we error out of the mount
+ */
+ }
+ if (reread_meta_blocks(s)) {
+ SWARN(silent, s,
+ "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init");
+ goto error;
+ }
+
+ if (replay_only(s))
+ goto error;
+
+ if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
+ SWARN(silent, s,
+ "clm-7000: Detected readonly device, marking FS readonly");
+ s->s_flags |= MS_RDONLY;
+ }
+ args.objectid = REISERFS_ROOT_OBJECTID;
+ args.dirid = REISERFS_ROOT_PARENT_OBJECTID;
+ root_inode =
+ iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
+ reiserfs_init_locked_inode, (void *)(&args));
+ if (!root_inode) {
+ SWARN(silent, s,
+ "jmacd-10: reiserfs_fill_super: get root inode failed");
+ goto error;
+ }
+
+ if (root_inode->i_state & I_NEW) {
+ reiserfs_read_locked_inode(root_inode, &args);
+ unlock_new_inode(root_inode);
+ }
+
+ s->s_root = d_alloc_root(root_inode);
+ if (!s->s_root) {
+ iput(root_inode);
+ goto error;
+ }
+ // define and initialize hash function
+ sbi->s_hash_function = hash_function(s);
+ if (sbi->s_hash_function == NULL) {
+ dput(s->s_root);
+ s->s_root = NULL;
+ goto error;
+ }
+
+ if (is_reiserfs_3_5(rs)
+ || (is_reiserfs_jr(rs) && SB_VERSION(s) == REISERFS_VERSION_1))
+ set_bit(REISERFS_3_5, &(sbi->s_properties));
+ else
+ set_bit(REISERFS_3_6, &(sbi->s_properties));
+
+ if (!(s->s_flags & MS_RDONLY)) {
+
+ errval = journal_begin(&th, s, 1);
+ if (errval) {
+ dput(s->s_root);
+ s->s_root = NULL;
+ goto error;
+ }
+ reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
+
+ set_sb_umount_state(rs, REISERFS_ERROR_FS);
+ set_sb_fs_state(rs, 0);
+
+ if (old_format_only(s)) {
+ /* filesystem of format 3.5 either with standard or non-standard
+ journal */
+ if (convert_reiserfs(s)) {
+ /* and -o conv is given */
+ if (!silent)
+ reiserfs_info(s,
+ "converting 3.5 filesystem to the 3.6 format");
+
+ if (is_reiserfs_3_5(rs))
+ /* put magic string of 3.6 format. 2.2 will not be able to
+ mount this filesystem anymore */
+ memcpy(rs->s_v1.s_magic,
+ reiserfs_3_6_magic_string,
+ sizeof
+ (reiserfs_3_6_magic_string));
+
+ set_sb_version(rs, REISERFS_VERSION_2);
+ reiserfs_convert_objectid_map_v1(s);
+ set_bit(REISERFS_3_6, &(sbi->s_properties));
+ clear_bit(REISERFS_3_5, &(sbi->s_properties));
+ } else if (!silent) {
+ reiserfs_info(s, "using 3.5.x disk format\n");
+ }
+ }
+
+ journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s));
+ errval = journal_end(&th, s, 1);
+ if (errval) {
+ dput(s->s_root);
+ s->s_root = NULL;
+ goto error;
+ }
+
+ if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
+ dput(s->s_root);
+ s->s_root = NULL;
+ goto error;
+ }
+
+ /* look for files which were to be removed in previous session */
+ finish_unfinished(s);
+ } else {
+ if (old_format_only(s) && !silent) {
+ reiserfs_info(s, "using 3.5.x disk format\n");
+ }
+
+ if ((errval = reiserfs_xattr_init(s, s->s_flags))) {
+ dput(s->s_root);
+ s->s_root = NULL;
+ goto error;
+ }
+ }
+ // mark hash in super block: it could be unset. overwrite should be ok
+ set_sb_hash_function_code(rs, function2code(sbi->s_hash_function));
+
+ handle_attrs(s);
+
+ reiserfs_proc_info_init(s);
+
+ init_waitqueue_head(&(sbi->s_wait));
+ spin_lock_init(&sbi->bitmap_lock);
+
+ return (0);
+
+ error:
+ if (jinit_done) { /* kill the commit thread, free journal ram */
+ journal_release_error(NULL, s);
+ }
+ if (SB_DISK_SUPER_BLOCK(s)) {
+ for (j = 0; j < SB_BMAP_NR(s); j++) {
+ if (SB_AP_BITMAP(s))
+ brelse(SB_AP_BITMAP(s)[j].bh);
+ }
+ if (SB_AP_BITMAP(s))
+ vfree(SB_AP_BITMAP(s));
+ }
+ if (SB_BUFFER_WITH_SB(s))
+ brelse(SB_BUFFER_WITH_SB(s));
#ifdef CONFIG_QUOTA
- for (j = 0; j < MAXQUOTAS; j++) {
- if (sbi->s_qf_names[j])
- kfree(sbi->s_qf_names[j]);
- }
+ for (j = 0; j < MAXQUOTAS; j++) {
+ if (sbi->s_qf_names[j])
+ kfree(sbi->s_qf_names[j]);
+ }
#endif
- if (sbi != NULL) {
- kfree(sbi);
- }
+ if (sbi != NULL) {
+ kfree(sbi);
+ }
- s->s_fs_info = NULL;
- return errval;
+ s->s_fs_info = NULL;
+ return errval;
}
-
-static int reiserfs_statfs (struct super_block * s, struct kstatfs * buf)
+static int reiserfs_statfs(struct super_block *s, struct kstatfs *buf)
{
- struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s);
-
- buf->f_namelen = (REISERFS_MAX_NAME (s->s_blocksize));
- buf->f_bfree = sb_free_blocks(rs);
- buf->f_bavail = buf->f_bfree;
- buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
- buf->f_bsize = s->s_blocksize;
- /* changed to accommodate gcc folks.*/
- buf->f_type = REISERFS_SUPER_MAGIC;
- return 0;
+ struct reiserfs_super_block *rs = SB_DISK_SUPER_BLOCK(s);
+
+ buf->f_namelen = (REISERFS_MAX_NAME(s->s_blocksize));
+ buf->f_bfree = sb_free_blocks(rs);
+ buf->f_bavail = buf->f_bfree;
+ buf->f_blocks = sb_block_count(rs) - sb_bmap_nr(rs) - 1;
+ buf->f_bsize = s->s_blocksize;
+ /* changed to accommodate gcc folks. */
+ buf->f_type = REISERFS_SUPER_MAGIC;
+ return 0;
}
#ifdef CONFIG_QUOTA
static int reiserfs_dquot_initialize(struct inode *inode, int type)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- /* We may create quota structure so we need to reserve enough blocks */
- reiserfs_write_lock(inode->i_sb);
- ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
- if (ret)
- goto out;
- ret = dquot_initialize(inode, type);
- err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(inode->i_sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ /* We may create quota structure so we need to reserve enough blocks */
+ reiserfs_write_lock(inode->i_sb);
+ ret =
+ journal_begin(&th, inode->i_sb,
+ 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
+ if (ret)
+ goto out;
+ ret = dquot_initialize(inode, type);
+ err =
+ journal_end(&th, inode->i_sb,
+ 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb));
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(inode->i_sb);
+ return ret;
}
static int reiserfs_dquot_drop(struct inode *inode)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- /* We may delete quota structure so we need to reserve enough blocks */
- reiserfs_write_lock(inode->i_sb);
- ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
- if (ret)
- goto out;
- ret = dquot_drop(inode);
- err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(inode->i_sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ /* We may delete quota structure so we need to reserve enough blocks */
+ reiserfs_write_lock(inode->i_sb);
+ ret =
+ journal_begin(&th, inode->i_sb,
+ 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
+ if (ret)
+ goto out;
+ ret = dquot_drop(inode);
+ err =
+ journal_end(&th, inode->i_sb,
+ 2 * REISERFS_QUOTA_DEL_BLOCKS(inode->i_sb));
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(inode->i_sb);
+ return ret;
}
static int reiserfs_write_dquot(struct dquot *dquot)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- reiserfs_write_lock(dquot->dq_sb);
- ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
- if (ret)
- goto out;
- ret = dquot_commit(dquot);
- err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(dquot->dq_sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ reiserfs_write_lock(dquot->dq_sb);
+ ret =
+ journal_begin(&th, dquot->dq_sb,
+ REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
+ if (ret)
+ goto out;
+ ret = dquot_commit(dquot);
+ err =
+ journal_end(&th, dquot->dq_sb,
+ REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(dquot->dq_sb);
+ return ret;
}
static int reiserfs_acquire_dquot(struct dquot *dquot)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- reiserfs_write_lock(dquot->dq_sb);
- ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
- if (ret)
- goto out;
- ret = dquot_acquire(dquot);
- err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(dquot->dq_sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ reiserfs_write_lock(dquot->dq_sb);
+ ret =
+ journal_begin(&th, dquot->dq_sb,
+ REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
+ if (ret)
+ goto out;
+ ret = dquot_acquire(dquot);
+ err =
+ journal_end(&th, dquot->dq_sb,
+ REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(dquot->dq_sb);
+ return ret;
}
static int reiserfs_release_dquot(struct dquot *dquot)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- reiserfs_write_lock(dquot->dq_sb);
- ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
- if (ret)
- goto out;
- ret = dquot_release(dquot);
- err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(dquot->dq_sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ reiserfs_write_lock(dquot->dq_sb);
+ ret =
+ journal_begin(&th, dquot->dq_sb,
+ REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
+ if (ret)
+ goto out;
+ ret = dquot_release(dquot);
+ err =
+ journal_end(&th, dquot->dq_sb,
+ REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(dquot->dq_sb);
+ return ret;
}
static int reiserfs_mark_dquot_dirty(struct dquot *dquot)
{
- /* Are we journalling quotas? */
- if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
- REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
- dquot_mark_dquot_dirty(dquot);
- return reiserfs_write_dquot(dquot);
- }
- else
- return dquot_mark_dquot_dirty(dquot);
+ /* Are we journalling quotas? */
+ if (REISERFS_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] ||
+ REISERFS_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) {
+ dquot_mark_dquot_dirty(dquot);
+ return reiserfs_write_dquot(dquot);
+ } else
+ return dquot_mark_dquot_dirty(dquot);
}
static int reiserfs_write_info(struct super_block *sb, int type)
{
- struct reiserfs_transaction_handle th;
- int ret, err;
-
- /* Data block + inode block */
- reiserfs_write_lock(sb);
- ret = journal_begin(&th, sb, 2);
- if (ret)
- goto out;
- ret = dquot_commit_info(sb, type);
- err = journal_end(&th, sb, 2);
- if (!ret && err)
- ret = err;
-out:
- reiserfs_write_unlock(sb);
- return ret;
+ struct reiserfs_transaction_handle th;
+ int ret, err;
+
+ /* Data block + inode block */
+ reiserfs_write_lock(sb);
+ ret = journal_begin(&th, sb, 2);
+ if (ret)
+ goto out;
+ ret = dquot_commit_info(sb, type);
+ err = journal_end(&th, sb, 2);
+ if (!ret && err)
+ ret = err;
+ out:
+ reiserfs_write_unlock(sb);
+ return ret;
}
/*
@@ -1977,45 +2116,48 @@ out:
static int reiserfs_quota_on_mount(struct super_block *sb, int type)
{
return vfs_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
- REISERFS_SB(sb)->s_jquota_fmt, type);
+ REISERFS_SB(sb)->s_jquota_fmt, type);
}
/*
* Standard function to be called on quota_on
*/
-static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
+static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
+ char *path)
{
- int err;
- struct nameidata nd;
-
- if (!(REISERFS_SB(sb)->s_mount_opt & (1<<REISERFS_QUOTA)))
- return -EINVAL;
- err = path_lookup(path, LOOKUP_FOLLOW, &nd);
- if (err)
- return err;
- /* Quotafile not on the same filesystem? */
- if (nd.mnt->mnt_sb != sb) {
- path_release(&nd);
- return -EXDEV;
- }
- /* We must not pack tails for quota files on reiserfs for quota IO to work */
- if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
- reiserfs_warning(sb, "reiserfs: Quota file must have tail packing disabled.");
- path_release(&nd);
- return -EINVAL;
- }
- /* Not journalling quota? No more tests needed... */
- if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
- !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
+ int err;
+ struct nameidata nd;
+
+ if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA)))
+ return -EINVAL;
+ err = path_lookup(path, LOOKUP_FOLLOW, &nd);
+ if (err)
+ return err;
+ /* Quotafile not on the same filesystem? */
+ if (nd.mnt->mnt_sb != sb) {
+ path_release(&nd);
+ return -EXDEV;
+ }
+ /* We must not pack tails for quota files on reiserfs for quota IO to work */
+ if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
+ reiserfs_warning(sb,
+ "reiserfs: Quota file must have tail packing disabled.");
+ path_release(&nd);
+ return -EINVAL;
+ }
+ /* Not journalling quota? No more tests needed... */
+ if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
+ !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
+ path_release(&nd);
+ return vfs_quota_on(sb, type, format_id, path);
+ }
+ /* Quotafile not of fs root? */
+ if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
+ reiserfs_warning(sb,
+ "reiserfs: Quota file not on filesystem root. "
+ "Journalled quota will not work.");
path_release(&nd);
- return vfs_quota_on(sb, type, format_id, path);
- }
- /* Quotafile not of fs root? */
- if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
- reiserfs_warning(sb, "reiserfs: Quota file not on filesystem root. "
- "Journalled quota will not work.");
- path_release(&nd);
- return vfs_quota_on(sb, type, format_id, path);
+ return vfs_quota_on(sb, type, format_id, path);
}
/* Read data from quotafile - avoid pagecache and such because we cannot afford
@@ -2025,42 +2167,44 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, ch
static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
size_t len, loff_t off)
{
- struct inode *inode = sb_dqopt(sb)->files[type];
- unsigned long blk = off >> sb->s_blocksize_bits;
- int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
- size_t toread;
- struct buffer_head tmp_bh, *bh;
- loff_t i_size = i_size_read(inode);
-
- if (off > i_size)
- return 0;
- if (off+len > i_size)
- len = i_size-off;
- toread = len;
- while (toread > 0) {
- tocopy = sb->s_blocksize - offset < toread ? sb->s_blocksize - offset : toread;
- tmp_bh.b_state = 0;
- /* Quota files are without tails so we can safely use this function */
- reiserfs_write_lock(sb);
- err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
- reiserfs_write_unlock(sb);
- if (err)
- return err;
- if (!buffer_mapped(&tmp_bh)) /* A hole? */
- memset(data, 0, tocopy);
- else {
- bh = sb_bread(sb, tmp_bh.b_blocknr);
- if (!bh)
- return -EIO;
- memcpy(data, bh->b_data+offset, tocopy);
- brelse(bh);
- }
- offset = 0;
- toread -= tocopy;
- data += tocopy;
- blk++;
- }
- return len;
+ struct inode *inode = sb_dqopt(sb)->files[type];
+ unsigned long blk = off >> sb->s_blocksize_bits;
+ int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
+ size_t toread;
+ struct buffer_head tmp_bh, *bh;
+ loff_t i_size = i_size_read(inode);
+
+ if (off > i_size)
+ return 0;
+ if (off + len > i_size)
+ len = i_size - off;
+ toread = len;
+ while (toread > 0) {
+ tocopy =
+ sb->s_blocksize - offset <
+ toread ? sb->s_blocksize - offset : toread;
+ tmp_bh.b_state = 0;
+ /* Quota files are without tails so we can safely use this function */
+ reiserfs_write_lock(sb);
+ err = reiserfs_get_block(inode, blk, &tmp_bh, 0);
+ reiserfs_write_unlock(sb);
+ if (err)
+ return err;
+ if (!buffer_mapped(&tmp_bh)) /* A hole? */
+ memset(data, 0, tocopy);
+ else {
+ bh = sb_bread(sb, tmp_bh.b_blocknr);
+ if (!bh)
+ return -EIO;
+ memcpy(data, bh->b_data + offset, tocopy);
+ brelse(bh);
+ }
+ offset = 0;
+ toread -= tocopy;
+ data += tocopy;
+ blk++;
+ }
+ return len;
}
/* Write to quotafile (we know the transaction is already started and has
@@ -2068,117 +2212,116 @@ static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
const char *data, size_t len, loff_t off)
{
- struct inode *inode = sb_dqopt(sb)->files[type];
- unsigned long blk = off >> sb->s_blocksize_bits;
- int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
- int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
- size_t towrite = len;
- struct buffer_head tmp_bh, *bh;
-
- down(&inode->i_sem);
- while (towrite > 0) {
- tocopy = sb->s_blocksize - offset < towrite ?
- sb->s_blocksize - offset : towrite;
- tmp_bh.b_state = 0;
- err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
- if (err)
- goto out;
- if (offset || tocopy != sb->s_blocksize)
- bh = sb_bread(sb, tmp_bh.b_blocknr);
- else
- bh = sb_getblk(sb, tmp_bh.b_blocknr);
- if (!bh) {
- err = -EIO;
- goto out;
- }
- lock_buffer(bh);
- memcpy(bh->b_data+offset, data, tocopy);
- flush_dcache_page(bh->b_page);
- set_buffer_uptodate(bh);
- unlock_buffer(bh);
- reiserfs_prepare_for_journal(sb, bh, 1);
- journal_mark_dirty(current->journal_info, sb, bh);
- if (!journal_quota)
- reiserfs_add_ordered_list(inode, bh);
- brelse(bh);
- offset = 0;
- towrite -= tocopy;
- data += tocopy;
- blk++;
- }
-out:
- if (len == towrite)
- return err;
- if (inode->i_size < off+len-towrite)
- i_size_write(inode, off+len-towrite);
- inode->i_version++;
- inode->i_mtime = inode->i_ctime = CURRENT_TIME;
- mark_inode_dirty(inode);
- up(&inode->i_sem);
- return len - towrite;
+ struct inode *inode = sb_dqopt(sb)->files[type];
+ unsigned long blk = off >> sb->s_blocksize_bits;
+ int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
+ int journal_quota = REISERFS_SB(sb)->s_qf_names[type] != NULL;
+ size_t towrite = len;
+ struct buffer_head tmp_bh, *bh;
+
+ down(&inode->i_sem);
+ while (towrite > 0) {
+ tocopy = sb->s_blocksize - offset < towrite ?
+ sb->s_blocksize - offset : towrite;
+ tmp_bh.b_state = 0;
+ err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
+ if (err)
+ goto out;
+ if (offset || tocopy != sb->s_blocksize)
+ bh = sb_bread(sb, tmp_bh.b_blocknr);
+ else
+ bh = sb_getblk(sb, tmp_bh.b_blocknr);
+ if (!bh) {
+ err = -EIO;
+ goto out;
+ }
+ lock_buffer(bh);
+ memcpy(bh->b_data + offset, data, tocopy);
+ flush_dcache_page(bh->b_page);
+ set_buffer_uptodate(bh);
+ unlock_buffer(bh);
+ reiserfs_prepare_for_journal(sb, bh, 1);
+ journal_mark_dirty(current->journal_info, sb, bh);
+ if (!journal_quota)
+ reiserfs_add_ordered_list(inode, bh);
+ brelse(bh);
+ offset = 0;
+ towrite -= tocopy;
+ data += tocopy;
+ blk++;
+ }
+ out:
+ if (len == towrite)
+ return err;
+ if (inode->i_size < off + len - towrite)
+ i_size_write(inode, off + len - towrite);
+ inode->i_version++;
+ inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ mark_inode_dirty(inode);
+ up(&inode->i_sem);
+ return len - towrite;
}
#endif
-static struct super_block*
-get_super_block (struct file_system_type *fs_type, int flags,
- const char *dev_name, void *data)
+static struct super_block *get_super_block(struct file_system_type *fs_type,
+ int flags, const char *dev_name,
+ void *data)
{
return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super);
}
-static int __init
-init_reiserfs_fs ( void )
+static int __init init_reiserfs_fs(void)
{
int ret;
- if ((ret = init_inodecache ())) {
+ if ((ret = init_inodecache())) {
return ret;
}
- if ((ret = reiserfs_xattr_register_handlers ()))
- goto failed_reiserfs_xattr_register_handlers;
+ if ((ret = reiserfs_xattr_register_handlers()))
+ goto failed_reiserfs_xattr_register_handlers;
- reiserfs_proc_info_global_init ();
- reiserfs_proc_register_global ("version", reiserfs_global_version_in_proc);
+ reiserfs_proc_info_global_init();
+ reiserfs_proc_register_global("version",
+ reiserfs_global_version_in_proc);
- ret = register_filesystem (& reiserfs_fs_type);
+ ret = register_filesystem(&reiserfs_fs_type);
if (ret == 0) {
return 0;
}
- reiserfs_xattr_unregister_handlers ();
+ reiserfs_xattr_unregister_handlers();
-failed_reiserfs_xattr_register_handlers:
- reiserfs_proc_unregister_global ("version");
- reiserfs_proc_info_global_done ();
- destroy_inodecache ();
+ failed_reiserfs_xattr_register_handlers:
+ reiserfs_proc_unregister_global("version");
+ reiserfs_proc_info_global_done();
+ destroy_inodecache();
return ret;
}
-static void __exit
-exit_reiserfs_fs ( void )
+static void __exit exit_reiserfs_fs(void)
{
- reiserfs_xattr_unregister_handlers ();
- reiserfs_proc_unregister_global ("version");
- reiserfs_proc_info_global_done ();
- unregister_filesystem (& reiserfs_fs_type);
- destroy_inodecache ();
+ reiserfs_xattr_unregister_handlers();
+ reiserfs_proc_unregister_global("version");
+ reiserfs_proc_info_global_done();
+ unregister_filesystem(&reiserfs_fs_type);
+ destroy_inodecache();
}
struct file_system_type reiserfs_fs_type = {
- .owner = THIS_MODULE,
- .name = "reiserfs",
- .get_sb = get_super_block,
- .kill_sb = kill_block_super,
- .fs_flags = FS_REQUIRES_DEV,
+ .owner = THIS_MODULE,
+ .name = "reiserfs",
+ .get_sb = get_super_block,
+ .kill_sb = kill_block_super,
+ .fs_flags = FS_REQUIRES_DEV,
};
-MODULE_DESCRIPTION ("ReiserFS journaled filesystem");
-MODULE_AUTHOR ("Hans Reiser <reiser@namesys.com>");
-MODULE_LICENSE ("GPL");
+MODULE_DESCRIPTION("ReiserFS journaled filesystem");
+MODULE_AUTHOR("Hans Reiser <reiser@namesys.com>");
+MODULE_LICENSE("GPL");
-module_init (init_reiserfs_fs);
-module_exit (exit_reiserfs_fs);
+module_init(init_reiserfs_fs);
+module_exit(exit_reiserfs_fs);
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index 6191909d516..c92e124f628 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -11,156 +11,159 @@
/* access to tail : when one is going to read tail it must make sure, that is not running.
direct2indirect and indirect2direct can not run concurrently */
-
/* Converts direct items to an unformatted node. Panics if file has no
tail. -ENOSPC if no disk space for conversion */
/* path points to first direct item of the file regarless of how many of
them are there */
-int direct2indirect (struct reiserfs_transaction_handle *th, struct inode * inode,
- struct path * path, struct buffer_head * unbh,
- loff_t tail_offset)
+int direct2indirect(struct reiserfs_transaction_handle *th, struct inode *inode,
+ struct path *path, struct buffer_head *unbh,
+ loff_t tail_offset)
{
- struct super_block * sb = inode->i_sb;
- struct buffer_head *up_to_date_bh ;
- struct item_head * p_le_ih = PATH_PITEM_HEAD (path);
- unsigned long total_tail = 0 ;
- struct cpu_key end_key; /* Key to search for the last byte of the
- converted item. */
- struct item_head ind_ih; /* new indirect item to be inserted or
- key of unfm pointer to be pasted */
- int n_blk_size,
- n_retval; /* returned value for reiserfs_insert_item and clones */
- unp_t unfm_ptr; /* Handle on an unformatted node
- that will be inserted in the
- tree. */
-
- BUG_ON (!th->t_trans_id);
-
- REISERFS_SB(sb)->s_direct2indirect ++;
-
- n_blk_size = sb->s_blocksize;
-
- /* and key to search for append or insert pointer to the new
- unformatted node. */
- copy_item_head (&ind_ih, p_le_ih);
- set_le_ih_k_offset (&ind_ih, tail_offset);
- set_le_ih_k_type (&ind_ih, TYPE_INDIRECT);
-
- /* Set the key to search for the place for new unfm pointer */
- make_cpu_key (&end_key, inode, tail_offset, TYPE_INDIRECT, 4);
-
- // FIXME: we could avoid this
- if ( search_for_position_by_key (sb, &end_key, path) == POSITION_FOUND ) {
- reiserfs_warning (sb, "PAP-14030: direct2indirect: "
- "pasted or inserted byte exists in the tree %K. "
- "Use fsck to repair.", &end_key);
- pathrelse(path);
- return -EIO;
- }
-
- p_le_ih = PATH_PITEM_HEAD (path);
-
- unfm_ptr = cpu_to_le32 (unbh->b_blocknr);
-
- if ( is_statdata_le_ih (p_le_ih) ) {
- /* Insert new indirect item. */
- set_ih_free_space (&ind_ih, 0); /* delete at nearest future */
- put_ih_item_len( &ind_ih, UNFM_P_SIZE );
- PATH_LAST_POSITION (path)++;
- n_retval = reiserfs_insert_item (th, path, &end_key, &ind_ih, inode,
+ struct super_block *sb = inode->i_sb;
+ struct buffer_head *up_to_date_bh;
+ struct item_head *p_le_ih = PATH_PITEM_HEAD(path);
+ unsigned long total_tail = 0;
+ struct cpu_key end_key; /* Key to search for the last byte of the
+ converted item. */
+ struct item_head ind_ih; /* new indirect item to be inserted or
+ key of unfm pointer to be pasted */
+ int n_blk_size, n_retval; /* returned value for reiserfs_insert_item and clones */
+ unp_t unfm_ptr; /* Handle on an unformatted node
+ that will be inserted in the
+ tree. */
+
+ BUG_ON(!th->t_trans_id);
+
+ REISERFS_SB(sb)->s_direct2indirect++;
+
+ n_blk_size = sb->s_blocksize;
+
+ /* and key to search for append or insert pointer to the new
+ unformatted node. */
+ copy_item_head(&ind_ih, p_le_ih);
+ set_le_ih_k_offset(&ind_ih, tail_offset);
+ set_le_ih_k_type(&ind_ih, TYPE_INDIRECT);
+
+ /* Set the key to search for the place for new unfm pointer */
+ make_cpu_key(&end_key, inode, tail_offset, TYPE_INDIRECT, 4);
+
+ // FIXME: we could avoid this
+ if (search_for_position_by_key(sb, &end_key, path) == POSITION_FOUND) {
+ reiserfs_warning(sb, "PAP-14030: direct2indirect: "
+ "pasted or inserted byte exists in the tree %K. "
+ "Use fsck to repair.", &end_key);
+ pathrelse(path);
+ return -EIO;
+ }
+
+ p_le_ih = PATH_PITEM_HEAD(path);
+
+ unfm_ptr = cpu_to_le32(unbh->b_blocknr);
+
+ if (is_statdata_le_ih(p_le_ih)) {
+ /* Insert new indirect item. */
+ set_ih_free_space(&ind_ih, 0); /* delete at nearest future */
+ put_ih_item_len(&ind_ih, UNFM_P_SIZE);
+ PATH_LAST_POSITION(path)++;
+ n_retval =
+ reiserfs_insert_item(th, path, &end_key, &ind_ih, inode,
(char *)&unfm_ptr);
- } else {
- /* Paste into last indirect item of an object. */
- n_retval = reiserfs_paste_into_item(th, path, &end_key, inode,
- (char *)&unfm_ptr, UNFM_P_SIZE);
- }
- if ( n_retval ) {
- return n_retval;
- }
-
- // note: from here there are two keys which have matching first
- // three key components. They only differ by the fourth one.
-
-
- /* Set the key to search for the direct items of the file */
- make_cpu_key (&end_key, inode, max_reiserfs_offset (inode), TYPE_DIRECT, 4);
-
- /* Move bytes from the direct items to the new unformatted node
- and delete them. */
- while (1) {
- int tail_size;
-
- /* end_key.k_offset is set so, that we will always have found
- last item of the file */
- if ( search_for_position_by_key (sb, &end_key, path) == POSITION_FOUND )
- reiserfs_panic (sb, "PAP-14050: direct2indirect: "
- "direct item (%K) not found", &end_key);
- p_le_ih = PATH_PITEM_HEAD (path);
- RFALSE( !is_direct_le_ih (p_le_ih),
- "vs-14055: direct item expected(%K), found %h",
- &end_key, p_le_ih);
- tail_size = (le_ih_k_offset (p_le_ih) & (n_blk_size - 1))
- + ih_item_len(p_le_ih) - 1;
-
- /* we only send the unbh pointer if the buffer is not up to date.
- ** this avoids overwriting good data from writepage() with old data
- ** from the disk or buffer cache
- ** Special case: unbh->b_page will be NULL if we are coming through
- ** DIRECT_IO handler here.
- */
- if (!unbh->b_page || buffer_uptodate(unbh) || PageUptodate(unbh->b_page)) {
- up_to_date_bh = NULL ;
} else {
- up_to_date_bh = unbh ;
+ /* Paste into last indirect item of an object. */
+ n_retval = reiserfs_paste_into_item(th, path, &end_key, inode,
+ (char *)&unfm_ptr,
+ UNFM_P_SIZE);
}
- n_retval = reiserfs_delete_item (th, path, &end_key, inode,
- up_to_date_bh) ;
-
- total_tail += n_retval ;
- if (tail_size == n_retval)
- // done: file does not have direct items anymore
- break;
-
- }
- /* if we've copied bytes from disk into the page, we need to zero
- ** out the unused part of the block (it was not up to date before)
- */
- if (up_to_date_bh) {
- unsigned pgoff = (tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
- char *kaddr=kmap_atomic(up_to_date_bh->b_page, KM_USER0);
- memset(kaddr + pgoff, 0, n_blk_size - total_tail) ;
- kunmap_atomic(kaddr, KM_USER0);
- }
-
- REISERFS_I(inode)->i_first_direct_byte = U32_MAX;
-
- return 0;
-}
+ if (n_retval) {
+ return n_retval;
+ }
+ // note: from here there are two keys which have matching first
+ // three key components. They only differ by the fourth one.
+
+ /* Set the key to search for the direct items of the file */
+ make_cpu_key(&end_key, inode, max_reiserfs_offset(inode), TYPE_DIRECT,
+ 4);
+
+ /* Move bytes from the direct items to the new unformatted node
+ and delete them. */
+ while (1) {
+ int tail_size;
+
+ /* end_key.k_offset is set so, that we will always have found
+ last item of the file */
+ if (search_for_position_by_key(sb, &end_key, path) ==
+ POSITION_FOUND)
+ reiserfs_panic(sb,
+ "PAP-14050: direct2indirect: "
+ "direct item (%K) not found", &end_key);
+ p_le_ih = PATH_PITEM_HEAD(path);
+ RFALSE(!is_direct_le_ih(p_le_ih),
+ "vs-14055: direct item expected(%K), found %h",
+ &end_key, p_le_ih);
+ tail_size = (le_ih_k_offset(p_le_ih) & (n_blk_size - 1))
+ + ih_item_len(p_le_ih) - 1;
+
+ /* we only send the unbh pointer if the buffer is not up to date.
+ ** this avoids overwriting good data from writepage() with old data
+ ** from the disk or buffer cache
+ ** Special case: unbh->b_page will be NULL if we are coming through
+ ** DIRECT_IO handler here.
+ */
+ if (!unbh->b_page || buffer_uptodate(unbh)
+ || PageUptodate(unbh->b_page)) {
+ up_to_date_bh = NULL;
+ } else {
+ up_to_date_bh = unbh;
+ }
+ n_retval = reiserfs_delete_item(th, path, &end_key, inode,
+ up_to_date_bh);
+
+ total_tail += n_retval;
+ if (tail_size == n_retval)
+ // done: file does not have direct items anymore
+ break;
+ }
+ /* if we've copied bytes from disk into the page, we need to zero
+ ** out the unused part of the block (it was not up to date before)
+ */
+ if (up_to_date_bh) {
+ unsigned pgoff =
+ (tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
+ char *kaddr = kmap_atomic(up_to_date_bh->b_page, KM_USER0);
+ memset(kaddr + pgoff, 0, n_blk_size - total_tail);
+ kunmap_atomic(kaddr, KM_USER0);
+ }
+
+ REISERFS_I(inode)->i_first_direct_byte = U32_MAX;
+
+ return 0;
+}
/* stolen from fs/buffer.c */
-void reiserfs_unmap_buffer(struct buffer_head *bh) {
- lock_buffer(bh) ;
- if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
- BUG() ;
- }
- clear_buffer_dirty(bh) ;
- /* Remove the buffer from whatever list it belongs to. We are mostly
- interested in removing it from per-sb j_dirty_buffers list, to avoid
- BUG() on attempt to write not mapped buffer */
- if ( (!list_empty(&bh->b_assoc_buffers) || bh->b_private) && bh->b_page) {
- struct inode *inode = bh->b_page->mapping->host;
- struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
- spin_lock(&j->j_dirty_buffers_lock);
- list_del_init(&bh->b_assoc_buffers);
- reiserfs_free_jh(bh);
- spin_unlock(&j->j_dirty_buffers_lock);
- }
- clear_buffer_mapped(bh) ;
- clear_buffer_req(bh) ;
- clear_buffer_new(bh);
- bh->b_bdev = NULL;
- unlock_buffer(bh) ;
+void reiserfs_unmap_buffer(struct buffer_head *bh)
+{
+ lock_buffer(bh);
+ if (buffer_journaled(bh) || buffer_journal_dirty(bh)) {
+ BUG();
+ }
+ clear_buffer_dirty(bh);
+ /* Remove the buffer from whatever list it belongs to. We are mostly
+ interested in removing it from per-sb j_dirty_buffers list, to avoid
+ BUG() on attempt to write not mapped buffer */
+ if ((!list_empty(&bh->b_assoc_buffers) || bh->b_private) && bh->b_page) {
+ struct inode *inode = bh->b_page->mapping->host;
+ struct reiserfs_journal *j = SB_JOURNAL(inode->i_sb);
+ spin_lock(&j->j_dirty_buffers_lock);
+ list_del_init(&bh->b_assoc_buffers);
+ reiserfs_free_jh(bh);
+ spin_unlock(&j->j_dirty_buffers_lock);
+ }
+ clear_buffer_mapped(bh);
+ clear_buffer_req(bh);
+ clear_buffer_new(bh);
+ bh->b_bdev = NULL;
+ unlock_buffer(bh);
}
/* this first locks inode (neither reads nor sync are permitted),
@@ -169,108 +172,108 @@ void reiserfs_unmap_buffer(struct buffer_head *bh) {
what we expect from it (number of cut bytes). But when tail remains
in the unformatted node, we set mode to SKIP_BALANCING and unlock
inode */
-int indirect2direct (struct reiserfs_transaction_handle *th,
- struct inode * p_s_inode,
- struct page *page,
- struct path * p_s_path, /* path to the indirect item. */
- const struct cpu_key * p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
- loff_t n_new_file_size, /* New file size. */
- char * p_c_mode)
+int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, struct page *page, struct path *p_s_path, /* path to the indirect item. */
+ const struct cpu_key *p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
+ loff_t n_new_file_size, /* New file size. */
+ char *p_c_mode)
{
- struct super_block * p_s_sb = p_s_inode->i_sb;
- struct item_head s_ih;
- unsigned long n_block_size = p_s_sb->s_blocksize;
- char * tail;
- int tail_len, round_tail_len;
- loff_t pos, pos1; /* position of first byte of the tail */
- struct cpu_key key;
+ struct super_block *p_s_sb = p_s_inode->i_sb;
+ struct item_head s_ih;
+ unsigned long n_block_size = p_s_sb->s_blocksize;
+ char *tail;
+ int tail_len, round_tail_len;
+ loff_t pos, pos1; /* position of first byte of the tail */
+ struct cpu_key key;
- BUG_ON (!th->t_trans_id);
+ BUG_ON(!th->t_trans_id);
- REISERFS_SB(p_s_sb)->s_indirect2direct ++;
+ REISERFS_SB(p_s_sb)->s_indirect2direct++;
- *p_c_mode = M_SKIP_BALANCING;
+ *p_c_mode = M_SKIP_BALANCING;
- /* store item head path points to. */
- copy_item_head (&s_ih, PATH_PITEM_HEAD(p_s_path));
-
- tail_len = (n_new_file_size & (n_block_size - 1));
- if (get_inode_sd_version (p_s_inode) == STAT_DATA_V2)
- round_tail_len = ROUND_UP (tail_len);
- else
- round_tail_len = tail_len;
-
- pos = le_ih_k_offset (&s_ih) - 1 + (ih_item_len(&s_ih) / UNFM_P_SIZE - 1) * p_s_sb->s_blocksize;
- pos1 = pos;
-
- // we are protected by i_sem. The tail can not disapper, not
- // append can be done either
- // we are in truncate or packing tail in file_release
-
- tail = (char *)kmap(page) ; /* this can schedule */
-
- if (path_changed (&s_ih, p_s_path)) {
- /* re-search indirect item */
- if ( search_for_position_by_key (p_s_sb, p_s_item_key, p_s_path) == POSITION_NOT_FOUND )
- reiserfs_panic(p_s_sb, "PAP-5520: indirect2direct: "
- "item to be converted %K does not exist", p_s_item_key);
+ /* store item head path points to. */
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+
+ tail_len = (n_new_file_size & (n_block_size - 1));
+ if (get_inode_sd_version(p_s_inode) == STAT_DATA_V2)
+ round_tail_len = ROUND_UP(tail_len);
+ else
+ round_tail_len = tail_len;
+
+ pos =
+ le_ih_k_offset(&s_ih) - 1 + (ih_item_len(&s_ih) / UNFM_P_SIZE -
+ 1) * p_s_sb->s_blocksize;
+ pos1 = pos;
+
+ // we are protected by i_sem. The tail can not disapper, not
+ // append can be done either
+ // we are in truncate or packing tail in file_release
+
+ tail = (char *)kmap(page); /* this can schedule */
+
+ if (path_changed(&s_ih, p_s_path)) {
+ /* re-search indirect item */
+ if (search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path)
+ == POSITION_NOT_FOUND)
+ reiserfs_panic(p_s_sb,
+ "PAP-5520: indirect2direct: "
+ "item to be converted %K does not exist",
+ p_s_item_key);
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
#ifdef CONFIG_REISERFS_CHECK
- pos = le_ih_k_offset (&s_ih) - 1 +
- (ih_item_len(&s_ih) / UNFM_P_SIZE - 1) * p_s_sb->s_blocksize;
- if (pos != pos1)
- reiserfs_panic (p_s_sb, "vs-5530: indirect2direct: "
- "tail position changed while we were reading it");
+ pos = le_ih_k_offset(&s_ih) - 1 +
+ (ih_item_len(&s_ih) / UNFM_P_SIZE -
+ 1) * p_s_sb->s_blocksize;
+ if (pos != pos1)
+ reiserfs_panic(p_s_sb, "vs-5530: indirect2direct: "
+ "tail position changed while we were reading it");
#endif
- }
-
-
- /* Set direct item header to insert. */
- make_le_item_head (&s_ih, NULL, get_inode_item_key_version (p_s_inode), pos1 + 1,
- TYPE_DIRECT, round_tail_len, 0xffff/*ih_free_space*/);
-
- /* we want a pointer to the first byte of the tail in the page.
- ** the page was locked and this part of the page was up to date when
- ** indirect2direct was called, so we know the bytes are still valid
- */
- tail = tail + (pos & (PAGE_CACHE_SIZE - 1)) ;
-
- PATH_LAST_POSITION(p_s_path)++;
-
- key = *p_s_item_key;
- set_cpu_key_k_type (&key, TYPE_DIRECT);
- key.key_length = 4;
- /* Insert tail as new direct item in the tree */
- if ( reiserfs_insert_item(th, p_s_path, &key, &s_ih, p_s_inode,
- tail ? tail : NULL) < 0 ) {
- /* No disk memory. So we can not convert last unformatted node
- to the direct item. In this case we used to adjust
- indirect items's ih_free_space. Now ih_free_space is not
- used, it would be ideal to write zeros to corresponding
- unformatted node. For now i_size is considered as guard for
- going out of file size */
- kunmap(page) ;
- return n_block_size - round_tail_len;
- }
- kunmap(page) ;
-
- /* make sure to get the i_blocks changes from reiserfs_insert_item */
- reiserfs_update_sd(th, p_s_inode);
+ }
- // note: we have now the same as in above direct2indirect
- // conversion: there are two keys which have matching first three
- // key components. They only differ by the fouhth one.
+ /* Set direct item header to insert. */
+ make_le_item_head(&s_ih, NULL, get_inode_item_key_version(p_s_inode),
+ pos1 + 1, TYPE_DIRECT, round_tail_len,
+ 0xffff /*ih_free_space */ );
+
+ /* we want a pointer to the first byte of the tail in the page.
+ ** the page was locked and this part of the page was up to date when
+ ** indirect2direct was called, so we know the bytes are still valid
+ */
+ tail = tail + (pos & (PAGE_CACHE_SIZE - 1));
+
+ PATH_LAST_POSITION(p_s_path)++;
+
+ key = *p_s_item_key;
+ set_cpu_key_k_type(&key, TYPE_DIRECT);
+ key.key_length = 4;
+ /* Insert tail as new direct item in the tree */
+ if (reiserfs_insert_item(th, p_s_path, &key, &s_ih, p_s_inode,
+ tail ? tail : NULL) < 0) {
+ /* No disk memory. So we can not convert last unformatted node
+ to the direct item. In this case we used to adjust
+ indirect items's ih_free_space. Now ih_free_space is not
+ used, it would be ideal to write zeros to corresponding
+ unformatted node. For now i_size is considered as guard for
+ going out of file size */
+ kunmap(page);
+ return n_block_size - round_tail_len;
+ }
+ kunmap(page);
- /* We have inserted new direct item and must remove last
- unformatted node. */
- *p_c_mode = M_CUT;
+ /* make sure to get the i_blocks changes from reiserfs_insert_item */
+ reiserfs_update_sd(th, p_s_inode);
- /* we store position of first direct item in the in-core inode */
- //mark_file_with_tail (p_s_inode, pos1 + 1);
- REISERFS_I(p_s_inode)->i_first_direct_byte = pos1 + 1;
-
- return n_block_size - round_tail_len;
-}
+ // note: we have now the same as in above direct2indirect
+ // conversion: there are two keys which have matching first three
+ // key components. They only differ by the fouhth one.
+ /* We have inserted new direct item and must remove last
+ unformatted node. */
+ *p_c_mode = M_CUT;
+ /* we store position of first direct item in the in-core inode */
+ //mark_file_with_tail (p_s_inode, pos1 + 1);
+ REISERFS_I(p_s_inode)->i_first_direct_byte = pos1 + 1;
+ return n_block_size - round_tail_len;
+}
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 45582fe8b46..e386d3db305 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -51,67 +51,68 @@
#define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs"
-static struct reiserfs_xattr_handler *find_xattr_handler_prefix (const char *prefix);
+static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
+ *prefix);
-static struct dentry *
-create_xa_root (struct super_block *sb)
+static struct dentry *create_xa_root(struct super_block *sb)
{
- struct dentry *privroot = dget (REISERFS_SB(sb)->priv_root);
- struct dentry *xaroot;
-
- /* This needs to be created at mount-time */
- if (!privroot)
- return ERR_PTR(-EOPNOTSUPP);
-
- xaroot = lookup_one_len (XAROOT_NAME, privroot, strlen (XAROOT_NAME));
- if (IS_ERR (xaroot)) {
- goto out;
- } else if (!xaroot->d_inode) {
- int err;
- down (&privroot->d_inode->i_sem);
- err = privroot->d_inode->i_op->mkdir (privroot->d_inode, xaroot, 0700);
- up (&privroot->d_inode->i_sem);
-
- if (err) {
- dput (xaroot);
- dput (privroot);
- return ERR_PTR (err);
- }
- REISERFS_SB(sb)->xattr_root = dget (xaroot);
- }
-
-out:
- dput (privroot);
- return xaroot;
+ struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root);
+ struct dentry *xaroot;
+
+ /* This needs to be created at mount-time */
+ if (!privroot)
+ return ERR_PTR(-EOPNOTSUPP);
+
+ xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME));
+ if (IS_ERR(xaroot)) {
+ goto out;
+ } else if (!xaroot->d_inode) {
+ int err;
+ down(&privroot->d_inode->i_sem);
+ err =
+ privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot,
+ 0700);
+ up(&privroot->d_inode->i_sem);
+
+ if (err) {
+ dput(xaroot);
+ dput(privroot);
+ return ERR_PTR(err);
+ }
+ REISERFS_SB(sb)->xattr_root = dget(xaroot);
+ }
+
+ out:
+ dput(privroot);
+ return xaroot;
}
/* This will return a dentry, or error, refering to the xa root directory.
* If the xa root doesn't exist yet, the dentry will be returned without
* an associated inode. This dentry can be used with ->mkdir to create
* the xa directory. */
-static struct dentry *
-__get_xa_root (struct super_block *s)
+static struct dentry *__get_xa_root(struct super_block *s)
{
- struct dentry *privroot = dget (REISERFS_SB(s)->priv_root);
- struct dentry *xaroot = NULL;
-
- if (IS_ERR (privroot) || !privroot)
- return privroot;
-
- xaroot = lookup_one_len (XAROOT_NAME, privroot, strlen (XAROOT_NAME));
- if (IS_ERR (xaroot)) {
- goto out;
- } else if (!xaroot->d_inode) {
- dput (xaroot);
- xaroot = NULL;
- goto out;
- }
-
- REISERFS_SB(s)->xattr_root = dget (xaroot);
-
-out:
- dput (privroot);
- return xaroot;
+ struct dentry *privroot = dget(REISERFS_SB(s)->priv_root);
+ struct dentry *xaroot = NULL;
+
+ if (IS_ERR(privroot) || !privroot)
+ return privroot;
+
+ xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME));
+ if (IS_ERR(xaroot)) {
+ goto out;
+ } else if (!xaroot->d_inode) {
+ dput(xaroot);
+ xaroot = NULL;
+ goto out;
+ }
+
+ REISERFS_SB(s)->xattr_root = dget(xaroot);
+
+ out:
+ dput(privroot);
+ return xaroot;
}
/* Returns the dentry (or NULL) referring to the root of the extended
@@ -119,147 +120,145 @@ out:
* Otherwise, we attempt to retreive it from disk. It may also return
* a pointer-encoded error.
*/
-static inline struct dentry *
-get_xa_root (struct super_block *s)
+static inline struct dentry *get_xa_root(struct super_block *s)
{
- struct dentry *dentry = dget (REISERFS_SB(s)->xattr_root);
+ struct dentry *dentry = dget(REISERFS_SB(s)->xattr_root);
- if (!dentry)
- dentry = __get_xa_root (s);
+ if (!dentry)
+ dentry = __get_xa_root(s);
- return dentry;
+ return dentry;
}
/* Opens the directory corresponding to the inode's extended attribute store.
* If flags allow, the tree to the directory may be created. If creation is
* prohibited, -ENODATA is returned. */
-static struct dentry *
-open_xa_dir (const struct inode *inode, int flags)
+static struct dentry *open_xa_dir(const struct inode *inode, int flags)
{
- struct dentry *xaroot, *xadir;
- char namebuf[17];
-
- xaroot = get_xa_root (inode->i_sb);
- if (IS_ERR (xaroot)) {
- return xaroot;
- } else if (!xaroot) {
- if (flags == 0 || flags & XATTR_CREATE) {
- xaroot = create_xa_root (inode->i_sb);
- if (IS_ERR (xaroot))
- return xaroot;
- }
- if (!xaroot)
- return ERR_PTR (-ENODATA);
- }
-
- /* ok, we have xaroot open */
-
- snprintf (namebuf, sizeof (namebuf), "%X.%X",
- le32_to_cpu (INODE_PKEY (inode)->k_objectid),
- inode->i_generation);
- xadir = lookup_one_len (namebuf, xaroot, strlen (namebuf));
- if (IS_ERR (xadir)) {
- dput (xaroot);
- return xadir;
- }
-
- if (!xadir->d_inode) {
- int err;
- if (flags == 0 || flags & XATTR_CREATE) {
- /* Although there is nothing else trying to create this directory,
- * another directory with the same hash may be created, so we need
- * to protect against that */
- err = xaroot->d_inode->i_op->mkdir (xaroot->d_inode, xadir, 0700);
- if (err) {
- dput (xaroot);
- dput (xadir);
- return ERR_PTR (err);
- }
- }
- if (!xadir->d_inode) {
- dput (xaroot);
- dput (xadir);
- return ERR_PTR (-ENODATA);
- }
- }
-
- dput (xaroot);
- return xadir;
+ struct dentry *xaroot, *xadir;
+ char namebuf[17];
+
+ xaroot = get_xa_root(inode->i_sb);
+ if (IS_ERR(xaroot)) {
+ return xaroot;
+ } else if (!xaroot) {
+ if (flags == 0 || flags & XATTR_CREATE) {
+ xaroot = create_xa_root(inode->i_sb);
+ if (IS_ERR(xaroot))
+ return xaroot;
+ }
+ if (!xaroot)
+ return ERR_PTR(-ENODATA);
+ }
+
+ /* ok, we have xaroot open */
+
+ snprintf(namebuf, sizeof(namebuf), "%X.%X",
+ le32_to_cpu(INODE_PKEY(inode)->k_objectid),
+ inode->i_generation);
+ xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
+ if (IS_ERR(xadir)) {
+ dput(xaroot);
+ return xadir;
+ }
+
+ if (!xadir->d_inode) {
+ int err;
+ if (flags == 0 || flags & XATTR_CREATE) {
+ /* Although there is nothing else trying to create this directory,
+ * another directory with the same hash may be created, so we need
+ * to protect against that */
+ err =
+ xaroot->d_inode->i_op->mkdir(xaroot->d_inode, xadir,
+ 0700);
+ if (err) {
+ dput(xaroot);
+ dput(xadir);
+ return ERR_PTR(err);
+ }
+ }
+ if (!xadir->d_inode) {
+ dput(xaroot);
+ dput(xadir);
+ return ERR_PTR(-ENODATA);
+ }
+ }
+
+ dput(xaroot);
+ return xadir;
}
/* Returns a dentry corresponding to a specific extended attribute file
* for the inode. If flags allow, the file is created. Otherwise, a
* valid or negative dentry, or an error is returned. */
-static struct dentry *
-get_xa_file_dentry (const struct inode *inode, const char *name, int flags)
+static struct dentry *get_xa_file_dentry(const struct inode *inode,
+ const char *name, int flags)
{
- struct dentry *xadir, *xafile;
- int err = 0;
-
- xadir = open_xa_dir (inode, flags);
- if (IS_ERR (xadir)) {
- return ERR_PTR (PTR_ERR (xadir));
- } else if (xadir && !xadir->d_inode) {
- dput (xadir);
- return ERR_PTR (-ENODATA);
- }
-
- xafile = lookup_one_len (name, xadir, strlen (name));
- if (IS_ERR (xafile)) {
- dput (xadir);
- return ERR_PTR (PTR_ERR (xafile));
- }
-
- if (xafile->d_inode) { /* file exists */
- if (flags & XATTR_CREATE) {
- err = -EEXIST;
- dput (xafile);
- goto out;
- }
- } else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
- goto out;
- } else {
- /* inode->i_sem is down, so nothing else can try to create
- * the same xattr */
- err = xadir->d_inode->i_op->create (xadir->d_inode, xafile,
- 0700|S_IFREG, NULL);
-
- if (err) {
- dput (xafile);
- goto out;
- }
- }
-
-out:
- dput (xadir);
- if (err)
- xafile = ERR_PTR (err);
- return xafile;
-}
+ struct dentry *xadir, *xafile;
+ int err = 0;
+
+ xadir = open_xa_dir(inode, flags);
+ if (IS_ERR(xadir)) {
+ return ERR_PTR(PTR_ERR(xadir));
+ } else if (xadir && !xadir->d_inode) {
+ dput(xadir);
+ return ERR_PTR(-ENODATA);
+ }
+
+ xafile = lookup_one_len(name, xadir, strlen(name));
+ if (IS_ERR(xafile)) {
+ dput(xadir);
+ return ERR_PTR(PTR_ERR(xafile));
+ }
+
+ if (xafile->d_inode) { /* file exists */
+ if (flags & XATTR_CREATE) {
+ err = -EEXIST;
+ dput(xafile);
+ goto out;
+ }
+ } else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
+ goto out;
+ } else {
+ /* inode->i_sem is down, so nothing else can try to create
+ * the same xattr */
+ err = xadir->d_inode->i_op->create(xadir->d_inode, xafile,
+ 0700 | S_IFREG, NULL);
+
+ if (err) {
+ dput(xafile);
+ goto out;
+ }
+ }
+ out:
+ dput(xadir);
+ if (err)
+ xafile = ERR_PTR(err);
+ return xafile;
+}
/* Opens a file pointer to the attribute associated with inode */
-static struct file *
-open_xa_file (const struct inode *inode, const char *name, int flags)
+static struct file *open_xa_file(const struct inode *inode, const char *name,
+ int flags)
{
- struct dentry *xafile;
- struct file *fp;
-
- xafile = get_xa_file_dentry (inode, name, flags);
- if (IS_ERR (xafile))
- return ERR_PTR (PTR_ERR (xafile));
- else if (!xafile->d_inode) {
- dput (xafile);
- return ERR_PTR (-ENODATA);
- }
+ struct dentry *xafile;
+ struct file *fp;
+
+ xafile = get_xa_file_dentry(inode, name, flags);
+ if (IS_ERR(xafile))
+ return ERR_PTR(PTR_ERR(xafile));
+ else if (!xafile->d_inode) {
+ dput(xafile);
+ return ERR_PTR(-ENODATA);
+ }
- fp = dentry_open (xafile, NULL, O_RDWR);
- /* dentry_open dputs the dentry if it fails */
+ fp = dentry_open(xafile, NULL, O_RDWR);
+ /* dentry_open dputs the dentry if it fails */
- return fp;
+ return fp;
}
-
/*
* this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
* we need to drop the path before calling the filldir struct. That
@@ -273,139 +272,146 @@ open_xa_file (const struct inode *inode, const char *name, int flags)
* we're called with i_sem held, so there are no worries about the directory
* changing underneath us.
*/
-static int __xattr_readdir(struct file * filp, void * dirent, filldir_t filldir)
+static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
- struct inode *inode = filp->f_dentry->d_inode;
- struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
- INITIALIZE_PATH (path_to_entry);
- struct buffer_head * bh;
- int entry_num;
- struct item_head * ih, tmp_ih;
- int search_res;
- char * local_buf;
- loff_t next_pos;
- char small_buf[32] ; /* avoid kmalloc if we can */
- struct reiserfs_de_head *deh;
- int d_reclen;
- char * d_name;
- off_t d_off;
- ino_t d_ino;
- struct reiserfs_dir_entry de;
-
-
- /* form key for search the next directory entry using f_pos field of
- file structure */
- next_pos = max_reiserfs_offset(inode);
-
- while (1) {
-research:
- if (next_pos <= DOT_DOT_OFFSET)
- break;
- make_cpu_key (&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
-
- search_res = search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry, &de);
- if (search_res == IO_ERROR) {
- // FIXME: we could just skip part of directory which could
- // not be read
- pathrelse(&path_to_entry);
- return -EIO;
- }
-
- if (search_res == NAME_NOT_FOUND)
- de.de_entry_num--;
+ struct inode *inode = filp->f_dentry->d_inode;
+ struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
+ INITIALIZE_PATH(path_to_entry);
+ struct buffer_head *bh;
+ int entry_num;
+ struct item_head *ih, tmp_ih;
+ int search_res;
+ char *local_buf;
+ loff_t next_pos;
+ char small_buf[32]; /* avoid kmalloc if we can */
+ struct reiserfs_de_head *deh;
+ int d_reclen;
+ char *d_name;
+ off_t d_off;
+ ino_t d_ino;
+ struct reiserfs_dir_entry de;
+
+ /* form key for search the next directory entry using f_pos field of
+ file structure */
+ next_pos = max_reiserfs_offset(inode);
+
+ while (1) {
+ research:
+ if (next_pos <= DOT_DOT_OFFSET)
+ break;
+ make_cpu_key(&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
+
+ search_res =
+ search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
+ &de);
+ if (search_res == IO_ERROR) {
+ // FIXME: we could just skip part of directory which could
+ // not be read
+ pathrelse(&path_to_entry);
+ return -EIO;
+ }
- set_de_name_and_namelen(&de);
- entry_num = de.de_entry_num;
- deh = &(de.de_deh[entry_num]);
+ if (search_res == NAME_NOT_FOUND)
+ de.de_entry_num--;
- bh = de.de_bh;
- ih = de.de_ih;
+ set_de_name_and_namelen(&de);
+ entry_num = de.de_entry_num;
+ deh = &(de.de_deh[entry_num]);
- if (!is_direntry_le_ih(ih)) {
- reiserfs_warning(inode->i_sb, "not direntry %h", ih);
- break;
- }
- copy_item_head(&tmp_ih, ih);
+ bh = de.de_bh;
+ ih = de.de_ih;
- /* we must have found item, that is item of this directory, */
- RFALSE( COMP_SHORT_KEYS (&(ih->ih_key), &pos_key),
- "vs-9000: found item %h does not match to dir we readdir %K",
- ih, &pos_key);
+ if (!is_direntry_le_ih(ih)) {
+ reiserfs_warning(inode->i_sb, "not direntry %h", ih);
+ break;
+ }
+ copy_item_head(&tmp_ih, ih);
- if (deh_offset(deh) <= DOT_DOT_OFFSET) {
- break;
- }
+ /* we must have found item, that is item of this directory, */
+ RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
+ "vs-9000: found item %h does not match to dir we readdir %K",
+ ih, &pos_key);
- /* look for the previous entry in the directory */
- next_pos = deh_offset (deh) - 1;
+ if (deh_offset(deh) <= DOT_DOT_OFFSET) {
+ break;
+ }
- if (!de_visible (deh))
- /* it is hidden entry */
- continue;
+ /* look for the previous entry in the directory */
+ next_pos = deh_offset(deh) - 1;
- d_reclen = entry_length(bh, ih, entry_num);
- d_name = B_I_DEH_ENTRY_FILE_NAME (bh, ih, deh);
- d_off = deh_offset (deh);
- d_ino = deh_objectid (deh);
+ if (!de_visible(deh))
+ /* it is hidden entry */
+ continue;
- if (!d_name[d_reclen - 1])
- d_reclen = strlen (d_name);
+ d_reclen = entry_length(bh, ih, entry_num);
+ d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
+ d_off = deh_offset(deh);
+ d_ino = deh_objectid(deh);
- if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)){
- /* too big to send back to VFS */
- continue ;
- }
+ if (!d_name[d_reclen - 1])
+ d_reclen = strlen(d_name);
- /* Ignore the .reiserfs_priv entry */
- if (reiserfs_xattrs (inode->i_sb) &&
- !old_format_only(inode->i_sb) &&
- deh_objectid (deh) == le32_to_cpu (INODE_PKEY(REISERFS_SB(inode->i_sb)->priv_root->d_inode)->k_objectid))
- continue;
+ if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)) {
+ /* too big to send back to VFS */
+ continue;
+ }
- if (d_reclen <= 32) {
- local_buf = small_buf ;
- } else {
- local_buf = reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb) ;
- if (!local_buf) {
- pathrelse (&path_to_entry);
- return -ENOMEM ;
- }
- if (item_moved (&tmp_ih, &path_to_entry)) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
-
- /* sigh, must retry. Do this same offset again */
- next_pos = d_off;
- goto research;
- }
- }
+ /* Ignore the .reiserfs_priv entry */
+ if (reiserfs_xattrs(inode->i_sb) &&
+ !old_format_only(inode->i_sb) &&
+ deh_objectid(deh) ==
+ le32_to_cpu(INODE_PKEY
+ (REISERFS_SB(inode->i_sb)->priv_root->d_inode)->
+ k_objectid))
+ continue;
+
+ if (d_reclen <= 32) {
+ local_buf = small_buf;
+ } else {
+ local_buf =
+ reiserfs_kmalloc(d_reclen, GFP_NOFS, inode->i_sb);
+ if (!local_buf) {
+ pathrelse(&path_to_entry);
+ return -ENOMEM;
+ }
+ if (item_moved(&tmp_ih, &path_to_entry)) {
+ reiserfs_kfree(local_buf, d_reclen,
+ inode->i_sb);
+
+ /* sigh, must retry. Do this same offset again */
+ next_pos = d_off;
+ goto research;
+ }
+ }
- // Note, that we copy name to user space via temporary
- // buffer (local_buf) because filldir will block if
- // user space buffer is swapped out. At that time
- // entry can move to somewhere else
- memcpy (local_buf, d_name, d_reclen);
+ // Note, that we copy name to user space via temporary
+ // buffer (local_buf) because filldir will block if
+ // user space buffer is swapped out. At that time
+ // entry can move to somewhere else
+ memcpy(local_buf, d_name, d_reclen);
- /* the filldir function might need to start transactions,
- * or do who knows what. Release the path now that we've
- * copied all the important stuff out of the deh
- */
- pathrelse (&path_to_entry);
-
- if (filldir (dirent, local_buf, d_reclen, d_off, d_ino,
- DT_UNKNOWN) < 0) {
- if (local_buf != small_buf) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
- }
- goto end;
- }
- if (local_buf != small_buf) {
- reiserfs_kfree(local_buf, d_reclen, inode->i_sb) ;
- }
- } /* while */
+ /* the filldir function might need to start transactions,
+ * or do who knows what. Release the path now that we've
+ * copied all the important stuff out of the deh
+ */
+ pathrelse(&path_to_entry);
+
+ if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
+ DT_UNKNOWN) < 0) {
+ if (local_buf != small_buf) {
+ reiserfs_kfree(local_buf, d_reclen,
+ inode->i_sb);
+ }
+ goto end;
+ }
+ if (local_buf != small_buf) {
+ reiserfs_kfree(local_buf, d_reclen, inode->i_sb);
+ }
+ } /* while */
-end:
- pathrelse (&path_to_entry);
- return 0;
+ end:
+ pathrelse(&path_to_entry);
+ return 0;
}
/*
@@ -417,63 +423,59 @@ end:
static
int xattr_readdir(struct file *file, filldir_t filler, void *buf)
{
- struct inode *inode = file->f_dentry->d_inode;
- int res = -ENOTDIR;
- if (!file->f_op || !file->f_op->readdir)
- goto out;
- down(&inode->i_sem);
+ struct inode *inode = file->f_dentry->d_inode;
+ int res = -ENOTDIR;
+ if (!file->f_op || !file->f_op->readdir)
+ goto out;
+ down(&inode->i_sem);
// down(&inode->i_zombie);
- res = -ENOENT;
- if (!IS_DEADDIR(inode)) {
- lock_kernel();
- res = __xattr_readdir(file, buf, filler);
- unlock_kernel();
- }
+ res = -ENOENT;
+ if (!IS_DEADDIR(inode)) {
+ lock_kernel();
+ res = __xattr_readdir(file, buf, filler);
+ unlock_kernel();
+ }
// up(&inode->i_zombie);
- up(&inode->i_sem);
-out:
- return res;
+ up(&inode->i_sem);
+ out:
+ return res;
}
-
/* Internal operations on file data */
-static inline void
-reiserfs_put_page(struct page *page)
+static inline void reiserfs_put_page(struct page *page)
{
- kunmap(page);
- page_cache_release(page);
+ kunmap(page);
+ page_cache_release(page);
}
-static struct page *
-reiserfs_get_page(struct inode *dir, unsigned long n)
+static struct page *reiserfs_get_page(struct inode *dir, unsigned long n)
{
- struct address_space *mapping = dir->i_mapping;
- struct page *page;
- /* We can deadlock if we try to free dentries,
- and an unlink/rmdir has just occured - GFP_NOFS avoids this */
- mapping->flags = (mapping->flags & ~__GFP_BITS_MASK) | GFP_NOFS;
- page = read_cache_page (mapping, n,
- (filler_t*)mapping->a_ops->readpage, NULL);
- if (!IS_ERR(page)) {
- wait_on_page_locked(page);
- kmap(page);
- if (!PageUptodate(page))
- goto fail;
-
- if (PageError(page))
- goto fail;
- }
- return page;
-
-fail:
- reiserfs_put_page(page);
- return ERR_PTR(-EIO);
+ struct address_space *mapping = dir->i_mapping;
+ struct page *page;
+ /* We can deadlock if we try to free dentries,
+ and an unlink/rmdir has just occured - GFP_NOFS avoids this */
+ mapping->flags = (mapping->flags & ~__GFP_BITS_MASK) | GFP_NOFS;
+ page = read_cache_page(mapping, n,
+ (filler_t *) mapping->a_ops->readpage, NULL);
+ if (!IS_ERR(page)) {
+ wait_on_page_locked(page);
+ kmap(page);
+ if (!PageUptodate(page))
+ goto fail;
+
+ if (PageError(page))
+ goto fail;
+ }
+ return page;
+
+ fail:
+ reiserfs_put_page(page);
+ return ERR_PTR(-EIO);
}
-static inline __u32
-xattr_hash (const char *msg, int len)
+static inline __u32 xattr_hash(const char *msg, int len)
{
- return csum_partial (msg, len, 0);
+ return csum_partial(msg, len, 0);
}
/* Generic extended attribute operations that can be used by xa plugins */
@@ -482,294 +484,300 @@ xattr_hash (const char *msg, int len)
* inode->i_sem: down
*/
int
-reiserfs_xattr_set (struct inode *inode, const char *name, const void *buffer,
- size_t buffer_size, int flags)
+reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
+ size_t buffer_size, int flags)
{
- int err = 0;
- struct file *fp;
- struct page *page;
- char *data;
- struct address_space *mapping;
- size_t file_pos = 0;
- size_t buffer_pos = 0;
- struct inode *xinode;
- struct iattr newattrs;
- __u32 xahash = 0;
-
- if (IS_RDONLY (inode))
- return -EROFS;
-
- if (IS_IMMUTABLE (inode) || IS_APPEND (inode))
- return -EPERM;
-
- if (get_inode_sd_version (inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
-
- /* Empty xattrs are ok, they're just empty files, no hash */
- if (buffer && buffer_size)
- xahash = xattr_hash (buffer, buffer_size);
-
-open_file:
- fp = open_xa_file (inode, name, flags);
- if (IS_ERR (fp)) {
- err = PTR_ERR (fp);
- goto out;
- }
-
- xinode = fp->f_dentry->d_inode;
- REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
-
- /* we need to copy it off.. */
- if (xinode->i_nlink > 1) {
- fput(fp);
- err = reiserfs_xattr_del (inode, name);
- if (err < 0)
- goto out;
- /* We just killed the old one, we're not replacing anymore */
- if (flags & XATTR_REPLACE)
- flags &= ~XATTR_REPLACE;
- goto open_file;
- }
-
- /* Resize it so we're ok to write there */
- newattrs.ia_size = buffer_size;
- newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
- down (&xinode->i_sem);
- err = notify_change(fp->f_dentry, &newattrs);
- if (err)
- goto out_filp;
-
- mapping = xinode->i_mapping;
- while (buffer_pos < buffer_size || buffer_pos == 0) {
- size_t chunk;
- size_t skip = 0;
- size_t page_offset = (file_pos & (PAGE_CACHE_SIZE - 1));
- if (buffer_size - buffer_pos > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE;
- else
- chunk = buffer_size - buffer_pos;
-
- page = reiserfs_get_page (xinode, file_pos >> PAGE_CACHE_SHIFT);
- if (IS_ERR (page)) {
- err = PTR_ERR (page);
- goto out_filp;
- }
-
- lock_page (page);
- data = page_address (page);
-
- if (file_pos == 0) {
- struct reiserfs_xattr_header *rxh;
- skip = file_pos = sizeof (struct reiserfs_xattr_header);
- if (chunk + skip > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE - skip;
- rxh = (struct reiserfs_xattr_header *)data;
- rxh->h_magic = cpu_to_le32 (REISERFS_XATTR_MAGIC);
- rxh->h_hash = cpu_to_le32 (xahash);
- }
-
- err = mapping->a_ops->prepare_write (fp, page, page_offset,
- page_offset + chunk + skip);
- if (!err) {
- if (buffer)
- memcpy (data + skip, buffer + buffer_pos, chunk);
- err = mapping->a_ops->commit_write (fp, page, page_offset,
- page_offset + chunk + skip);
+ int err = 0;
+ struct file *fp;
+ struct page *page;
+ char *data;
+ struct address_space *mapping;
+ size_t file_pos = 0;
+ size_t buffer_pos = 0;
+ struct inode *xinode;
+ struct iattr newattrs;
+ __u32 xahash = 0;
+
+ if (IS_RDONLY(inode))
+ return -EROFS;
+
+ if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
+ return -EPERM;
+
+ if (get_inode_sd_version(inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
+
+ /* Empty xattrs are ok, they're just empty files, no hash */
+ if (buffer && buffer_size)
+ xahash = xattr_hash(buffer, buffer_size);
+
+ open_file:
+ fp = open_xa_file(inode, name, flags);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ goto out;
+ }
+
+ xinode = fp->f_dentry->d_inode;
+ REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+
+ /* we need to copy it off.. */
+ if (xinode->i_nlink > 1) {
+ fput(fp);
+ err = reiserfs_xattr_del(inode, name);
+ if (err < 0)
+ goto out;
+ /* We just killed the old one, we're not replacing anymore */
+ if (flags & XATTR_REPLACE)
+ flags &= ~XATTR_REPLACE;
+ goto open_file;
+ }
+
+ /* Resize it so we're ok to write there */
+ newattrs.ia_size = buffer_size;
+ newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+ down(&xinode->i_sem);
+ err = notify_change(fp->f_dentry, &newattrs);
+ if (err)
+ goto out_filp;
+
+ mapping = xinode->i_mapping;
+ while (buffer_pos < buffer_size || buffer_pos == 0) {
+ size_t chunk;
+ size_t skip = 0;
+ size_t page_offset = (file_pos & (PAGE_CACHE_SIZE - 1));
+ if (buffer_size - buffer_pos > PAGE_CACHE_SIZE)
+ chunk = PAGE_CACHE_SIZE;
+ else
+ chunk = buffer_size - buffer_pos;
+
+ page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ if (IS_ERR(page)) {
+ err = PTR_ERR(page);
+ goto out_filp;
+ }
+
+ lock_page(page);
+ data = page_address(page);
+
+ if (file_pos == 0) {
+ struct reiserfs_xattr_header *rxh;
+ skip = file_pos = sizeof(struct reiserfs_xattr_header);
+ if (chunk + skip > PAGE_CACHE_SIZE)
+ chunk = PAGE_CACHE_SIZE - skip;
+ rxh = (struct reiserfs_xattr_header *)data;
+ rxh->h_magic = cpu_to_le32(REISERFS_XATTR_MAGIC);
+ rxh->h_hash = cpu_to_le32(xahash);
+ }
+
+ err = mapping->a_ops->prepare_write(fp, page, page_offset,
+ page_offset + chunk + skip);
+ if (!err) {
+ if (buffer)
+ memcpy(data + skip, buffer + buffer_pos, chunk);
+ err =
+ mapping->a_ops->commit_write(fp, page, page_offset,
+ page_offset + chunk +
+ skip);
+ }
+ unlock_page(page);
+ reiserfs_put_page(page);
+ buffer_pos += chunk;
+ file_pos += chunk;
+ skip = 0;
+ if (err || buffer_size == 0 || !buffer)
+ break;
+ }
+
+ /* We can't mark the inode dirty if it's not hashed. This is the case
+ * when we're inheriting the default ACL. If we dirty it, the inode
+ * gets marked dirty, but won't (ever) make it onto the dirty list until
+ * it's synced explicitly to clear I_DIRTY. This is bad. */
+ if (!hlist_unhashed(&inode->i_hash)) {
+ inode->i_ctime = CURRENT_TIME_SEC;
+ mark_inode_dirty(inode);
}
- unlock_page (page);
- reiserfs_put_page (page);
- buffer_pos += chunk;
- file_pos += chunk;
- skip = 0;
- if (err || buffer_size == 0 || !buffer)
- break;
- }
-
- /* We can't mark the inode dirty if it's not hashed. This is the case
- * when we're inheriting the default ACL. If we dirty it, the inode
- * gets marked dirty, but won't (ever) make it onto the dirty list until
- * it's synced explicitly to clear I_DIRTY. This is bad. */
- if (!hlist_unhashed(&inode->i_hash)) {
- inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty (inode);
- }
-
-out_filp:
- up (&xinode->i_sem);
- fput(fp);
-
-out:
- return err;
+
+ out_filp:
+ up(&xinode->i_sem);
+ fput(fp);
+
+ out:
+ return err;
}
/*
* inode->i_sem: down
*/
int
-reiserfs_xattr_get (const struct inode *inode, const char *name, void *buffer,
- size_t buffer_size)
+reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
+ size_t buffer_size)
{
- ssize_t err = 0;
- struct file *fp;
- size_t isize;
- size_t file_pos = 0;
- size_t buffer_pos = 0;
- struct page *page;
- struct inode *xinode;
- __u32 hash = 0;
-
- if (name == NULL)
- return -EINVAL;
-
- /* We can't have xattrs attached to v1 items since they don't have
- * generation numbers */
- if (get_inode_sd_version (inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
-
- fp = open_xa_file (inode, name, FL_READONLY);
- if (IS_ERR (fp)) {
- err = PTR_ERR (fp);
- goto out;
- }
-
- xinode = fp->f_dentry->d_inode;
- isize = xinode->i_size;
- REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
-
- /* Just return the size needed */
- if (buffer == NULL) {
- err = isize - sizeof (struct reiserfs_xattr_header);
- goto out_dput;
- }
-
- if (buffer_size < isize - sizeof (struct reiserfs_xattr_header)) {
- err = -ERANGE;
- goto out_dput;
- }
-
- while (file_pos < isize) {
- size_t chunk;
- char *data;
- size_t skip = 0;
- if (isize - file_pos > PAGE_CACHE_SIZE)
- chunk = PAGE_CACHE_SIZE;
- else
- chunk = isize - file_pos;
-
- page = reiserfs_get_page (xinode, file_pos >> PAGE_CACHE_SHIFT);
- if (IS_ERR (page)) {
- err = PTR_ERR (page);
- goto out_dput;
- }
-
- lock_page (page);
- data = page_address (page);
- if (file_pos == 0) {
- struct reiserfs_xattr_header *rxh =
- (struct reiserfs_xattr_header *)data;
- skip = file_pos = sizeof (struct reiserfs_xattr_header);
- chunk -= skip;
- /* Magic doesn't match up.. */
- if (rxh->h_magic != cpu_to_le32 (REISERFS_XATTR_MAGIC)) {
- unlock_page (page);
- reiserfs_put_page (page);
- reiserfs_warning (inode->i_sb, "Invalid magic for xattr (%s) "
- "associated with %k", name,
- INODE_PKEY (inode));
- err = -EIO;
- goto out_dput;
- }
- hash = le32_to_cpu (rxh->h_hash);
- }
- memcpy (buffer + buffer_pos, data + skip, chunk);
- unlock_page (page);
- reiserfs_put_page (page);
- file_pos += chunk;
- buffer_pos += chunk;
- skip = 0;
- }
- err = isize - sizeof (struct reiserfs_xattr_header);
-
- if (xattr_hash (buffer, isize - sizeof (struct reiserfs_xattr_header)) != hash) {
- reiserfs_warning (inode->i_sb, "Invalid hash for xattr (%s) associated "
- "with %k", name, INODE_PKEY (inode));
- err = -EIO;
- }
-
-out_dput:
- fput(fp);
-
-out:
- return err;
+ ssize_t err = 0;
+ struct file *fp;
+ size_t isize;
+ size_t file_pos = 0;
+ size_t buffer_pos = 0;
+ struct page *page;
+ struct inode *xinode;
+ __u32 hash = 0;
+
+ if (name == NULL)
+ return -EINVAL;
+
+ /* We can't have xattrs attached to v1 items since they don't have
+ * generation numbers */
+ if (get_inode_sd_version(inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
+
+ fp = open_xa_file(inode, name, FL_READONLY);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ goto out;
+ }
+
+ xinode = fp->f_dentry->d_inode;
+ isize = xinode->i_size;
+ REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+
+ /* Just return the size needed */
+ if (buffer == NULL) {
+ err = isize - sizeof(struct reiserfs_xattr_header);
+ goto out_dput;
+ }
+
+ if (buffer_size < isize - sizeof(struct reiserfs_xattr_header)) {
+ err = -ERANGE;
+ goto out_dput;
+ }
+
+ while (file_pos < isize) {
+ size_t chunk;
+ char *data;
+ size_t skip = 0;
+ if (isize - file_pos > PAGE_CACHE_SIZE)
+ chunk = PAGE_CACHE_SIZE;
+ else
+ chunk = isize - file_pos;
+
+ page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
+ if (IS_ERR(page)) {
+ err = PTR_ERR(page);
+ goto out_dput;
+ }
+
+ lock_page(page);
+ data = page_address(page);
+ if (file_pos == 0) {
+ struct reiserfs_xattr_header *rxh =
+ (struct reiserfs_xattr_header *)data;
+ skip = file_pos = sizeof(struct reiserfs_xattr_header);
+ chunk -= skip;
+ /* Magic doesn't match up.. */
+ if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
+ unlock_page(page);
+ reiserfs_put_page(page);
+ reiserfs_warning(inode->i_sb,
+ "Invalid magic for xattr (%s) "
+ "associated with %k", name,
+ INODE_PKEY(inode));
+ err = -EIO;
+ goto out_dput;
+ }
+ hash = le32_to_cpu(rxh->h_hash);
+ }
+ memcpy(buffer + buffer_pos, data + skip, chunk);
+ unlock_page(page);
+ reiserfs_put_page(page);
+ file_pos += chunk;
+ buffer_pos += chunk;
+ skip = 0;
+ }
+ err = isize - sizeof(struct reiserfs_xattr_header);
+
+ if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
+ hash) {
+ reiserfs_warning(inode->i_sb,
+ "Invalid hash for xattr (%s) associated "
+ "with %k", name, INODE_PKEY(inode));
+ err = -EIO;
+ }
+
+ out_dput:
+ fput(fp);
+
+ out:
+ return err;
}
static int
-__reiserfs_xattr_del (struct dentry *xadir, const char *name, int namelen)
+__reiserfs_xattr_del(struct dentry *xadir, const char *name, int namelen)
{
- struct dentry *dentry;
- struct inode *dir = xadir->d_inode;
- int err = 0;
-
- dentry = lookup_one_len (name, xadir, namelen);
- if (IS_ERR (dentry)) {
- err = PTR_ERR (dentry);
- goto out;
- } else if (!dentry->d_inode) {
- err = -ENODATA;
- goto out_file;
- }
-
- /* Skip directories.. */
- if (S_ISDIR (dentry->d_inode->i_mode))
- goto out_file;
-
- if (!is_reiserfs_priv_object (dentry->d_inode)) {
- reiserfs_warning (dir->i_sb, "OID %08x [%.*s/%.*s] doesn't have "
- "priv flag set [parent is %sset].",
- le32_to_cpu (INODE_PKEY (dentry->d_inode)->k_objectid),
- xadir->d_name.len, xadir->d_name.name, namelen, name,
- is_reiserfs_priv_object (xadir->d_inode) ? "" : "not ");
- dput (dentry);
- return -EIO;
- }
-
- err = dir->i_op->unlink (dir, dentry);
- if (!err)
- d_delete (dentry);
-
-out_file:
- dput (dentry);
-
-out:
- return err;
-}
+ struct dentry *dentry;
+ struct inode *dir = xadir->d_inode;
+ int err = 0;
+
+ dentry = lookup_one_len(name, xadir, namelen);
+ if (IS_ERR(dentry)) {
+ err = PTR_ERR(dentry);
+ goto out;
+ } else if (!dentry->d_inode) {
+ err = -ENODATA;
+ goto out_file;
+ }
+
+ /* Skip directories.. */
+ if (S_ISDIR(dentry->d_inode->i_mode))
+ goto out_file;
+
+ if (!is_reiserfs_priv_object(dentry->d_inode)) {
+ reiserfs_warning(dir->i_sb, "OID %08x [%.*s/%.*s] doesn't have "
+ "priv flag set [parent is %sset].",
+ le32_to_cpu(INODE_PKEY(dentry->d_inode)->
+ k_objectid), xadir->d_name.len,
+ xadir->d_name.name, namelen, name,
+ is_reiserfs_priv_object(xadir->
+ d_inode) ? "" :
+ "not ");
+ dput(dentry);
+ return -EIO;
+ }
+ err = dir->i_op->unlink(dir, dentry);
+ if (!err)
+ d_delete(dentry);
-int
-reiserfs_xattr_del (struct inode *inode, const char *name)
+ out_file:
+ dput(dentry);
+
+ out:
+ return err;
+}
+
+int reiserfs_xattr_del(struct inode *inode, const char *name)
{
- struct dentry *dir;
- int err;
+ struct dentry *dir;
+ int err;
- if (IS_RDONLY (inode))
- return -EROFS;
+ if (IS_RDONLY(inode))
+ return -EROFS;
- dir = open_xa_dir (inode, FL_READONLY);
- if (IS_ERR (dir)) {
- err = PTR_ERR (dir);
- goto out;
- }
+ dir = open_xa_dir(inode, FL_READONLY);
+ if (IS_ERR(dir)) {
+ err = PTR_ERR(dir);
+ goto out;
+ }
- err = __reiserfs_xattr_del (dir, name, strlen (name));
- dput (dir);
+ err = __reiserfs_xattr_del(dir, name, strlen(name));
+ dput(dir);
- if (!err) {
- inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty (inode);
- }
+ if (!err) {
+ inode->i_ctime = CURRENT_TIME_SEC;
+ mark_inode_dirty(inode);
+ }
-out:
- return err;
+ out:
+ return err;
}
/* The following are side effects of other operations that aren't explicitly
@@ -777,167 +785,163 @@ out:
* or ownership changes, object deletions, etc. */
static int
-reiserfs_delete_xattrs_filler (void *buf, const char *name, int namelen,
- loff_t offset, ino_t ino, unsigned int d_type)
+reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
+ loff_t offset, ino_t ino, unsigned int d_type)
{
- struct dentry *xadir = (struct dentry *)buf;
+ struct dentry *xadir = (struct dentry *)buf;
- return __reiserfs_xattr_del (xadir, name, namelen);
+ return __reiserfs_xattr_del(xadir, name, namelen);
}
/* This is called w/ inode->i_sem downed */
-int
-reiserfs_delete_xattrs (struct inode *inode)
+int reiserfs_delete_xattrs(struct inode *inode)
{
- struct file *fp;
- struct dentry *dir, *root;
- int err = 0;
-
- /* Skip out, an xattr has no xattrs associated with it */
- if (is_reiserfs_priv_object (inode) ||
- get_inode_sd_version (inode) == STAT_DATA_V1 ||
- !reiserfs_xattrs(inode->i_sb))
- {
- return 0;
- }
- reiserfs_read_lock_xattrs (inode->i_sb);
- dir = open_xa_dir (inode, FL_READONLY);
- reiserfs_read_unlock_xattrs (inode->i_sb);
- if (IS_ERR (dir)) {
- err = PTR_ERR (dir);
- goto out;
- } else if (!dir->d_inode) {
- dput (dir);
- return 0;
- }
-
- fp = dentry_open (dir, NULL, O_RDWR);
- if (IS_ERR (fp)) {
- err = PTR_ERR (fp);
- /* dentry_open dputs the dentry if it fails */
- goto out;
- }
-
- lock_kernel ();
- err = xattr_readdir (fp, reiserfs_delete_xattrs_filler, dir);
- if (err) {
- unlock_kernel ();
- goto out_dir;
- }
-
- /* Leftovers besides . and .. -- that's not good. */
- if (dir->d_inode->i_nlink <= 2) {
- root = get_xa_root (inode->i_sb);
- reiserfs_write_lock_xattrs (inode->i_sb);
- err = vfs_rmdir (root->d_inode, dir);
- reiserfs_write_unlock_xattrs (inode->i_sb);
- dput (root);
- } else {
- reiserfs_warning (inode->i_sb,
- "Couldn't remove all entries in directory");
- }
- unlock_kernel ();
-
-out_dir:
- fput(fp);
-
-out:
- if (!err)
- REISERFS_I(inode)->i_flags = REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
- return err;
+ struct file *fp;
+ struct dentry *dir, *root;
+ int err = 0;
+
+ /* Skip out, an xattr has no xattrs associated with it */
+ if (is_reiserfs_priv_object(inode) ||
+ get_inode_sd_version(inode) == STAT_DATA_V1 ||
+ !reiserfs_xattrs(inode->i_sb)) {
+ return 0;
+ }
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ dir = open_xa_dir(inode, FL_READONLY);
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ if (IS_ERR(dir)) {
+ err = PTR_ERR(dir);
+ goto out;
+ } else if (!dir->d_inode) {
+ dput(dir);
+ return 0;
+ }
+
+ fp = dentry_open(dir, NULL, O_RDWR);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ /* dentry_open dputs the dentry if it fails */
+ goto out;
+ }
+
+ lock_kernel();
+ err = xattr_readdir(fp, reiserfs_delete_xattrs_filler, dir);
+ if (err) {
+ unlock_kernel();
+ goto out_dir;
+ }
+
+ /* Leftovers besides . and .. -- that's not good. */
+ if (dir->d_inode->i_nlink <= 2) {
+ root = get_xa_root(inode->i_sb);
+ reiserfs_write_lock_xattrs(inode->i_sb);
+ err = vfs_rmdir(root->d_inode, dir);
+ reiserfs_write_unlock_xattrs(inode->i_sb);
+ dput(root);
+ } else {
+ reiserfs_warning(inode->i_sb,
+ "Couldn't remove all entries in directory");
+ }
+ unlock_kernel();
+
+ out_dir:
+ fput(fp);
+
+ out:
+ if (!err)
+ REISERFS_I(inode)->i_flags =
+ REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
+ return err;
}
struct reiserfs_chown_buf {
- struct inode *inode;
- struct dentry *xadir;
- struct iattr *attrs;
+ struct inode *inode;
+ struct dentry *xadir;
+ struct iattr *attrs;
};
/* XXX: If there is a better way to do this, I'd love to hear about it */
static int
-reiserfs_chown_xattrs_filler (void *buf, const char *name, int namelen,
- loff_t offset, ino_t ino, unsigned int d_type)
+reiserfs_chown_xattrs_filler(void *buf, const char *name, int namelen,
+ loff_t offset, ino_t ino, unsigned int d_type)
{
- struct reiserfs_chown_buf *chown_buf = (struct reiserfs_chown_buf *)buf;
- struct dentry *xafile, *xadir = chown_buf->xadir;
- struct iattr *attrs = chown_buf->attrs;
- int err = 0;
-
- xafile = lookup_one_len (name, xadir, namelen);
- if (IS_ERR (xafile))
- return PTR_ERR (xafile);
- else if (!xafile->d_inode) {
- dput (xafile);
- return -ENODATA;
- }
-
- if (!S_ISDIR (xafile->d_inode->i_mode))
- err = notify_change (xafile, attrs);
- dput (xafile);
-
- return err;
+ struct reiserfs_chown_buf *chown_buf = (struct reiserfs_chown_buf *)buf;
+ struct dentry *xafile, *xadir = chown_buf->xadir;
+ struct iattr *attrs = chown_buf->attrs;
+ int err = 0;
+
+ xafile = lookup_one_len(name, xadir, namelen);
+ if (IS_ERR(xafile))
+ return PTR_ERR(xafile);
+ else if (!xafile->d_inode) {
+ dput(xafile);
+ return -ENODATA;
+ }
+
+ if (!S_ISDIR(xafile->d_inode->i_mode))
+ err = notify_change(xafile, attrs);
+ dput(xafile);
+
+ return err;
}
-int
-reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs)
+int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
{
- struct file *fp;
- struct dentry *dir;
- int err = 0;
- struct reiserfs_chown_buf buf;
- unsigned int ia_valid = attrs->ia_valid;
-
- /* Skip out, an xattr has no xattrs associated with it */
- if (is_reiserfs_priv_object (inode) ||
- get_inode_sd_version (inode) == STAT_DATA_V1 ||
- !reiserfs_xattrs(inode->i_sb))
- {
- return 0;
- }
- reiserfs_read_lock_xattrs (inode->i_sb);
- dir = open_xa_dir (inode, FL_READONLY);
- reiserfs_read_unlock_xattrs (inode->i_sb);
- if (IS_ERR (dir)) {
- if (PTR_ERR (dir) != -ENODATA)
- err = PTR_ERR (dir);
- goto out;
- } else if (!dir->d_inode) {
- dput (dir);
- goto out;
- }
-
- fp = dentry_open (dir, NULL, O_RDWR);
- if (IS_ERR (fp)) {
- err = PTR_ERR (fp);
- /* dentry_open dputs the dentry if it fails */
- goto out;
- }
-
- lock_kernel ();
-
- attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
- buf.xadir = dir;
- buf.attrs = attrs;
- buf.inode = inode;
-
- err = xattr_readdir (fp, reiserfs_chown_xattrs_filler, &buf);
- if (err) {
- unlock_kernel ();
- goto out_dir;
- }
-
- err = notify_change (dir, attrs);
- unlock_kernel ();
-
-out_dir:
- fput(fp);
-
-out:
- attrs->ia_valid = ia_valid;
- return err;
-}
+ struct file *fp;
+ struct dentry *dir;
+ int err = 0;
+ struct reiserfs_chown_buf buf;
+ unsigned int ia_valid = attrs->ia_valid;
+
+ /* Skip out, an xattr has no xattrs associated with it */
+ if (is_reiserfs_priv_object(inode) ||
+ get_inode_sd_version(inode) == STAT_DATA_V1 ||
+ !reiserfs_xattrs(inode->i_sb)) {
+ return 0;
+ }
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ dir = open_xa_dir(inode, FL_READONLY);
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ if (IS_ERR(dir)) {
+ if (PTR_ERR(dir) != -ENODATA)
+ err = PTR_ERR(dir);
+ goto out;
+ } else if (!dir->d_inode) {
+ dput(dir);
+ goto out;
+ }
+
+ fp = dentry_open(dir, NULL, O_RDWR);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ /* dentry_open dputs the dentry if it fails */
+ goto out;
+ }
+ lock_kernel();
+
+ attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
+ buf.xadir = dir;
+ buf.attrs = attrs;
+ buf.inode = inode;
+
+ err = xattr_readdir(fp, reiserfs_chown_xattrs_filler, &buf);
+ if (err) {
+ unlock_kernel();
+ goto out_dir;
+ }
+
+ err = notify_change(dir, attrs);
+ unlock_kernel();
+
+ out_dir:
+ fput(fp);
+
+ out:
+ attrs->ia_valid = ia_valid;
+ return err;
+}
/* Actual operations that are exported to VFS-land */
@@ -946,61 +950,60 @@ out:
* Preliminary locking: we down dentry->d_inode->i_sem
*/
ssize_t
-reiserfs_getxattr (struct dentry *dentry, const char *name, void *buffer,
- size_t size)
+reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
+ size_t size)
{
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix (name);
- int err;
-
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version (dentry->d_inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
-
- reiserfs_read_lock_xattr_i (dentry->d_inode);
- reiserfs_read_lock_xattrs (dentry->d_sb);
- err = xah->get (dentry->d_inode, name, buffer, size);
- reiserfs_read_unlock_xattrs (dentry->d_sb);
- reiserfs_read_unlock_xattr_i (dentry->d_inode);
- return err;
+ struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
+ int err;
+
+ if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
+ get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
+
+ reiserfs_read_lock_xattr_i(dentry->d_inode);
+ reiserfs_read_lock_xattrs(dentry->d_sb);
+ err = xah->get(dentry->d_inode, name, buffer, size);
+ reiserfs_read_unlock_xattrs(dentry->d_sb);
+ reiserfs_read_unlock_xattr_i(dentry->d_inode);
+ return err;
}
-
/*
* Inode operation setxattr()
*
* dentry->d_inode->i_sem down
*/
int
-reiserfs_setxattr (struct dentry *dentry, const char *name, const void *value,
- size_t size, int flags)
+reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
+ size_t size, int flags)
{
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix (name);
- int err;
- int lock;
-
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version (dentry->d_inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
-
- if (IS_RDONLY (dentry->d_inode))
- return -EROFS;
-
- if (IS_IMMUTABLE (dentry->d_inode) || IS_APPEND (dentry->d_inode))
- return -EROFS;
-
- reiserfs_write_lock_xattr_i (dentry->d_inode);
- lock = !has_xattr_dir (dentry->d_inode);
- if (lock)
- reiserfs_write_lock_xattrs (dentry->d_sb);
- else
- reiserfs_read_lock_xattrs (dentry->d_sb);
- err = xah->set (dentry->d_inode, name, value, size, flags);
- if (lock)
- reiserfs_write_unlock_xattrs (dentry->d_sb);
- else
- reiserfs_read_unlock_xattrs (dentry->d_sb);
- reiserfs_write_unlock_xattr_i (dentry->d_inode);
- return err;
+ struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
+ int err;
+ int lock;
+
+ if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
+ get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
+
+ if (IS_RDONLY(dentry->d_inode))
+ return -EROFS;
+
+ if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode))
+ return -EROFS;
+
+ reiserfs_write_lock_xattr_i(dentry->d_inode);
+ lock = !has_xattr_dir(dentry->d_inode);
+ if (lock)
+ reiserfs_write_lock_xattrs(dentry->d_sb);
+ else
+ reiserfs_read_lock_xattrs(dentry->d_sb);
+ err = xah->set(dentry->d_inode, name, value, size, flags);
+ if (lock)
+ reiserfs_write_unlock_xattrs(dentry->d_sb);
+ else
+ reiserfs_read_unlock_xattrs(dentry->d_sb);
+ reiserfs_write_unlock_xattr_i(dentry->d_inode);
+ return err;
}
/*
@@ -1008,344 +1011,343 @@ reiserfs_setxattr (struct dentry *dentry, const char *name, const void *value,
*
* dentry->d_inode->i_sem down
*/
-int
-reiserfs_removexattr (struct dentry *dentry, const char *name)
+int reiserfs_removexattr(struct dentry *dentry, const char *name)
{
- int err;
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix (name);
+ int err;
+ struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version (dentry->d_inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
+ if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
+ get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
- if (IS_RDONLY (dentry->d_inode))
- return -EROFS;
+ if (IS_RDONLY(dentry->d_inode))
+ return -EROFS;
- if (IS_IMMUTABLE (dentry->d_inode) || IS_APPEND (dentry->d_inode))
- return -EPERM;
+ if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode))
+ return -EPERM;
- reiserfs_write_lock_xattr_i (dentry->d_inode);
- reiserfs_read_lock_xattrs (dentry->d_sb);
+ reiserfs_write_lock_xattr_i(dentry->d_inode);
+ reiserfs_read_lock_xattrs(dentry->d_sb);
- /* Deletion pre-operation */
- if (xah->del) {
- err = xah->del (dentry->d_inode, name);
- if (err)
- goto out;
- }
+ /* Deletion pre-operation */
+ if (xah->del) {
+ err = xah->del(dentry->d_inode, name);
+ if (err)
+ goto out;
+ }
- err = reiserfs_xattr_del (dentry->d_inode, name);
+ err = reiserfs_xattr_del(dentry->d_inode, name);
- dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty (dentry->d_inode);
+ dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
+ mark_inode_dirty(dentry->d_inode);
-out:
- reiserfs_read_unlock_xattrs (dentry->d_sb);
- reiserfs_write_unlock_xattr_i (dentry->d_inode);
- return err;
+ out:
+ reiserfs_read_unlock_xattrs(dentry->d_sb);
+ reiserfs_write_unlock_xattr_i(dentry->d_inode);
+ return err;
}
-
/* This is what filldir will use:
* r_pos will always contain the amount of space required for the entire
* list. If r_pos becomes larger than r_size, we need more space and we
* return an error indicating this. If r_pos is less than r_size, then we've
* filled the buffer successfully and we return success */
struct reiserfs_listxattr_buf {
- int r_pos;
- int r_size;
- char *r_buf;
- struct inode *r_inode;
+ int r_pos;
+ int r_size;
+ char *r_buf;
+ struct inode *r_inode;
};
static int
-reiserfs_listxattr_filler (void *buf, const char *name, int namelen,
- loff_t offset, ino_t ino, unsigned int d_type)
+reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
+ loff_t offset, ino_t ino, unsigned int d_type)
{
- struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
- int len = 0;
- if (name[0] != '.' || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix (name);
- if (!xah) return 0; /* Unsupported xattr name, skip it */
-
- /* We call ->list() twice because the operation isn't required to just
- * return the name back - we want to make sure we have enough space */
- len += xah->list (b->r_inode, name, namelen, NULL);
-
- if (len) {
- if (b->r_pos + len + 1 <= b->r_size) {
- char *p = b->r_buf + b->r_pos;
- p += xah->list (b->r_inode, name, namelen, p);
- *p++ = '\0';
- }
- b->r_pos += len + 1;
- }
- }
-
- return 0;
+ struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
+ int len = 0;
+ if (name[0] != '.'
+ || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
+ struct reiserfs_xattr_handler *xah =
+ find_xattr_handler_prefix(name);
+ if (!xah)
+ return 0; /* Unsupported xattr name, skip it */
+
+ /* We call ->list() twice because the operation isn't required to just
+ * return the name back - we want to make sure we have enough space */
+ len += xah->list(b->r_inode, name, namelen, NULL);
+
+ if (len) {
+ if (b->r_pos + len + 1 <= b->r_size) {
+ char *p = b->r_buf + b->r_pos;
+ p += xah->list(b->r_inode, name, namelen, p);
+ *p++ = '\0';
+ }
+ b->r_pos += len + 1;
+ }
+ }
+
+ return 0;
}
+
/*
* Inode operation listxattr()
*
* Preliminary locking: we down dentry->d_inode->i_sem
*/
-ssize_t
-reiserfs_listxattr (struct dentry *dentry, char *buffer, size_t size)
+ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
{
- struct file *fp;
- struct dentry *dir;
- int err = 0;
- struct reiserfs_listxattr_buf buf;
-
- if (!dentry->d_inode)
- return -EINVAL;
-
- if (!reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version (dentry->d_inode) == STAT_DATA_V1)
- return -EOPNOTSUPP;
-
- reiserfs_read_lock_xattr_i (dentry->d_inode);
- reiserfs_read_lock_xattrs (dentry->d_sb);
- dir = open_xa_dir (dentry->d_inode, FL_READONLY);
- reiserfs_read_unlock_xattrs (dentry->d_sb);
- if (IS_ERR (dir)) {
- err = PTR_ERR (dir);
- if (err == -ENODATA)
- err = 0; /* Not an error if there aren't any xattrs */
- goto out;
- }
-
- fp = dentry_open (dir, NULL, O_RDWR);
- if (IS_ERR (fp)) {
- err = PTR_ERR (fp);
- /* dentry_open dputs the dentry if it fails */
- goto out;
- }
-
- buf.r_buf = buffer;
- buf.r_size = buffer ? size : 0;
- buf.r_pos = 0;
- buf.r_inode = dentry->d_inode;
-
- REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
-
- err = xattr_readdir (fp, reiserfs_listxattr_filler, &buf);
- if (err)
- goto out_dir;
-
- if (buf.r_pos > buf.r_size && buffer != NULL)
- err = -ERANGE;
- else
- err = buf.r_pos;
-
-out_dir:
- fput(fp);
-
-out:
- reiserfs_read_unlock_xattr_i (dentry->d_inode);
- return err;
+ struct file *fp;
+ struct dentry *dir;
+ int err = 0;
+ struct reiserfs_listxattr_buf buf;
+
+ if (!dentry->d_inode)
+ return -EINVAL;
+
+ if (!reiserfs_xattrs(dentry->d_sb) ||
+ get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ return -EOPNOTSUPP;
+
+ reiserfs_read_lock_xattr_i(dentry->d_inode);
+ reiserfs_read_lock_xattrs(dentry->d_sb);
+ dir = open_xa_dir(dentry->d_inode, FL_READONLY);
+ reiserfs_read_unlock_xattrs(dentry->d_sb);
+ if (IS_ERR(dir)) {
+ err = PTR_ERR(dir);
+ if (err == -ENODATA)
+ err = 0; /* Not an error if there aren't any xattrs */
+ goto out;
+ }
+
+ fp = dentry_open(dir, NULL, O_RDWR);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ /* dentry_open dputs the dentry if it fails */
+ goto out;
+ }
+
+ buf.r_buf = buffer;
+ buf.r_size = buffer ? size : 0;
+ buf.r_pos = 0;
+ buf.r_inode = dentry->d_inode;
+
+ REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
+
+ err = xattr_readdir(fp, reiserfs_listxattr_filler, &buf);
+ if (err)
+ goto out_dir;
+
+ if (buf.r_pos > buf.r_size && buffer != NULL)
+ err = -ERANGE;
+ else
+ err = buf.r_pos;
+
+ out_dir:
+ fput(fp);
+
+ out:
+ reiserfs_read_unlock_xattr_i(dentry->d_inode);
+ return err;
}
/* This is the implementation for the xattr plugin infrastructure */
-static struct list_head xattr_handlers = LIST_HEAD_INIT (xattr_handlers);
+static struct list_head xattr_handlers = LIST_HEAD_INIT(xattr_handlers);
static DEFINE_RWLOCK(handler_lock);
-static struct reiserfs_xattr_handler *
-find_xattr_handler_prefix (const char *prefix)
+static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
+ *prefix)
{
- struct reiserfs_xattr_handler *xah = NULL;
- struct list_head *p;
-
- read_lock (&handler_lock);
- list_for_each (p, &xattr_handlers) {
- xah = list_entry (p, struct reiserfs_xattr_handler, handlers);
- if (strncmp (xah->prefix, prefix, strlen (xah->prefix)) == 0)
- break;
- xah = NULL;
- }
-
- read_unlock (&handler_lock);
- return xah;
+ struct reiserfs_xattr_handler *xah = NULL;
+ struct list_head *p;
+
+ read_lock(&handler_lock);
+ list_for_each(p, &xattr_handlers) {
+ xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
+ if (strncmp(xah->prefix, prefix, strlen(xah->prefix)) == 0)
+ break;
+ xah = NULL;
+ }
+
+ read_unlock(&handler_lock);
+ return xah;
}
-static void
-__unregister_handlers (void)
+static void __unregister_handlers(void)
{
- struct reiserfs_xattr_handler *xah;
- struct list_head *p, *tmp;
+ struct reiserfs_xattr_handler *xah;
+ struct list_head *p, *tmp;
- list_for_each_safe (p, tmp, &xattr_handlers) {
- xah = list_entry (p, struct reiserfs_xattr_handler, handlers);
- if (xah->exit)
- xah->exit();
+ list_for_each_safe(p, tmp, &xattr_handlers) {
+ xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
+ if (xah->exit)
+ xah->exit();
- list_del_init (p);
- }
- INIT_LIST_HEAD (&xattr_handlers);
+ list_del_init(p);
+ }
+ INIT_LIST_HEAD(&xattr_handlers);
}
-int __init
-reiserfs_xattr_register_handlers (void)
+int __init reiserfs_xattr_register_handlers(void)
{
- int err = 0;
- struct reiserfs_xattr_handler *xah;
- struct list_head *p;
+ int err = 0;
+ struct reiserfs_xattr_handler *xah;
+ struct list_head *p;
- write_lock (&handler_lock);
+ write_lock(&handler_lock);
- /* If we're already initialized, nothing to do */
- if (!list_empty (&xattr_handlers)) {
- write_unlock (&handler_lock);
- return 0;
- }
+ /* If we're already initialized, nothing to do */
+ if (!list_empty(&xattr_handlers)) {
+ write_unlock(&handler_lock);
+ return 0;
+ }
- /* Add the handlers */
- list_add_tail (&user_handler.handlers, &xattr_handlers);
- list_add_tail (&trusted_handler.handlers, &xattr_handlers);
+ /* Add the handlers */
+ list_add_tail(&user_handler.handlers, &xattr_handlers);
+ list_add_tail(&trusted_handler.handlers, &xattr_handlers);
#ifdef CONFIG_REISERFS_FS_SECURITY
- list_add_tail (&security_handler.handlers, &xattr_handlers);
+ list_add_tail(&security_handler.handlers, &xattr_handlers);
#endif
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
- list_add_tail (&posix_acl_access_handler.handlers, &xattr_handlers);
- list_add_tail (&posix_acl_default_handler.handlers, &xattr_handlers);
+ list_add_tail(&posix_acl_access_handler.handlers, &xattr_handlers);
+ list_add_tail(&posix_acl_default_handler.handlers, &xattr_handlers);
#endif
- /* Run initializers, if available */
- list_for_each (p, &xattr_handlers) {
- xah = list_entry (p, struct reiserfs_xattr_handler, handlers);
- if (xah->init) {
- err = xah->init ();
- if (err) {
- list_del_init (p);
- break;
- }
- }
- }
-
- /* Clean up other handlers, if any failed */
- if (err)
- __unregister_handlers ();
-
- write_unlock (&handler_lock);
- return err;
+ /* Run initializers, if available */
+ list_for_each(p, &xattr_handlers) {
+ xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
+ if (xah->init) {
+ err = xah->init();
+ if (err) {
+ list_del_init(p);
+ break;
+ }
+ }
+ }
+
+ /* Clean up other handlers, if any failed */
+ if (err)
+ __unregister_handlers();
+
+ write_unlock(&handler_lock);
+ return err;
}
-void
-reiserfs_xattr_unregister_handlers (void)
+void reiserfs_xattr_unregister_handlers(void)
{
- write_lock (&handler_lock);
- __unregister_handlers ();
- write_unlock (&handler_lock);
+ write_lock(&handler_lock);
+ __unregister_handlers();
+ write_unlock(&handler_lock);
}
/* This will catch lookups from the fs root to .reiserfs_priv */
static int
-xattr_lookup_poison (struct dentry *dentry, struct qstr *q1, struct qstr *name)
+xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
{
- struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root;
- if (name->len == priv_root->d_name.len &&
- name->hash == priv_root->d_name.hash &&
- !memcmp (name->name, priv_root->d_name.name, name->len)) {
- return -ENOENT;
- } else if (q1->len == name->len &&
- !memcmp(q1->name, name->name, name->len))
- return 0;
- return 1;
+ struct dentry *priv_root = REISERFS_SB(dentry->d_sb)->priv_root;
+ if (name->len == priv_root->d_name.len &&
+ name->hash == priv_root->d_name.hash &&
+ !memcmp(name->name, priv_root->d_name.name, name->len)) {
+ return -ENOENT;
+ } else if (q1->len == name->len &&
+ !memcmp(q1->name, name->name, name->len))
+ return 0;
+ return 1;
}
static struct dentry_operations xattr_lookup_poison_ops = {
- .d_compare = xattr_lookup_poison,
+ .d_compare = xattr_lookup_poison,
};
-
/* We need to take a copy of the mount flags since things like
* MS_RDONLY don't get set until *after* we're called.
* mount_flags != mount_options */
-int
-reiserfs_xattr_init (struct super_block *s, int mount_flags)
+int reiserfs_xattr_init(struct super_block *s, int mount_flags)
{
- int err = 0;
-
- /* We need generation numbers to ensure that the oid mapping is correct
- * v3.5 filesystems don't have them. */
- if (!old_format_only (s)) {
- set_bit (REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
- } else if (reiserfs_xattrs_optional (s)) {
- /* Old format filesystem, but optional xattrs have been enabled
- * at mount time. Error out. */
- reiserfs_warning (s, "xattrs/ACLs not supported on pre v3.6 "
- "format filesystem. Failing mount.");
- err = -EOPNOTSUPP;
- goto error;
- } else {
- /* Old format filesystem, but no optional xattrs have been enabled. This
- * means we silently disable xattrs on the filesystem. */
- clear_bit (REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
- }
-
- /* If we don't have the privroot located yet - go find it */
- if (reiserfs_xattrs (s) && !REISERFS_SB(s)->priv_root) {
- struct dentry *dentry;
- dentry = lookup_one_len (PRIVROOT_NAME, s->s_root,
- strlen (PRIVROOT_NAME));
- if (!IS_ERR (dentry)) {
- if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
- struct inode *inode = dentry->d_parent->d_inode;
- down (&inode->i_sem);
- err = inode->i_op->mkdir (inode, dentry, 0700);
- up (&inode->i_sem);
- if (err) {
- dput (dentry);
- dentry = NULL;
- }
-
- if (dentry && dentry->d_inode)
- reiserfs_warning (s, "Created %s on %s - reserved for "
- "xattr storage.", PRIVROOT_NAME,
- reiserfs_bdevname (inode->i_sb));
- } else if (!dentry->d_inode) {
- dput (dentry);
- dentry = NULL;
- }
- } else
- err = PTR_ERR (dentry);
-
- if (!err && dentry) {
- s->s_root->d_op = &xattr_lookup_poison_ops;
- reiserfs_mark_inode_private (dentry->d_inode);
- REISERFS_SB(s)->priv_root = dentry;
- } else if (!(mount_flags & MS_RDONLY)) { /* xattrs are unavailable */
- /* If we're read-only it just means that the dir hasn't been
- * created. Not an error -- just no xattrs on the fs. We'll
- * check again if we go read-write */
- reiserfs_warning (s, "xattrs/ACLs enabled and couldn't "
- "find/create .reiserfs_priv. Failing mount.");
- err = -EOPNOTSUPP;
- }
- }
-
-error:
- /* This is only nonzero if there was an error initializing the xattr
- * directory or if there is a condition where we don't support them. */
- if (err) {
- clear_bit (REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
- clear_bit (REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
- clear_bit (REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
- }
-
- /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */
- s->s_flags = s->s_flags & ~MS_POSIXACL;
- if (reiserfs_posixacl (s))
- s->s_flags |= MS_POSIXACL;
-
- return err;
+ int err = 0;
+
+ /* We need generation numbers to ensure that the oid mapping is correct
+ * v3.5 filesystems don't have them. */
+ if (!old_format_only(s)) {
+ set_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
+ } else if (reiserfs_xattrs_optional(s)) {
+ /* Old format filesystem, but optional xattrs have been enabled
+ * at mount time. Error out. */
+ reiserfs_warning(s, "xattrs/ACLs not supported on pre v3.6 "
+ "format filesystem. Failing mount.");
+ err = -EOPNOTSUPP;
+ goto error;
+ } else {
+ /* Old format filesystem, but no optional xattrs have been enabled. This
+ * means we silently disable xattrs on the filesystem. */
+ clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
+ }
+
+ /* If we don't have the privroot located yet - go find it */
+ if (reiserfs_xattrs(s) && !REISERFS_SB(s)->priv_root) {
+ struct dentry *dentry;
+ dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
+ strlen(PRIVROOT_NAME));
+ if (!IS_ERR(dentry)) {
+ if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
+ struct inode *inode = dentry->d_parent->d_inode;
+ down(&inode->i_sem);
+ err = inode->i_op->mkdir(inode, dentry, 0700);
+ up(&inode->i_sem);
+ if (err) {
+ dput(dentry);
+ dentry = NULL;
+ }
+
+ if (dentry && dentry->d_inode)
+ reiserfs_warning(s,
+ "Created %s on %s - reserved for "
+ "xattr storage.",
+ PRIVROOT_NAME,
+ reiserfs_bdevname
+ (inode->i_sb));
+ } else if (!dentry->d_inode) {
+ dput(dentry);
+ dentry = NULL;
+ }
+ } else
+ err = PTR_ERR(dentry);
+
+ if (!err && dentry) {
+ s->s_root->d_op = &xattr_lookup_poison_ops;
+ reiserfs_mark_inode_private(dentry->d_inode);
+ REISERFS_SB(s)->priv_root = dentry;
+ } else if (!(mount_flags & MS_RDONLY)) { /* xattrs are unavailable */
+ /* If we're read-only it just means that the dir hasn't been
+ * created. Not an error -- just no xattrs on the fs. We'll
+ * check again if we go read-write */
+ reiserfs_warning(s, "xattrs/ACLs enabled and couldn't "
+ "find/create .reiserfs_priv. Failing mount.");
+ err = -EOPNOTSUPP;
+ }
+ }
+
+ error:
+ /* This is only nonzero if there was an error initializing the xattr
+ * directory or if there is a condition where we don't support them. */
+ if (err) {
+ clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
+ clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
+ clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
+ }
+
+ /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */
+ s->s_flags = s->s_flags & ~MS_POSIXACL;
+ if (reiserfs_posixacl(s))
+ s->s_flags |= MS_POSIXACL;
+
+ return err;
}
static int
-__reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd,
- int need_lock)
+__reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd,
+ int need_lock)
{
- umode_t mode = inode->i_mode;
+ umode_t mode = inode->i_mode;
if (mask & MAY_WRITE) {
/*
@@ -1363,50 +1365,50 @@ __reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd,
}
/* We don't do permission checks on the internal objects.
- * Permissions are determined by the "owning" object. */
- if (is_reiserfs_priv_object (inode))
+ * Permissions are determined by the "owning" object. */
+ if (is_reiserfs_priv_object(inode))
return 0;
if (current->fsuid == inode->i_uid) {
mode >>= 6;
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
} else if (reiserfs_posixacl(inode->i_sb) &&
- get_inode_sd_version (inode) != STAT_DATA_V1) {
- struct posix_acl *acl;
+ get_inode_sd_version(inode) != STAT_DATA_V1) {
+ struct posix_acl *acl;
/* ACL can't contain additional permissions if
the ACL_MASK entry is 0 */
if (!(mode & S_IRWXG))
goto check_groups;
- if (need_lock) {
- reiserfs_read_lock_xattr_i (inode);
- reiserfs_read_lock_xattrs (inode->i_sb);
+ if (need_lock) {
+ reiserfs_read_lock_xattr_i(inode);
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ }
+ acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
+ if (need_lock) {
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ reiserfs_read_unlock_xattr_i(inode);
}
- acl = reiserfs_get_acl (inode, ACL_TYPE_ACCESS);
- if (need_lock) {
- reiserfs_read_unlock_xattrs (inode->i_sb);
- reiserfs_read_unlock_xattr_i (inode);
+ if (IS_ERR(acl)) {
+ if (PTR_ERR(acl) == -ENODATA)
+ goto check_groups;
+ return PTR_ERR(acl);
}
- if (IS_ERR (acl)) {
- if (PTR_ERR (acl) == -ENODATA)
- goto check_groups;
- return PTR_ERR (acl);
- }
-
- if (acl) {
- int err = posix_acl_permission (inode, acl, mask);
- posix_acl_release (acl);
- if (err == -EACCES) {
- goto check_capabilities;
- }
- return err;
+
+ if (acl) {
+ int err = posix_acl_permission(inode, acl, mask);
+ posix_acl_release(acl);
+ if (err == -EACCES) {
+ goto check_capabilities;
+ }
+ return err;
} else {
goto check_groups;
- }
+ }
#endif
} else {
-check_groups:
+ check_groups:
if (in_group_p(inode->i_gid))
mode >>= 3;
}
@@ -1414,10 +1416,10 @@ check_groups:
/*
* If the DACs are ok we don't need any capability check.
*/
- if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask))
+ if (((mode & mask & (MAY_READ | MAY_WRITE | MAY_EXEC)) == mask))
return 0;
-check_capabilities:
+ check_capabilities:
/*
* Read/write DACs are always overridable.
* Executable DACs are overridable if at least one exec bit is set.
@@ -1437,14 +1439,13 @@ check_capabilities:
return -EACCES;
}
-int
-reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd)
+int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd)
{
- return __reiserfs_permission (inode, mask, nd, 1);
+ return __reiserfs_permission(inode, mask, nd, 1);
}
int
-reiserfs_permission_locked (struct inode *inode, int mask, struct nameidata *nd)
+reiserfs_permission_locked(struct inode *inode, int mask, struct nameidata *nd)
{
- return __reiserfs_permission (inode, mask, nd, 0);
+ return __reiserfs_permission(inode, mask, nd, 0);
}
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index c312881c5f5..6703efa3c43 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -9,7 +9,8 @@
#include <linux/reiserfs_acl.h>
#include <asm/uaccess.h>
-static int reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl);
+static int reiserfs_set_acl(struct inode *inode, int type,
+ struct posix_acl *acl);
static int
xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
@@ -34,14 +35,13 @@ xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
} else
acl = NULL;
- error = reiserfs_set_acl (inode, type, acl);
+ error = reiserfs_set_acl(inode, type, acl);
-release_and_out:
+ release_and_out:
posix_acl_release(acl);
return error;
}
-
static int
xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
{
@@ -51,7 +51,7 @@ xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
if (!reiserfs_posixacl(inode->i_sb))
return -EOPNOTSUPP;
- acl = reiserfs_get_acl (inode, type);
+ acl = reiserfs_get_acl(inode, type);
if (IS_ERR(acl))
return PTR_ERR(acl);
if (acl == NULL)
@@ -62,12 +62,10 @@ xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
return error;
}
-
/*
* Convert from filesystem to in-memory representation.
*/
-static struct posix_acl *
-posix_acl_from_disk(const void *value, size_t size)
+static struct posix_acl *posix_acl_from_disk(const void *value, size_t size)
{
const char *end = (char *)value + size;
int n, count;
@@ -76,8 +74,8 @@ posix_acl_from_disk(const void *value, size_t size)
if (!value)
return NULL;
if (size < sizeof(reiserfs_acl_header))
- return ERR_PTR(-EINVAL);
- if (((reiserfs_acl_header *)value)->a_version !=
+ return ERR_PTR(-EINVAL);
+ if (((reiserfs_acl_header *) value)->a_version !=
cpu_to_le32(REISERFS_ACL_VERSION))
return ERR_PTR(-EINVAL);
value = (char *)value + sizeof(reiserfs_acl_header);
@@ -89,41 +87,39 @@ posix_acl_from_disk(const void *value, size_t size)
acl = posix_acl_alloc(count, GFP_NOFS);
if (!acl)
return ERR_PTR(-ENOMEM);
- for (n=0; n < count; n++) {
- reiserfs_acl_entry *entry =
- (reiserfs_acl_entry *)value;
+ for (n = 0; n < count; n++) {
+ reiserfs_acl_entry *entry = (reiserfs_acl_entry *) value;
if ((char *)value + sizeof(reiserfs_acl_entry_short) > end)
goto fail;
- acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
+ acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
- switch(acl->a_entries[n].e_tag) {
- case ACL_USER_OBJ:
- case ACL_GROUP_OBJ:
- case ACL_MASK:
- case ACL_OTHER:
- value = (char *)value +
- sizeof(reiserfs_acl_entry_short);
- acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
- break;
-
- case ACL_USER:
- case ACL_GROUP:
- value = (char *)value + sizeof(reiserfs_acl_entry);
- if ((char *)value > end)
- goto fail;
- acl->a_entries[n].e_id =
- le32_to_cpu(entry->e_id);
- break;
-
- default:
+ switch (acl->a_entries[n].e_tag) {
+ case ACL_USER_OBJ:
+ case ACL_GROUP_OBJ:
+ case ACL_MASK:
+ case ACL_OTHER:
+ value = (char *)value +
+ sizeof(reiserfs_acl_entry_short);
+ acl->a_entries[n].e_id = ACL_UNDEFINED_ID;
+ break;
+
+ case ACL_USER:
+ case ACL_GROUP:
+ value = (char *)value + sizeof(reiserfs_acl_entry);
+ if ((char *)value > end)
goto fail;
+ acl->a_entries[n].e_id = le32_to_cpu(entry->e_id);
+ break;
+
+ default:
+ goto fail;
}
}
if (value != end)
goto fail;
return acl;
-fail:
+ fail:
posix_acl_release(acl);
return ERR_PTR(-EINVAL);
}
@@ -131,46 +127,46 @@ fail:
/*
* Convert from in-memory to filesystem representation.
*/
-static void *
-posix_acl_to_disk(const struct posix_acl *acl, size_t *size)
+static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
{
reiserfs_acl_header *ext_acl;
char *e;
int n;
*size = reiserfs_acl_size(acl->a_count);
- ext_acl = (reiserfs_acl_header *)kmalloc(sizeof(reiserfs_acl_header) +
- acl->a_count * sizeof(reiserfs_acl_entry), GFP_NOFS);
+ ext_acl = (reiserfs_acl_header *) kmalloc(sizeof(reiserfs_acl_header) +
+ acl->a_count *
+ sizeof(reiserfs_acl_entry),
+ GFP_NOFS);
if (!ext_acl)
return ERR_PTR(-ENOMEM);
ext_acl->a_version = cpu_to_le32(REISERFS_ACL_VERSION);
e = (char *)ext_acl + sizeof(reiserfs_acl_header);
- for (n=0; n < acl->a_count; n++) {
- reiserfs_acl_entry *entry = (reiserfs_acl_entry *)e;
- entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
+ for (n = 0; n < acl->a_count; n++) {
+ reiserfs_acl_entry *entry = (reiserfs_acl_entry *) e;
+ entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
- switch(acl->a_entries[n].e_tag) {
- case ACL_USER:
- case ACL_GROUP:
- entry->e_id =
- cpu_to_le32(acl->a_entries[n].e_id);
- e += sizeof(reiserfs_acl_entry);
- break;
-
- case ACL_USER_OBJ:
- case ACL_GROUP_OBJ:
- case ACL_MASK:
- case ACL_OTHER:
- e += sizeof(reiserfs_acl_entry_short);
- break;
-
- default:
- goto fail;
+ switch (acl->a_entries[n].e_tag) {
+ case ACL_USER:
+ case ACL_GROUP:
+ entry->e_id = cpu_to_le32(acl->a_entries[n].e_id);
+ e += sizeof(reiserfs_acl_entry);
+ break;
+
+ case ACL_USER_OBJ:
+ case ACL_GROUP_OBJ:
+ case ACL_MASK:
+ case ACL_OTHER:
+ e += sizeof(reiserfs_acl_entry_short);
+ break;
+
+ default:
+ goto fail;
}
}
return (char *)ext_acl;
-fail:
+ fail:
kfree(ext_acl);
return ERR_PTR(-EINVAL);
}
@@ -181,59 +177,58 @@ fail:
* inode->i_sem: down
* BKL held [before 2.5.x]
*/
-struct posix_acl *
-reiserfs_get_acl(struct inode *inode, int type)
+struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
{
char *name, *value;
struct posix_acl *acl, **p_acl;
size_t size;
int retval;
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
-
- switch (type) {
- case ACL_TYPE_ACCESS:
- name = POSIX_ACL_XATTR_ACCESS;
- p_acl = &reiserfs_i->i_acl_access;
- break;
- case ACL_TYPE_DEFAULT:
- name = POSIX_ACL_XATTR_DEFAULT;
- p_acl = &reiserfs_i->i_acl_default;
- break;
- default:
- return ERR_PTR (-EINVAL);
- }
-
- if (IS_ERR (*p_acl)) {
- if (PTR_ERR (*p_acl) == -ENODATA)
- return NULL;
- } else if (*p_acl != NULL)
- return posix_acl_dup (*p_acl);
-
- size = reiserfs_xattr_get (inode, name, NULL, 0);
- if ((int)size < 0) {
- if (size == -ENODATA || size == -ENOSYS) {
- *p_acl = ERR_PTR (-ENODATA);
- return NULL;
- }
- return ERR_PTR (size);
- }
+ struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
+
+ switch (type) {
+ case ACL_TYPE_ACCESS:
+ name = POSIX_ACL_XATTR_ACCESS;
+ p_acl = &reiserfs_i->i_acl_access;
+ break;
+ case ACL_TYPE_DEFAULT:
+ name = POSIX_ACL_XATTR_DEFAULT;
+ p_acl = &reiserfs_i->i_acl_default;
+ break;
+ default:
+ return ERR_PTR(-EINVAL);
+ }
+
+ if (IS_ERR(*p_acl)) {
+ if (PTR_ERR(*p_acl) == -ENODATA)
+ return NULL;
+ } else if (*p_acl != NULL)
+ return posix_acl_dup(*p_acl);
+
+ size = reiserfs_xattr_get(inode, name, NULL, 0);
+ if ((int)size < 0) {
+ if (size == -ENODATA || size == -ENOSYS) {
+ *p_acl = ERR_PTR(-ENODATA);
+ return NULL;
+ }
+ return ERR_PTR(size);
+ }
- value = kmalloc (size, GFP_NOFS);
- if (!value)
- return ERR_PTR (-ENOMEM);
+ value = kmalloc(size, GFP_NOFS);
+ if (!value)
+ return ERR_PTR(-ENOMEM);
retval = reiserfs_xattr_get(inode, name, value, size);
if (retval == -ENODATA || retval == -ENOSYS) {
/* This shouldn't actually happen as it should have
been caught above.. but just in case */
acl = NULL;
- *p_acl = ERR_PTR (-ENODATA);
- } else if (retval < 0) {
+ *p_acl = ERR_PTR(-ENODATA);
+ } else if (retval < 0) {
acl = ERR_PTR(retval);
} else {
acl = posix_acl_from_disk(value, retval);
- *p_acl = posix_acl_dup (acl);
- }
+ *p_acl = posix_acl_dup(acl);
+ }
kfree(value);
return acl;
@@ -248,72 +243,72 @@ reiserfs_get_acl(struct inode *inode, int type)
static int
reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
{
- char *name;
+ char *name;
void *value = NULL;
struct posix_acl **p_acl;
size_t size;
int error;
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
+ struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP;
- switch (type) {
- case ACL_TYPE_ACCESS:
- name = POSIX_ACL_XATTR_ACCESS;
- p_acl = &reiserfs_i->i_acl_access;
- if (acl) {
- mode_t mode = inode->i_mode;
- error = posix_acl_equiv_mode (acl, &mode);
- if (error < 0)
- return error;
- else {
- inode->i_mode = mode;
- if (error == 0)
- acl = NULL;
- }
- }
- break;
- case ACL_TYPE_DEFAULT:
- name = POSIX_ACL_XATTR_DEFAULT;
- p_acl = &reiserfs_i->i_acl_default;
- if (!S_ISDIR (inode->i_mode))
- return acl ? -EACCES : 0;
- break;
- default:
- return -EINVAL;
- }
-
- if (acl) {
- value = posix_acl_to_disk(acl, &size);
- if (IS_ERR(value))
- return (int)PTR_ERR(value);
- error = reiserfs_xattr_set(inode, name, value, size, 0);
+ switch (type) {
+ case ACL_TYPE_ACCESS:
+ name = POSIX_ACL_XATTR_ACCESS;
+ p_acl = &reiserfs_i->i_acl_access;
+ if (acl) {
+ mode_t mode = inode->i_mode;
+ error = posix_acl_equiv_mode(acl, &mode);
+ if (error < 0)
+ return error;
+ else {
+ inode->i_mode = mode;
+ if (error == 0)
+ acl = NULL;
+ }
+ }
+ break;
+ case ACL_TYPE_DEFAULT:
+ name = POSIX_ACL_XATTR_DEFAULT;
+ p_acl = &reiserfs_i->i_acl_default;
+ if (!S_ISDIR(inode->i_mode))
+ return acl ? -EACCES : 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (acl) {
+ value = posix_acl_to_disk(acl, &size);
+ if (IS_ERR(value))
+ return (int)PTR_ERR(value);
+ error = reiserfs_xattr_set(inode, name, value, size, 0);
} else {
- error = reiserfs_xattr_del (inode, name);
- if (error == -ENODATA) {
- /* This may seem odd here, but it means that the ACL was set
- * with a value representable with mode bits. If there was
- * an ACL before, reiserfs_xattr_del already dirtied the inode.
- */
- mark_inode_dirty (inode);
- error = 0;
- }
- }
+ error = reiserfs_xattr_del(inode, name);
+ if (error == -ENODATA) {
+ /* This may seem odd here, but it means that the ACL was set
+ * with a value representable with mode bits. If there was
+ * an ACL before, reiserfs_xattr_del already dirtied the inode.
+ */
+ mark_inode_dirty(inode);
+ error = 0;
+ }
+ }
if (value)
kfree(value);
- if (!error) {
- /* Release the old one */
- if (!IS_ERR (*p_acl) && *p_acl)
- posix_acl_release (*p_acl);
+ if (!error) {
+ /* Release the old one */
+ if (!IS_ERR(*p_acl) && *p_acl)
+ posix_acl_release(*p_acl);
- if (acl == NULL)
- *p_acl = ERR_PTR (-ENODATA);
- else
- *p_acl = posix_acl_dup (acl);
- }
+ if (acl == NULL)
+ *p_acl = ERR_PTR(-ENODATA);
+ else
+ *p_acl = posix_acl_dup(acl);
+ }
return error;
}
@@ -321,192 +316,190 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
/* dir->i_sem: down,
* inode is new and not released into the wild yet */
int
-reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode)
+reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
+ struct inode *inode)
{
- struct posix_acl *acl;
- int err = 0;
-
- /* ACLs only get applied to files and directories */
- if (S_ISLNK (inode->i_mode))
- return 0;
-
- /* ACLs can only be used on "new" objects, so if it's an old object
- * there is nothing to inherit from */
- if (get_inode_sd_version (dir) == STAT_DATA_V1)
- goto apply_umask;
-
- /* Don't apply ACLs to objects in the .reiserfs_priv tree.. This
- * would be useless since permissions are ignored, and a pain because
- * it introduces locking cycles */
- if (is_reiserfs_priv_object (dir)) {
- reiserfs_mark_inode_private (inode);
- goto apply_umask;
- }
-
- acl = reiserfs_get_acl (dir, ACL_TYPE_DEFAULT);
- if (IS_ERR (acl)) {
- if (PTR_ERR (acl) == -ENODATA)
- goto apply_umask;
- return PTR_ERR (acl);
- }
-
- if (acl) {
- struct posix_acl *acl_copy;
- mode_t mode = inode->i_mode;
- int need_acl;
-
- /* Copy the default ACL to the default ACL of a new directory */
- if (S_ISDIR (inode->i_mode)) {
- err = reiserfs_set_acl (inode, ACL_TYPE_DEFAULT, acl);
- if (err)
- goto cleanup;
- }
-
- /* Now we reconcile the new ACL and the mode,
- potentially modifying both */
- acl_copy = posix_acl_clone (acl, GFP_NOFS);
- if (!acl_copy) {
- err = -ENOMEM;
- goto cleanup;
- }
-
-
- need_acl = posix_acl_create_masq (acl_copy, &mode);
- if (need_acl >= 0) {
- if (mode != inode->i_mode) {
- inode->i_mode = mode;
- }
-
- /* If we need an ACL.. */
- if (need_acl > 0) {
- err = reiserfs_set_acl (inode, ACL_TYPE_ACCESS, acl_copy);
- if (err)
- goto cleanup_copy;
- }
- }
-cleanup_copy:
- posix_acl_release (acl_copy);
-cleanup:
- posix_acl_release (acl);
- } else {
-apply_umask:
- /* no ACL, apply umask */
- inode->i_mode &= ~current->fs->umask;
- }
-
- return err;
+ struct posix_acl *acl;
+ int err = 0;
+
+ /* ACLs only get applied to files and directories */
+ if (S_ISLNK(inode->i_mode))
+ return 0;
+
+ /* ACLs can only be used on "new" objects, so if it's an old object
+ * there is nothing to inherit from */
+ if (get_inode_sd_version(dir) == STAT_DATA_V1)
+ goto apply_umask;
+
+ /* Don't apply ACLs to objects in the .reiserfs_priv tree.. This
+ * would be useless since permissions are ignored, and a pain because
+ * it introduces locking cycles */
+ if (is_reiserfs_priv_object(dir)) {
+ reiserfs_mark_inode_private(inode);
+ goto apply_umask;
+ }
+
+ acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT);
+ if (IS_ERR(acl)) {
+ if (PTR_ERR(acl) == -ENODATA)
+ goto apply_umask;
+ return PTR_ERR(acl);
+ }
+
+ if (acl) {
+ struct posix_acl *acl_copy;
+ mode_t mode = inode->i_mode;
+ int need_acl;
+
+ /* Copy the default ACL to the default ACL of a new directory */
+ if (S_ISDIR(inode->i_mode)) {
+ err = reiserfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
+ if (err)
+ goto cleanup;
+ }
+
+ /* Now we reconcile the new ACL and the mode,
+ potentially modifying both */
+ acl_copy = posix_acl_clone(acl, GFP_NOFS);
+ if (!acl_copy) {
+ err = -ENOMEM;
+ goto cleanup;
+ }
+
+ need_acl = posix_acl_create_masq(acl_copy, &mode);
+ if (need_acl >= 0) {
+ if (mode != inode->i_mode) {
+ inode->i_mode = mode;
+ }
+
+ /* If we need an ACL.. */
+ if (need_acl > 0) {
+ err =
+ reiserfs_set_acl(inode, ACL_TYPE_ACCESS,
+ acl_copy);
+ if (err)
+ goto cleanup_copy;
+ }
+ }
+ cleanup_copy:
+ posix_acl_release(acl_copy);
+ cleanup:
+ posix_acl_release(acl);
+ } else {
+ apply_umask:
+ /* no ACL, apply umask */
+ inode->i_mode &= ~current->fs->umask;
+ }
+
+ return err;
}
/* Looks up and caches the result of the default ACL.
* We do this so that we don't need to carry the xattr_sem into
* reiserfs_new_inode if we don't need to */
-int
-reiserfs_cache_default_acl (struct inode *inode)
+int reiserfs_cache_default_acl(struct inode *inode)
{
- int ret = 0;
- if (reiserfs_posixacl (inode->i_sb) &&
- !is_reiserfs_priv_object (inode)) {
- struct posix_acl *acl;
- reiserfs_read_lock_xattr_i (inode);
- reiserfs_read_lock_xattrs (inode->i_sb);
- acl = reiserfs_get_acl (inode, ACL_TYPE_DEFAULT);
- reiserfs_read_unlock_xattrs (inode->i_sb);
- reiserfs_read_unlock_xattr_i (inode);
- ret = acl ? 1 : 0;
- posix_acl_release (acl);
- }
-
- return ret;
+ int ret = 0;
+ if (reiserfs_posixacl(inode->i_sb) && !is_reiserfs_priv_object(inode)) {
+ struct posix_acl *acl;
+ reiserfs_read_lock_xattr_i(inode);
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT);
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ reiserfs_read_unlock_xattr_i(inode);
+ ret = acl ? 1 : 0;
+ posix_acl_release(acl);
+ }
+
+ return ret;
}
-int
-reiserfs_acl_chmod (struct inode *inode)
+int reiserfs_acl_chmod(struct inode *inode)
{
- struct posix_acl *acl, *clone;
- int error;
+ struct posix_acl *acl, *clone;
+ int error;
- if (S_ISLNK(inode->i_mode))
- return -EOPNOTSUPP;
+ if (S_ISLNK(inode->i_mode))
+ return -EOPNOTSUPP;
- if (get_inode_sd_version (inode) == STAT_DATA_V1 ||
- !reiserfs_posixacl(inode->i_sb))
- {
- return 0;
+ if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
+ !reiserfs_posixacl(inode->i_sb)) {
+ return 0;
}
- reiserfs_read_lock_xattrs (inode->i_sb);
- acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
- reiserfs_read_unlock_xattrs (inode->i_sb);
- if (!acl)
- return 0;
- if (IS_ERR(acl))
- return PTR_ERR(acl);
- clone = posix_acl_clone(acl, GFP_NOFS);
- posix_acl_release(acl);
- if (!clone)
- return -ENOMEM;
- error = posix_acl_chmod_masq(clone, inode->i_mode);
- if (!error) {
- int lock = !has_xattr_dir (inode);
- reiserfs_write_lock_xattr_i (inode);
- if (lock)
- reiserfs_write_lock_xattrs (inode->i_sb);
- else
- reiserfs_read_lock_xattrs (inode->i_sb);
- error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
- if (lock)
- reiserfs_write_unlock_xattrs (inode->i_sb);
- else
- reiserfs_read_unlock_xattrs (inode->i_sb);
- reiserfs_write_unlock_xattr_i (inode);
- }
- posix_acl_release(clone);
- return error;
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ if (!acl)
+ return 0;
+ if (IS_ERR(acl))
+ return PTR_ERR(acl);
+ clone = posix_acl_clone(acl, GFP_NOFS);
+ posix_acl_release(acl);
+ if (!clone)
+ return -ENOMEM;
+ error = posix_acl_chmod_masq(clone, inode->i_mode);
+ if (!error) {
+ int lock = !has_xattr_dir(inode);
+ reiserfs_write_lock_xattr_i(inode);
+ if (lock)
+ reiserfs_write_lock_xattrs(inode->i_sb);
+ else
+ reiserfs_read_lock_xattrs(inode->i_sb);
+ error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
+ if (lock)
+ reiserfs_write_unlock_xattrs(inode->i_sb);
+ else
+ reiserfs_read_unlock_xattrs(inode->i_sb);
+ reiserfs_write_unlock_xattr_i(inode);
+ }
+ posix_acl_release(clone);
+ return error;
}
static int
posix_acl_access_get(struct inode *inode, const char *name,
- void *buffer, size_t size)
+ void *buffer, size_t size)
{
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
return -EINVAL;
return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
}
static int
posix_acl_access_set(struct inode *inode, const char *name,
- const void *value, size_t size, int flags)
+ const void *value, size_t size, int flags)
{
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
return -EINVAL;
return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
}
-static int
-posix_acl_access_del (struct inode *inode, const char *name)
+static int posix_acl_access_del(struct inode *inode, const char *name)
{
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- struct posix_acl **acl = &reiserfs_i->i_acl_access;
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS)-1)
- return -EINVAL;
- if (!IS_ERR (*acl) && *acl) {
- posix_acl_release (*acl);
- *acl = ERR_PTR (-ENODATA);
- }
-
- return 0;
+ struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
+ struct posix_acl **acl = &reiserfs_i->i_acl_access;
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
+ return -EINVAL;
+ if (!IS_ERR(*acl) && *acl) {
+ posix_acl_release(*acl);
+ *acl = ERR_PTR(-ENODATA);
+ }
+
+ return 0;
}
static int
-posix_acl_access_list (struct inode *inode, const char *name, int namelen, char *out)
+posix_acl_access_list(struct inode *inode, const char *name, int namelen,
+ char *out)
{
- int len = namelen;
- if (!reiserfs_posixacl (inode->i_sb))
- return 0;
- if (out)
- memcpy (out, name, len);
+ int len = namelen;
+ if (!reiserfs_posixacl(inode->i_sb))
+ return 0;
+ if (out)
+ memcpy(out, name, len);
- return len;
+ return len;
}
struct reiserfs_xattr_handler posix_acl_access_handler = {
@@ -518,48 +511,48 @@ struct reiserfs_xattr_handler posix_acl_access_handler = {
};
static int
-posix_acl_default_get (struct inode *inode, const char *name,
- void *buffer, size_t size)
+posix_acl_default_get(struct inode *inode, const char *name,
+ void *buffer, size_t size)
{
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
return -EINVAL;
return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
}
static int
posix_acl_default_set(struct inode *inode, const char *name,
- const void *value, size_t size, int flags)
+ const void *value, size_t size, int flags)
{
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
return -EINVAL;
return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
}
-static int
-posix_acl_default_del (struct inode *inode, const char *name)
+static int posix_acl_default_del(struct inode *inode, const char *name)
{
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- struct posix_acl **acl = &reiserfs_i->i_acl_default;
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT)-1)
- return -EINVAL;
- if (!IS_ERR (*acl) && *acl) {
- posix_acl_release (*acl);
- *acl = ERR_PTR (-ENODATA);
- }
-
- return 0;
+ struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
+ struct posix_acl **acl = &reiserfs_i->i_acl_default;
+ if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
+ return -EINVAL;
+ if (!IS_ERR(*acl) && *acl) {
+ posix_acl_release(*acl);
+ *acl = ERR_PTR(-ENODATA);
+ }
+
+ return 0;
}
static int
-posix_acl_default_list (struct inode *inode, const char *name, int namelen, char *out)
+posix_acl_default_list(struct inode *inode, const char *name, int namelen,
+ char *out)
{
- int len = namelen;
- if (!reiserfs_posixacl (inode->i_sb))
- return 0;
- if (out)
- memcpy (out, name, len);
+ int len = namelen;
+ if (!reiserfs_posixacl(inode->i_sb))
+ return 0;
+ if (out)
+ memcpy(out, name, len);
- return len;
+ return len;
}
struct reiserfs_xattr_handler posix_acl_default_handler = {
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index e044d511711..5e90a95ad60 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -9,57 +9,55 @@
#define XATTR_SECURITY_PREFIX "security."
static int
-security_get (struct inode *inode, const char *name, void *buffer, size_t size)
+security_get(struct inode *inode, const char *name, void *buffer, size_t size)
{
- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
+ return -EINVAL;
- if (is_reiserfs_priv_object(inode))
- return -EPERM;
+ if (is_reiserfs_priv_object(inode))
+ return -EPERM;
- return reiserfs_xattr_get (inode, name, buffer, size);
+ return reiserfs_xattr_get(inode, name, buffer, size);
}
static int
-security_set (struct inode *inode, const char *name, const void *buffer,
- size_t size, int flags)
+security_set(struct inode *inode, const char *name, const void *buffer,
+ size_t size, int flags)
{
- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
+ return -EINVAL;
- if (is_reiserfs_priv_object(inode))
- return -EPERM;
+ if (is_reiserfs_priv_object(inode))
+ return -EPERM;
- return reiserfs_xattr_set (inode, name, buffer, size, flags);
+ return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int
-security_del (struct inode *inode, const char *name)
+static int security_del(struct inode *inode, const char *name)
{
- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
+ return -EINVAL;
- if (is_reiserfs_priv_object(inode))
- return -EPERM;
+ if (is_reiserfs_priv_object(inode))
+ return -EPERM;
- return 0;
+ return 0;
}
static int
-security_list (struct inode *inode, const char *name, int namelen, char *out)
+security_list(struct inode *inode, const char *name, int namelen, char *out)
{
- int len = namelen;
+ int len = namelen;
- if (is_reiserfs_priv_object(inode))
- return 0;
+ if (is_reiserfs_priv_object(inode))
+ return 0;
- if (out)
- memcpy (out, name, len);
+ if (out)
+ memcpy(out, name, len);
- return len;
+ return len;
}
-
struct reiserfs_xattr_handler security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.get = security_get,
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index 43762197fb0..2501f7e66ab 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -9,69 +9,67 @@
#define XATTR_TRUSTED_PREFIX "trusted."
static int
-trusted_get (struct inode *inode, const char *name, void *buffer, size_t size)
+trusted_get(struct inode *inode, const char *name, void *buffer, size_t size)
{
- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs(inode->i_sb))
+ return -EOPNOTSUPP;
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return -EPERM;
+ if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ return -EPERM;
- return reiserfs_xattr_get (inode, name, buffer, size);
+ return reiserfs_xattr_get(inode, name, buffer, size);
}
static int
-trusted_set (struct inode *inode, const char *name, const void *buffer,
- size_t size, int flags)
+trusted_set(struct inode *inode, const char *name, const void *buffer,
+ size_t size, int flags)
{
- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs(inode->i_sb))
+ return -EOPNOTSUPP;
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return -EPERM;
+ if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ return -EPERM;
- return reiserfs_xattr_set (inode, name, buffer, size, flags);
+ return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int
-trusted_del (struct inode *inode, const char *name)
+static int trusted_del(struct inode *inode, const char *name)
{
- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs(inode->i_sb))
+ return -EOPNOTSUPP;
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return -EPERM;
+ if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ return -EPERM;
- return 0;
+ return 0;
}
static int
-trusted_list (struct inode *inode, const char *name, int namelen, char *out)
+trusted_list(struct inode *inode, const char *name, int namelen, char *out)
{
- int len = namelen;
+ int len = namelen;
- if (!reiserfs_xattrs (inode->i_sb))
- return 0;
+ if (!reiserfs_xattrs(inode->i_sb))
+ return 0;
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return 0;
+ if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ return 0;
- if (out)
- memcpy (out, name, len);
+ if (out)
+ memcpy(out, name, len);
- return len;
+ return len;
}
-
struct reiserfs_xattr_handler trusted_handler = {
.prefix = XATTR_TRUSTED_PREFIX,
.get = trusted_get,
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c
index 0772806466a..51458048ca6 100644
--- a/fs/reiserfs/xattr_user.c
+++ b/fs/reiserfs/xattr_user.c
@@ -13,81 +13,80 @@
#define XATTR_USER_PREFIX "user."
static int
-user_get (struct inode *inode, const char *name, void *buffer, size_t size)
+user_get(struct inode *inode, const char *name, void *buffer, size_t size)
{
- int error;
+ int error;
- if (strlen(name) < sizeof(XATTR_USER_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_USER_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs_user (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs_user(inode->i_sb))
+ return -EOPNOTSUPP;
- error = reiserfs_permission_locked (inode, MAY_READ, NULL);
- if (error)
- return error;
+ error = reiserfs_permission_locked(inode, MAY_READ, NULL);
+ if (error)
+ return error;
- return reiserfs_xattr_get (inode, name, buffer, size);
+ return reiserfs_xattr_get(inode, name, buffer, size);
}
static int
-user_set (struct inode *inode, const char *name, const void *buffer,
- size_t size, int flags)
+user_set(struct inode *inode, const char *name, const void *buffer,
+ size_t size, int flags)
{
- int error;
+ int error;
- if (strlen(name) < sizeof(XATTR_USER_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_USER_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs_user (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs_user(inode->i_sb))
+ return -EOPNOTSUPP;
- if (!S_ISREG (inode->i_mode) &&
- (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX))
- return -EPERM;
+ if (!S_ISREG(inode->i_mode) &&
+ (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
+ return -EPERM;
- error = reiserfs_permission_locked (inode, MAY_WRITE, NULL);
- if (error)
- return error;
+ error = reiserfs_permission_locked(inode, MAY_WRITE, NULL);
+ if (error)
+ return error;
- return reiserfs_xattr_set (inode, name, buffer, size, flags);
+ return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int
-user_del (struct inode *inode, const char *name)
+static int user_del(struct inode *inode, const char *name)
{
- int error;
+ int error;
- if (strlen(name) < sizeof(XATTR_USER_PREFIX))
- return -EINVAL;
+ if (strlen(name) < sizeof(XATTR_USER_PREFIX))
+ return -EINVAL;
- if (!reiserfs_xattrs_user (inode->i_sb))
- return -EOPNOTSUPP;
+ if (!reiserfs_xattrs_user(inode->i_sb))
+ return -EOPNOTSUPP;
- if (!S_ISREG (inode->i_mode) &&
- (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX))
- return -EPERM;
+ if (!S_ISREG(inode->i_mode) &&
+ (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
+ return -EPERM;
- error = reiserfs_permission_locked (inode, MAY_WRITE, NULL);
- if (error)
- return error;
+ error = reiserfs_permission_locked(inode, MAY_WRITE, NULL);
+ if (error)
+ return error;
- return 0;
+ return 0;
}
static int
-user_list (struct inode *inode, const char *name, int namelen, char *out)
+user_list(struct inode *inode, const char *name, int namelen, char *out)
{
- int len = namelen;
- if (!reiserfs_xattrs_user (inode->i_sb))
- return 0;
+ int len = namelen;
+ if (!reiserfs_xattrs_user(inode->i_sb))
+ return 0;
- if (out)
- memcpy (out, name, len);
+ if (out)
+ memcpy(out, name, len);
- return len;
+ return len;
}
struct reiserfs_xattr_handler user_handler = {
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index d72c1ce4855..335288b9be0 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -3,7 +3,7 @@
*/
#include <linux/module.h>
-#include <linux/dnotify.h>
+#include <linux/fsnotify.h>
#include <linux/kobject.h>
#include <linux/namei.h>
#include <asm/uaccess.h>
@@ -391,9 +391,6 @@ int sysfs_create_file(struct kobject * kobj, const struct attribute * attr)
* sysfs_update_file - update the modified timestamp on an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
- *
- * Also call dnotify for the dentry, which lots of userspace programs
- * use.
*/
int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
{
@@ -408,7 +405,7 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
victim->d_inode->i_mtime = CURRENT_TIME;
- dnotify_parent(victim, DN_MODIFY);
+ fsnotify_modify(victim);
/**
* Drop reference from initial sysfs_get_dentry().
diff --git a/fs/xattr.c b/fs/xattr.c
index 93dee70a1db..6acd5c63da9 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -16,6 +16,7 @@
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/module.h>
+#include <linux/fsnotify.h>
#include <asm/uaccess.h>
/*
@@ -57,8 +58,10 @@ setxattr(struct dentry *d, char __user *name, void __user *value,
if (error)
goto out;
error = d->d_inode->i_op->setxattr(d, kname, kvalue, size, flags);
- if (!error)
+ if (!error) {
+ fsnotify_xattr(d);
security_inode_post_setxattr(d, kname, kvalue, size, flags);
+ }
out:
up(&d->d_inode->i_sem);
}
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index 2b41e47b7d8..2f6ab189fc6 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -64,7 +64,7 @@
/* Version string */
-#define ACPI_CA_VERSION 0x20050309
+#define ACPI_CA_VERSION 0x20050408
/*
* OS name, used for the _OS object. The _OS object is essentially obsolete,
@@ -130,9 +130,8 @@
#define ACPI_MAX_GPE_BLOCKS 2
#define ACPI_GPE_REGISTER_WIDTH 8
-/*
- * Method info (in WALK_STATE), containing local variables and argumetns
- */
+/* Method info (in WALK_STATE), containing local variables and argumetns */
+
#define ACPI_METHOD_NUM_LOCALS 8
#define ACPI_METHOD_MAX_LOCAL 7
diff --git a/include/acpi/acdebug.h b/include/acpi/acdebug.h
index 223b2a506e4..8ba372b0f24 100644
--- a/include/acpi/acdebug.h
+++ b/include/acpi/acdebug.h
@@ -61,9 +61,7 @@ struct argument_info
#define PARAM_LIST(pl) pl
-
#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose)
-
#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
acpi_os_printf PARAM_LIST(fp);}
@@ -71,13 +69,9 @@ struct argument_info
#define EX_SINGLE_STEP 2
-/* Prototypes */
-
-
/*
* dbxface - external debugger interfaces
*/
-
acpi_status
acpi_db_initialize (
void);
@@ -92,20 +86,10 @@ acpi_db_single_step (
union acpi_parse_object *op,
u32 op_type);
-acpi_status
-acpi_db_start_command (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *op);
-
-void
-acpi_db_method_end (
- struct acpi_walk_state *walk_state);
-
/*
* dbcmds - debug commands and output routines
*/
-
acpi_status
acpi_db_disassemble_method (
char *name);
@@ -177,57 +161,30 @@ acpi_db_find_references (
char *object_arg);
void
-acpi_db_display_locks (void);
-
+acpi_db_display_locks (
+ void);
void
acpi_db_display_resources (
char *object_arg);
void
-acpi_db_display_gpes (void);
+acpi_db_display_gpes (
+ void);
void
acpi_db_check_integrity (
void);
-acpi_status
-acpi_db_integrity_walk (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
-acpi_status
-acpi_db_walk_and_match_name (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
-acpi_status
-acpi_db_walk_for_references (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
-acpi_status
-acpi_db_walk_for_specific_objects (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
void
acpi_db_generate_gpe (
char *gpe_arg,
char *block_arg);
+
/*
* dbdisply - debug display commands
*/
-
void
acpi_db_display_method_info (
union acpi_parse_object *op);
@@ -271,19 +228,10 @@ acpi_db_display_argument_object (
union acpi_operand_object *obj_desc,
struct acpi_walk_state *walk_state);
-void
-acpi_db_dump_parser_descriptor (
- union acpi_parse_object *op);
-
-void *
-acpi_db_get_pointer (
- void *target);
-
/*
* dbexec - debugger control method execution
*/
-
void
acpi_db_execute (
char *name,
@@ -296,44 +244,15 @@ acpi_db_create_execution_threads (
char *num_loops_arg,
char *method_name_arg);
-acpi_status
-acpi_db_execute_method (
- struct acpi_db_method_info *info,
- struct acpi_buffer *return_obj);
-
-void
-acpi_db_execute_setup (
- struct acpi_db_method_info *info);
-
-u32
-acpi_db_get_outstanding_allocations (
- void);
-
-void ACPI_SYSTEM_XFACE
-acpi_db_method_thread (
- void *context);
-
-acpi_status
-acpi_db_execution_walk (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
/*
* dbfileio - Debugger file I/O commands
*/
-
acpi_object_type
acpi_db_match_argument (
char *user_argument,
struct argument_info *arguments);
-acpi_status
-ae_local_load_table (
- struct acpi_table_header *table_ptr);
-
void
acpi_db_close_debug_file (
void);
@@ -356,16 +275,17 @@ acpi_db_read_table_from_file (
char *filename,
struct acpi_table_header **table);
+
/*
* dbhistry - debugger HISTORY command
*/
-
void
acpi_db_add_to_history (
char *command_line);
void
-acpi_db_display_history (void);
+acpi_db_display_history (
+ void);
char *
acpi_db_get_from_history (
@@ -375,7 +295,6 @@ acpi_db_get_from_history (
/*
* dbinput - user front-end to the AML debugger
*/
-
acpi_status
acpi_db_command_dispatch (
char *input_buffer,
@@ -386,71 +305,28 @@ void ACPI_SYSTEM_XFACE
acpi_db_execute_thread (
void *context);
-void
-acpi_db_display_help (
- char *help_type);
-
-char *
-acpi_db_get_next_token (
- char *string,
- char **next);
-
-u32
-acpi_db_get_line (
- char *input_buffer);
-
-u32
-acpi_db_match_command (
- char *user_command);
-
-void
-acpi_db_single_thread (
- void);
-
/*
* dbstats - Generation and display of ACPI table statistics
*/
-
void
acpi_db_generate_statistics (
union acpi_parse_object *root,
u8 is_method);
-
acpi_status
acpi_db_display_statistics (
char *type_arg);
-acpi_status
-acpi_db_classify_one_object (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
-
-void
-acpi_db_count_namespace_objects (
- void);
-
-void
-acpi_db_enumerate_object (
- union acpi_operand_object *obj_desc);
-
/*
* dbutils - AML debugger utilities
*/
-
void
acpi_db_set_output_destination (
u32 where);
void
-acpi_db_dump_buffer (
- u32 address);
-
-void
acpi_db_dump_object (
union acpi_object *obj_desc,
u32 level);
@@ -459,14 +335,8 @@ void
acpi_db_prep_namestring (
char *name);
-
-acpi_status
-acpi_db_second_pass_parse (
- union acpi_parse_object *root);
-
struct acpi_namespace_node *
acpi_db_local_ns_lookup (
char *name);
-
#endif /* __ACDEBUG_H__ */
diff --git a/include/acpi/acdisasm.h b/include/acpi/acdisasm.h
index 26d907eae6f..dbfa877121b 100644
--- a/include/acpi/acdisasm.h
+++ b/include/acpi/acdisasm.h
@@ -102,58 +102,16 @@ acpi_status (*asl_walk_callback) (
/*
* dmwalk
*/
-
-void
-acpi_dm_walk_parse_tree (
- union acpi_parse_object *op,
- asl_walk_callback descending_callback,
- asl_walk_callback ascending_callback,
- void *context);
-
-acpi_status
-acpi_dm_descending_op (
- union acpi_parse_object *op,
- u32 level,
- void *context);
-
-acpi_status
-acpi_dm_ascending_op (
- union acpi_parse_object *op,
- u32 level,
- void *context);
-
-
-/*
- * dmopcode
- */
-
-void
-acpi_dm_validate_name (
- char *name,
- union acpi_parse_object *op);
-
-u32
-acpi_dm_dump_name (
- char *name);
-
-void
-acpi_dm_unicode (
- union acpi_parse_object *op);
-
void
acpi_dm_disassemble (
struct acpi_walk_state *walk_state,
union acpi_parse_object *origin,
u32 num_opcodes);
-void
-acpi_dm_namestring (
- char *name);
-
-void
-acpi_dm_display_path (
- union acpi_parse_object *op);
+/*
+ * dmopcode
+ */
void
acpi_dm_disassemble_one_op (
struct acpi_walk_state *walk_state,
@@ -165,18 +123,9 @@ acpi_dm_decode_internal_object (
union acpi_operand_object *obj_desc);
u32
-acpi_dm_block_type (
- union acpi_parse_object *op);
-
-u32
acpi_dm_list_type (
union acpi_parse_object *op);
-acpi_status
-acpi_ps_display_object_pathname (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *op);
-
void
acpi_dm_method_flags (
union acpi_parse_object *op);
@@ -197,10 +146,6 @@ void
acpi_dm_match_op (
union acpi_parse_object *op);
-void
-acpi_dm_match_keyword (
- union acpi_parse_object *op);
-
u8
acpi_dm_comma_if_list_member (
union acpi_parse_object *op);
@@ -211,13 +156,25 @@ acpi_dm_comma_if_field_member (
/*
- * dmobject
+ * dmnames
*/
+u32
+acpi_dm_dump_name (
+ char *name);
+
+acpi_status
+acpi_ps_display_object_pathname (
+ struct acpi_walk_state *walk_state,
+ union acpi_parse_object *op);
void
-acpi_dm_decode_node (
- struct acpi_namespace_node *node);
+acpi_dm_namestring (
+ char *name);
+
+/*
+ * dmobject
+ */
void
acpi_dm_display_internal_object (
union acpi_operand_object *obj_desc,
@@ -241,6 +198,16 @@ acpi_dm_dump_method_info (
/*
* dmbuffer
*/
+void
+acpi_dm_disasm_byte_list (
+ u32 level,
+ u8 *byte_data,
+ u32 byte_count);
+
+void
+acpi_dm_byte_list (
+ struct acpi_op_walk_info *info,
+ union acpi_parse_object *op);
void
acpi_is_eisa_id (
@@ -262,18 +229,6 @@ acpi_dm_is_string_buffer (
/*
* dmresrc
*/
-
-void
-acpi_dm_disasm_byte_list (
- u32 level,
- u8 *byte_data,
- u32 byte_count);
-
-void
-acpi_dm_byte_list (
- struct acpi_op_walk_info *info,
- union acpi_parse_object *op);
-
void
acpi_dm_resource_descriptor (
struct acpi_op_walk_info *info,
@@ -296,19 +251,10 @@ void
acpi_dm_decode_attribute (
u8 attribute);
+
/*
* dmresrcl
*/
-
-void
-acpi_dm_io_flags (
- u8 flags);
-
-void
-acpi_dm_memory_flags (
- u8 flags,
- u8 specific_flags);
-
void
acpi_dm_word_descriptor (
struct asl_word_address_desc *resource,
@@ -373,7 +319,6 @@ acpi_dm_vendor_large_descriptor (
/*
* dmresrcs
*/
-
void
acpi_dm_irq_descriptor (
struct asl_irq_format_desc *resource,
@@ -420,7 +365,6 @@ acpi_dm_vendor_small_descriptor (
/*
* dmutils
*/
-
void
acpi_dm_add_to_external_list (
char *path);
diff --git a/include/acpi/acdispat.h b/include/acpi/acdispat.h
index 237d6343358..8f5f2f71b1d 100644
--- a/include/acpi/acdispat.h
+++ b/include/acpi/acdispat.h
@@ -50,40 +50,9 @@
#define NAMEOF_ARG_NTE "__A0"
-/* Common interfaces */
-
-acpi_status
-acpi_ds_obj_stack_push (
- void *object,
- struct acpi_walk_state *walk_state);
-
-acpi_status
-acpi_ds_obj_stack_pop (
- u32 pop_count,
- struct acpi_walk_state *walk_state);
-
-#ifdef ACPI_FUTURE_USAGE
-void *
-acpi_ds_obj_stack_get_value (
- u32 index,
- struct acpi_walk_state *walk_state);
-#endif
-
-acpi_status
-acpi_ds_obj_stack_pop_object (
- union acpi_operand_object **object,
- struct acpi_walk_state *walk_state);
-
-
-/* dsopcode - support for late evaluation */
-
-acpi_status
-acpi_ds_execute_arguments (
- struct acpi_namespace_node *node,
- struct acpi_namespace_node *scope_node,
- u32 aml_length,
- u8 *aml_start);
-
+/*
+ * dsopcode - support for late evaluation
+ */
acpi_status
acpi_ds_get_buffer_field_arguments (
union acpi_operand_object *obj_desc);
@@ -101,15 +70,6 @@ acpi_ds_get_package_arguments (
union acpi_operand_object *obj_desc);
acpi_status
-acpi_ds_init_buffer_field (
- u16 aml_opcode,
- union acpi_operand_object *obj_desc,
- union acpi_operand_object *buffer_desc,
- union acpi_operand_object *offset_desc,
- union acpi_operand_object *length_desc,
- union acpi_operand_object *result_desc);
-
-acpi_status
acpi_ds_eval_buffer_field_operands (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op);
@@ -130,9 +90,9 @@ acpi_ds_initialize_region (
acpi_handle obj_handle);
-/* dsctrl - Parser/Interpreter interface, control stack routines */
-
-
+/*
+ * dsctrl - Parser/Interpreter interface, control stack routines
+ */
acpi_status
acpi_ds_exec_begin_control_op (
struct acpi_walk_state *walk_state,
@@ -144,9 +104,9 @@ acpi_ds_exec_end_control_op (
union acpi_parse_object *op);
-/* dsexec - Parser/Interpreter interface, method execution callbacks */
-
-
+/*
+ * dsexec - Parser/Interpreter interface, method execution callbacks
+ */
acpi_status
acpi_ds_get_predicate_value (
struct acpi_walk_state *walk_state,
@@ -162,14 +122,9 @@ acpi_ds_exec_end_op (
struct acpi_walk_state *state);
-/* dsfield - Parser/Interpreter interface for AML fields */
-
-acpi_status
-acpi_ds_get_field_names (
- struct acpi_create_field_info *info,
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *arg);
-
+/*
+ * dsfield - Parser/Interpreter interface for AML fields
+ */
acpi_status
acpi_ds_create_field (
union acpi_parse_object *op,
@@ -199,8 +154,9 @@ acpi_ds_init_field_objects (
struct acpi_walk_state *walk_state);
-/* dsload - Parser/Interpreter interface, namespace load callbacks */
-
+/*
+ * dsload - Parser/Interpreter interface, namespace load callbacks
+ */
acpi_status
acpi_ds_load1_begin_op (
struct acpi_walk_state *walk_state,
@@ -225,9 +181,9 @@ acpi_ds_init_callbacks (
u32 pass_number);
-/* dsmthdat - method data (locals/args) */
-
-
+/*
+ * dsmthdat - method data (locals/args)
+ */
acpi_status
acpi_ds_store_object_to_local (
u16 opcode,
@@ -250,14 +206,6 @@ u8
acpi_ds_is_method_value (
union acpi_operand_object *obj_desc);
-#ifdef ACPI_FUTURE_USAGE
-acpi_object_type
-acpi_ds_method_data_get_type (
- u16 opcode,
- u32 index,
- struct acpi_walk_state *walk_state);
-#endif
-
acpi_status
acpi_ds_method_data_get_value (
u16 opcode,
@@ -265,12 +213,6 @@ acpi_ds_method_data_get_value (
struct acpi_walk_state *walk_state,
union acpi_operand_object **dest_desc);
-void
-acpi_ds_method_data_delete_value (
- u16 opcode,
- u32 index,
- struct acpi_walk_state *walk_state);
-
acpi_status
acpi_ds_method_data_init_args (
union acpi_operand_object **params,
@@ -288,16 +230,10 @@ void
acpi_ds_method_data_init (
struct acpi_walk_state *walk_state);
-acpi_status
-acpi_ds_method_data_set_value (
- u16 opcode,
- u32 index,
- union acpi_operand_object *object,
- struct acpi_walk_state *walk_state);
-
-
-/* dsmethod - Parser/Interpreter interface - control method parsing */
+/*
+ * dsmethod - Parser/Interpreter interface - control method parsing
+ */
acpi_status
acpi_ds_parse_method (
acpi_handle obj_handle);
@@ -324,20 +260,18 @@ acpi_ds_begin_method_execution (
struct acpi_namespace_node *calling_method_node);
-/* dsobj - Parser/Interpreter interface - object initialization and conversion */
-
-acpi_status
-acpi_ds_init_one_object (
- acpi_handle obj_handle,
- u32 level,
- void *context,
- void **return_value);
-
+/*
+ * dsinit
+ */
acpi_status
acpi_ds_initialize_objects (
struct acpi_table_desc *table_desc,
struct acpi_namespace_node *start_node);
+
+/*
+ * dsobject - Parser/Interpreter interface - object initialization and conversion
+ */
acpi_status
acpi_ds_build_internal_buffer_obj (
struct acpi_walk_state *walk_state,
@@ -353,12 +287,6 @@ acpi_ds_build_internal_package_obj (
union acpi_operand_object **obj_desc);
acpi_status
-acpi_ds_build_internal_object (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *op,
- union acpi_operand_object **obj_desc_ptr);
-
-acpi_status
acpi_ds_init_object_from_op (
struct acpi_walk_state *walk_state,
union acpi_parse_object *op,
@@ -372,8 +300,9 @@ acpi_ds_create_node (
union acpi_parse_object *op);
-/* dsutils - Parser/Interpreter interface utility routines */
-
+/*
+ * dsutils - Parser/Interpreter interface utility routines
+ */
void
acpi_ds_clear_implicit_return (
struct acpi_walk_state *walk_state);
@@ -418,7 +347,6 @@ acpi_ds_clear_operands (
/*
* dswscope - Scope Stack manipulation
*/
-
acpi_status
acpi_ds_scope_stack_push (
struct acpi_namespace_node *node,
@@ -435,7 +363,18 @@ acpi_ds_scope_stack_clear (
struct acpi_walk_state *walk_state);
-/* dswstate - parser WALK_STATE management routines */
+/*
+ * dswstate - parser WALK_STATE management routines
+ */
+acpi_status
+acpi_ds_obj_stack_push (
+ void *object,
+ struct acpi_walk_state *walk_state);
+
+acpi_status
+acpi_ds_obj_stack_pop (
+ u32 pop_count,
+ struct acpi_walk_state *walk_state);
struct acpi_walk_state *
acpi_ds_create_walk_state (
@@ -454,12 +393,6 @@ acpi_ds_init_aml_walk (
struct acpi_parameter_info *info,
u32 pass_number);
-#ifdef ACPI_FUTURE_USAGE
-acpi_status
-acpi_ds_obj_stack_delete_all (
- struct acpi_walk_state *walk_state);
-#endif
-
acpi_status
acpi_ds_obj_stack_pop_and_delete (
u32 pop_count,
@@ -494,20 +427,8 @@ struct acpi_walk_state *
acpi_ds_get_current_walk_state (
struct acpi_thread_state *thread);
-#ifdef ACPI_ENABLE_OBJECT_CACHE
-void
-acpi_ds_delete_walk_state_cache (
- void);
-#endif
-
#ifdef ACPI_FUTURE_USAGE
acpi_status
-acpi_ds_result_insert (
- void *object,
- u32 index,
- struct acpi_walk_state *walk_state);
-
-acpi_status
acpi_ds_result_remove (
union acpi_operand_object **object,
u32 index,
@@ -529,4 +450,10 @@ acpi_ds_result_pop_from_bottom (
union acpi_operand_object **object,
struct acpi_walk_state *walk_state);
+#ifdef ACPI_ENABLE_OBJECT_CACHE
+void
+acpi_ds_delete_walk_state_cache (
+ void);
+#endif
+
#endif /* _ACDISPAT_H_ */
diff --git a/include/acpi/acevents.h b/include/acpi/acevents.h
index 2dec083ba1c..61a27c8c507 100644
--- a/include/acpi/acevents.h
+++ b/include/acpi/acevents.h
@@ -45,6 +45,9 @@
#define __ACEVENTS_H__
+/*
+ * evevent
+ */
acpi_status
acpi_ev_initialize_events (
void);
@@ -53,28 +56,14 @@ acpi_status
acpi_ev_install_xrupt_handlers (
void);
-
-/*
- * Evfixed - Fixed event handling
- */
-
-acpi_status
-acpi_ev_fixed_event_initialize (
- void);
-
u32
acpi_ev_fixed_event_detect (
void);
-u32
-acpi_ev_fixed_event_dispatch (
- u32 event);
-
/*
- * Evmisc
+ * evmisc
*/
-
u8
acpi_ev_is_notify_object (
struct acpi_namespace_node *node);
@@ -100,24 +89,10 @@ acpi_ev_queue_notify_request (
struct acpi_namespace_node *node,
u32 notify_value);
-void ACPI_SYSTEM_XFACE
-acpi_ev_notify_dispatch (
- void *context);
-
/*
- * Evgpe - GPE handling and dispatch
+ * evgpe - GPE handling and dispatch
*/
-
-acpi_status
-acpi_ev_walk_gpe_list (
- ACPI_GPE_CALLBACK gpe_walk_callback,
- u32 flags);
-
-u8
-acpi_ev_valid_gpe_event (
- struct acpi_gpe_event_info *gpe_event_info);
-
acpi_status
acpi_ev_update_gpe_enable_masks (
struct acpi_gpe_event_info *gpe_event_info,
@@ -137,9 +112,23 @@ acpi_ev_get_gpe_event_info (
acpi_handle gpe_device,
u32 gpe_number);
+
+/*
+ * evgpeblk
+ */
+u8
+acpi_ev_valid_gpe_event (
+ struct acpi_gpe_event_info *gpe_event_info);
+
acpi_status
-acpi_ev_gpe_initialize (
- void);
+acpi_ev_walk_gpe_list (
+ ACPI_GPE_CALLBACK gpe_walk_callback,
+ u32 flags);
+
+acpi_status
+acpi_ev_delete_gpe_handlers (
+ struct acpi_gpe_xrupt_info *gpe_xrupt_info,
+ struct acpi_gpe_block_info *gpe_block);
acpi_status
acpi_ev_create_gpe_block (
@@ -154,11 +143,6 @@ acpi_status
acpi_ev_delete_gpe_block (
struct acpi_gpe_block_info *gpe_block);
-acpi_status
-acpi_ev_delete_gpe_handlers (
- struct acpi_gpe_xrupt_info *gpe_xrupt_info,
- struct acpi_gpe_block_info *gpe_block);
-
u32
acpi_ev_gpe_dispatch (
struct acpi_gpe_event_info *gpe_event_info,
@@ -177,10 +161,14 @@ acpi_status
acpi_ev_check_for_wake_only_gpe (
struct acpi_gpe_event_info *gpe_event_info);
+acpi_status
+acpi_ev_gpe_initialize (
+ void);
+
+
/*
- * Evregion - Address Space handling
+ * evregion - Address Space handling
*/
-
acpi_status
acpi_ev_install_region_handlers (
void);
@@ -198,13 +186,6 @@ acpi_ev_address_space_dispatch (
void *value);
acpi_status
-acpi_ev_install_handler (
- acpi_handle obj_handle,
- u32 level,
- void *context,
- void **return_value);
-
-acpi_status
acpi_ev_attach_region (
union acpi_operand_object *handler_obj,
union acpi_operand_object *region_obj,
@@ -233,17 +214,10 @@ acpi_ev_execute_reg_method (
union acpi_operand_object *region_obj,
u32 function);
-acpi_status
-acpi_ev_reg_run (
- acpi_handle obj_handle,
- u32 level,
- void *context,
- void **return_value);
/*
- * Evregini - Region initialization and setup
+ * evregini - Region initialization and setup
*/
-
acpi_status
acpi_ev_system_memory_region_setup (
acpi_handle handle,
@@ -293,9 +267,8 @@ acpi_ev_initialize_region (
/*
- * Evsci - SCI (System Control Interrupt) handling/dispatch
+ * evsci - SCI (System Control Interrupt) handling/dispatch
*/
-
u32 ACPI_SYSTEM_XFACE
acpi_ev_gpe_xrupt_handler (
void *context);
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 53f8b50fac1..60d737b2d70 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -48,7 +48,6 @@
/*
* Exceptions returned by external ACPI interfaces
*/
-
#define AE_CODE_ENVIRONMENTAL 0x0000
#define AE_CODE_PROGRAMMER 0x1000
#define AE_CODE_ACPI_TABLES 0x2000
@@ -99,6 +98,7 @@
#define AE_CODE_ENV_MAX 0x001E
+
/*
* Programmer exceptions
*/
@@ -168,6 +168,7 @@
#define AE_CODE_AML_MAX 0x0021
+
/*
* Internal exceptions used for control
*/
@@ -188,6 +189,7 @@
#ifdef DEFINE_ACPI_GLOBALS
+
/*
* String versions of the exception codes above
* These strings must match the corresponding defines exactly
@@ -304,5 +306,4 @@ char const *acpi_gbl_exception_names_ctrl[] =
#endif /* ACPI GLOBALS */
-
#endif /* __ACEXCEP_H__ */
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index c7f387a972c..4946696088c 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -146,15 +146,15 @@ ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT;
ACPI_EXTERN FACS_DESCRIPTOR *acpi_gbl_FACS;
ACPI_EXTERN struct acpi_common_facs acpi_gbl_common_fACS;
/*
- * Since there may be multiple SSDTs and PSDTS, a single pointer is not
+ * Since there may be multiple SSDTs and PSDTs, a single pointer is not
* sufficient; Therefore, there isn't one!
*/
/*
- * Handle both ACPI 1.0 and ACPI 2.0 Integer widths
- * If we are running a method that exists in a 32-bit ACPI table.
- * Use only 32 bits of the Integer for conversion.
+ * Handle both ACPI 1.0 and ACPI 2.0 Integer widths:
+ * If we are executing a method that exists in a 32-bit ACPI table,
+ * use only the lower 32 bits of the (internal) 64-bit Integer.
*/
ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
@@ -246,6 +246,7 @@ ACPI_EXTERN acpi_size acpi_gbl_lowest_stack_pointer;
ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
#endif
+
/*****************************************************************************
*
* Interpreter globals
@@ -268,6 +269,7 @@ ACPI_EXTERN u8 acpi_gbl_cm_single_step;
ACPI_EXTERN union acpi_parse_object *acpi_gbl_parsed_namespace_root;
+
/*****************************************************************************
*
* Hardware globals
@@ -298,7 +300,6 @@ ACPI_EXTERN acpi_handle acpi_gbl_gpe_lock;
*
****************************************************************************/
-
ACPI_EXTERN u8 acpi_gbl_db_output_flags;
#ifdef ACPI_DISASSEMBLER
@@ -353,5 +354,4 @@ ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
#endif /* ACPI_DEBUGGER */
-
#endif /* __ACGLOBAL_H__ */
diff --git a/include/acpi/achware.h b/include/acpi/achware.h
index 28ad1398c15..9d63641b8e7 100644
--- a/include/acpi/achware.h
+++ b/include/acpi/achware.h
@@ -46,22 +46,26 @@
/* PM Timer ticks per second (HZ) */
+
#define PM_TIMER_FREQUENCY 3579545
+/* Values for the _SST reserved method */
-/* Prototypes */
+#define ACPI_SST_INDICATOR_OFF 0
+#define ACPI_SST_WORKING 1
+#define ACPI_SST_WAKING 2
+#define ACPI_SST_SLEEPING 3
+#define ACPI_SST_SLEEP_CONTEXT 4
-acpi_status
-acpi_hw_initialize (
- void);
+/* Prototypes */
-acpi_status
-acpi_hw_shutdown (
- void);
+/*
+ * hwacpi - high level functions
+ */
acpi_status
-acpi_hw_initialize_system_info (
+acpi_hw_initialize (
void);
acpi_status
@@ -72,12 +76,10 @@ u32
acpi_hw_get_mode (
void);
-u32
-acpi_hw_get_mode_capabilities (
- void);
-
-/* Register I/O Prototypes */
+/*
+ * hwregs - ACPI Register I/O
+ */
struct acpi_bit_register_info *
acpi_hw_get_bit_register_info (
u32 register_id);
@@ -111,8 +113,9 @@ acpi_hw_clear_acpi_status (
u32 flags);
-/* GPE support */
-
+/*
+ * hwgpe - GPE support
+ */
acpi_status
acpi_hw_write_gpe_enable_reg (
struct acpi_gpe_event_info *gpe_event_info);
@@ -131,12 +134,12 @@ acpi_hw_clear_gpe_block (
struct acpi_gpe_xrupt_info *gpe_xrupt_info,
struct acpi_gpe_block_info *gpe_block);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_hw_get_gpe_status (
struct acpi_gpe_event_info *gpe_event_info,
acpi_event_status *event_status);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
acpi_status
acpi_hw_disable_all_gpes (
@@ -155,15 +158,11 @@ acpi_hw_enable_runtime_gpe_block (
struct acpi_gpe_xrupt_info *gpe_xrupt_info,
struct acpi_gpe_block_info *gpe_block);
-acpi_status
-acpi_hw_enable_wakeup_gpe_block (
- struct acpi_gpe_xrupt_info *gpe_xrupt_info,
- struct acpi_gpe_block_info *gpe_block);
-
-
-/* ACPI Timer prototypes */
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
+/*
+ * hwtimer - ACPI Timer prototypes
+ */
acpi_status
acpi_get_timer_resolution (
u32 *resolution);
@@ -177,6 +176,7 @@ acpi_get_timer_duration (
u32 start_ticks,
u32 end_ticks,
u32 *time_elapsed);
-#endif /* ACPI_FUTURE_USAGE */
+#endif /* ACPI_FUTURE_USAGE */
+
#endif /* __ACHWARE_H__ */
diff --git a/include/acpi/acinterp.h b/include/acpi/acinterp.h
index c5301f5ffaf..5c7172477a0 100644
--- a/include/acpi/acinterp.h
+++ b/include/acpi/acinterp.h
@@ -48,37 +48,9 @@
#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
-acpi_status
-acpi_ex_resolve_operands (
- u16 opcode,
- union acpi_operand_object **stack_ptr,
- struct acpi_walk_state *walk_state);
-
-acpi_status
-acpi_ex_check_object_type (
- acpi_object_type type_needed,
- acpi_object_type this_type,
- void *object);
-
-/*
- * exxface - External interpreter interfaces
- */
-
-acpi_status
-acpi_ex_load_table (
- acpi_table_type table_id);
-
-acpi_status
-acpi_ex_execute_method (
- struct acpi_namespace_node *method_node,
- union acpi_operand_object **params,
- union acpi_operand_object **return_obj_desc);
-
-
/*
* exconvrt - object conversion
*/
-
acpi_status
acpi_ex_convert_to_integer (
union acpi_operand_object *obj_desc,
@@ -110,17 +82,10 @@ acpi_ex_convert_to_target_type (
union acpi_operand_object **result_desc,
struct acpi_walk_state *walk_state);
-u32
-acpi_ex_convert_to_ascii (
- acpi_integer integer,
- u16 base,
- u8 *string,
- u8 max_length);
/*
* exfield - ACPI AML (p-code) execution - field manipulation
*/
-
acpi_status
acpi_ex_common_buffer_setup (
union acpi_operand_object *obj_desc,
@@ -128,42 +93,6 @@ acpi_ex_common_buffer_setup (
u32 *datum_count);
acpi_status
-acpi_ex_extract_from_field (
- union acpi_operand_object *obj_desc,
- void *buffer,
- u32 buffer_length);
-
-acpi_status
-acpi_ex_insert_into_field (
- union acpi_operand_object *obj_desc,
- void *buffer,
- u32 buffer_length);
-
-acpi_status
-acpi_ex_setup_region (
- union acpi_operand_object *obj_desc,
- u32 field_datum_byte_offset);
-
-acpi_status
-acpi_ex_access_region (
- union acpi_operand_object *obj_desc,
- u32 field_datum_byte_offset,
- acpi_integer *value,
- u32 read_write);
-
-u8
-acpi_ex_register_overflow (
- union acpi_operand_object *obj_desc,
- acpi_integer value);
-
-acpi_status
-acpi_ex_field_datum_io (
- union acpi_operand_object *obj_desc,
- u32 field_datum_byte_offset,
- acpi_integer *value,
- u32 read_write);
-
-acpi_status
acpi_ex_write_with_update_rule (
union acpi_operand_object *obj_desc,
acpi_integer mask,
@@ -198,28 +127,33 @@ acpi_ex_write_data_to_field (
union acpi_operand_object *obj_desc,
union acpi_operand_object **result_desc);
+
/*
- * exmisc - ACPI AML (p-code) execution - specific opcodes
+ * exfldio - low level field I/O
*/
-
acpi_status
-acpi_ex_opcode_3A_0T_0R (
- struct acpi_walk_state *walk_state);
+acpi_ex_extract_from_field (
+ union acpi_operand_object *obj_desc,
+ void *buffer,
+ u32 buffer_length);
acpi_status
-acpi_ex_opcode_3A_1T_1R (
- struct acpi_walk_state *walk_state);
+acpi_ex_insert_into_field (
+ union acpi_operand_object *obj_desc,
+ void *buffer,
+ u32 buffer_length);
acpi_status
-acpi_ex_opcode_6A_0T_1R (
- struct acpi_walk_state *walk_state);
+acpi_ex_access_region (
+ union acpi_operand_object *obj_desc,
+ u32 field_datum_byte_offset,
+ acpi_integer *value,
+ u32 read_write);
-u8
-acpi_ex_do_match (
- u32 match_op,
- union acpi_operand_object *package_obj,
- union acpi_operand_object *match_obj);
+/*
+ * exmisc - misc support routines
+ */
acpi_status
acpi_ex_get_object_reference (
union acpi_operand_object *obj_desc,
@@ -227,13 +161,6 @@ acpi_ex_get_object_reference (
struct acpi_walk_state *walk_state);
acpi_status
-acpi_ex_resolve_multiple (
- struct acpi_walk_state *walk_state,
- union acpi_operand_object *operand,
- acpi_object_type *return_type,
- union acpi_operand_object **return_desc);
-
-acpi_status
acpi_ex_concat_template (
union acpi_operand_object *obj_desc,
union acpi_operand_object *obj_desc2,
@@ -308,13 +235,6 @@ acpi_ex_create_method (
/*
* exconfig - dynamic table load/unload
*/
-
-acpi_status
-acpi_ex_add_table (
- struct acpi_table_header *table,
- struct acpi_namespace_node *parent_node,
- union acpi_operand_object **ddb_handle);
-
acpi_status
acpi_ex_load_op (
union acpi_operand_object *obj_desc,
@@ -334,7 +254,6 @@ acpi_ex_unload_table (
/*
* exmutex - mutex support
*/
-
acpi_status
acpi_ex_acquire_mutex (
union acpi_operand_object *time_desc,
@@ -354,15 +273,10 @@ void
acpi_ex_unlink_mutex (
union acpi_operand_object *obj_desc);
-void
-acpi_ex_link_mutex (
- union acpi_operand_object *obj_desc,
- struct acpi_thread_state *thread);
/*
- * exprep - ACPI AML (p-code) execution - prep utilities
+ * exprep - ACPI AML execution - prep utilities
*/
-
acpi_status
acpi_ex_prep_common_field_object (
union acpi_operand_object *obj_desc,
@@ -375,10 +289,10 @@ acpi_status
acpi_ex_prep_field_value (
struct acpi_create_field_info *info);
+
/*
* exsystem - Interface to OS services
*/
-
acpi_status
acpi_ex_system_do_notify_op (
union acpi_operand_object *value,
@@ -421,9 +335,8 @@ acpi_ex_system_wait_semaphore (
/*
- * exmonadic - ACPI AML (p-code) execution, monadic operators
+ * exoparg1 - ACPI AML execution, 1 operand
*/
-
acpi_status
acpi_ex_opcode_0A_0T_1R (
struct acpi_walk_state *walk_state);
@@ -445,9 +358,8 @@ acpi_ex_opcode_1A_1T_0R (
struct acpi_walk_state *walk_state);
/*
- * exdyadic - ACPI AML (p-code) execution, dyadic operators
+ * exoparg2 - ACPI AML execution, 2 operands
*/
-
acpi_status
acpi_ex_opcode_2A_0T_0R (
struct acpi_walk_state *walk_state);
@@ -466,21 +378,56 @@ acpi_ex_opcode_2A_2T_1R (
/*
- * exresolv - Object resolution and get value functions
+ * exoparg3 - ACPI AML execution, 3 operands
+ */
+acpi_status
+acpi_ex_opcode_3A_0T_0R (
+ struct acpi_walk_state *walk_state);
+
+acpi_status
+acpi_ex_opcode_3A_1T_1R (
+ struct acpi_walk_state *walk_state);
+
+
+/*
+ * exoparg6 - ACPI AML execution, 6 operands
*/
+acpi_status
+acpi_ex_opcode_6A_0T_1R (
+ struct acpi_walk_state *walk_state);
+
+/*
+ * exresolv - Object resolution and get value functions
+ */
acpi_status
acpi_ex_resolve_to_value (
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state);
acpi_status
+acpi_ex_resolve_multiple (
+ struct acpi_walk_state *walk_state,
+ union acpi_operand_object *operand,
+ acpi_object_type *return_type,
+ union acpi_operand_object **return_desc);
+
+
+/*
+ * exresnte - resolve namespace node
+ */
+acpi_status
acpi_ex_resolve_node_to_value (
struct acpi_namespace_node **stack_ptr,
struct acpi_walk_state *walk_state);
+
+/*
+ * exresop - resolve operand to value
+ */
acpi_status
-acpi_ex_resolve_object_to_value (
+acpi_ex_resolve_operands (
+ u16 opcode,
union acpi_operand_object **stack_ptr,
struct acpi_walk_state *walk_state);
@@ -488,7 +435,6 @@ acpi_ex_resolve_object_to_value (
/*
* exdump - Interpreter debug output routines
*/
-
void
acpi_ex_dump_operand (
union acpi_operand_object *obj_desc,
@@ -504,7 +450,7 @@ acpi_ex_dump_operands (
char *module_name,
u32 line_number);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
void
acpi_ex_dump_object_descriptor (
union acpi_operand_object *object,
@@ -514,46 +460,12 @@ void
acpi_ex_dump_node (
struct acpi_namespace_node *node,
u32 flags);
+#endif /* ACPI_FUTURE_USAGE */
-void
-acpi_ex_out_string (
- char *title,
- char *value);
-
-void
-acpi_ex_out_pointer (
- char *title,
- void *value);
-
-void
-acpi_ex_out_integer (
- char *title,
- u32 value);
-
-void
-acpi_ex_out_address (
- char *title,
- acpi_physical_address value);
-#endif /* ACPI_FUTURE_USAGE */
/*
- * exnames - interpreter/scanner name load/execute
+ * exnames - AML namestring support
*/
-
-char *
-acpi_ex_allocate_name_string (
- u32 prefix_count,
- u32 num_name_segs);
-
-u32
-acpi_ex_good_char (
- u32 character);
-
-acpi_status
-acpi_ex_name_segment (
- u8 **in_aml_address,
- char *name_string);
-
acpi_status
acpi_ex_get_name_string (
acpi_object_type data_type,
@@ -561,16 +473,10 @@ acpi_ex_get_name_string (
char **out_name_string,
u32 *out_name_length);
-acpi_status
-acpi_ex_do_name (
- acpi_object_type data_type,
- acpi_interpreter_mode load_exec_mode);
-
/*
* exstore - Object store support
*/
-
acpi_status
acpi_ex_store (
union acpi_operand_object *val_desc,
@@ -578,12 +484,6 @@ acpi_ex_store (
struct acpi_walk_state *walk_state);
acpi_status
-acpi_ex_store_object_to_index (
- union acpi_operand_object *val_desc,
- union acpi_operand_object *dest_desc,
- struct acpi_walk_state *walk_state);
-
-acpi_status
acpi_ex_store_object_to_node (
union acpi_operand_object *source_desc,
struct acpi_namespace_node *node,
@@ -593,10 +493,10 @@ acpi_ex_store_object_to_node (
#define ACPI_IMPLICIT_CONVERSION TRUE
#define ACPI_NO_IMPLICIT_CONVERSION FALSE
+
/*
- * exstoren
+ * exstoren - resolve/store object
*/
-
acpi_status
acpi_ex_resolve_object (
union acpi_operand_object **source_desc_ptr,
@@ -612,9 +512,8 @@ acpi_ex_store_object_to_object (
/*
- * excopy - object copy
+ * exstorob - store object - buffer/string
*/
-
acpi_status
acpi_ex_store_buffer_to_buffer (
union acpi_operand_object *source_desc,
@@ -625,6 +524,10 @@ acpi_ex_store_string_to_string (
union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc);
+
+/*
+ * excopy - object copy
+ */
acpi_status
acpi_ex_copy_integer_to_index_field (
union acpi_operand_object *source_desc,
@@ -645,10 +548,10 @@ acpi_ex_copy_integer_to_buffer_field (
union acpi_operand_object *source_desc,
union acpi_operand_object *target_desc);
+
/*
* exutils - interpreter/scanner utilities
*/
-
acpi_status
acpi_ex_enter_interpreter (
void);
@@ -669,11 +572,6 @@ void
acpi_ex_release_global_lock (
u8 locked);
-u32
-acpi_ex_digits_needed (
- acpi_integer value,
- u32 base);
-
void
acpi_ex_eisa_id_to_string (
u32 numeric_id,
@@ -688,7 +586,6 @@ acpi_ex_unsigned_integer_to_string (
/*
* exregion - default op_region handlers
*/
-
acpi_status
acpi_ex_system_memory_space_handler (
u32 function,
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index 01d3b4bc0c8..030e641115c 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -72,7 +72,6 @@ typedef u32 acpi_mutex_handle;
*
* NOTE: any changes here must be reflected in the acpi_gbl_mutex_names table also!
*/
-
#define ACPI_MTX_EXECUTE 0
#define ACPI_MTX_INTERPRETER 1
#define ACPI_MTX_PARSER 2
@@ -151,13 +150,13 @@ typedef u16 acpi_owner_id;
#define ACPI_FIELD_DWORD_GRANULARITY 4
#define ACPI_FIELD_QWORD_GRANULARITY 8
+
/*****************************************************************************
*
* Namespace typedefs and structs
*
****************************************************************************/
-
/* Operational modes of the AML interpreter/scanner */
typedef enum
@@ -176,7 +175,6 @@ typedef enum
* data_type is used to differentiate between internal descriptors, and MUST
* be the first byte in this structure.
*/
-
union acpi_name_union
{
u32 integer;
@@ -415,7 +413,6 @@ struct acpi_field_info
*
****************************************************************************/
-
#define ACPI_CONTROL_NORMAL 0xC0
#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
@@ -424,6 +421,7 @@ struct acpi_field_info
/* Forward declarations */
+
struct acpi_walk_state ;
struct acpi_obj_mutex;
union acpi_parse_object ;
@@ -601,7 +599,6 @@ struct acpi_opcode_info
u8 type; /* Opcode type */
};
-
union acpi_parse_value
{
acpi_integer integer; /* Integer constant (Up to 64 bits) */
@@ -613,7 +610,6 @@ union acpi_parse_value
union acpi_parse_object *arg; /* arguments and contained ops */
};
-
#define ACPI_PARSE_COMMON \
u8 data_type; /* To differentiate various internal objs */\
u8 flags; /* Type of Op */\
@@ -691,7 +687,6 @@ struct acpi_parse_obj_asl
char parse_op_name[12];
};
-
union acpi_parse_object
{
struct acpi_parse_obj_common common;
@@ -834,7 +829,6 @@ struct acpi_bit_register_info
*
****************************************************************************/
-
/* resource_type values */
#define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index fcaced16b16..09be937d2c3 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -539,11 +539,6 @@
#define ACPI_DUMP_ENTRY(a,b) acpi_ns_dump_entry (a,b)
-
-#ifdef ACPI_FUTURE_USAGE
-#define ACPI_DUMP_TABLES(a,b) acpi_ns_dump_tables(a,b)
-#endif
-
#define ACPI_DUMP_PATHNAME(a,b,c,d) acpi_ns_dump_pathname(a,b,c,d)
#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
#define ACPI_DUMP_BUFFER(a,b) acpi_ut_dump_buffer((u8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
@@ -596,11 +591,6 @@
#define ACPI_DUMP_STACK_ENTRY(a)
#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
#define ACPI_DUMP_ENTRY(a,b)
-
-#ifdef ACPI_FUTURE_USAGE
-#define ACPI_DUMP_TABLES(a,b)
-#endif
-
#define ACPI_DUMP_PATHNAME(a,b,c,d)
#define ACPI_DUMP_RESOURCE_LIST(a)
#define ACPI_DUMP_BUFFER(a,b)
diff --git a/include/acpi/acnames.h b/include/acpi/acnames.h
new file mode 100644
index 00000000000..deb7cb06f5f
--- /dev/null
+++ b/include/acpi/acnames.h
@@ -0,0 +1,84 @@
+/******************************************************************************
+ *
+ * Name: acnames.h - Global names and strings
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2005, R. Byron Moore
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef __ACNAMES_H__
+#define __ACNAMES_H__
+
+/* Method names - these methods can appear anywhere in the namespace */
+
+#define METHOD_NAME__HID "_HID"
+#define METHOD_NAME__CID "_CID"
+#define METHOD_NAME__UID "_UID"
+#define METHOD_NAME__ADR "_ADR"
+#define METHOD_NAME__INI "_INI"
+#define METHOD_NAME__STA "_STA"
+#define METHOD_NAME__REG "_REG"
+#define METHOD_NAME__SEG "_SEG"
+#define METHOD_NAME__BBN "_BBN"
+#define METHOD_NAME__PRT "_PRT"
+#define METHOD_NAME__CRS "_CRS"
+#define METHOD_NAME__PRS "_PRS"
+#define METHOD_NAME__PRW "_PRW"
+#define METHOD_NAME__SRS "_SRS"
+
+/* Method names - these methods must appear at the namespace root */
+
+#define METHOD_NAME__BFS "\\_BFS"
+#define METHOD_NAME__GTS "\\_GTS"
+#define METHOD_NAME__PTS "\\_PTS"
+#define METHOD_NAME__SST "\\_SI._SST"
+#define METHOD_NAME__WAK "\\_WAK"
+
+/* Definitions of the predefined namespace names */
+
+#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */
+#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */
+#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */
+
+#define ACPI_NS_ROOT_PATH "\\"
+#define ACPI_NS_SYSTEM_BUS "_SB_"
+
+
+#endif /* __ACNAMES_H__ */
+
+
diff --git a/include/acpi/acnamesp.h b/include/acpi/acnamesp.h
index 8b3cdc3566b..d1b3ce80056 100644
--- a/include/acpi/acnamesp.h
+++ b/include/acpi/acnamesp.h
@@ -57,17 +57,6 @@
#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */
#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */
-
-/* Definitions of the predefined namespace names */
-
-#define ACPI_UNKNOWN_NAME (u32) 0x3F3F3F3F /* Unknown name is "????" */
-#define ACPI_ROOT_NAME (u32) 0x5F5F5F5C /* Root name is "\___" */
-#define ACPI_SYS_BUS_NAME (u32) 0x5F53425F /* Sys bus name is "_SB_" */
-
-#define ACPI_NS_ROOT_PATH "\\"
-#define ACPI_NS_SYSTEM_BUS "_SB_"
-
-
/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
#define ACPI_NS_NO_UPSEARCH 0
@@ -80,10 +69,9 @@
#define ACPI_NS_WALK_NO_UNLOCK FALSE
-acpi_status
-acpi_ns_load_namespace (
- void);
-
+/*
+ * nsinit - Namespace initialization
+ */
acpi_status
acpi_ns_initialize_objects (
void);
@@ -93,23 +81,22 @@ acpi_ns_initialize_devices (
void);
-/* Namespace init - nsxfinit */
-
+/*
+ * nsload - Namespace loading
+ */
acpi_status
-acpi_ns_init_one_device (
- acpi_handle obj_handle,
- u32 nesting_level,
- void *context,
- void **return_value);
+acpi_ns_load_namespace (
+ void);
acpi_status
-acpi_ns_init_one_object (
- acpi_handle obj_handle,
- u32 level,
- void *context,
- void **return_value);
+acpi_ns_load_table (
+ struct acpi_table_desc *table_desc,
+ struct acpi_namespace_node *node);
+/*
+ * nswalk - walk the namespace
+ */
acpi_status
acpi_ns_walk_namespace (
acpi_object_type type,
@@ -126,37 +113,24 @@ acpi_ns_get_next_node (
struct acpi_namespace_node *parent,
struct acpi_namespace_node *child);
-void
-acpi_ns_delete_namespace_by_owner (
- u16 table_id);
-
-
-/* Namespace loading - nsload */
-
-acpi_status
-acpi_ns_one_complete_parse (
- u32 pass_number,
- struct acpi_table_desc *table_desc);
+/*
+ * nsparse - table parsing
+ */
acpi_status
acpi_ns_parse_table (
struct acpi_table_desc *table_desc,
struct acpi_namespace_node *scope);
acpi_status
-acpi_ns_load_table (
- struct acpi_table_desc *table_desc,
- struct acpi_namespace_node *node);
-
-acpi_status
-acpi_ns_load_table_by_type (
- acpi_table_type table_type);
+acpi_ns_one_complete_parse (
+ u32 pass_number,
+ struct acpi_table_desc *table_desc);
/*
- * Top-level namespace access - nsaccess
+ * nsaccess - Top-level namespace access
*/
-
acpi_status
acpi_ns_root_initialize (
void);
@@ -173,9 +147,8 @@ acpi_ns_lookup (
/*
- * Named object allocation/deallocation - nsalloc
+ * nsalloc - Named object allocation/deallocation
*/
-
struct acpi_namespace_node *
acpi_ns_create_node (
u32 name);
@@ -189,6 +162,10 @@ acpi_ns_delete_namespace_subtree (
struct acpi_namespace_node *parent_handle);
void
+acpi_ns_delete_namespace_by_owner (
+ u16 table_id);
+
+void
acpi_ns_detach_object (
struct acpi_namespace_node *node);
@@ -201,36 +178,16 @@ acpi_ns_compare_names (
char *name1,
char *name2);
-void
-acpi_ns_remove_reference (
- struct acpi_namespace_node *node);
-
/*
- * Namespace modification - nsmodify
+ * nsdump - Namespace dump/print utilities
*/
-
-#ifdef ACPI_FUTURE_USAGE
-acpi_status
-acpi_ns_unload_namespace (
- acpi_handle handle);
-
-acpi_status
-acpi_ns_delete_subtree (
- acpi_handle start_handle);
-#endif
-
-
-/*
- * Namespace dump/print utilities - nsdump
- */
-
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
void
acpi_ns_dump_tables (
acpi_handle search_base,
u32 max_depth);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
void
acpi_ns_dump_entry (
@@ -249,19 +206,6 @@ acpi_ns_print_pathname (
u32 num_segments,
char *pathname);
-#ifdef ACPI_FUTURE_USAGE
-acpi_status
-acpi_ns_dump_one_device (
- acpi_handle obj_handle,
- u32 level,
- void *context,
- void **return_value);
-
-void
-acpi_ns_dump_root_devices (
- void);
-#endif /* ACPI_FUTURE_USAGE */
-
acpi_status
acpi_ns_dump_one_object (
acpi_handle obj_handle,
@@ -269,7 +213,7 @@ acpi_ns_dump_one_object (
void *context,
void **return_value);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
void
acpi_ns_dump_objects (
acpi_object_type type,
@@ -277,13 +221,12 @@ acpi_ns_dump_objects (
u32 max_depth,
u32 ownder_id,
acpi_handle start_handle);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
/*
- * Namespace evaluation functions - nseval
+ * nseval - Namespace evaluation functions
*/
-
acpi_status
acpi_ns_evaluate_by_handle (
struct acpi_parameter_info *info);
@@ -298,40 +241,14 @@ acpi_ns_evaluate_relative (
char *pathname,
struct acpi_parameter_info *info);
-acpi_status
-acpi_ns_execute_control_method (
- struct acpi_parameter_info *info);
-
-acpi_status
-acpi_ns_get_object_value (
- struct acpi_parameter_info *info);
-
-
-/*
- * Parent/Child/Peer utility functions
- */
-
-#ifdef ACPI_FUTURE_USAGE
-acpi_name
-acpi_ns_find_parent_name (
- struct acpi_namespace_node *node_to_search);
-#endif
-
/*
- * Name and Scope manipulation - nsnames
+ * nsnames - Name and Scope manipulation
*/
-
u32
acpi_ns_opens_scope (
acpi_object_type type);
-void
-acpi_ns_build_external_path (
- struct acpi_namespace_node *node,
- acpi_size size,
- char *name_buffer);
-
char *
acpi_ns_get_external_pathname (
struct acpi_namespace_node *node);
@@ -363,9 +280,8 @@ acpi_ns_get_pathname_length (
/*
- * Object management for namespace nodes - nsobject
+ * nsobject - Object management for namespace nodes
*/
-
acpi_status
acpi_ns_attach_object (
struct acpi_namespace_node *node,
@@ -399,9 +315,8 @@ acpi_ns_get_attached_data (
/*
- * Namespace searching and entry - nssearch
+ * nssearch - Namespace searching and entry
*/
-
acpi_status
acpi_ns_search_and_enter (
u32 entry_name,
@@ -428,17 +343,12 @@ acpi_ns_install_node (
/*
- * Utility functions - nsutils
+ * nsutils - Utility functions
*/
-
u8
acpi_ns_valid_root_prefix (
char prefix);
-u8
-acpi_ns_valid_path_separator (
- char sep);
-
acpi_object_type
acpi_ns_get_type (
struct acpi_namespace_node *node);
@@ -511,5 +421,4 @@ struct acpi_namespace_node *
acpi_ns_get_next_valid_node (
struct acpi_namespace_node *node);
-
#endif /* __ACNAMESP_H__ */
diff --git a/include/acpi/acobject.h b/include/acpi/acobject.h
index 036023a940b..e079b94e4fc 100644
--- a/include/acpi/acobject.h
+++ b/include/acpi/acobject.h
@@ -133,6 +133,7 @@ struct acpi_object_integer
acpi_integer value;
};
+
/*
* Note: The String and Buffer object must be identical through the Pointer
* element. There is code that depends on this.
@@ -468,7 +469,6 @@ union acpi_operand_object
*
*****************************************************************************/
-
/* Object descriptor types */
#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */
diff --git a/include/acpi/acopcode.h b/include/acpi/acopcode.h
new file mode 100644
index 00000000000..118ecba4cf0
--- /dev/null
+++ b/include/acpi/acopcode.h
@@ -0,0 +1,325 @@
+/******************************************************************************
+ *
+ * Name: acopcode.h - AML opcode information for the AML parser and interpreter
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2005, R. Byron Moore
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef __ACOPCODE_H__
+#define __ACOPCODE_H__
+
+#define MAX_EXTENDED_OPCODE 0x88
+#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
+#define MAX_INTERNAL_OPCODE
+#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
+
+/* Used for non-assigned opcodes */
+
+#define _UNK 0x6B
+
+/*
+ * Reserved ASCII characters. Do not use any of these for
+ * internal opcodes, since they are used to differentiate
+ * name strings from AML opcodes
+ */
+#define _ASC 0x6C
+#define _NAM 0x6C
+#define _PFX 0x6D
+
+
+/*
+ * All AML opcodes and the parse-time arguments for each. Used by the AML
+ * parser Each list is compressed into a 32-bit number and stored in the
+ * master opcode table (in psopcode.c).
+ */
+#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
+#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
+#define ARGP_ARG0 ARG_NONE
+#define ARGP_ARG1 ARG_NONE
+#define ARGP_ARG2 ARG_NONE
+#define ARGP_ARG3 ARG_NONE
+#define ARGP_ARG4 ARG_NONE
+#define ARGP_ARG5 ARG_NONE
+#define ARGP_ARG6 ARG_NONE
+#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
+#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_BREAK_OP ARG_NONE
+#define ARGP_BREAK_POINT_OP ARG_NONE
+#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
+#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
+#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
+#define ARGP_CONTINUE_OP ARG_NONE
+#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME)
+#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
+#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_DEBUG_OP ARG_NONE
+#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
+#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
+#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
+#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
+#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
+#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
+#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
+#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
+#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
+#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
+#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_LOCAL0 ARG_NONE
+#define ARGP_LOCAL1 ARG_NONE
+#define ARGP_LOCAL2 ARG_NONE
+#define ARGP_LOCAL3 ARG_NONE
+#define ARGP_LOCAL4 ARG_NONE
+#define ARGP_LOCAL5 ARG_NONE
+#define ARGP_LOCAL6 ARG_NONE
+#define ARGP_LOCAL7 ARG_NONE
+#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
+#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
+#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
+#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_NOOP_OP ARG_NONE
+#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
+#define ARGP_ONE_OP ARG_NONE
+#define ARGP_ONES_OP ARG_NONE
+#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
+#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
+#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
+#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
+#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
+#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_REVISION_OP ARG_NONE
+#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
+#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
+#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
+#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
+#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
+#define ARGP_TIMER_OP ARG_NONE
+#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
+#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
+#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
+#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
+#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
+#define ARGP_ZERO_OP ARG_NONE
+
+
+/*
+ * All AML opcodes and the runtime arguments for each. Used by the AML
+ * interpreter Each list is compressed into a 32-bit number and stored
+ * in the master opcode table (in psopcode.c).
+ *
+ * (Used by prep_operands procedure and the ASL Compiler)
+ */
+#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
+#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
+#define ARGI_ARG0 ARG_NONE
+#define ARGI_ARG1 ARG_NONE
+#define ARGI_ARG2 ARG_NONE
+#define ARGI_ARG3 ARG_NONE
+#define ARGI_ARG4 ARG_NONE
+#define ARGI_ARG5 ARG_NONE
+#define ARGI_ARG6 ARG_NONE
+#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_BREAK_OP ARG_NONE
+#define ARGI_BREAK_POINT_OP ARG_NONE
+#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
+#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
+#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
+#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
+#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
+#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
+#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
+#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
+#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
+#define ARGI_DEBUG_OP ARG_NONE
+#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
+#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
+#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
+#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
+#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
+#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
+#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
+#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_IF_OP ARGI_INVALID_OPCODE
+#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF)
+#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
+#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
+#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
+#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
+#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
+#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
+#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF)
+#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
+#define ARGI_LOCAL0 ARG_NONE
+#define ARGI_LOCAL1 ARG_NONE
+#define ARGI_LOCAL2 ARG_NONE
+#define ARGI_LOCAL3 ARG_NONE
+#define ARGI_LOCAL4 ARG_NONE
+#define ARGI_LOCAL5 ARG_NONE
+#define ARGI_LOCAL6 ARG_NONE
+#define ARGI_LOCAL7 ARG_NONE
+#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
+#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
+#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
+#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
+#define ARGI_NAME_OP ARGI_INVALID_OPCODE
+#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
+#define ARGI_NOOP_OP ARG_NONE
+#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
+#define ARGI_ONE_OP ARG_NONE
+#define ARGI_ONES_OP ARG_NONE
+#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
+#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
+#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
+#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
+#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
+#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
+#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
+#define ARGI_REVISION_OP ARG_NONE
+#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
+#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
+#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
+#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
+#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
+#define ARGI_STRING_OP ARGI_INVALID_OPCODE
+#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
+#define ARGI_TIMER_OP ARG_NONE
+#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
+#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
+#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
+#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
+#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
+#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
+#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
+#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
+#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
+#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
+#define ARGI_WORD_OP ARGI_INVALID_OPCODE
+#define ARGI_ZERO_OP ARG_NONE
+
+#endif /* __ACOPCODE_H__ */
diff --git a/include/acpi/acparser.h b/include/acpi/acparser.h
index c0395ef2b0d..69827657181 100644
--- a/include/acpi/acparser.h
+++ b/include/acpi/acparser.h
@@ -64,8 +64,17 @@
#define ACPI_PARSE_DEFERRED_OP 0x0100
-/* Parser external interfaces */
+/******************************************************************************
+ *
+ * Parser interfaces
+ *
+ *****************************************************************************/
+
+
+/*
+ * psxface - Parser external interfaces
+ */
acpi_status
acpi_psx_load_table (
u8 *pcode_addr,
@@ -76,23 +85,13 @@ acpi_psx_execute (
struct acpi_parameter_info *info);
-/******************************************************************************
- *
- * Parser interfaces
- *
- *****************************************************************************/
-
-
-/* psargs - Parse AML opcode arguments */
-
+/*
+ * psargs - Parse AML opcode arguments
+ */
u8 *
acpi_ps_get_next_package_end (
struct acpi_parse_state *parser_state);
-u32
-acpi_ps_get_next_package_length (
- struct acpi_parse_state *parser_state);
-
char *
acpi_ps_get_next_namestring (
struct acpi_parse_state *parser_state);
@@ -110,10 +109,6 @@ acpi_ps_get_next_namepath (
union acpi_parse_object *arg,
u8 method_call);
-union acpi_parse_object *
-acpi_ps_get_next_field (
- struct acpi_parse_state *parser_state);
-
acpi_status
acpi_ps_get_next_arg (
struct acpi_walk_state *walk_state,
@@ -122,8 +117,9 @@ acpi_ps_get_next_arg (
union acpi_parse_object **return_arg);
-/* psfind */
-
+/*
+ * psfind
+ */
union acpi_parse_object *
acpi_ps_find_name (
union acpi_parse_object *scope,
@@ -135,8 +131,9 @@ acpi_ps_get_parent (
union acpi_parse_object *op);
-/* psopcode - AML Opcode information */
-
+/*
+ * psopcode - AML Opcode information
+ */
const struct acpi_opcode_info *
acpi_ps_get_opcode_info (
u16 opcode);
@@ -146,56 +143,25 @@ acpi_ps_get_opcode_name (
u16 opcode);
-/* psparse - top level parsing routines */
-
-u32
-acpi_ps_get_opcode_size (
- u32 opcode);
-
-void
-acpi_ps_complete_this_op (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *op);
-
-acpi_status
-acpi_ps_next_parse_state (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object *op,
- acpi_status callback_status);
-
-acpi_status
-acpi_ps_find_object (
- struct acpi_walk_state *walk_state,
- union acpi_parse_object **out_op);
-
-void
-acpi_ps_delete_parse_tree (
- union acpi_parse_object *root);
-
-acpi_status
-acpi_ps_parse_loop (
- struct acpi_walk_state *walk_state);
-
+/*
+ * psparse - top level parsing routines
+ */
acpi_status
acpi_ps_parse_aml (
struct acpi_walk_state *walk_state);
-acpi_status
-acpi_ps_parse_table (
- u8 *aml,
- u32 aml_size,
- acpi_parse_downwards descending_callback,
- acpi_parse_upwards ascending_callback,
- union acpi_parse_object **root_object);
+u32
+acpi_ps_get_opcode_size (
+ u32 opcode);
u16
acpi_ps_peek_opcode (
struct acpi_parse_state *state);
-/* psscope - Scope stack management routines */
-
-
+/*
+ * psscope - Scope stack management routines
+ */
acpi_status
acpi_ps_init_scope (
struct acpi_parse_state *parser_state,
@@ -228,8 +194,9 @@ acpi_ps_cleanup_scope (
struct acpi_parse_state *state);
-/* pstree - parse tree manipulation routines */
-
+/*
+ * pstree - parse tree manipulation routines
+ */
void
acpi_ps_append_arg(
union acpi_parse_object *op,
@@ -247,20 +214,17 @@ acpi_ps_get_arg(
union acpi_parse_object *op,
u32 argn);
-#ifdef ACPI_FUTURE_USAGE
-union acpi_parse_object *
-acpi_ps_get_child (
- union acpi_parse_object *op);
-
+#ifdef ACPI_FUTURE_USAGE
union acpi_parse_object *
acpi_ps_get_depth_next (
union acpi_parse_object *origin,
union acpi_parse_object *op);
-#endif /* ACPI_FUTURE_USAGE */
-
+#endif /* ACPI_FUTURE_USAGE */
-/* pswalk - parse tree walk routines */
+/*
+ * pswalk - parse tree walk routines
+ */
acpi_status
acpi_ps_walk_parsed_aml (
union acpi_parse_object *start_op,
@@ -283,9 +247,14 @@ acpi_status
acpi_ps_delete_completed_op (
struct acpi_walk_state *walk_state);
+void
+acpi_ps_delete_parse_tree (
+ union acpi_parse_object *root);
-/* psutils - parser utilities */
+/*
+ * psutils - parser utilities
+ */
union acpi_parse_object *
acpi_ps_create_scope_op (
void);
@@ -303,12 +272,6 @@ void
acpi_ps_free_op (
union acpi_parse_object *op);
-#ifdef ACPI_ENABLE_OBJECT_CACHE
-void
-acpi_ps_delete_parse_cache (
- void);
-#endif
-
u8
acpi_ps_is_leading_char (
u32 c);
@@ -317,20 +280,27 @@ u8
acpi_ps_is_prefix_char (
u32 c);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
u32
acpi_ps_get_name(
union acpi_parse_object *op);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
void
acpi_ps_set_name(
union acpi_parse_object *op,
u32 name);
+#ifdef ACPI_ENABLE_OBJECT_CACHE
+void
+acpi_ps_delete_parse_cache (
+ void);
+#endif
-/* psdump - display parser tree */
+/*
+ * psdump - display parser tree
+ */
u32
acpi_ps_sprint_path (
char *buffer_start,
diff --git a/include/acpi/acpi.h b/include/acpi/acpi.h
index ad53252dd42..a69d7894204 100644
--- a/include/acpi/acpi.h
+++ b/include/acpi/acpi.h
@@ -49,6 +49,7 @@
* We put them here because we don't want to duplicate them
* in the rest of the source code again and again.
*/
+#include "acnames.h" /* Global ACPI names and strings */
#include "acconfig.h" /* Configuration constants */
#include "platform/acenv.h" /* Target environment specific items */
#include "actypes.h" /* Fundamental common data types */
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 9ad142476f3..8d0e1290bc7 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -351,6 +351,27 @@ int acpi_match_ids (struct acpi_device *device, char *ids);
int acpi_create_dir(struct acpi_device *);
void acpi_remove_dir(struct acpi_device *);
+
+/*
+ * Bind physical devices with ACPI devices
+ */
+#include <linux/device.h>
+struct acpi_bus_type {
+ struct list_head list;
+ struct bus_type *bus;
+ /* For general devices under the bus*/
+ int (*find_device)(struct device *, acpi_handle*);
+ /* For bridges, such as PCI root bridge, IDE controller */
+ int (*find_bridge)(struct device *, acpi_handle *);
+};
+int register_acpi_bus_type(struct acpi_bus_type *);
+int unregister_acpi_bus_type(struct acpi_bus_type *);
+struct device *acpi_get_physical_device(acpi_handle);
+/* helper */
+acpi_handle acpi_get_child(acpi_handle, acpi_integer);
+acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
+#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data))
+
#endif /*CONFIG_ACPI_BUS*/
#endif /*__ACPI_BUS_H__*/
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 4ec722d7338..caeaa71a566 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -109,5 +109,10 @@ int acpi_ec_ecdt_probe (void);
int acpi_processor_set_thermal_limit(acpi_handle handle, int type);
+/* --------------------------------------------------------------------------
+ Hot Keys
+ -------------------------------------------------------------------------- */
+
+extern int acpi_specific_hotkey_enabled;
#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 857c8072eb1..ea489f23521 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -79,7 +79,6 @@ struct acpi_signal_fatal_info
/*
* OSL Initialization and shutdown primitives
*/
-
acpi_status
acpi_os_initialize (
void);
@@ -92,7 +91,6 @@ acpi_os_terminate (
/*
* ACPI Table interfaces
*/
-
acpi_status
acpi_os_get_root_pointer (
u32 flags,
@@ -112,7 +110,6 @@ acpi_os_table_override (
/*
* Synchronization primitives
*/
-
acpi_status
acpi_os_create_semaphore (
u32 max_units,
@@ -156,7 +153,6 @@ acpi_os_release_lock (
/*
* Memory allocation and mapping
*/
-
void *
acpi_os_allocate (
acpi_size size);
@@ -187,7 +183,6 @@ acpi_os_get_physical_address (
/*
* Interrupt handlers
*/
-
acpi_status
acpi_os_install_interrupt_handler (
u32 gsi,
@@ -203,7 +198,6 @@ acpi_os_remove_interrupt_handler (
/*
* Threads and Scheduling
*/
-
u32
acpi_os_get_thread_id (
void);
@@ -234,7 +228,6 @@ acpi_os_stall (
/*
* Platform and hardware-independent I/O interfaces
*/
-
acpi_status
acpi_os_read_port (
acpi_io_address address,
@@ -251,7 +244,6 @@ acpi_os_write_port (
/*
* Platform and hardware-independent physical memory interfaces
*/
-
acpi_status
acpi_os_read_memory (
acpi_physical_address address,
@@ -270,7 +262,6 @@ acpi_os_write_memory (
* Note: Can't use "Register" as a parameter, changed to "Reg" --
* certain compilers complain.
*/
-
acpi_status
acpi_os_read_pci_configuration (
struct acpi_pci_id *pci_id,
@@ -288,7 +279,6 @@ acpi_os_write_pci_configuration (
/*
* Interim function needed for PCI IRQ routing
*/
-
void
acpi_os_derive_pci_id(
acpi_handle rhandle,
@@ -298,7 +288,6 @@ acpi_os_derive_pci_id(
/*
* Miscellaneous
*/
-
u8
acpi_os_readable (
void *pointer,
@@ -323,7 +312,6 @@ acpi_os_signal (
/*
* Debug print routines
*/
-
void ACPI_INTERNAL_VAR_XFACE
acpi_os_printf (
const char *format,
@@ -339,11 +327,10 @@ acpi_os_redirect_output (
void *destination);
+#ifdef ACPI_FUTURE_USAGE
/*
* Debug input
*/
-
-#ifdef ACPI_FUTURE_USAGE
u32
acpi_os_get_line (
char *buffer);
@@ -353,7 +340,6 @@ acpi_os_get_line (
/*
* Directory manipulation
*/
-
void *
acpi_os_open_directory (
char *pathname,
@@ -377,7 +363,6 @@ acpi_os_close_directory (
/*
* Debug
*/
-
void
acpi_os_dbg_assert(
void *failed_assertion,
@@ -385,5 +370,4 @@ acpi_os_dbg_assert(
u32 line_number,
char *message);
-
#endif /* __ACPIOSXF_H__ */
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 00d78b79652..f8f619f8e4f 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -50,10 +50,9 @@
#include "actbl.h"
- /*
+/*
* Global interfaces
*/
-
acpi_status
acpi_initialize_subsystem (
void);
@@ -106,9 +105,8 @@ acpi_install_initialization_handler (
#endif
/*
- * ACPI Memory manager
+ * ACPI Memory managment
*/
-
void *
acpi_allocate (
u32 size);
@@ -125,7 +123,6 @@ acpi_free (
/*
* ACPI table manipulation interfaces
*/
-
acpi_status
acpi_find_root_pointer (
u32 flags,
@@ -168,7 +165,6 @@ acpi_get_firmware_table (
/*
* Namespace and name interfaces
*/
-
acpi_status
acpi_walk_namespace (
acpi_object_type type,
@@ -218,7 +214,6 @@ acpi_get_data (
/*
* Object manipulation and enumeration
*/
-
acpi_status
acpi_evaluate_object (
acpi_handle object,
@@ -262,7 +257,6 @@ acpi_get_parent (
/*
* Event handler interfaces
*/
-
acpi_status
acpi_install_fixed_event_handler (
u32 acpi_event,
@@ -319,7 +313,6 @@ acpi_install_exception_handler (
/*
* Event interfaces
*/
-
acpi_status
acpi_acquire_global_lock (
u16 timeout,
@@ -404,7 +397,6 @@ acpi_remove_gpe_block (
/*
* Resource interfaces
*/
-
typedef
acpi_status (*ACPI_WALK_RESOURCE_CALLBACK) (
struct acpi_resource *resource,
@@ -448,7 +440,6 @@ acpi_resource_to_address64 (
/*
* Hardware (ACPI device) interfaces
*/
-
acpi_status
acpi_get_register (
u32 register_id,
diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h
index 93c55ff5c23..ed679264c12 100644
--- a/include/acpi/acresrc.h
+++ b/include/acpi/acresrc.h
@@ -48,7 +48,6 @@
/*
* Function prototypes called from Acpi* APIs
*/
-
acpi_status
acpi_rs_get_prt_method_data (
acpi_handle handle,
@@ -60,12 +59,12 @@ acpi_rs_get_crs_method_data (
acpi_handle handle,
struct acpi_buffer *ret_buffer);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_rs_get_prs_method_data (
acpi_handle handle,
struct acpi_buffer *ret_buffer);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
acpi_status
acpi_rs_get_method_data (
@@ -95,61 +94,9 @@ acpi_rs_create_pci_routing_table (
/*
- * Function prototypes called from acpi_rs_create*
+ * rsdump
*/
-#ifdef ACPI_FUTURE_USAGE
-void
-acpi_rs_dump_irq (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_address16 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_address32 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_address64 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_dma (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_io (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_extended_irq (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_fixed_io (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_fixed_memory32 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_memory24 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_memory32 (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_start_depend_fns (
- union acpi_resource_data *data);
-
-void
-acpi_rs_dump_vendor_specific (
- union acpi_resource_data *data);
-
+#ifdef ACPI_FUTURE_USAGE
void
acpi_rs_dump_resource_list (
struct acpi_resource *resource);
@@ -157,8 +104,12 @@ acpi_rs_dump_resource_list (
void
acpi_rs_dump_irq_list (
u8 *route_table);
-#endif /* ACPI_FUTURE_USAGE */
+#endif /* ACPI_FUTURE_USAGE */
+
+/*
+ * rscalc
+ */
acpi_status
acpi_rs_get_byte_stream_start (
u8 *byte_stream_buffer,
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index c97843f6bcb..e6b9e36a2ed 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -56,7 +56,6 @@
* Walk state - current state of a parse tree walk. Used for both a leisurely stroll through
* the tree (for whatever reason), and for control method execution.
*/
-
#define ACPI_NEXT_OP_DOWNWARD 1
#define ACPI_NEXT_OP_UPWARD 2
diff --git a/include/acpi/actables.h b/include/acpi/actables.h
index e8f5d4ffd45..39df92e21a0 100644
--- a/include/acpi/actables.h
+++ b/include/acpi/actables.h
@@ -50,17 +50,9 @@
#define SIZE_IN_HEADER 0
-#ifdef ACPI_FUTURE_USAGE
-acpi_status
-acpi_tb_handle_to_object (
- u16 table_id,
- struct acpi_table_desc **table_desc);
-#endif
-
/*
* tbconvrt - Table conversion routines
*/
-
acpi_status
acpi_tb_convert_to_xsdt (
struct acpi_table_desc *table_info);
@@ -78,10 +70,10 @@ acpi_tb_get_table_count (
struct rsdp_descriptor *RSDP,
struct acpi_table_header *RSDT);
+
/*
* tbget - Table "get" routines
*/
-
acpi_status
acpi_tb_get_table (
struct acpi_pointer *address,
@@ -99,17 +91,6 @@ acpi_tb_get_table_body (
struct acpi_table_desc *table_info);
acpi_status
-acpi_tb_get_this_table (
- struct acpi_pointer *address,
- struct acpi_table_header *header,
- struct acpi_table_desc *table_info);
-
-acpi_status
-acpi_tb_table_override (
- struct acpi_table_header *header,
- struct acpi_table_desc *table_info);
-
-acpi_status
acpi_tb_get_table_ptr (
acpi_table_type table_type,
u32 instance,
@@ -127,36 +108,23 @@ acpi_status
acpi_tb_validate_rsdt (
struct acpi_table_header *table_ptr);
+
+/*
+ * tbgetall - get multiple required tables
+ */
acpi_status
acpi_tb_get_required_tables (
void);
-acpi_status
-acpi_tb_get_primary_table (
- struct acpi_pointer *address,
- struct acpi_table_desc *table_info);
-
-acpi_status
-acpi_tb_get_secondary_table (
- struct acpi_pointer *address,
- acpi_string signature,
- struct acpi_table_desc *table_info);
/*
* tbinstall - Table installation
*/
-
acpi_status
acpi_tb_install_table (
struct acpi_table_desc *table_info);
acpi_status
-acpi_tb_match_signature (
- char *signature,
- struct acpi_table_desc *table_info,
- u8 search_type);
-
-acpi_status
acpi_tb_recognize_table (
struct acpi_table_desc *table_info,
u8 search_type);
@@ -170,7 +138,6 @@ acpi_tb_init_table_descriptor (
/*
* tbremove - Table removal and deletion
*/
-
void
acpi_tb_delete_all_tables (
void);
@@ -189,35 +156,23 @@ acpi_tb_uninstall_table (
/*
- * tbrsd - RSDP, RSDT utilities
+ * tbxfroot - RSDP, RSDT utilities
*/
+acpi_status
+acpi_tb_find_table (
+ char *signature,
+ char *oem_id,
+ char *oem_table_id,
+ struct acpi_table_header **table_ptr);
acpi_status
acpi_tb_get_table_rsdt (
void);
-u8 *
-acpi_tb_scan_memory_for_rsdp (
- u8 *start_address,
- u32 length);
-
-acpi_status
-acpi_tb_find_rsdp (
- struct acpi_table_desc *table_info,
- u32 flags);
-
/*
* tbutils - common table utilities
*/
-
-acpi_status
-acpi_tb_find_table (
- char *signature,
- char *oem_id,
- char *oem_table_id,
- struct acpi_table_header **table_ptr);
-
acpi_status
acpi_tb_verify_table_checksum (
struct acpi_table_header *table_header);
@@ -231,5 +186,4 @@ acpi_status
acpi_tb_validate_table_header (
struct acpi_table_header *table_header);
-
#endif /* __ACTABLES_H__ */
diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
index 7eee731112b..b5cdcca444c 100644
--- a/include/acpi/actbl.h
+++ b/include/acpi/actbl.h
@@ -133,7 +133,6 @@ struct acpi_table_header /* ACPI common table header */
#define DUAL_PIC 0
#define MULTIPLE_APIC 1
-
/* Master MADT */
struct multiple_apic_table
@@ -144,7 +143,6 @@ struct multiple_apic_table
u32 reserved1 : 31;
};
-
/* Values for Type in APIC_HEADER_DEF */
#define APIC_PROCESSOR 0
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 7acb550af3e..3a451dc48ac 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -478,7 +478,6 @@ typedef u32 acpi_object_type;
#define ACPI_TYPE_INVALID 0x1E
#define ACPI_TYPE_NOT_FOUND 0xFF
-
/*
* Bitmapped ACPI types. Used internally only
*/
@@ -803,7 +802,6 @@ struct acpi_system_info
/*
* Types specific to the OS service interfaces
*/
-
typedef u32
(ACPI_SYSTEM_XFACE *acpi_osd_handler) (
void *context);
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index 0de26b8f102..192d0bea388 100644
--- a/include/acpi/acutils.h
+++ b/include/acpi/acutils.h
@@ -52,13 +52,6 @@ acpi_status (*acpi_pkg_callback) (
union acpi_generic_state *state,
void *context);
-acpi_status
-acpi_ut_walk_package_tree (
- union acpi_operand_object *source_object,
- void *target_object,
- acpi_pkg_callback walk_callback,
- void *context);
-
struct acpi_pkg_info
{
u8 *free_space;
@@ -79,37 +72,13 @@ struct acpi_pkg_info
#define DB_QWORD_DISPLAY 8
-/* Global initialization interfaces */
-
-void
-acpi_ut_init_globals (
- void);
-
-void
-acpi_ut_terminate (
- void);
-
-
/*
- * ut_init - miscellaneous initialization and shutdown
+ * utglobal - Global data structures and procedures
*/
-
-acpi_status
-acpi_ut_hardware_initialize (
- void);
-
void
-acpi_ut_subsystem_shutdown (
- void);
-
-acpi_status
-acpi_ut_validate_fadt (
+acpi_ut_init_globals (
void);
-/*
- * ut_global - Global data structures and procedures
- */
-
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
char *
@@ -157,9 +126,24 @@ acpi_ut_allocate_owner_id (
/*
- * ut_clib - Local implementations of C library functions
+ * utinit - miscellaneous initialization and shutdown
*/
+acpi_status
+acpi_ut_hardware_initialize (
+ void);
+void
+acpi_ut_subsystem_shutdown (
+ void);
+
+acpi_status
+acpi_ut_validate_fadt (
+ void);
+
+
+/*
+ * utclib - Local implementations of C library functions
+ */
#ifndef ACPI_USE_SYSTEM_CLIBRARY
acpi_size
@@ -260,10 +244,10 @@ extern const u8 _acpi_ctype[];
#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
/*
- * ut_copy - Object construction and conversion interfaces
+ * utcopy - Object construction and conversion interfaces
*/
-
acpi_status
acpi_ut_build_simple_object(
union acpi_operand_object *obj,
@@ -278,30 +262,11 @@ acpi_ut_build_package_object (
u32 *space_used);
acpi_status
-acpi_ut_copy_ielement_to_eelement (
- u8 object_type,
- union acpi_operand_object *source_object,
- union acpi_generic_state *state,
- void *context);
-
-acpi_status
-acpi_ut_copy_ielement_to_ielement (
- u8 object_type,
- union acpi_operand_object *source_object,
- union acpi_generic_state *state,
- void *context);
-
-acpi_status
acpi_ut_copy_iobject_to_eobject (
union acpi_operand_object *obj,
struct acpi_buffer *ret_buffer);
acpi_status
-acpi_ut_copy_esimple_to_isimple(
- union acpi_object *user_obj,
- union acpi_operand_object **return_obj);
-
-acpi_status
acpi_ut_copy_eobject_to_iobject (
union acpi_object *obj,
union acpi_operand_object **internal_obj);
@@ -312,17 +277,6 @@ acpi_ut_copy_isimple_to_isimple (
union acpi_operand_object *dest_obj);
acpi_status
-acpi_ut_copy_ipackage_to_ipackage (
- union acpi_operand_object *source_obj,
- union acpi_operand_object *dest_obj,
- struct acpi_walk_state *walk_state);
-
-acpi_status
-acpi_ut_copy_simple_object (
- union acpi_operand_object *source_desc,
- union acpi_operand_object *dest_desc);
-
-acpi_status
acpi_ut_copy_iobject_to_iobject (
union acpi_operand_object *source_desc,
union acpi_operand_object **dest_desc,
@@ -330,9 +284,8 @@ acpi_ut_copy_iobject_to_iobject (
/*
- * ut_create - Object creation
+ * utcreate - Object creation
*/
-
acpi_status
acpi_ut_update_object_reference (
union acpi_operand_object *object,
@@ -340,9 +293,8 @@ acpi_ut_update_object_reference (
/*
- * ut_debug - Debug interfaces
+ * utdebug - Debug interfaces
*/
-
void
acpi_ut_init_stack_ptr_trace (
void);
@@ -440,11 +392,14 @@ acpi_ut_debug_print_raw (
/*
- * ut_delete - Object deletion
+ * utdelete - Object deletion and reference counts
*/
+void
+acpi_ut_add_reference (
+ union acpi_operand_object *object);
void
-acpi_ut_delete_internal_obj (
+acpi_ut_remove_reference (
union acpi_operand_object *object);
void
@@ -461,25 +416,8 @@ acpi_ut_delete_internal_object_list (
/*
- * ut_eval - object evaluation
+ * uteval - object evaluation
*/
-
-/* Method name strings */
-
-#define METHOD_NAME__HID "_HID"
-#define METHOD_NAME__CID "_CID"
-#define METHOD_NAME__UID "_UID"
-#define METHOD_NAME__ADR "_ADR"
-#define METHOD_NAME__STA "_STA"
-#define METHOD_NAME__REG "_REG"
-#define METHOD_NAME__SEG "_SEG"
-#define METHOD_NAME__BBN "_BBN"
-#define METHOD_NAME__PRT "_PRT"
-#define METHOD_NAME__CRS "_CRS"
-#define METHOD_NAME__PRS "_PRS"
-#define METHOD_NAME__PRW "_PRW"
-
-
acpi_status
acpi_ut_osi_implementation (
struct acpi_walk_state *walk_state);
@@ -522,39 +460,10 @@ acpi_ut_execute_sxds (
struct acpi_namespace_node *device_node,
u8 *highest);
-/*
- * ut_mutex - mutual exclusion interfaces
- */
-
-acpi_status
-acpi_ut_mutex_initialize (
- void);
-
-void
-acpi_ut_mutex_terminate (
- void);
-
-acpi_status
-acpi_ut_create_mutex (
- acpi_mutex_handle mutex_id);
-
-acpi_status
-acpi_ut_delete_mutex (
- acpi_mutex_handle mutex_id);
-
-acpi_status
-acpi_ut_acquire_mutex (
- acpi_mutex_handle mutex_id);
-
-acpi_status
-acpi_ut_release_mutex (
- acpi_mutex_handle mutex_id);
-
/*
- * ut_object - internal object create/delete/cache routines
+ * utobject - internal object create/delete/cache routines
*/
-
union acpi_operand_object *
acpi_ut_create_internal_object_dbg (
char *module_name,
@@ -587,50 +496,15 @@ union acpi_operand_object *
acpi_ut_create_string_object (
acpi_size string_size);
-
-/*
- * ut_ref_cnt - Object reference count management
- */
-
-void
-acpi_ut_add_reference (
- union acpi_operand_object *object);
-
-void
-acpi_ut_remove_reference (
- union acpi_operand_object *object);
-
-/*
- * ut_size - Object size routines
- */
-
-acpi_status
-acpi_ut_get_simple_object_size (
- union acpi_operand_object *obj,
- acpi_size *obj_length);
-
-acpi_status
-acpi_ut_get_package_object_size (
- union acpi_operand_object *obj,
- acpi_size *obj_length);
-
acpi_status
acpi_ut_get_object_size(
union acpi_operand_object *obj,
acpi_size *obj_length);
-acpi_status
-acpi_ut_get_element_length (
- u8 object_type,
- union acpi_operand_object *source_object,
- union acpi_generic_state *state,
- void *context);
-
/*
- * ut_state - Generic state creation/cache routines
+ * utstate - Generic state creation/cache routines
*/
-
void
acpi_ut_push_generic_state (
union acpi_generic_state **list_head,
@@ -666,14 +540,14 @@ acpi_ut_create_update_state_and_push (
u16 action,
union acpi_generic_state **state_list);
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
acpi_status
acpi_ut_create_pkg_state_and_push (
void *internal_object,
void *external_object,
u16 index,
union acpi_generic_state **state_list);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
union acpi_generic_state *
acpi_ut_create_control_state (
@@ -693,15 +567,10 @@ acpi_ut_delete_object_cache (
void);
#endif
+
/*
- * utmisc
+ * utmath
*/
-
-void
-acpi_ut_print_string (
- char *string,
- u8 max_length);
-
acpi_status
acpi_ut_divide (
acpi_integer in_dividend,
@@ -716,6 +585,25 @@ acpi_ut_short_divide (
acpi_integer *out_quotient,
u32 *out_remainder);
+/*
+ * utmisc
+ */
+acpi_status
+acpi_ut_walk_package_tree (
+ union acpi_operand_object *source_object,
+ void *target_object,
+ acpi_pkg_callback walk_callback,
+ void *context);
+
+char *
+acpi_ut_strupr (
+ char *src_string);
+
+void
+acpi_ut_print_string (
+ char *string,
+ u8 max_length);
+
u8
acpi_ut_valid_acpi_name (
u32 name);
@@ -734,11 +622,21 @@ acpi_ut_strtoul64 (
#define ACPI_ANY_BASE 0
-#ifdef ACPI_FUTURE_USAGE
-char *
-acpi_ut_strupr (
- char *src_string);
-#endif
+acpi_status
+acpi_ut_mutex_initialize (
+ void);
+
+void
+acpi_ut_mutex_terminate (
+ void);
+
+acpi_status
+acpi_ut_acquire_mutex (
+ acpi_mutex_handle mutex_id);
+
+acpi_status
+acpi_ut_release_mutex (
+ acpi_mutex_handle mutex_id);
u8 *
acpi_ut_get_resource_end_tag (
@@ -768,9 +666,8 @@ acpi_ut_display_init_pathname (
/*
- * Utalloc - memory allocation and object caching
+ * utalloc - memory allocation and object caching
*/
-
void *
acpi_ut_acquire_from_cache (
u32 list_id);
@@ -795,9 +692,6 @@ acpi_ut_initialize_buffer (
struct acpi_buffer *buffer,
acpi_size required_length);
-
-/* Memory allocation functions */
-
void *
acpi_ut_allocate (
acpi_size size,
@@ -812,9 +706,7 @@ acpi_ut_callocate (
char *module,
u32 line);
-
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
void *
acpi_ut_allocate_and_track (
acpi_size size,
@@ -836,34 +728,11 @@ acpi_ut_free_and_track (
char *module,
u32 line);
-struct acpi_debug_mem_block *
-acpi_ut_find_allocation (
- u32 list_id,
- void *allocation);
-
-acpi_status
-acpi_ut_track_allocation (
- u32 list_id,
- struct acpi_debug_mem_block *address,
- acpi_size size,
- u8 alloc_type,
- u32 component,
- char *module,
- u32 line);
-
-acpi_status
-acpi_ut_remove_allocation (
- u32 list_id,
- struct acpi_debug_mem_block *address,
- u32 component,
- char *module,
- u32 line);
-
-#ifdef ACPI_FUTURE_USAGE
+#ifdef ACPI_FUTURE_USAGE
void
acpi_ut_dump_allocation_info (
void);
-#endif
+#endif /* ACPI_FUTURE_USAGE */
void
acpi_ut_dump_allocations (
@@ -871,5 +740,4 @@ acpi_ut_dump_allocations (
char *module);
#endif
-
#endif /* _ACUTILS_H */
diff --git a/include/acpi/amlcode.h b/include/acpi/amlcode.h
index 2ec538eac58..55e97ed2919 100644
--- a/include/acpi/amlcode.h
+++ b/include/acpi/amlcode.h
@@ -146,8 +146,7 @@
/* prefixed opcodes */
-#define AML_EXTOP (u16) 0x005b
-
+#define AML_EXTOP (u16) 0x005b /* prefix for 2-byte opcodes */
#define AML_MUTEX_OP (u16) 0x5b01
#define AML_EVENT_OP (u16) 0x5b02
@@ -194,7 +193,6 @@
* Use only "Unknown" AML opcodes, don't attempt to use
* any valid ACPI ASCII values (A-Z, 0-9, '-')
*/
-
#define AML_INT_NAMEPATH_OP (u16) 0x002d
#define AML_INT_NAMEDFIELD_OP (u16) 0x0030
#define AML_INT_RESERVEDFIELD_OP (u16) 0x0031
@@ -214,7 +212,6 @@
* There can be up to 31 unique argument types
* Zero is reserved as end-of-list indicator
*/
-
#define ARGP_BYTEDATA 0x01
#define ARGP_BYTELIST 0x02
#define ARGP_CHARLIST 0x03
@@ -295,7 +292,6 @@
/*
* opcode groups and types
*/
-
#define OPGRP_NAMED 0x01
#define OPGRP_FIELD 0x02
#define OPGRP_BYTELIST 0x04
@@ -381,6 +377,12 @@
#define AML_TYPE_UNDEFINED 0x19
#define AML_TYPE_BOGUS 0x1A
+/* AML Package Length encodings */
+
+#define ACPI_AML_PACKAGE_TYPE1 0x40
+#define ACPI_AML_PACKAGE_TYPE2 0x4000
+#define ACPI_AML_PACKAGE_TYPE3 0x400000
+#define ACPI_AML_PACKAGE_TYPE4 0x40000000
/*
* Opcode classes
diff --git a/include/acpi/pdc_intel.h b/include/acpi/pdc_intel.h
new file mode 100644
index 00000000000..fd6730e4e56
--- /dev/null
+++ b/include/acpi/pdc_intel.h
@@ -0,0 +1,29 @@
+
+/* _PDC bit definition for Intel processors */
+
+#ifndef __PDC_INTEL_H__
+#define __PDC_INTEL_H__
+
+#define ACPI_PDC_P_FFH (0x0001)
+#define ACPI_PDC_C_C1_HALT (0x0002)
+#define ACPI_PDC_T_FFH (0x0004)
+#define ACPI_PDC_SMP_C1PT (0x0008)
+#define ACPI_PDC_SMP_C2C3 (0x0010)
+#define ACPI_PDC_SMP_P_SWCOORD (0x0020)
+#define ACPI_PDC_SMP_C_SWCOORD (0x0040)
+#define ACPI_PDC_SMP_T_SWCOORD (0x0080)
+#define ACPI_PDC_C_C1_FFH (0x0100)
+
+
+#define ACPI_PDC_EST_CAPABILITY_SMP (ACPI_PDC_SMP_C1PT | \
+ ACPI_PDC_C_C1_HALT)
+
+#define ACPI_PDC_EST_CAPABILITY_SMP_MSR (ACPI_PDC_EST_CAPABILITY_SMP | \
+ ACPI_PDC_P_FFH)
+
+#define ACPI_PDC_C_CAPABILITY_SMP (ACPI_PDC_SMP_C2C3 | \
+ ACPI_PDC_SMP_C1PT | \
+ ACPI_PDC_C_C1_HALT)
+
+#endif /* __PDC_INTEL_H__ */
+
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index 57bf9362335..adf969efa51 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -198,6 +198,7 @@
#endif
#endif /* !DEBUGGER_THREADING */
+
/******************************************************************************
*
* C library configuration
@@ -209,7 +210,6 @@
* Use the standard C library headers.
* We want to keep these to a minimum.
*/
-
#ifdef ACPI_USE_STANDARD_HEADERS
/*
* Use the standard headers from the standard locations
@@ -224,14 +224,8 @@
/*
* We will be linking to the standard Clib functions
*/
-
#define ACPI_STRSTR(s1,s2) strstr((s1), (s2))
#define ACPI_STRCHR(s1,c) strchr((s1), (c))
-
-#ifdef ACPI_FUTURE_USAGE
-#define ACPI_STRUPR(s) (void) acpi_ut_strupr ((s))
-#endif
-
#define ACPI_STRLEN(s) (acpi_size) strlen((s))
#define ACPI_STRCPY(d,s) (void) strcpy((d), (s))
#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (acpi_size)(n))
@@ -254,14 +248,15 @@
#define ACPI_IS_ALPHA isalpha
#define ACPI_IS_ASCII isascii
+#else
+
/******************************************************************************
*
* Not using native C library, use local implementations
*
*****************************************************************************/
-#else
-/*
+ /*
* Use local definitions of C library macros and functions
* NOTE: The function implementations may not be as efficient
* as an inline or assembly code implementation provided by a
@@ -278,14 +273,12 @@ typedef char *va_list;
/*
* Storage alignment properties
*/
-
#define _AUPBND (sizeof (acpi_native_int) - 1)
#define _ADNBND (sizeof (acpi_native_int) - 1)
/*
* Variable argument list macro definitions
*/
-
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
#define va_arg(ap, T) (*(T *)(((ap) += (_bnd (T, _AUPBND))) - (_bnd (T,_ADNBND))))
#define va_end(ap) (void) 0
@@ -296,11 +289,6 @@ typedef char *va_list;
#define ACPI_STRSTR(s1,s2) acpi_ut_strstr ((s1), (s2))
#define ACPI_STRCHR(s1,c) acpi_ut_strchr ((s1), (c))
-
-#ifdef ACPI_FUTURE_USAGE
-#define ACPI_STRUPR(s) (void) acpi_ut_strupr ((s))
-#endif
-
#define ACPI_STRLEN(s) (acpi_size) acpi_ut_strlen ((s))
#define ACPI_STRCPY(d,s) (void) acpi_ut_strcpy ((d), (s))
#define ACPI_STRNCPY(d,s,n) (void) acpi_ut_strncpy ((d), (s), (acpi_size)(n))
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 2f50a5bb0c7..50cfea4ff6c 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -4,6 +4,8 @@
#include <linux/kernel.h>
#include <linux/config.h>
+#include <asm/acpi.h>
+
#define ACPI_PROCESSOR_BUSY_METRIC 10
#define ACPI_PROCESSOR_MAX_POWER 8
@@ -14,6 +16,8 @@
#define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */
#define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4
+#define ACPI_PDC_REVISION_ID 0x1
+
/* Power Management */
struct acpi_processor_cx;
@@ -59,6 +63,9 @@ struct acpi_processor_power {
u32 bm_activity;
int count;
struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
+
+ /* the _PDC objects passed by the driver, if any */
+ struct acpi_object_list *pdc;
};
/* Performance Management */
@@ -82,8 +89,6 @@ struct acpi_processor_px {
acpi_integer status; /* success indicator */
};
-#define ACPI_PDC_REVISION_ID 0x1
-
struct acpi_processor_performance {
unsigned int state;
unsigned int platform_limit;
@@ -179,7 +184,32 @@ int acpi_processor_notify_smm(struct module *calling_module);
extern struct acpi_processor *processors[NR_CPUS];
extern struct acpi_processor_errata errata;
+int acpi_processor_set_pdc(struct acpi_processor *pr,
+ struct acpi_object_list *pdc_in);
+
+#ifdef ARCH_HAS_POWER_PDC_INIT
+void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
+ unsigned int cpu);
+void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
+ unsigned int cpu);
+#else
+static inline void acpi_processor_power_init_pdc(
+ struct acpi_processor_power *pow, unsigned int cpu)
+{
+ pow->pdc = NULL;
+ return;
+}
+
+static inline void acpi_processor_power_init_bm_check(
+ struct acpi_processor_flags *flags, unsigned int cpu)
+{
+ flags->bm_check = 1;
+ return;
+}
+#endif
+
/* in processor_perflib.c */
+
#ifdef CONFIG_CPU_FREQ
void acpi_processor_ppc_init(void);
void acpi_processor_ppc_exit(void);
diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h
index b7806aa3785..28957697e59 100644
--- a/include/asm-alpha/pci.h
+++ b/include/asm-alpha/pci.h
@@ -58,7 +58,7 @@ struct pci_controller {
extern void pcibios_set_master(struct pci_dev *dev);
-extern inline void pcibios_penalize_isa_irq(int irq)
+extern inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h
index e139463d9a0..22b53e369f5 100644
--- a/include/asm-alpha/pgtable.h
+++ b/include/asm-alpha/pgtable.h
@@ -132,6 +132,10 @@
#define __S110 _PAGE_S(0)
#define __S111 _PAGE_S(0)
+/*
+ * pgprot_noncached() is only for infiniband pci support, and a real
+ * implementation for RAM would be more complicated.
+ */
#define pgprot_noncached(prot) (prot)
/*
diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h
index e300646fe65..b28f1c95dd6 100644
--- a/include/asm-arm/pci.h
+++ b/include/asm-arm/pci.h
@@ -14,7 +14,7 @@ static inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
index d032729b19d..5edad5b70fd 100644
--- a/include/asm-h8300/pci.h
+++ b/include/asm-h8300/pci.h
@@ -15,7 +15,7 @@ extern inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-extern inline void pcibios_penalize_isa_irq(int irq)
+extern inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index c976c1dadec..cf828ace13f 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -28,6 +28,8 @@
#ifdef __KERNEL__
+#include <acpi/pdc_intel.h>
+
#include <asm/system.h> /* defines cmpxchg */
#define COMPILER_DEPENDENT_INT64 long long
@@ -101,12 +103,6 @@ __acpi_release_global_lock (unsigned int *lock)
:"=r"(n_hi), "=r"(n_lo) \
:"0"(n_hi), "1"(n_lo))
-/*
- * Refer Intel ACPI _PDC support document for bit definitions
- */
-#define ACPI_PDC_EST_CAPABILITY_SMP 0xa
-#define ACPI_PDC_EST_CAPABILITY_MSR 0x1
-
#ifdef CONFIG_ACPI_BOOT
extern int acpi_lapic;
extern int acpi_ioapic;
@@ -185,6 +181,8 @@ extern void acpi_reserve_bootmem(void);
extern u8 x86_acpiid_to_apicid[];
+#define ARCH_HAS_POWER_PDC_INIT 1
+
#endif /*__KERNEL__*/
#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-i386/apicdef.h b/include/asm-i386/apicdef.h
index 0fed5e3c699..a96a8f48fbf 100644
--- a/include/asm-i386/apicdef.h
+++ b/include/asm-i386/apicdef.h
@@ -109,11 +109,7 @@
#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
-#ifdef CONFIG_NUMA
- #define MAX_IO_APICS 32
-#else
- #define MAX_IO_APICS 8
-#endif
+#define MAX_IO_APICS 64
/*
* the local APIC register structure, memory mapped. Not terribly well
diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h
index 3561899eb82..78c85985aee 100644
--- a/include/asm-i386/pci.h
+++ b/include/asm-i386/pci.h
@@ -27,7 +27,7 @@ void pcibios_config_init(void);
struct pci_bus * pcibios_scan_root(int bus);
void pcibios_set_master(struct pci_dev *dev);
-void pcibios_penalize_isa_irq(int irq);
+void pcibios_penalize_isa_irq(int irq, int active);
struct irq_routing_table *pcibios_get_irq_routing_table(void);
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index e25e4c71a87..a7cb377745b 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -296,8 +296,11 @@
#define __NR_keyctl 288
#define __NR_ioprio_set 289
#define __NR_ioprio_get 290
+#define __NR_inotify_init 291
+#define __NR_inotify_add_watch 292
+#define __NR_inotify_rm_watch 293
-#define NR_syscalls 291
+#define NR_syscalls 294
/*
* user-visible error numbers are in the range -1 - -128: see
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
index 6a26a977f25..4c06d455139 100644
--- a/include/asm-ia64/acpi.h
+++ b/include/asm-ia64/acpi.h
@@ -98,6 +98,15 @@ const char *acpi_get_sysname (void);
int acpi_request_vector (u32 int_type);
int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
+/*
+ * Record the cpei override flag and current logical cpu. This is
+ * useful for CPU removal.
+ */
+extern unsigned int can_cpei_retarget(void);
+extern unsigned int is_cpu_cpei_target(unsigned int cpu);
+extern void set_cpei_target_cpu(unsigned int cpu);
+extern unsigned int get_cpei_target_cpu(void);
+
#ifdef CONFIG_ACPI_NUMA
/* Proximity bitmap length; _PXM is at most 255 (8 bit)*/
#define MAX_PXM_DOMAINS (256)
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
index 0c4c5d801d3..f11771eadc4 100644
--- a/include/asm-ia64/pci.h
+++ b/include/asm-ia64/pci.h
@@ -47,7 +47,7 @@ pcibios_set_master (struct pci_dev *dev)
}
static inline void
-pcibios_penalize_isa_irq (int irq)
+pcibios_penalize_isa_irq (int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-m68k/pci.h b/include/asm-m68k/pci.h
index 9e7d79ab5d1..9d2c07abe44 100644
--- a/include/asm-m68k/pci.h
+++ b/include/asm-m68k/pci.h
@@ -43,7 +43,7 @@ static inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h
index 2d323b6e147..d70dc355c1f 100644
--- a/include/asm-mips/pci.h
+++ b/include/asm-mips/pci.h
@@ -69,7 +69,7 @@ extern unsigned long PCIBIOS_MIN_MEM;
extern void pcibios_set_master(struct pci_dev *dev);
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-ppc/kexec.h b/include/asm-ppc/kexec.h
index 73191310d8d..6d2aa0aa464 100644
--- a/include/asm-ppc/kexec.h
+++ b/include/asm-ppc/kexec.h
@@ -27,6 +27,8 @@
#ifndef __ASSEMBLY__
+extern void *crash_notes;
+
struct kimage;
extern void machine_kexec_simple(struct kimage *image);
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h
index db0a2a0ec74..a13d55870e6 100644
--- a/include/asm-ppc/pci.h
+++ b/include/asm-ppc/pci.h
@@ -37,7 +37,7 @@ extern inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-extern inline void pcibios_penalize_isa_irq(int irq)
+extern inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h
index d12dfce21e2..faa77222307 100644
--- a/include/asm-ppc64/pci.h
+++ b/include/asm-ppc64/pci.h
@@ -37,7 +37,7 @@ static inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h
index 26044889c77..0a523c85b11 100644
--- a/include/asm-sh/pci.h
+++ b/include/asm-sh/pci.h
@@ -36,7 +36,7 @@ struct pci_dev;
extern void pcibios_set_master(struct pci_dev *dev);
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-sh64/pci.h b/include/asm-sh64/pci.h
index c68870e02d9..aa8043089bb 100644
--- a/include/asm-sh64/pci.h
+++ b/include/asm-sh64/pci.h
@@ -26,7 +26,7 @@ extern void pcibios_set_master(struct pci_dev *dev);
/*
* Set penalize isa irq function
*/
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
index 44bb38758c9..97052baf90c 100644
--- a/include/asm-sparc/pci.h
+++ b/include/asm-sparc/pci.h
@@ -20,7 +20,7 @@ extern inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-extern inline void pcibios_penalize_isa_irq(int irq)
+extern inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index 84e41c1ef3f..a4ab0ec7143 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -23,7 +23,7 @@ static inline void pcibios_set_master(struct pci_dev *dev)
/* No special bus mastering setup handling */
}
-static inline void pcibios_penalize_isa_irq(int irq)
+static inline void pcibios_penalize_isa_irq(int irq, int active)
{
/* We don't do dynamic PCI IRQ allocation */
}
diff --git a/include/asm-um/mmu_context.h b/include/asm-um/mmu_context.h
index 7529c9c853d..095bb627b96 100644
--- a/include/asm-um/mmu_context.h
+++ b/include/asm-um/mmu_context.h
@@ -16,8 +16,12 @@
#define deactivate_mm(tsk,mm) do { } while (0)
+extern void force_flush_all(void);
+
static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
{
+ if (old != new)
+ force_flush_all();
}
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index a6b41b89206..dc8c981af27 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -28,6 +28,8 @@
#ifdef __KERNEL__
+#include <acpi/pdc_intel.h>
+
#define COMPILER_DEPENDENT_INT64 long long
#define COMPILER_DEPENDENT_UINT64 unsigned long long
@@ -99,12 +101,6 @@ __acpi_release_global_lock (unsigned int *lock)
:"=r"(n_hi), "=r"(n_lo) \
:"0"(n_hi), "1"(n_lo))
-/*
- * Refer Intel ACPI _PDC support document for bit definitions
- */
-#define ACPI_PDC_EST_CAPABILITY_SMP 0xa
-#define ACPI_PDC_EST_CAPABILITY_MSR 0x1
-
#ifdef CONFIG_ACPI_BOOT
extern int acpi_lapic;
extern int acpi_ioapic;
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index c1961db88fa..eeb3088a1c9 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -33,7 +33,7 @@ extern int (*pci_config_read)(int seg, int bus, int dev, int fn, int reg, int le
extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int len, u32 value);
void pcibios_set_master(struct pci_dev *dev);
-void pcibios_penalize_isa_irq(int irq);
+void pcibios_penalize_isa_irq(int irq, int active);
struct irq_routing_table *pcibios_get_irq_routing_table(void);
int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ef8483673aa..f85cbe919e1 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -206,7 +206,10 @@ struct acpi_table_plat_int_src {
u8 eid;
u8 iosapic_vector;
u32 global_irq;
- u32 reserved;
+ struct {
+ u32 cpei_override_flag:1;
+ u32 reserved:31;
+ } plint_flags;
} __attribute__ ((packed));
enum acpi_interrupt_id {
@@ -475,7 +478,7 @@ struct acpi_prt_list {
struct pci_dev;
int acpi_pci_irq_enable (struct pci_dev *dev);
-void acpi_penalize_isa_irq(int irq);
+void acpi_penalize_isa_irq(int irq, int active);
#ifdef CONFIG_ACPI_DEALLOCATE_IRQ
void acpi_pci_irq_disable (struct pci_dev *dev);
diff --git a/include/linux/device.h b/include/linux/device.h
index f378c846e6d..06e5d42f2c7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -284,8 +284,10 @@ struct device {
struct device_driver *driver; /* which driver has allocated this
device */
void *driver_data; /* data private to the driver */
- void *platform_data; /* Platform specific data (e.g. ACPI,
- BIOS data relevant to device) */
+ void *platform_data; /* Platform specific data, device
+ core doesn't touch it */
+ void *firmware_data; /* Firmware specific data (e.g. ACPI,
+ BIOS data),reserved for device core*/
struct dev_pm_info power;
u64 *dma_mask; /* dma mask (if dma'able device) */
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index cf3847edc50..ce8518e658b 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -33,7 +33,7 @@ extern int eth_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, void *daddr,
void *saddr, unsigned len);
extern int eth_rebuild_header(struct sk_buff *skb);
-extern unsigned short eth_type_trans(struct sk_buff *skb, struct net_device *dev);
+extern __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
unsigned char * haddr);
extern int eth_header_cache(struct neighbour *neigh,
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 4b6e1ab216a..c16662836c5 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -239,6 +239,20 @@ struct ext3_new_group_data {
#define EXT3_IOC_SETRSVSZ _IOW('f', 6, long)
/*
+ * Mount options
+ */
+struct ext3_mount_options {
+ unsigned long s_mount_opt;
+ uid_t s_resuid;
+ gid_t s_resgid;
+ unsigned long s_commit_interval;
+#ifdef CONFIG_QUOTA
+ int s_jquota_fmt;
+ char *s_qf_names[MAXQUOTAS];
+#endif
+};
+
+/*
* Structure of an inode on the disk
*/
struct ext3_inode {
diff --git a/include/linux/fddidevice.h b/include/linux/fddidevice.h
index 002f6367697..e61e42dfd31 100644
--- a/include/linux/fddidevice.h
+++ b/include/linux/fddidevice.h
@@ -25,7 +25,7 @@
#include <linux/if_fddi.h>
#ifdef __KERNEL__
-extern unsigned short fddi_type_trans(struct sk_buff *skb,
+extern __be16 fddi_type_trans(struct sk_buff *skb,
struct net_device *dev);
extern struct net_device *alloc_fddidev(int sizeof_priv);
#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 302ec20838c..c9bf3746a9f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -474,6 +474,11 @@ struct inode {
struct dnotify_struct *i_dnotify; /* for directory notifications */
#endif
+#ifdef CONFIG_INOTIFY
+ struct list_head inotify_watches; /* watches on this inode */
+ struct semaphore inotify_sem; /* protects the watches list */
+#endif
+
unsigned long i_state;
unsigned long dirtied_when; /* jiffies of first dirtying */
@@ -1393,7 +1398,6 @@ extern void emergency_remount(void);
extern int do_remount_sb(struct super_block *sb, int flags,
void *data, int force);
extern sector_t bmap(struct inode *, sector_t);
-extern int setattr_mask(unsigned int);
extern int notify_change(struct dentry *, struct iattr *);
extern int permission(struct inode *, int, struct nameidata *);
extern int generic_permission(struct inode *, int,
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
new file mode 100644
index 00000000000..eb581b6cfca
--- /dev/null
+++ b/include/linux/fsnotify.h
@@ -0,0 +1,248 @@
+#ifndef _LINUX_FS_NOTIFY_H
+#define _LINUX_FS_NOTIFY_H
+
+/*
+ * include/linux/fsnotify.h - generic hooks for filesystem notification, to
+ * reduce in-source duplication from both dnotify and inotify.
+ *
+ * We don't compile any of this away in some complicated menagerie of ifdefs.
+ * Instead, we rely on the code inside to optimize away as needed.
+ *
+ * (C) Copyright 2005 Robert Love
+ */
+
+#ifdef __KERNEL__
+
+#include <linux/dnotify.h>
+#include <linux/inotify.h>
+
+/*
+ * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
+ */
+static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
+ const char *old_name, const char *new_name,
+ int isdir)
+{
+ u32 cookie = inotify_get_cookie();
+
+ if (old_dir == new_dir)
+ inode_dir_notify(old_dir, DN_RENAME);
+ else {
+ inode_dir_notify(old_dir, DN_DELETE);
+ inode_dir_notify(new_dir, DN_CREATE);
+ }
+
+ if (isdir)
+ isdir = IN_ISDIR;
+ inotify_inode_queue_event(old_dir, IN_MOVED_FROM|isdir,cookie,old_name);
+ inotify_inode_queue_event(new_dir, IN_MOVED_TO|isdir, cookie, new_name);
+}
+
+/*
+ * fsnotify_unlink - file was unlinked
+ */
+static inline void fsnotify_unlink(struct dentry *dentry, struct inode *dir)
+{
+ struct inode *inode = dentry->d_inode;
+
+ inode_dir_notify(dir, DN_DELETE);
+ inotify_inode_queue_event(dir, IN_DELETE, 0, dentry->d_name.name);
+ inotify_inode_queue_event(inode, IN_DELETE_SELF, 0, NULL);
+
+ inotify_inode_is_dead(inode);
+}
+
+/*
+ * fsnotify_rmdir - directory was removed
+ */
+static inline void fsnotify_rmdir(struct dentry *dentry, struct inode *inode,
+ struct inode *dir)
+{
+ inode_dir_notify(dir, DN_DELETE);
+ inotify_inode_queue_event(dir,IN_DELETE|IN_ISDIR,0,dentry->d_name.name);
+ inotify_inode_queue_event(inode, IN_DELETE_SELF | IN_ISDIR, 0, NULL);
+ inotify_inode_is_dead(inode);
+}
+
+/*
+ * fsnotify_create - 'name' was linked in
+ */
+static inline void fsnotify_create(struct inode *inode, const char *name)
+{
+ inode_dir_notify(inode, DN_CREATE);
+ inotify_inode_queue_event(inode, IN_CREATE, 0, name);
+}
+
+/*
+ * fsnotify_mkdir - directory 'name' was created
+ */
+static inline void fsnotify_mkdir(struct inode *inode, const char *name)
+{
+ inode_dir_notify(inode, DN_CREATE);
+ inotify_inode_queue_event(inode, IN_CREATE | IN_ISDIR, 0, name);
+}
+
+/*
+ * fsnotify_access - file was read
+ */
+static inline void fsnotify_access(struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+ u32 mask = IN_ACCESS;
+
+ if (S_ISDIR(inode->i_mode))
+ mask |= IN_ISDIR;
+
+ dnotify_parent(dentry, DN_ACCESS);
+ inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
+ inotify_inode_queue_event(inode, mask, 0, NULL);
+}
+
+/*
+ * fsnotify_modify - file was modified
+ */
+static inline void fsnotify_modify(struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+ u32 mask = IN_MODIFY;
+
+ if (S_ISDIR(inode->i_mode))
+ mask |= IN_ISDIR;
+
+ dnotify_parent(dentry, DN_MODIFY);
+ inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
+ inotify_inode_queue_event(inode, mask, 0, NULL);
+}
+
+/*
+ * fsnotify_open - file was opened
+ */
+static inline void fsnotify_open(struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+ u32 mask = IN_OPEN;
+
+ if (S_ISDIR(inode->i_mode))
+ mask |= IN_ISDIR;
+
+ inotify_inode_queue_event(inode, mask, 0, NULL);
+ inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
+}
+
+/*
+ * fsnotify_close - file was closed
+ */
+static inline void fsnotify_close(struct file *file)
+{
+ struct dentry *dentry = file->f_dentry;
+ struct inode *inode = dentry->d_inode;
+ const char *name = dentry->d_name.name;
+ mode_t mode = file->f_mode;
+ u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
+
+ if (S_ISDIR(inode->i_mode))
+ mask |= IN_ISDIR;
+
+ inotify_dentry_parent_queue_event(dentry, mask, 0, name);
+ inotify_inode_queue_event(inode, mask, 0, NULL);
+}
+
+/*
+ * fsnotify_xattr - extended attributes were changed
+ */
+static inline void fsnotify_xattr(struct dentry *dentry)
+{
+ struct inode *inode = dentry->d_inode;
+ u32 mask = IN_ATTRIB;
+
+ if (S_ISDIR(inode->i_mode))
+ mask |= IN_ISDIR;
+
+ inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
+ inotify_inode_queue_event(inode, mask, 0, NULL);
+}
+
+/*
+ * fsnotify_change - notify_change event. file was modified and/or metadata
+ * was changed.
+ */
+static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
+{
+ struct inode *inode = dentry->d_inode;
+ int dn_mask = 0;
+ u32 in_mask = 0;
+
+ if (ia_valid & ATTR_UID) {
+ in_mask |= IN_ATTRIB;
+ dn_mask |= DN_ATTRIB;
+ }
+ if (ia_valid & ATTR_GID) {
+ in_mask |= IN_ATTRIB;
+ dn_mask |= DN_ATTRIB;
+ }
+ if (ia_valid & ATTR_SIZE) {
+ in_mask |= IN_MODIFY;
+ dn_mask |= DN_MODIFY;
+ }
+ /* both times implies a utime(s) call */
+ if ((ia_valid & (ATTR_ATIME | ATTR_MTIME)) == (ATTR_ATIME | ATTR_MTIME))
+ {
+ in_mask |= IN_ATTRIB;
+ dn_mask |= DN_ATTRIB;
+ } else if (ia_valid & ATTR_ATIME) {
+ in_mask |= IN_ACCESS;
+ dn_mask |= DN_ACCESS;
+ } else if (ia_valid & ATTR_MTIME) {
+ in_mask |= IN_MODIFY;
+ dn_mask |= DN_MODIFY;
+ }
+ if (ia_valid & ATTR_MODE) {
+ in_mask |= IN_ATTRIB;
+ dn_mask |= DN_ATTRIB;
+ }
+
+ if (dn_mask)
+ dnotify_parent(dentry, dn_mask);
+ if (in_mask) {
+ if (S_ISDIR(inode->i_mode))
+ in_mask |= IN_ISDIR;
+ inotify_inode_queue_event(inode, in_mask, 0, NULL);
+ inotify_dentry_parent_queue_event(dentry, in_mask, 0,
+ dentry->d_name.name);
+ }
+}
+
+#ifdef CONFIG_INOTIFY /* inotify helpers */
+
+/*
+ * fsnotify_oldname_init - save off the old filename before we change it
+ */
+static inline const char *fsnotify_oldname_init(const char *name)
+{
+ return kstrdup(name, GFP_KERNEL);
+}
+
+/*
+ * fsnotify_oldname_free - free the name we got from fsnotify_oldname_init
+ */
+static inline void fsnotify_oldname_free(const char *old_name)
+{
+ kfree(old_name);
+}
+
+#else /* CONFIG_INOTIFY */
+
+static inline const char *fsnotify_oldname_init(const char *name)
+{
+ return NULL;
+}
+
+static inline void fsnotify_oldname_free(const char *old_name)
+{
+}
+
+#endif /* ! CONFIG_INOTIFY */
+
+#endif /* __KERNEL__ */
+
+#endif /* _LINUX_FS_NOTIFY_H */
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 8336dba1897..5912874ca83 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -2,6 +2,7 @@
#define LINUX_HARDIRQ_H
#include <linux/config.h>
+#include <linux/preempt.h>
#include <linux/smp_lock.h>
#include <asm/hardirq.h>
#include <asm/system.h>
diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h
index ed2927ef1ff..df695e9ae32 100644
--- a/include/linux/hdlc.h
+++ b/include/linux/hdlc.h
@@ -242,8 +242,8 @@ static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev)
}
-static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
+ struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev);
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
new file mode 100644
index 00000000000..a40c2bf0408
--- /dev/null
+++ b/include/linux/inotify.h
@@ -0,0 +1,108 @@
+/*
+ * Inode based directory notification for Linux
+ *
+ * Copyright (C) 2005 John McCutchan
+ */
+
+#ifndef _LINUX_INOTIFY_H
+#define _LINUX_INOTIFY_H
+
+#include <linux/types.h>
+
+/*
+ * struct inotify_event - structure read from the inotify device for each event
+ *
+ * When you are watching a directory, you will receive the filename for events
+ * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
+ */
+struct inotify_event {
+ __s32 wd; /* watch descriptor */
+ __u32 mask; /* watch mask */
+ __u32 cookie; /* cookie to synchronize two events */
+ __u32 len; /* length (including nulls) of name */
+ char name[0]; /* stub for possible name */
+};
+
+/* the following are legal, implemented events that user-space can watch for */
+#define IN_ACCESS 0x00000001 /* File was accessed */
+#define IN_MODIFY 0x00000002 /* File was modified */
+#define IN_ATTRIB 0x00000004 /* Metadata changed */
+#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
+#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
+#define IN_OPEN 0x00000020 /* File was opened */
+#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
+#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
+#define IN_CREATE 0x00000100 /* Subfile was created */
+#define IN_DELETE 0x00000200 /* Subfile was deleted */
+#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
+
+/* the following are legal events. they are sent as needed to any watch */
+#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
+#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
+#define IN_IGNORED 0x00008000 /* File was ignored */
+
+/* helper events */
+#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
+#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
+
+/* special flags */
+#define IN_ISDIR 0x40000000 /* event occurred against dir */
+#define IN_ONESHOT 0x80000000 /* only send event once */
+
+/*
+ * All of the events - we build the list by hand so that we can add flags in
+ * the future and not break backward compatibility. Apps will get only the
+ * events that they originally wanted. Be sure to add new events here!
+ */
+#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
+ IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
+ IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF)
+
+#ifdef __KERNEL__
+
+#include <linux/dcache.h>
+#include <linux/fs.h>
+#include <linux/config.h>
+
+#ifdef CONFIG_INOTIFY
+
+extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
+ const char *);
+extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
+ const char *);
+extern void inotify_unmount_inodes(struct list_head *);
+extern void inotify_inode_is_dead(struct inode *);
+extern u32 inotify_get_cookie(void);
+
+#else
+
+static inline void inotify_inode_queue_event(struct inode *inode,
+ __u32 mask, __u32 cookie,
+ const char *filename)
+{
+}
+
+static inline void inotify_dentry_parent_queue_event(struct dentry *dentry,
+ __u32 mask, __u32 cookie,
+ const char *filename)
+{
+}
+
+static inline void inotify_unmount_inodes(struct list_head *list)
+{
+}
+
+static inline void inotify_inode_is_dead(struct inode *inode)
+{
+}
+
+static inline u32 inotify_get_cookie(void)
+{
+ return 0;
+}
+
+#endif /* CONFIG_INOTIFY */
+
+#endif /* __KERNEL __ */
+
+#endif /* _LINUX_INOTIFY_H */
diff --git a/include/linux/mount.h b/include/linux/mount.h
index 74b4727a4e3..f8f39937e30 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -12,6 +12,7 @@
#define _LINUX_MOUNT_H
#ifdef __KERNEL__
+#include <linux/types.h>
#include <linux/list.h>
#include <linux/spinlock.h>
#include <asm/atomic.h>
@@ -76,6 +77,7 @@ extern int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
extern void mark_mounts_for_expiry(struct list_head *mounts);
extern spinlock_t vfsmount_lock;
+extern dev_t name_to_dev_t(char *name);
#endif
#endif /* _LINUX_MOUNT_H */
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 27e4d164a10..2f0c085f2c7 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -16,6 +16,7 @@
#define NETLINK_AUDIT 9 /* auditing */
#define NETLINK_FIB_LOOKUP 10
#define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */
+#define NETLINK_NETFILTER 12 /* netfilter subsystem */
#define NETLINK_IP6_FW 13
#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 14479325e3f..7aeb208ed71 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -176,7 +176,7 @@ struct pm_ops {
};
extern void pm_set_ops(struct pm_ops *);
-
+extern struct pm_ops *pm_ops;
extern int pm_suspend(suspend_state_t state);
diff --git a/include/linux/reiserfs_acl.h b/include/linux/reiserfs_acl.h
index 0760507a545..0a3605099c4 100644
--- a/include/linux/reiserfs_acl.h
+++ b/include/linux/reiserfs_acl.h
@@ -4,29 +4,29 @@
#define REISERFS_ACL_VERSION 0x0001
typedef struct {
- __le16 e_tag;
- __le16 e_perm;
- __le32 e_id;
+ __le16 e_tag;
+ __le16 e_perm;
+ __le32 e_id;
} reiserfs_acl_entry;
typedef struct {
- __le16 e_tag;
- __le16 e_perm;
+ __le16 e_tag;
+ __le16 e_perm;
} reiserfs_acl_entry_short;
typedef struct {
- __le32 a_version;
+ __le32 a_version;
} reiserfs_acl_header;
static inline size_t reiserfs_acl_size(int count)
{
if (count <= 4) {
return sizeof(reiserfs_acl_header) +
- count * sizeof(reiserfs_acl_entry_short);
+ count * sizeof(reiserfs_acl_entry_short);
} else {
return sizeof(reiserfs_acl_header) +
- 4 * sizeof(reiserfs_acl_entry_short) +
- (count - 4) * sizeof(reiserfs_acl_entry);
+ 4 * sizeof(reiserfs_acl_entry_short) +
+ (count - 4) * sizeof(reiserfs_acl_entry);
}
}
@@ -46,14 +46,14 @@ static inline int reiserfs_acl_count(size_t size)
}
}
-
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
-struct posix_acl * reiserfs_get_acl(struct inode *inode, int type);
-int reiserfs_acl_chmod (struct inode *inode);
-int reiserfs_inherit_default_acl (struct inode *dir, struct dentry *dentry, struct inode *inode);
-int reiserfs_cache_default_acl (struct inode *dir);
-extern int reiserfs_xattr_posix_acl_init (void) __init;
-extern int reiserfs_xattr_posix_acl_exit (void);
+struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
+int reiserfs_acl_chmod(struct inode *inode);
+int reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
+ struct inode *inode);
+int reiserfs_cache_default_acl(struct inode *dir);
+extern int reiserfs_xattr_posix_acl_init(void) __init;
+extern int reiserfs_xattr_posix_acl_exit(void);
extern struct reiserfs_xattr_handler posix_acl_default_handler;
extern struct reiserfs_xattr_handler posix_acl_access_handler;
#else
@@ -61,28 +61,26 @@ extern struct reiserfs_xattr_handler posix_acl_access_handler;
#define reiserfs_get_acl NULL
#define reiserfs_cache_default_acl(inode) 0
-static inline int
-reiserfs_xattr_posix_acl_init (void)
+static inline int reiserfs_xattr_posix_acl_init(void)
{
- return 0;
+ return 0;
}
-static inline int
-reiserfs_xattr_posix_acl_exit (void)
+static inline int reiserfs_xattr_posix_acl_exit(void)
{
- return 0;
+ return 0;
}
-static inline int
-reiserfs_acl_chmod (struct inode *inode)
+static inline int reiserfs_acl_chmod(struct inode *inode)
{
- return 0;
+ return 0;
}
static inline int
-reiserfs_inherit_default_acl (const struct inode *dir, struct dentry *dentry, struct inode *inode)
+reiserfs_inherit_default_acl(const struct inode *dir, struct dentry *dentry,
+ struct inode *inode)
{
- return 0;
+ return 0;
}
#endif
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 4c7c5689ad9..17e458e17e2 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -3,11 +3,10 @@
*/
/* this file has an amazingly stupid
- name, yura please fix it to be
- reiserfs.h, and merge all the rest
- of our .h files that are in this
- directory into it. */
-
+ name, yura please fix it to be
+ reiserfs.h, and merge all the rest
+ of our .h files that are in this
+ directory into it. */
#ifndef _LINUX_REISER_FS_H
#define _LINUX_REISER_FS_H
@@ -74,9 +73,9 @@
/* debug levels. Right now, CONFIG_REISERFS_CHECK means print all debug
** messages.
*/
-#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
+#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
-void reiserfs_warning (struct super_block *s, const char * fmt, ...);
+void reiserfs_warning(struct super_block *s, const char *fmt, ...);
/* assertions handling */
/** always check a condition and panic if it's false. */
@@ -105,82 +104,78 @@ if( !( cond ) ) \
* Structure of super block on disk, a version of which in RAM is often accessed as REISERFS_SB(s)->s_rs
* the version in RAM is part of a larger structure containing fields never written to disk.
*/
-#define UNSET_HASH 0 // read_super will guess about, what hash names
- // in directories were sorted with
+#define UNSET_HASH 0 // read_super will guess about, what hash names
+ // in directories were sorted with
#define TEA_HASH 1
#define YURA_HASH 2
#define R5_HASH 3
#define DEFAULT_HASH R5_HASH
-
struct journal_params {
- __le32 jp_journal_1st_block; /* where does journal start from on its
- * device */
- __le32 jp_journal_dev; /* journal device st_rdev */
- __le32 jp_journal_size; /* size of the journal */
- __le32 jp_journal_trans_max; /* max number of blocks in a transaction. */
- __le32 jp_journal_magic; /* random value made on fs creation (this
- * was sb_journal_block_count) */
- __le32 jp_journal_max_batch; /* max number of blocks to batch into a
- * trans */
- __le32 jp_journal_max_commit_age; /* in seconds, how old can an async
- * commit be */
- __le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction
- * be */
+ __le32 jp_journal_1st_block; /* where does journal start from on its
+ * device */
+ __le32 jp_journal_dev; /* journal device st_rdev */
+ __le32 jp_journal_size; /* size of the journal */
+ __le32 jp_journal_trans_max; /* max number of blocks in a transaction. */
+ __le32 jp_journal_magic; /* random value made on fs creation (this
+ * was sb_journal_block_count) */
+ __le32 jp_journal_max_batch; /* max number of blocks to batch into a
+ * trans */
+ __le32 jp_journal_max_commit_age; /* in seconds, how old can an async
+ * commit be */
+ __le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction
+ * be */
};
/* this is the super from 3.5.X, where X >= 10 */
-struct reiserfs_super_block_v1
-{
- __le32 s_block_count; /* blocks count */
- __le32 s_free_blocks; /* free blocks count */
- __le32 s_root_block; /* root block number */
- struct journal_params s_journal;
- __le16 s_blocksize; /* block size */
- __le16 s_oid_maxsize; /* max size of object id array, see
- * get_objectid() commentary */
- __le16 s_oid_cursize; /* current size of object id array */
- __le16 s_umount_state; /* this is set to 1 when filesystem was
- * umounted, to 2 - when not */
- char s_magic[10]; /* reiserfs magic string indicates that
- * file system is reiserfs:
- * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
- __le16 s_fs_state; /* it is set to used by fsck to mark which
- * phase of rebuilding is done */
- __le32 s_hash_function_code; /* indicate, what hash function is being use
- * to sort names in a directory*/
- __le16 s_tree_height; /* height of disk tree */
- __le16 s_bmap_nr; /* amount of bitmap blocks needed to address
- * each block of file system */
- __le16 s_version; /* this field is only reliable on filesystem
- * with non-standard journal */
- __le16 s_reserved_for_journal; /* size in blocks of journal area on main
- * device, we need to keep after
- * making fs with non-standard journal */
+struct reiserfs_super_block_v1 {
+ __le32 s_block_count; /* blocks count */
+ __le32 s_free_blocks; /* free blocks count */
+ __le32 s_root_block; /* root block number */
+ struct journal_params s_journal;
+ __le16 s_blocksize; /* block size */
+ __le16 s_oid_maxsize; /* max size of object id array, see
+ * get_objectid() commentary */
+ __le16 s_oid_cursize; /* current size of object id array */
+ __le16 s_umount_state; /* this is set to 1 when filesystem was
+ * umounted, to 2 - when not */
+ char s_magic[10]; /* reiserfs magic string indicates that
+ * file system is reiserfs:
+ * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
+ __le16 s_fs_state; /* it is set to used by fsck to mark which
+ * phase of rebuilding is done */
+ __le32 s_hash_function_code; /* indicate, what hash function is being use
+ * to sort names in a directory*/
+ __le16 s_tree_height; /* height of disk tree */
+ __le16 s_bmap_nr; /* amount of bitmap blocks needed to address
+ * each block of file system */
+ __le16 s_version; /* this field is only reliable on filesystem
+ * with non-standard journal */
+ __le16 s_reserved_for_journal; /* size in blocks of journal area on main
+ * device, we need to keep after
+ * making fs with non-standard journal */
} __attribute__ ((__packed__));
#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
/* this is the on disk super block */
-struct reiserfs_super_block
-{
- struct reiserfs_super_block_v1 s_v1;
- __le32 s_inode_generation;
- __le32 s_flags; /* Right now used only by inode-attributes, if enabled */
- unsigned char s_uuid[16]; /* filesystem unique identifier */
- unsigned char s_label[16]; /* filesystem volume label */
- char s_unused[88] ; /* zero filled by mkreiserfs and
- * reiserfs_convert_objectid_map_v1()
- * so any additions must be updated
- * there as well. */
-} __attribute__ ((__packed__));
+struct reiserfs_super_block {
+ struct reiserfs_super_block_v1 s_v1;
+ __le32 s_inode_generation;
+ __le32 s_flags; /* Right now used only by inode-attributes, if enabled */
+ unsigned char s_uuid[16]; /* filesystem unique identifier */
+ unsigned char s_label[16]; /* filesystem volume label */
+ char s_unused[88]; /* zero filled by mkreiserfs and
+ * reiserfs_convert_objectid_map_v1()
+ * so any additions must be updated
+ * there as well. */
+} __attribute__ ((__packed__));
#define SB_SIZE (sizeof(struct reiserfs_super_block))
#define REISERFS_VERSION_1 0
#define REISERFS_VERSION_2 2
-
// on-disk super block fields converted to cpu form
#define SB_DISK_SUPER_BLOCK(s) (REISERFS_SB(s)->s_rs)
#define SB_V1_DISK_SUPER_BLOCK(s) (&(SB_DISK_SUPER_BLOCK(s)->s_v1))
@@ -210,13 +205,12 @@ struct reiserfs_super_block
#define PUT_SB_TREE_HEIGHT(s, val) \
do { SB_V1_DISK_SUPER_BLOCK(s)->s_tree_height = cpu_to_le16(val); } while (0)
#define PUT_SB_REISERFS_STATE(s, val) \
- do { SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state = cpu_to_le16(val); } while (0)
+ do { SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state = cpu_to_le16(val); } while (0)
#define PUT_SB_VERSION(s, val) \
do { SB_V1_DISK_SUPER_BLOCK(s)->s_version = cpu_to_le16(val); } while (0)
#define PUT_SB_BMAP_NR(s, val) \
do { SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0)
-
#define SB_ONDISK_JP(s) (&SB_V1_DISK_SUPER_BLOCK(s)->s_journal)
#define SB_ONDISK_JOURNAL_SIZE(s) \
le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_size))
@@ -231,21 +225,19 @@ struct reiserfs_super_block
block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \
&& block < SB_JOURNAL_1st_RESERVED_BLOCK(s) + \
((!is_reiserfs_jr(SB_DISK_SUPER_BLOCK(s)) ? \
- SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s)))
-
-
+ SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s)))
/* used by gcc */
#define REISERFS_SUPER_MAGIC 0x52654973
/* used by file system utilities that
- look at the superblock, etc. */
+ look at the superblock, etc. */
#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
-int is_reiserfs_3_5 (struct reiserfs_super_block * rs);
-int is_reiserfs_3_6 (struct reiserfs_super_block * rs);
-int is_reiserfs_jr (struct reiserfs_super_block * rs);
+int is_reiserfs_3_5(struct reiserfs_super_block *rs);
+int is_reiserfs_3_6(struct reiserfs_super_block *rs);
+int is_reiserfs_jr(struct reiserfs_super_block *rs);
/* ReiserFS leaves the first 64k unused, so that partition labels have
enough space. If someone wants to write a fancy bootloader that
@@ -272,8 +264,8 @@ typedef __u32 b_blocknr_t;
typedef __le32 unp_t;
struct unfm_nodeinfo {
- unp_t unfm_nodenum;
- unsigned short unfm_freespace;
+ unp_t unfm_nodenum;
+ unsigned short unfm_freespace;
};
/* there are two formats of keys: 3.5 and 3.6
@@ -285,7 +277,6 @@ struct unfm_nodeinfo {
#define STAT_DATA_V1 0
#define STAT_DATA_V2 1
-
static inline struct reiserfs_inode_info *REISERFS_I(const struct inode *inode)
{
return container_of(inode, struct reiserfs_inode_info, vfs_inode);
@@ -343,15 +334,13 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
file would fit into one DIRECT item.
Primary intention for this one is to increase performance by decreasing
seeking.
-*/
+*/
#define STORE_TAIL_IN_UNFM_S2(n_file_size,n_tail_size,n_block_size) \
(\
(!(n_tail_size)) || \
(((n_file_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) ) \
)
-
-
/*
* values for s_umount_state field
*/
@@ -364,9 +353,9 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
#define TYPE_STAT_DATA 0
#define TYPE_INDIRECT 1
#define TYPE_DIRECT 2
-#define TYPE_DIRENTRY 3
-#define TYPE_MAXTYPE 3
-#define TYPE_ANY 15 // FIXME: comment is required
+#define TYPE_DIRENTRY 3
+#define TYPE_MAXTYPE 3
+#define TYPE_ANY 15 // FIXME: comment is required
/***************************************************************************/
/* KEY & ITEM HEAD */
@@ -376,60 +365,62 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
// directories use this key as well as old files
//
struct offset_v1 {
- __le32 k_offset;
- __le32 k_uniqueness;
+ __le32 k_offset;
+ __le32 k_uniqueness;
} __attribute__ ((__packed__));
struct offset_v2 {
__le64 v;
} __attribute__ ((__packed__));
-static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 )
+static inline __u16 offset_v2_k_type(const struct offset_v2 *v2)
{
__u8 type = le64_to_cpu(v2->v) >> 60;
- return (type <= TYPE_MAXTYPE)?type:TYPE_ANY;
+ return (type <= TYPE_MAXTYPE) ? type : TYPE_ANY;
}
-
-static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type )
+
+static inline void set_offset_v2_k_type(struct offset_v2 *v2, int type)
{
- v2->v = (v2->v & cpu_to_le64(~0ULL>>4)) | cpu_to_le64((__u64)type<<60);
+ v2->v =
+ (v2->v & cpu_to_le64(~0ULL >> 4)) | cpu_to_le64((__u64) type << 60);
}
-
-static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 )
+
+static inline loff_t offset_v2_k_offset(const struct offset_v2 *v2)
{
- return le64_to_cpu(v2->v) & (~0ULL>>4);
+ return le64_to_cpu(v2->v) & (~0ULL >> 4);
}
-static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){
- offset &= (~0ULL>>4);
- v2->v = (v2->v & cpu_to_le64(15ULL<<60)) | cpu_to_le64(offset);
+static inline void set_offset_v2_k_offset(struct offset_v2 *v2, loff_t offset)
+{
+ offset &= (~0ULL >> 4);
+ v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset);
}
/* Key of an item determines its location in the S+tree, and
is composed of 4 components */
struct reiserfs_key {
- __le32 k_dir_id; /* packing locality: by default parent
- directory object id */
- __le32 k_objectid; /* object identifier */
- union {
- struct offset_v1 k_offset_v1;
- struct offset_v2 k_offset_v2;
- } __attribute__ ((__packed__)) u;
+ __le32 k_dir_id; /* packing locality: by default parent
+ directory object id */
+ __le32 k_objectid; /* object identifier */
+ union {
+ struct offset_v1 k_offset_v1;
+ struct offset_v2 k_offset_v2;
+ } __attribute__ ((__packed__)) u;
} __attribute__ ((__packed__));
struct in_core_key {
- __u32 k_dir_id; /* packing locality: by default parent
- directory object id */
- __u32 k_objectid; /* object identifier */
- __u64 k_offset;
- __u8 k_type;
+ __u32 k_dir_id; /* packing locality: by default parent
+ directory object id */
+ __u32 k_objectid; /* object identifier */
+ __u64 k_offset;
+ __u8 k_type;
};
struct cpu_key {
- struct in_core_key on_disk_key;
- int version;
- int key_length; /* 3 in all cases but direct2indirect and
- indirect2direct conversion */
+ struct in_core_key on_disk_key;
+ int version;
+ int key_length; /* 3 in all cases but direct2indirect and
+ indirect2direct conversion */
};
/* Our function for comparing keys can compare keys of different
@@ -475,8 +466,7 @@ struct cpu_key {
indirect items) and specifies the location of the item itself
within the block. */
-struct item_head
-{
+struct item_head {
/* Everything in the tree is found by searching for it based on
* its key.*/
struct reiserfs_key ih_key;
@@ -492,13 +482,13 @@ struct item_head
number of directory entries in the directory item. */
__le16 ih_entry_count;
} __attribute__ ((__packed__)) u;
- __le16 ih_item_len; /* total size of the item body */
- __le16 ih_item_location; /* an offset to the item body
- * within the block */
- __le16 ih_version; /* 0 for all old items, 2 for new
- ones. Highest bit is set by fsck
- temporary, cleaned after all
- done */
+ __le16 ih_item_len; /* total size of the item body */
+ __le16 ih_item_location; /* an offset to the item body
+ * within the block */
+ __le16 ih_version; /* 0 for all old items, 2 for new
+ ones. Highest bit is set by fsck
+ temporary, cleaned after all
+ done */
} __attribute__ ((__packed__));
/* size of item header */
#define IH_SIZE (sizeof(struct item_head))
@@ -515,7 +505,6 @@ struct item_head
#define put_ih_location(ih, val) do { (ih)->ih_item_location = cpu_to_le16(val); } while (0)
#define put_ih_item_len(ih, val) do { (ih)->ih_item_len = cpu_to_le16(val); } while (0)
-
#define unreachable_item(ih) (ih_version(ih) & (1 << 15))
#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih))
@@ -537,40 +526,48 @@ struct item_head
#define V1_INDIRECT_UNIQUENESS 0xfffffffe
#define V1_DIRECT_UNIQUENESS 0xffffffff
#define V1_DIRENTRY_UNIQUENESS 500
-#define V1_ANY_UNIQUENESS 555 // FIXME: comment is required
+#define V1_ANY_UNIQUENESS 555 // FIXME: comment is required
//
// here are conversion routines
//
-static inline int uniqueness2type (__u32 uniqueness) CONSTF;
-static inline int uniqueness2type (__u32 uniqueness)
+static inline int uniqueness2type(__u32 uniqueness) CONSTF;
+static inline int uniqueness2type(__u32 uniqueness)
{
- switch ((int)uniqueness) {
- case V1_SD_UNIQUENESS: return TYPE_STAT_DATA;
- case V1_INDIRECT_UNIQUENESS: return TYPE_INDIRECT;
- case V1_DIRECT_UNIQUENESS: return TYPE_DIRECT;
- case V1_DIRENTRY_UNIQUENESS: return TYPE_DIRENTRY;
- default:
- reiserfs_warning (NULL, "vs-500: unknown uniqueness %d",
- uniqueness);
+ switch ((int)uniqueness) {
+ case V1_SD_UNIQUENESS:
+ return TYPE_STAT_DATA;
+ case V1_INDIRECT_UNIQUENESS:
+ return TYPE_INDIRECT;
+ case V1_DIRECT_UNIQUENESS:
+ return TYPE_DIRECT;
+ case V1_DIRENTRY_UNIQUENESS:
+ return TYPE_DIRENTRY;
+ default:
+ reiserfs_warning(NULL, "vs-500: unknown uniqueness %d",
+ uniqueness);
case V1_ANY_UNIQUENESS:
- return TYPE_ANY;
- }
+ return TYPE_ANY;
+ }
}
-static inline __u32 type2uniqueness (int type) CONSTF;
-static inline __u32 type2uniqueness (int type)
+static inline __u32 type2uniqueness(int type) CONSTF;
+static inline __u32 type2uniqueness(int type)
{
- switch (type) {
- case TYPE_STAT_DATA: return V1_SD_UNIQUENESS;
- case TYPE_INDIRECT: return V1_INDIRECT_UNIQUENESS;
- case TYPE_DIRECT: return V1_DIRECT_UNIQUENESS;
- case TYPE_DIRENTRY: return V1_DIRENTRY_UNIQUENESS;
- default:
- reiserfs_warning (NULL, "vs-501: unknown type %d", type);
+ switch (type) {
+ case TYPE_STAT_DATA:
+ return V1_SD_UNIQUENESS;
+ case TYPE_INDIRECT:
+ return V1_INDIRECT_UNIQUENESS;
+ case TYPE_DIRECT:
+ return V1_DIRECT_UNIQUENESS;
+ case TYPE_DIRENTRY:
+ return V1_DIRENTRY_UNIQUENESS;
+ default:
+ reiserfs_warning(NULL, "vs-501: unknown type %d", type);
case TYPE_ANY:
- return V1_ANY_UNIQUENESS;
- }
+ return V1_ANY_UNIQUENESS;
+ }
}
//
@@ -578,57 +575,56 @@ static inline __u32 type2uniqueness (int type)
// there is no way to get version of object from key, so, provide
// version to these defines
//
-static inline loff_t le_key_k_offset (int version, const struct reiserfs_key * key)
+static inline loff_t le_key_k_offset(int version,
+ const struct reiserfs_key *key)
{
- return (version == KEY_FORMAT_3_5) ?
- le32_to_cpu( key->u.k_offset_v1.k_offset ) :
- offset_v2_k_offset( &(key->u.k_offset_v2) );
+ return (version == KEY_FORMAT_3_5) ?
+ le32_to_cpu(key->u.k_offset_v1.k_offset) :
+ offset_v2_k_offset(&(key->u.k_offset_v2));
}
-static inline loff_t le_ih_k_offset (const struct item_head * ih)
+static inline loff_t le_ih_k_offset(const struct item_head *ih)
{
- return le_key_k_offset (ih_version (ih), &(ih->ih_key));
+ return le_key_k_offset(ih_version(ih), &(ih->ih_key));
}
-static inline loff_t le_key_k_type (int version, const struct reiserfs_key * key)
+static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key)
{
- return (version == KEY_FORMAT_3_5) ?
- uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) :
- offset_v2_k_type( &(key->u.k_offset_v2) );
+ return (version == KEY_FORMAT_3_5) ?
+ uniqueness2type(le32_to_cpu(key->u.k_offset_v1.k_uniqueness)) :
+ offset_v2_k_type(&(key->u.k_offset_v2));
}
-static inline loff_t le_ih_k_type (const struct item_head * ih)
+static inline loff_t le_ih_k_type(const struct item_head *ih)
{
- return le_key_k_type (ih_version (ih), &(ih->ih_key));
+ return le_key_k_type(ih_version(ih), &(ih->ih_key));
}
-
-static inline void set_le_key_k_offset (int version, struct reiserfs_key * key, loff_t offset)
+static inline void set_le_key_k_offset(int version, struct reiserfs_key *key,
+ loff_t offset)
{
- (version == KEY_FORMAT_3_5) ?
- (void)(key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */
- (void)(set_offset_v2_k_offset( &(key->u.k_offset_v2), offset ));
+ (version == KEY_FORMAT_3_5) ? (void)(key->u.k_offset_v1.k_offset = cpu_to_le32(offset)) : /* jdm check */
+ (void)(set_offset_v2_k_offset(&(key->u.k_offset_v2), offset));
}
-
-static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset)
+static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset)
{
- set_le_key_k_offset (ih_version (ih), &(ih->ih_key), offset);
+ set_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset);
}
-
-static inline void set_le_key_k_type (int version, struct reiserfs_key * key, int type)
+static inline void set_le_key_k_type(int version, struct reiserfs_key *key,
+ int type)
{
- (version == KEY_FORMAT_3_5) ?
- (void)(key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))):
- (void)(set_offset_v2_k_type( &(key->u.k_offset_v2), type ));
+ (version == KEY_FORMAT_3_5) ?
+ (void)(key->u.k_offset_v1.k_uniqueness =
+ cpu_to_le32(type2uniqueness(type)))
+ : (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type));
}
-static inline void set_le_ih_k_type (struct item_head * ih, int type)
+static inline void set_le_ih_k_type(struct item_head *ih, int type)
{
- set_le_key_k_type (ih_version (ih), &(ih->ih_key), type);
+ set_le_key_k_type(ih_version(ih), &(ih->ih_key), type);
}
-
#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY)
#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT)
#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT)
@@ -642,34 +638,32 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type)
#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key))
#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key))
-
-
//
// key is pointer to cpu key, result is cpu
//
-static inline loff_t cpu_key_k_offset (const struct cpu_key * key)
+static inline loff_t cpu_key_k_offset(const struct cpu_key *key)
{
- return key->on_disk_key.k_offset;
+ return key->on_disk_key.k_offset;
}
-static inline loff_t cpu_key_k_type (const struct cpu_key * key)
+static inline loff_t cpu_key_k_type(const struct cpu_key *key)
{
- return key->on_disk_key.k_type;
+ return key->on_disk_key.k_type;
}
-static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset)
+static inline void set_cpu_key_k_offset(struct cpu_key *key, loff_t offset)
{
key->on_disk_key.k_offset = offset;
}
-static inline void set_cpu_key_k_type (struct cpu_key * key, int type)
+static inline void set_cpu_key_k_type(struct cpu_key *key, int type)
{
key->on_disk_key.k_type = type;
}
-static inline void cpu_key_k_offset_dec (struct cpu_key * key)
+static inline void cpu_key_k_offset_dec(struct cpu_key *key)
{
- key->on_disk_key.k_offset --;
+ key->on_disk_key.k_offset--;
}
#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
@@ -677,34 +671,25 @@ static inline void cpu_key_k_offset_dec (struct cpu_key * key)
#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
#define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA)
-
/* are these used ? */
#define is_direntry_cpu_ih(ih) (is_direntry_cpu_key (&((ih)->ih_key)))
#define is_direct_cpu_ih(ih) (is_direct_cpu_key (&((ih)->ih_key)))
#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
-
-
-
-
#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
-/* maximal length of item */
+/* maximal length of item */
#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
#define MIN_ITEM_LEN 1
-
/* object identifier for root dir */
#define REISERFS_ROOT_OBJECTID 2
#define REISERFS_ROOT_PARENT_OBJECTID 1
extern struct reiserfs_key root_key;
-
-
-
/*
* Picture represents a leaf of the S+tree
* ______________________________________________________
@@ -716,13 +701,13 @@ extern struct reiserfs_key root_key;
/* Header of a disk block. More precisely, header of a formatted leaf
or internal node, and not the header of an unformatted node. */
-struct block_head {
- __le16 blk_level; /* Level of a block in the tree. */
- __le16 blk_nr_item; /* Number of keys/items in a block. */
- __le16 blk_free_space; /* Block free space in bytes. */
- __le16 blk_reserved;
- /* dump this in v4/planA */
- struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
+struct block_head {
+ __le16 blk_level; /* Level of a block in the tree. */
+ __le16 blk_nr_item; /* Number of keys/items in a block. */
+ __le16 blk_free_space; /* Block free space in bytes. */
+ __le16 blk_reserved;
+ /* dump this in v4/planA */
+ struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
};
#define BLKH_SIZE (sizeof(struct block_head))
@@ -741,12 +726,12 @@ struct block_head {
* values for blk_level field of the struct block_head
*/
-#define FREE_LEVEL 0 /* when node gets removed from the tree its
- blk_level is set to FREE_LEVEL. It is then
- used to see whether the node is still in the
- tree */
+#define FREE_LEVEL 0 /* when node gets removed from the tree its
+ blk_level is set to FREE_LEVEL. It is then
+ used to see whether the node is still in the
+ tree */
-#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level.*/
+#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level. */
/* Given the buffer head of a formatted node, resolve to the block head of that node. */
#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data))
@@ -759,7 +744,6 @@ struct block_head {
#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
-
/* Get right delimiting key. -- little endian */
#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))
@@ -770,41 +754,36 @@ struct block_head {
#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
&& B_LEVEL(p_s_bh) <= MAX_HEIGHT)
-
-
-
/***************************************************************************/
/* STAT DATA */
/***************************************************************************/
-
//
// old stat data is 32 bytes long. We are going to distinguish new one by
// different size
//
-struct stat_data_v1
-{
- __le16 sd_mode; /* file type, permissions */
- __le16 sd_nlink; /* number of hard links */
- __le16 sd_uid; /* owner */
- __le16 sd_gid; /* group */
- __le32 sd_size; /* file size */
- __le32 sd_atime; /* time of last access */
- __le32 sd_mtime; /* time file was last modified */
- __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
- union {
- __le32 sd_rdev;
- __le32 sd_blocks; /* number of blocks file uses */
- } __attribute__ ((__packed__)) u;
- __le32 sd_first_direct_byte; /* first byte of file which is stored
- in a direct item: except that if it
- equals 1 it is a symlink and if it
- equals ~(__u32)0 there is no
- direct item. The existence of this
- field really grates on me. Let's
- replace it with a macro based on
- sd_size and our tail suppression
- policy. Someday. -Hans */
+struct stat_data_v1 {
+ __le16 sd_mode; /* file type, permissions */
+ __le16 sd_nlink; /* number of hard links */
+ __le16 sd_uid; /* owner */
+ __le16 sd_gid; /* group */
+ __le32 sd_size; /* file size */
+ __le32 sd_atime; /* time of last access */
+ __le32 sd_mtime; /* time file was last modified */
+ __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
+ union {
+ __le32 sd_rdev;
+ __le32 sd_blocks; /* number of blocks file uses */
+ } __attribute__ ((__packed__)) u;
+ __le32 sd_first_direct_byte; /* first byte of file which is stored
+ in a direct item: except that if it
+ equals 1 it is a symlink and if it
+ equals ~(__u32)0 there is no
+ direct item. The existence of this
+ field really grates on me. Let's
+ replace it with a macro based on
+ sd_size and our tail suppression
+ policy. Someday. -Hans */
} __attribute__ ((__packed__));
#define SD_V1_SIZE (sizeof(struct stat_data_v1))
@@ -862,29 +841,29 @@ struct stat_data_v1
/* Stat Data on disk (reiserfs version of UFS disk inode minus the
address blocks) */
struct stat_data {
- __le16 sd_mode; /* file type, permissions */
- __le16 sd_attrs; /* persistent inode flags */
- __le32 sd_nlink; /* number of hard links */
- __le64 sd_size; /* file size */
- __le32 sd_uid; /* owner */
- __le32 sd_gid; /* group */
- __le32 sd_atime; /* time of last access */
- __le32 sd_mtime; /* time file was last modified */
- __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
- __le32 sd_blocks;
- union {
- __le32 sd_rdev;
- __le32 sd_generation;
- //__le32 sd_first_direct_byte;
- /* first byte of file which is stored in a
- direct item: except that if it equals 1
- it is a symlink and if it equals
- ~(__u32)0 there is no direct item. The
- existence of this field really grates
- on me. Let's replace it with a macro
- based on sd_size and our tail
- suppression policy? */
- } __attribute__ ((__packed__)) u;
+ __le16 sd_mode; /* file type, permissions */
+ __le16 sd_attrs; /* persistent inode flags */
+ __le32 sd_nlink; /* number of hard links */
+ __le64 sd_size; /* file size */
+ __le32 sd_uid; /* owner */
+ __le32 sd_gid; /* group */
+ __le32 sd_atime; /* time of last access */
+ __le32 sd_mtime; /* time file was last modified */
+ __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
+ __le32 sd_blocks;
+ union {
+ __le32 sd_rdev;
+ __le32 sd_generation;
+ //__le32 sd_first_direct_byte;
+ /* first byte of file which is stored in a
+ direct item: except that if it equals 1
+ it is a symlink and if it equals
+ ~(__u32)0 there is no direct item. The
+ existence of this field really grates
+ on me. Let's replace it with a macro
+ based on sd_size and our tail
+ suppression policy? */
+ } __attribute__ ((__packed__)) u;
} __attribute__ ((__packed__));
//
// this is 44 bytes long
@@ -919,7 +898,6 @@ struct stat_data {
#define sd_v2_attrs(sdp) (le16_to_cpu((sdp)->sd_attrs))
#define set_sd_v2_attrs(sdp,v) ((sdp)->sd_attrs = cpu_to_le16(v))
-
/***************************************************************************/
/* DIRECTORY STRUCTURE */
/***************************************************************************/
@@ -954,17 +932,14 @@ struct stat_data {
/* NOT IMPLEMENTED:
Directory will someday contain stat data of object */
-
-
-struct reiserfs_de_head
-{
- __le32 deh_offset; /* third component of the directory entry key */
- __le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
- by directory entry */
- __le32 deh_objectid; /* objectid of the object, that is referenced by directory entry */
- __le16 deh_location; /* offset of name in the whole item */
- __le16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
- entry is hidden (unlinked) */
+struct reiserfs_de_head {
+ __le32 deh_offset; /* third component of the directory entry key */
+ __le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
+ by directory entry */
+ __le32 deh_objectid; /* objectid of the object, that is referenced by directory entry */
+ __le16 deh_location; /* offset of name in the whole item */
+ __le16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
+ entry is hidden (unlinked) */
} __attribute__ ((__packed__));
#define DEH_SIZE sizeof(struct reiserfs_de_head)
#define deh_offset(p_deh) (le32_to_cpu((p_deh)->deh_offset))
@@ -986,7 +961,7 @@ struct reiserfs_de_head
/* old format directories have this size when empty */
#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)
-#define DEH_Statdata 0 /* not used now */
+#define DEH_Statdata 0 /* not used now */
#define DEH_Visible 2
/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */
@@ -1023,10 +998,10 @@ struct reiserfs_de_head
#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
-extern void make_empty_dir_item_v1 (char * body, __le32 dirid, __le32 objid,
- __le32 par_dirid, __le32 par_objid);
-extern void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
- __le32 par_dirid, __le32 par_objid);
+extern void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid,
+ __le32 par_dirid, __le32 par_objid);
+extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid,
+ __le32 par_dirid, __le32 par_objid);
/* array of the entry headers */
/* get item body */
@@ -1043,53 +1018,48 @@ extern void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
#define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \
((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh))))
*/
-static inline int entry_length (const struct buffer_head * bh,
- const struct item_head * ih, int pos_in_item)
+static inline int entry_length(const struct buffer_head *bh,
+ const struct item_head *ih, int pos_in_item)
{
- struct reiserfs_de_head * deh;
+ struct reiserfs_de_head *deh;
- deh = B_I_DEH (bh, ih) + pos_in_item;
- if (pos_in_item)
- return deh_location(deh-1) - deh_location(deh);
+ deh = B_I_DEH(bh, ih) + pos_in_item;
+ if (pos_in_item)
+ return deh_location(deh - 1) - deh_location(deh);
- return ih_item_len(ih) - deh_location(deh);
+ return ih_item_len(ih) - deh_location(deh);
}
-
-
/* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */
#define I_ENTRY_COUNT(ih) (ih_entry_count((ih)))
-
/* name by bh, ih and entry_num */
#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num))))
// two entries per block (at least)
#define REISERFS_MAX_NAME(block_size) 255
-
/* this structure is used for operations on directory entries. It is
not a disk structure. */
/* When reiserfs_find_entry or search_by_entry_key find directory
entry, they return filled reiserfs_dir_entry structure */
-struct reiserfs_dir_entry
-{
- struct buffer_head * de_bh;
- int de_item_num;
- struct item_head * de_ih;
- int de_entry_num;
- struct reiserfs_de_head * de_deh;
- int de_entrylen;
- int de_namelen;
- char * de_name;
- char * de_gen_number_bit_string;
-
- __u32 de_dir_id;
- __u32 de_objectid;
-
- struct cpu_key de_entry_key;
+struct reiserfs_dir_entry {
+ struct buffer_head *de_bh;
+ int de_item_num;
+ struct item_head *de_ih;
+ int de_entry_num;
+ struct reiserfs_de_head *de_deh;
+ int de_entrylen;
+ int de_namelen;
+ char *de_name;
+ char *de_gen_number_bit_string;
+
+ __u32 de_dir_id;
+ __u32 de_objectid;
+
+ struct cpu_key de_entry_key;
};
-
+
/* these defines are useful when a particular member of a reiserfs_dir_entry is needed */
/* pointer to file name, stored in entry */
@@ -1099,8 +1069,6 @@ struct reiserfs_dir_entry
#define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \
(I_DEH_N_ENTRY_LENGTH (ih, deh, entry_num) - (de_with_sd (deh) ? SD_SIZE : 0))
-
-
/* hash value occupies bits from 7 up to 30 */
#define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL)
/* generation number occupies 7 bits starting from 0 up to 6 */
@@ -1109,7 +1077,6 @@ struct reiserfs_dir_entry
#define SET_GENERATION_NUMBER(offset,gen_number) (GET_HASH_VALUE(offset)|(gen_number))
-
/*
* Picture represents an internal node of the reiserfs tree
* ______________________________________________________
@@ -1125,9 +1092,9 @@ struct reiserfs_dir_entry
/* Disk child pointer: The pointer from an internal node of the tree
to a node that is on disk. */
struct disk_child {
- __le32 dc_block_number; /* Disk child's block number. */
- __le16 dc_size; /* Disk child's used space. */
- __le16 dc_reserved;
+ __le32 dc_block_number; /* Disk child's block number. */
+ __le16 dc_size; /* Disk child's used space. */
+ __le16 dc_reserved;
};
#define DC_SIZE (sizeof(struct disk_child))
@@ -1144,7 +1111,7 @@ struct disk_child {
#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos)))
#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val ))
- /* maximal value of field child_size in structure disk_child */
+ /* maximal value of field child_size in structure disk_child */
/* child size is the combined size of all items and their headers */
#define MAX_CHILD_SIZE(bh) ((int)( (bh)->b_size - BLKH_SIZE ))
@@ -1159,7 +1126,6 @@ struct disk_child {
/* PATH STRUCTURES AND DEFINES */
/***************************************************************************/
-
/* Search_by_key fills up the path from the root to the leaf as it descends the tree looking for the
key. It uses reiserfs_bread to try to find buffers in the cache given their block number. If it
does not find them in the cache it reads them from disk. For each node search_by_key finds using
@@ -1168,20 +1134,18 @@ struct disk_child {
is looking through a leaf node bin_search will find the position of the item which has key either
equal to given key, or which is the maximal key less than the given key. */
-struct path_element {
- struct buffer_head * pe_buffer; /* Pointer to the buffer at the path in the tree. */
- int pe_position; /* Position in the tree node which is placed in the */
- /* buffer above. */
+struct path_element {
+ struct buffer_head *pe_buffer; /* Pointer to the buffer at the path in the tree. */
+ int pe_position; /* Position in the tree node which is placed in the */
+ /* buffer above. */
};
-#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */
-#define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */
-#define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */
-
-#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
-#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
-
+#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */
+#define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */
+#define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */
+#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
+#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
/* We need to keep track of who the ancestors of nodes are. When we
perform a search we record which nodes were visited while
@@ -1200,14 +1164,14 @@ excessive effort to avoid disturbing the precious VFS code.:-( The
gods only know how we are going to SMP the code that uses them.
znodes are the way! */
-#define PATH_READA 0x1 /* do read ahead */
-#define PATH_READA_BACK 0x2 /* read backwards */
+#define PATH_READA 0x1 /* do read ahead */
+#define PATH_READA_BACK 0x2 /* read backwards */
-struct path {
- int path_length; /* Length of the array above. */
- int reada;
- struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements. */
- int pos_in_item;
+struct path {
+ int path_length; /* Length of the array above. */
+ int reada;
+ struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements. */
+ int pos_in_item;
};
#define pos_in_item(path) ((path)->pos_in_item)
@@ -1224,25 +1188,23 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
/* Get position in the element at the path by path and path position. */
#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
-
#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
/* you know, to the person who didn't
- write this the macro name does not
- at first suggest what it does.
- Maybe POSITION_FROM_PATH_END? Or
- maybe we should just focus on
- dumping paths... -Hans */
+ write this the macro name does not
+ at first suggest what it does.
+ Maybe POSITION_FROM_PATH_END? Or
+ maybe we should just focus on
+ dumping paths... -Hans */
#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
-
#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
/* in do_balance leaf has h == 0 in contrast with path structure,
where root has level == 0. That is why we need these defines */
#define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h)) /* tb->S[h] */
-#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */
-#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
-#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */
+#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */
+#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
+#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */
#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
@@ -1253,7 +1215,6 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
#define item_moved(ih,path) comp_items(ih, path)
#define path_changed(ih,path) comp_items (ih, path)
-
/***************************************************************************/
/* MISC */
/***************************************************************************/
@@ -1272,30 +1233,26 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset
#define U32_MAX (~(__u32)0)
-static inline loff_t max_reiserfs_offset (struct inode * inode)
+static inline loff_t max_reiserfs_offset(struct inode *inode)
{
- if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
- return (loff_t)U32_MAX;
+ if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
+ return (loff_t) U32_MAX;
- return (loff_t)((~(__u64)0) >> 4);
+ return (loff_t) ((~(__u64) 0) >> 4);
}
-
/*#define MAX_KEY_UNIQUENESS MAX_UL_INT*/
#define MAX_KEY_OBJECTID MAX_UL_INT
-
#define MAX_B_NUM MAX_UL_INT
#define MAX_FC_NUM MAX_US_INT
-
/* the purpose is to detect overflow of an unsigned short */
#define REISERFS_LINK_MAX (MAX_US_INT - 1000)
-
/* The following defines are used in reiserfs_insert_item and reiserfs_append_item */
-#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */
-#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
+#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */
+#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
#define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
#define get_generation(s) atomic_read (&fs_generation(s))
@@ -1303,7 +1260,6 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
#define __fs_changed(gen,s) (gen != get_generation (s))
#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);})
-
/***************************************************************************/
/* FIXATE NODES */
/***************************************************************************/
@@ -1324,38 +1280,34 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
calculating what we can shift to neighbors and how many nodes we
have to have if we do not any shiftings, if we shift to left/right
neighbor or to both. */
-struct virtual_item
-{
- int vi_index; // index in the array of item operations
- unsigned short vi_type; // left/right mergeability
- unsigned short vi_item_len; /* length of item that it will have after balancing */
- struct item_head * vi_ih;
- const char * vi_item; // body of item (old or new)
- const void * vi_new_data; // 0 always but paste mode
- void * vi_uarea; // item specific area
+struct virtual_item {
+ int vi_index; // index in the array of item operations
+ unsigned short vi_type; // left/right mergeability
+ unsigned short vi_item_len; /* length of item that it will have after balancing */
+ struct item_head *vi_ih;
+ const char *vi_item; // body of item (old or new)
+ const void *vi_new_data; // 0 always but paste mode
+ void *vi_uarea; // item specific area
};
-
-struct virtual_node
-{
- char * vn_free_ptr; /* this is a pointer to the free space in the buffer */
- unsigned short vn_nr_item; /* number of items in virtual node */
- short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */
- short vn_mode; /* mode of balancing (paste, insert, delete, cut) */
- short vn_affected_item_num;
- short vn_pos_in_item;
- struct item_head * vn_ins_ih; /* item header of inserted item, 0 for other modes */
- const void * vn_data;
- struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */
+struct virtual_node {
+ char *vn_free_ptr; /* this is a pointer to the free space in the buffer */
+ unsigned short vn_nr_item; /* number of items in virtual node */
+ short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */
+ short vn_mode; /* mode of balancing (paste, insert, delete, cut) */
+ short vn_affected_item_num;
+ short vn_pos_in_item;
+ struct item_head *vn_ins_ih; /* item header of inserted item, 0 for other modes */
+ const void *vn_data;
+ struct virtual_item *vn_vi; /* array of items (including a new one, excluding item to be deleted) */
};
/* used by directory items when creating virtual nodes */
struct direntry_uarea {
- int flags;
- __u16 entry_count;
- __u16 entry_sizes[1];
-} __attribute__ ((__packed__)) ;
-
+ int flags;
+ __u16 entry_count;
+ __u16 entry_sizes[1];
+} __attribute__ ((__packed__));
/***************************************************************************/
/* TREE BALANCE */
@@ -1378,73 +1330,72 @@ struct direntry_uarea {
#define MAX_AMOUNT_NEEDED 2
/* someday somebody will prefix every field in this struct with tb_ */
-struct tree_balance
-{
- int tb_mode;
- int need_balance_dirty;
- struct super_block * tb_sb;
- struct reiserfs_transaction_handle *transaction_handle ;
- struct path * tb_path;
- struct buffer_head * L[MAX_HEIGHT]; /* array of left neighbors of nodes in the path */
- struct buffer_head * R[MAX_HEIGHT]; /* array of right neighbors of nodes in the path*/
- struct buffer_head * FL[MAX_HEIGHT]; /* array of fathers of the left neighbors */
- struct buffer_head * FR[MAX_HEIGHT]; /* array of fathers of the right neighbors */
- struct buffer_head * CFL[MAX_HEIGHT]; /* array of common parents of center node and its left neighbor */
- struct buffer_head * CFR[MAX_HEIGHT]; /* array of common parents of center node and its right neighbor */
-
- struct buffer_head * FEB[MAX_FEB_SIZE]; /* array of empty buffers. Number of buffers in array equals
- cur_blknum. */
- struct buffer_head * used[MAX_FEB_SIZE];
- struct buffer_head * thrown[MAX_FEB_SIZE];
- int lnum[MAX_HEIGHT]; /* array of number of items which must be
- shifted to the left in order to balance the
- current node; for leaves includes item that
- will be partially shifted; for internal
- nodes, it is the number of child pointers
- rather than items. It includes the new item
- being created. The code sometimes subtracts
- one to get the number of wholly shifted
- items for other purposes. */
- int rnum[MAX_HEIGHT]; /* substitute right for left in comment above */
- int lkey[MAX_HEIGHT]; /* array indexed by height h mapping the key delimiting L[h] and
- S[h] to its item number within the node CFL[h] */
- int rkey[MAX_HEIGHT]; /* substitute r for l in comment above */
- int insert_size[MAX_HEIGHT]; /* the number of bytes by we are trying to add or remove from
- S[h]. A negative value means removing. */
- int blknum[MAX_HEIGHT]; /* number of nodes that will replace node S[h] after
- balancing on the level h of the tree. If 0 then S is
- being deleted, if 1 then S is remaining and no new nodes
- are being created, if 2 or 3 then 1 or 2 new nodes is
- being created */
-
- /* fields that are used only for balancing leaves of the tree */
- int cur_blknum; /* number of empty blocks having been already allocated */
- int s0num; /* number of items that fall into left most node when S[0] splits */
- int s1num; /* number of items that fall into first new node when S[0] splits */
- int s2num; /* number of items that fall into second new node when S[0] splits */
- int lbytes; /* number of bytes which can flow to the left neighbor from the left */
- /* most liquid item that cannot be shifted from S[0] entirely */
- /* if -1 then nothing will be partially shifted */
- int rbytes; /* number of bytes which will flow to the right neighbor from the right */
- /* most liquid item that cannot be shifted from S[0] entirely */
- /* if -1 then nothing will be partially shifted */
- int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */
- /* note: if S[0] splits into 3 nodes, then items do not need to be cut */
- int s2bytes;
- struct buffer_head * buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */
- char * vn_buf; /* kmalloced memory. Used to create
+struct tree_balance {
+ int tb_mode;
+ int need_balance_dirty;
+ struct super_block *tb_sb;
+ struct reiserfs_transaction_handle *transaction_handle;
+ struct path *tb_path;
+ struct buffer_head *L[MAX_HEIGHT]; /* array of left neighbors of nodes in the path */
+ struct buffer_head *R[MAX_HEIGHT]; /* array of right neighbors of nodes in the path */
+ struct buffer_head *FL[MAX_HEIGHT]; /* array of fathers of the left neighbors */
+ struct buffer_head *FR[MAX_HEIGHT]; /* array of fathers of the right neighbors */
+ struct buffer_head *CFL[MAX_HEIGHT]; /* array of common parents of center node and its left neighbor */
+ struct buffer_head *CFR[MAX_HEIGHT]; /* array of common parents of center node and its right neighbor */
+
+ struct buffer_head *FEB[MAX_FEB_SIZE]; /* array of empty buffers. Number of buffers in array equals
+ cur_blknum. */
+ struct buffer_head *used[MAX_FEB_SIZE];
+ struct buffer_head *thrown[MAX_FEB_SIZE];
+ int lnum[MAX_HEIGHT]; /* array of number of items which must be
+ shifted to the left in order to balance the
+ current node; for leaves includes item that
+ will be partially shifted; for internal
+ nodes, it is the number of child pointers
+ rather than items. It includes the new item
+ being created. The code sometimes subtracts
+ one to get the number of wholly shifted
+ items for other purposes. */
+ int rnum[MAX_HEIGHT]; /* substitute right for left in comment above */
+ int lkey[MAX_HEIGHT]; /* array indexed by height h mapping the key delimiting L[h] and
+ S[h] to its item number within the node CFL[h] */
+ int rkey[MAX_HEIGHT]; /* substitute r for l in comment above */
+ int insert_size[MAX_HEIGHT]; /* the number of bytes by we are trying to add or remove from
+ S[h]. A negative value means removing. */
+ int blknum[MAX_HEIGHT]; /* number of nodes that will replace node S[h] after
+ balancing on the level h of the tree. If 0 then S is
+ being deleted, if 1 then S is remaining and no new nodes
+ are being created, if 2 or 3 then 1 or 2 new nodes is
+ being created */
+
+ /* fields that are used only for balancing leaves of the tree */
+ int cur_blknum; /* number of empty blocks having been already allocated */
+ int s0num; /* number of items that fall into left most node when S[0] splits */
+ int s1num; /* number of items that fall into first new node when S[0] splits */
+ int s2num; /* number of items that fall into second new node when S[0] splits */
+ int lbytes; /* number of bytes which can flow to the left neighbor from the left */
+ /* most liquid item that cannot be shifted from S[0] entirely */
+ /* if -1 then nothing will be partially shifted */
+ int rbytes; /* number of bytes which will flow to the right neighbor from the right */
+ /* most liquid item that cannot be shifted from S[0] entirely */
+ /* if -1 then nothing will be partially shifted */
+ int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */
+ /* note: if S[0] splits into 3 nodes, then items do not need to be cut */
+ int s2bytes;
+ struct buffer_head *buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */
+ char *vn_buf; /* kmalloced memory. Used to create
virtual node and keep map of
dirtied bitmap blocks */
- int vn_buf_size; /* size of the vn_buf */
- struct virtual_node * tb_vn; /* VN starts after bitmap of bitmap blocks */
+ int vn_buf_size; /* size of the vn_buf */
+ struct virtual_node *tb_vn; /* VN starts after bitmap of bitmap blocks */
- int fs_gen; /* saved value of `reiserfs_generation' counter
- see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
+ int fs_gen; /* saved value of `reiserfs_generation' counter
+ see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- struct in_core_key key; /* key pointer, to pass to block allocator or
- another low-level subsystem */
+ struct in_core_key key; /* key pointer, to pass to block allocator or
+ another low-level subsystem */
#endif
-} ;
+};
/* These are modes of balancing */
@@ -1479,13 +1430,12 @@ struct tree_balance
/* used in do_balance for passing parent of node information that has
been gotten from tb struct */
struct buffer_info {
- struct tree_balance * tb;
- struct buffer_head * bi_bh;
- struct buffer_head * bi_parent;
- int bi_position;
+ struct tree_balance *tb;
+ struct buffer_head *bi_bh;
+ struct buffer_head *bi_parent;
+ int bi_position;
};
-
/* there are 4 types of items: stat data, directory item, indirect, direct.
+-------------------+------------+--------------+------------+
| | k_offset | k_uniqueness | mergeable? |
@@ -1503,24 +1453,24 @@ struct buffer_info {
*/
struct item_operations {
- int (*bytes_number) (struct item_head * ih, int block_size);
- void (*decrement_key) (struct cpu_key *);
- int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize);
- void (*print_item) (struct item_head *, char * item);
- void (*check_item) (struct item_head *, char * item);
-
- int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi,
- int is_affected, int insert_size);
- int (*check_left) (struct virtual_item * vi, int free,
- int start_skip, int end_skip);
- int (*check_right) (struct virtual_item * vi, int free);
- int (*part_size) (struct virtual_item * vi, int from, int to);
- int (*unit_num) (struct virtual_item * vi);
- void (*print_vi) (struct virtual_item * vi);
+ int (*bytes_number) (struct item_head * ih, int block_size);
+ void (*decrement_key) (struct cpu_key *);
+ int (*is_left_mergeable) (struct reiserfs_key * ih,
+ unsigned long bsize);
+ void (*print_item) (struct item_head *, char *item);
+ void (*check_item) (struct item_head *, char *item);
+
+ int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi,
+ int is_affected, int insert_size);
+ int (*check_left) (struct virtual_item * vi, int free,
+ int start_skip, int end_skip);
+ int (*check_right) (struct virtual_item * vi, int free);
+ int (*part_size) (struct virtual_item * vi, int from, int to);
+ int (*unit_num) (struct virtual_item * vi);
+ void (*print_vi) (struct virtual_item * vi);
};
-
-extern struct item_operations * item_ops [TYPE_ANY + 1];
+extern struct item_operations *item_ops[TYPE_ANY + 1];
#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)
#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)
@@ -1533,8 +1483,6 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi)
#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi)
-
-
#define COMP_SHORT_KEYS comp_short_keys
/* number of blocks pointed to by the indirect item */
@@ -1545,8 +1493,7 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */
-
-/* get the item header */
+/* get the item header */
#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
/* get key */
@@ -1577,9 +1524,9 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
#define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
struct reiserfs_iget_args {
- __u32 objectid ;
- __u32 dirid ;
-} ;
+ __u32 objectid;
+ __u32 dirid;
+};
/***************************************************************************/
/* FUNCTION DECLARATIONS */
@@ -1595,11 +1542,11 @@ struct reiserfs_iget_args {
/* first block written in a commit. */
struct reiserfs_journal_desc {
- __le32 j_trans_id ; /* id of commit */
- __le32 j_len ; /* length of commit. len +1 is the commit block */
- __le32 j_mount_id ; /* mount id of this trans*/
- __le32 j_realblock[1] ; /* real locations for each block */
-} ;
+ __le32 j_trans_id; /* id of commit */
+ __le32 j_len; /* length of commit. len +1 is the commit block */
+ __le32 j_mount_id; /* mount id of this trans */
+ __le32 j_realblock[1]; /* real locations for each block */
+};
#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)
#define get_desc_trans_len(d) le32_to_cpu((d)->j_len)
@@ -1611,10 +1558,10 @@ struct reiserfs_journal_desc {
/* last block written in a commit */
struct reiserfs_journal_commit {
- __le32 j_trans_id ; /* must match j_trans_id from the desc block */
- __le32 j_len ; /* ditto */
- __le32 j_realblock[1] ; /* real locations for each block */
-} ;
+ __le32 j_trans_id; /* must match j_trans_id from the desc block */
+ __le32 j_len; /* ditto */
+ __le32 j_realblock[1]; /* real locations for each block */
+};
#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)
#define get_commit_trans_len(c) le32_to_cpu((c)->j_len)
@@ -1628,19 +1575,19 @@ struct reiserfs_journal_commit {
** and this transaction does not need to be replayed.
*/
struct reiserfs_journal_header {
- __le32 j_last_flush_trans_id ; /* id of last fully flushed transaction */
- __le32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */
- __le32 j_mount_id ;
- /* 12 */ struct journal_params jh_journal;
-} ;
+ __le32 j_last_flush_trans_id; /* id of last fully flushed transaction */
+ __le32 j_first_unflushed_offset; /* offset in the log of where to start replay after a crash */
+ __le32 j_mount_id;
+ /* 12 */ struct journal_params jh_journal;
+};
/* biggest tunable defines are right here */
-#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */
-#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */
+#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */
+#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */
#define JOURNAL_TRANS_MIN_DEFAULT 256
-#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */
+#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */
#define JOURNAL_MIN_RATIO 2
-#define JOURNAL_MAX_COMMIT_AGE 30
+#define JOURNAL_MAX_COMMIT_AGE 30
#define JOURNAL_MAX_TRANS_AGE 30
#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)
#ifdef CONFIG_QUOTA
@@ -1664,10 +1611,10 @@ struct reiserfs_journal_header {
** the current number of nodes is > max, the node is freed, otherwise,
** it is put on a free list for faster use later.
*/
-#define REISERFS_MIN_BITMAP_NODES 10
-#define REISERFS_MAX_BITMAP_NODES 100
+#define REISERFS_MIN_BITMAP_NODES 10
+#define REISERFS_MAX_BITMAP_NODES 100
-#define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */
+#define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */
#define JBH_HASH_MASK 8191
#define _jhashfn(sb,block) \
@@ -1681,14 +1628,14 @@ struct reiserfs_journal_header {
#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
enum reiserfs_bh_state_bits {
- BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */
- BH_JDirty_wait,
- BH_JNew, /* disk block was taken off free list before
- * being in a finished transaction, or
- * written to disk. Can be reused immed. */
- BH_JPrepared,
- BH_JRestore_dirty,
- BH_JTest, // debugging only will go away
+ BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */
+ BH_JDirty_wait,
+ BH_JNew, /* disk block was taken off free list before
+ * being in a finished transaction, or
+ * written to disk. Can be reused immed. */
+ BH_JPrepared,
+ BH_JRestore_dirty,
+ BH_JTest, // debugging only will go away
};
BUFFER_FNS(JDirty, journaled);
@@ -1708,175 +1655,192 @@ TAS_BUFFER_FNS(JTest, journal_test);
** transaction handle which is passed around for all journal calls
*/
struct reiserfs_transaction_handle {
- struct super_block *t_super ; /* super for this FS when journal_begin was
- called. saves calls to reiserfs_get_super
- also used by nested transactions to make
- sure they are nesting on the right FS
- _must_ be first in the handle
- */
- int t_refcount;
- int t_blocks_logged ; /* number of blocks this writer has logged */
- int t_blocks_allocated ; /* number of blocks this writer allocated */
- unsigned long t_trans_id ; /* sanity check, equals the current trans id */
- void *t_handle_save ; /* save existing current->journal_info */
- unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
- should be displaced from others */
- struct list_head t_list;
-} ;
+ struct super_block *t_super; /* super for this FS when journal_begin was
+ called. saves calls to reiserfs_get_super
+ also used by nested transactions to make
+ sure they are nesting on the right FS
+ _must_ be first in the handle
+ */
+ int t_refcount;
+ int t_blocks_logged; /* number of blocks this writer has logged */
+ int t_blocks_allocated; /* number of blocks this writer allocated */
+ unsigned long t_trans_id; /* sanity check, equals the current trans id */
+ void *t_handle_save; /* save existing current->journal_info */
+ unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
+ should be displaced from others */
+ struct list_head t_list;
+};
/* used to keep track of ordered and tail writes, attached to the buffer
* head through b_journal_head.
*/
struct reiserfs_jh {
- struct reiserfs_journal_list *jl;
- struct buffer_head *bh;
- struct list_head list;
+ struct reiserfs_journal_list *jl;
+ struct buffer_head *bh;
+ struct list_head list;
};
void reiserfs_free_jh(struct buffer_head *bh);
int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh);
int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh);
-int journal_mark_dirty(struct reiserfs_transaction_handle *, struct super_block *, struct buffer_head *bh) ;
-
-static inline int
-reiserfs_file_data_log(struct inode *inode) {
- if (reiserfs_data_log(inode->i_sb) ||
- (REISERFS_I(inode)->i_flags & i_data_log))
- return 1 ;
- return 0 ;
+int journal_mark_dirty(struct reiserfs_transaction_handle *,
+ struct super_block *, struct buffer_head *bh);
+
+static inline int reiserfs_file_data_log(struct inode *inode)
+{
+ if (reiserfs_data_log(inode->i_sb) ||
+ (REISERFS_I(inode)->i_flags & i_data_log))
+ return 1;
+ return 0;
}
-static inline int reiserfs_transaction_running(struct super_block *s) {
- struct reiserfs_transaction_handle *th = current->journal_info ;
- if (th && th->t_super == s)
- return 1 ;
- if (th && th->t_super == NULL)
- BUG();
- return 0 ;
+static inline int reiserfs_transaction_running(struct super_block *s)
+{
+ struct reiserfs_transaction_handle *th = current->journal_info;
+ if (th && th->t_super == s)
+ return 1;
+ if (th && th->t_super == NULL)
+ BUG();
+ return 0;
}
int reiserfs_async_progress_wait(struct super_block *s);
-struct reiserfs_transaction_handle *
-reiserfs_persistent_transaction(struct super_block *, int count);
+struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
+ super_block
+ *,
+ int count);
int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *);
int reiserfs_commit_page(struct inode *inode, struct page *page,
- unsigned from, unsigned to);
+ unsigned from, unsigned to);
int reiserfs_flush_old_commits(struct super_block *);
-int reiserfs_commit_for_inode(struct inode *) ;
-int reiserfs_inode_needs_commit(struct inode *) ;
-void reiserfs_update_inode_transaction(struct inode *) ;
-void reiserfs_wait_on_write_block(struct super_block *s) ;
-void reiserfs_block_writes(struct reiserfs_transaction_handle *th) ;
-void reiserfs_allow_writes(struct super_block *s) ;
-void reiserfs_check_lock_depth(struct super_block *s, char *caller) ;
-int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ;
-void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ;
-int journal_init(struct super_block *, const char * j_dev_name, int old_format, unsigned int) ;
-int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ;
-int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ;
-int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
-int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ;
-int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, b_blocknr_t blocknr) ;
-int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ;
-int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ;
-int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
-int journal_join_abort(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ;
-void reiserfs_journal_abort (struct super_block *sb, int errno);
-void reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...);
-int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ;
-
-void add_save_link (struct reiserfs_transaction_handle * th,
- struct inode * inode, int truncate);
-int remove_save_link (struct inode * inode, int truncate);
+int reiserfs_commit_for_inode(struct inode *);
+int reiserfs_inode_needs_commit(struct inode *);
+void reiserfs_update_inode_transaction(struct inode *);
+void reiserfs_wait_on_write_block(struct super_block *s);
+void reiserfs_block_writes(struct reiserfs_transaction_handle *th);
+void reiserfs_allow_writes(struct super_block *s);
+void reiserfs_check_lock_depth(struct super_block *s, char *caller);
+int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh,
+ int wait);
+void reiserfs_restore_prepared_buffer(struct super_block *,
+ struct buffer_head *bh);
+int journal_init(struct super_block *, const char *j_dev_name, int old_format,
+ unsigned int);
+int journal_release(struct reiserfs_transaction_handle *, struct super_block *);
+int journal_release_error(struct reiserfs_transaction_handle *,
+ struct super_block *);
+int journal_end(struct reiserfs_transaction_handle *, struct super_block *,
+ unsigned long);
+int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *,
+ unsigned long);
+int journal_mark_freed(struct reiserfs_transaction_handle *,
+ struct super_block *, b_blocknr_t blocknr);
+int journal_transaction_should_end(struct reiserfs_transaction_handle *, int);
+int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr,
+ int searchall, b_blocknr_t * next);
+int journal_begin(struct reiserfs_transaction_handle *,
+ struct super_block *p_s_sb, unsigned long);
+int journal_join_abort(struct reiserfs_transaction_handle *,
+ struct super_block *p_s_sb, unsigned long);
+void reiserfs_journal_abort(struct super_block *sb, int errno);
+void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
+int reiserfs_allocate_list_bitmaps(struct super_block *s,
+ struct reiserfs_list_bitmap *, int);
+
+void add_save_link(struct reiserfs_transaction_handle *th,
+ struct inode *inode, int truncate);
+int remove_save_link(struct inode *inode, int truncate);
/* objectid.c */
-__u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th);
-void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release);
-int reiserfs_convert_objectid_map_v1(struct super_block *) ;
+__u32 reiserfs_get_unused_objectid(struct reiserfs_transaction_handle *th);
+void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
+ __u32 objectid_to_release);
+int reiserfs_convert_objectid_map_v1(struct super_block *);
/* stree.c */
int B_IS_IN_TREE(const struct buffer_head *);
-extern void copy_item_head(struct item_head * p_v_to,
- const struct item_head * p_v_from);
+extern void copy_item_head(struct item_head *p_v_to,
+ const struct item_head *p_v_from);
// first key is in cpu form, second - le
-extern int comp_short_keys (const struct reiserfs_key * le_key,
- const struct cpu_key * cpu_key);
-extern void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from);
+extern int comp_short_keys(const struct reiserfs_key *le_key,
+ const struct cpu_key *cpu_key);
+extern void le_key2cpu_key(struct cpu_key *to, const struct reiserfs_key *from);
// both are in le form
-extern int comp_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
-extern int comp_short_le_keys (const struct reiserfs_key *, const struct reiserfs_key *);
+extern int comp_le_keys(const struct reiserfs_key *,
+ const struct reiserfs_key *);
+extern int comp_short_le_keys(const struct reiserfs_key *,
+ const struct reiserfs_key *);
//
// get key version from on disk key - kludge
//
-static inline int le_key_version (const struct reiserfs_key * key)
+static inline int le_key_version(const struct reiserfs_key *key)
{
- int type;
-
- type = offset_v2_k_type( &(key->u.k_offset_v2));
- if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY)
- return KEY_FORMAT_3_5;
-
- return KEY_FORMAT_3_6;
-
-}
+ int type;
+ type = offset_v2_k_type(&(key->u.k_offset_v2));
+ if (type != TYPE_DIRECT && type != TYPE_INDIRECT
+ && type != TYPE_DIRENTRY)
+ return KEY_FORMAT_3_5;
+
+ return KEY_FORMAT_3_6;
-static inline void copy_key (struct reiserfs_key *to, const struct reiserfs_key *from)
-{
- memcpy (to, from, KEY_SIZE);
}
+static inline void copy_key(struct reiserfs_key *to,
+ const struct reiserfs_key *from)
+{
+ memcpy(to, from, KEY_SIZE);
+}
-int comp_items (const struct item_head * stored_ih, const struct path * p_s_path);
-const struct reiserfs_key * get_rkey (const struct path * p_s_chk_path,
- const struct super_block * p_s_sb);
-int search_by_key (struct super_block *, const struct cpu_key *,
- struct path *, int);
+int comp_items(const struct item_head *stored_ih, const struct path *p_s_path);
+const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
+ const struct super_block *p_s_sb);
+int search_by_key(struct super_block *, const struct cpu_key *,
+ struct path *, int);
#define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
-int search_for_position_by_key (struct super_block * p_s_sb,
- const struct cpu_key * p_s_cpu_key,
- struct path * p_s_search_path);
-extern void decrement_bcount (struct buffer_head * p_s_bh);
-void decrement_counters_in_path (struct path * p_s_search_path);
-void pathrelse (struct path * p_s_search_path);
-int reiserfs_check_path(struct path *p) ;
-void pathrelse_and_restore (struct super_block *s, struct path * p_s_search_path);
-
-int reiserfs_insert_item (struct reiserfs_transaction_handle *th,
- struct path * path,
- const struct cpu_key * key,
- struct item_head * ih,
- struct inode *inode, const char * body);
-
-int reiserfs_paste_into_item (struct reiserfs_transaction_handle *th,
- struct path * path,
- const struct cpu_key * key,
- struct inode *inode,
- const char * body, int paste_size);
-
-int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th,
- struct path * path,
- struct cpu_key * key,
- struct inode * inode,
- struct page *page,
- loff_t new_file_size);
-
-int reiserfs_delete_item (struct reiserfs_transaction_handle *th,
- struct path * path,
- const struct cpu_key * key,
- struct inode * inode,
- struct buffer_head * p_s_un_bh);
-
-void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th,
- struct inode *inode, struct reiserfs_key * key);
-int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode);
-int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
- struct inode * p_s_inode, struct page *,
- int update_timestamps);
+int search_for_position_by_key(struct super_block *p_s_sb,
+ const struct cpu_key *p_s_cpu_key,
+ struct path *p_s_search_path);
+extern void decrement_bcount(struct buffer_head *p_s_bh);
+void decrement_counters_in_path(struct path *p_s_search_path);
+void pathrelse(struct path *p_s_search_path);
+int reiserfs_check_path(struct path *p);
+void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path);
+
+int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
+ struct path *path,
+ const struct cpu_key *key,
+ struct item_head *ih,
+ struct inode *inode, const char *body);
+
+int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th,
+ struct path *path,
+ const struct cpu_key *key,
+ struct inode *inode,
+ const char *body, int paste_size);
+
+int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
+ struct path *path,
+ struct cpu_key *key,
+ struct inode *inode,
+ struct page *page, loff_t new_file_size);
+
+int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
+ struct path *path,
+ const struct cpu_key *key,
+ struct inode *inode, struct buffer_head *p_s_un_bh);
+
+void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
+ struct inode *inode, struct reiserfs_key *key);
+int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
+ struct inode *p_s_inode);
+int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
+ struct inode *p_s_inode, struct page *,
+ int update_timestamps);
#define i_block_size(inode) ((inode)->i_sb->s_blocksize)
#define file_size(inode) ((inode)->i_size)
@@ -1885,66 +1849,67 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
#define tail_has_to_be_packed(inode) (have_large_tails ((inode)->i_sb)?\
!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):have_small_tails ((inode)->i_sb)?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):0 )
-void padd_item (char * item, int total_length, int length);
+void padd_item(char *item, int total_length, int length);
/* inode.c */
/* args for the create parameter of reiserfs_get_block */
-#define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */
-#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
-#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
-#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
-#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
-#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
-
-int restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path);
-void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ;
-int reiserfs_find_actor(struct inode * inode, void *p) ;
-int reiserfs_init_locked_inode(struct inode * inode, void *p) ;
-void reiserfs_delete_inode (struct inode * inode);
-int reiserfs_write_inode (struct inode * inode, int) ;
-int reiserfs_get_block (struct inode * inode, sector_t block, struct buffer_head * bh_result, int create);
-struct dentry *reiserfs_get_dentry(struct super_block *, void *) ;
-struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 *data,
- int len, int fhtype,
- int (*acceptable)(void *contect, struct dentry *de),
- void *context) ;
-int reiserfs_encode_fh( struct dentry *dentry, __u32 *data, int *lenp,
- int connectable );
-
-int reiserfs_truncate_file(struct inode *, int update_timestamps) ;
-void make_cpu_key (struct cpu_key * cpu_key, struct inode * inode, loff_t offset,
- int type, int key_length);
-void make_le_item_head (struct item_head * ih, const struct cpu_key * key,
- int version,
- loff_t offset, int type, int length, int entry_count);
-struct inode * reiserfs_iget (struct super_block * s,
- const struct cpu_key * key);
-
-
-int reiserfs_new_inode (struct reiserfs_transaction_handle *th,
- struct inode * dir, int mode,
- const char * symname, loff_t i_size,
- struct dentry *dentry, struct inode *inode);
-
-void reiserfs_update_sd_size (struct reiserfs_transaction_handle *th,
- struct inode * inode, loff_t size);
+#define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */
+#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
+#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
+#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
+#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
+#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
+
+int restart_transaction(struct reiserfs_transaction_handle *th,
+ struct inode *inode, struct path *path);
+void reiserfs_read_locked_inode(struct inode *inode,
+ struct reiserfs_iget_args *args);
+int reiserfs_find_actor(struct inode *inode, void *p);
+int reiserfs_init_locked_inode(struct inode *inode, void *p);
+void reiserfs_delete_inode(struct inode *inode);
+int reiserfs_write_inode(struct inode *inode, int);
+int reiserfs_get_block(struct inode *inode, sector_t block,
+ struct buffer_head *bh_result, int create);
+struct dentry *reiserfs_get_dentry(struct super_block *, void *);
+struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
+ int len, int fhtype,
+ int (*acceptable) (void *contect,
+ struct dentry * de),
+ void *context);
+int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
+ int connectable);
+
+int reiserfs_truncate_file(struct inode *, int update_timestamps);
+void make_cpu_key(struct cpu_key *cpu_key, struct inode *inode, loff_t offset,
+ int type, int key_length);
+void make_le_item_head(struct item_head *ih, const struct cpu_key *key,
+ int version,
+ loff_t offset, int type, int length, int entry_count);
+struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key);
+
+int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
+ struct inode *dir, int mode,
+ const char *symname, loff_t i_size,
+ struct dentry *dentry, struct inode *inode);
+
+void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
+ struct inode *inode, loff_t size);
static inline void reiserfs_update_sd(struct reiserfs_transaction_handle *th,
- struct inode *inode)
+ struct inode *inode)
{
- reiserfs_update_sd_size(th, inode, inode->i_size) ;
+ reiserfs_update_sd_size(th, inode, inode->i_size);
}
-void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode );
-void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs );
+void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
+void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
/* namei.c */
-void set_de_name_and_namelen (struct reiserfs_dir_entry * de);
-int search_by_entry_key (struct super_block * sb, const struct cpu_key * key,
- struct path * path,
- struct reiserfs_dir_entry * de);
-struct dentry *reiserfs_get_parent(struct dentry *) ;
+void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
+int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
+ struct path *path, struct reiserfs_dir_entry *de);
+struct dentry *reiserfs_get_parent(struct dentry *);
/* procfs.c */
#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
@@ -1953,15 +1918,15 @@ struct dentry *reiserfs_get_parent(struct dentry *) ;
#undef REISERFS_PROC_INFO
#endif
-int reiserfs_proc_info_init( struct super_block *sb );
-int reiserfs_proc_info_done( struct super_block *sb );
-struct proc_dir_entry *reiserfs_proc_register_global( char *name,
- read_proc_t *func );
-void reiserfs_proc_unregister_global( const char *name );
-int reiserfs_proc_info_global_init( void );
-int reiserfs_proc_info_global_done( void );
-int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset,
- int count, int *eof, void *data );
+int reiserfs_proc_info_init(struct super_block *sb);
+int reiserfs_proc_info_done(struct super_block *sb);
+struct proc_dir_entry *reiserfs_proc_register_global(char *name,
+ read_proc_t * func);
+void reiserfs_proc_unregister_global(const char *name);
+int reiserfs_proc_info_global_init(void);
+int reiserfs_proc_info_global_done(void);
+int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
+ int count, int *eof, void *data);
#if defined( REISERFS_PROC_INFO )
@@ -1993,123 +1958,132 @@ extern struct inode_operations reiserfs_special_inode_operations;
extern struct file_operations reiserfs_dir_operations;
/* tail_conversion.c */
-int direct2indirect (struct reiserfs_transaction_handle *, struct inode *, struct path *, struct buffer_head *, loff_t);
-int indirect2direct (struct reiserfs_transaction_handle *, struct inode *, struct page *, struct path *, const struct cpu_key *, loff_t, char *);
-void reiserfs_unmap_buffer(struct buffer_head *) ;
-
+int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
+ struct path *, struct buffer_head *, loff_t);
+int indirect2direct(struct reiserfs_transaction_handle *, struct inode *,
+ struct page *, struct path *, const struct cpu_key *,
+ loff_t, char *);
+void reiserfs_unmap_buffer(struct buffer_head *);
/* file.c */
extern struct inode_operations reiserfs_file_inode_operations;
extern struct file_operations reiserfs_file_operations;
-extern struct address_space_operations reiserfs_address_space_operations ;
+extern struct address_space_operations reiserfs_address_space_operations;
/* fix_nodes.c */
#ifdef CONFIG_REISERFS_CHECK
-void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s);
-void reiserfs_kfree (const void * vp, size_t size, struct super_block * s);
+void *reiserfs_kmalloc(size_t size, int flags, struct super_block *s);
+void reiserfs_kfree(const void *vp, size_t size, struct super_block *s);
#else
static inline void *reiserfs_kmalloc(size_t size, int flags,
- struct super_block *s)
+ struct super_block *s)
{
return kmalloc(size, flags);
}
static inline void reiserfs_kfree(const void *vp, size_t size,
- struct super_block *s)
+ struct super_block *s)
{
kfree(vp);
}
#endif
-int fix_nodes (int n_op_mode, struct tree_balance * p_s_tb,
- struct item_head * p_s_ins_ih, const void *);
-void unfix_nodes (struct tree_balance *);
-
+int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb,
+ struct item_head *p_s_ins_ih, const void *);
+void unfix_nodes(struct tree_balance *);
/* prints.c */
-void reiserfs_panic (struct super_block * s, const char * fmt, ...) __attribute__ ( ( noreturn ) );
-void reiserfs_info (struct super_block *s, const char * fmt, ...);
-void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...);
-void print_indirect_item (struct buffer_head * bh, int item_num);
-void store_print_tb (struct tree_balance * tb);
-void print_cur_tb (char * mes);
-void print_de (struct reiserfs_dir_entry * de);
-void print_bi (struct buffer_info * bi, char * mes);
-#define PRINT_LEAF_ITEMS 1 /* print all items */
-#define PRINT_DIRECTORY_ITEMS 2 /* print directory items */
-#define PRINT_DIRECT_ITEMS 4 /* print contents of direct items */
-void print_block (struct buffer_head * bh, ...);
-void print_bmap (struct super_block * s, int silent);
-void print_bmap_block (int i, char * data, int size, int silent);
+void reiserfs_panic(struct super_block *s, const char *fmt, ...)
+ __attribute__ ((noreturn));
+void reiserfs_info(struct super_block *s, const char *fmt, ...);
+void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
+void print_indirect_item(struct buffer_head *bh, int item_num);
+void store_print_tb(struct tree_balance *tb);
+void print_cur_tb(char *mes);
+void print_de(struct reiserfs_dir_entry *de);
+void print_bi(struct buffer_info *bi, char *mes);
+#define PRINT_LEAF_ITEMS 1 /* print all items */
+#define PRINT_DIRECTORY_ITEMS 2 /* print directory items */
+#define PRINT_DIRECT_ITEMS 4 /* print contents of direct items */
+void print_block(struct buffer_head *bh, ...);
+void print_bmap(struct super_block *s, int silent);
+void print_bmap_block(int i, char *data, int size, int silent);
/*void print_super_block (struct super_block * s, char * mes);*/
-void print_objectid_map (struct super_block * s);
-void print_block_head (struct buffer_head * bh, char * mes);
-void check_leaf (struct buffer_head * bh);
-void check_internal (struct buffer_head * bh);
-void print_statistics (struct super_block * s);
-char * reiserfs_hashname(int code);
+void print_objectid_map(struct super_block *s);
+void print_block_head(struct buffer_head *bh, char *mes);
+void check_leaf(struct buffer_head *bh);
+void check_internal(struct buffer_head *bh);
+void print_statistics(struct super_block *s);
+char *reiserfs_hashname(int code);
/* lbalance.c */
-int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew);
-int leaf_shift_left (struct tree_balance * tb, int shift_num, int shift_bytes);
-int leaf_shift_right (struct tree_balance * tb, int shift_num, int shift_bytes);
-void leaf_delete_items (struct buffer_info * cur_bi, int last_first, int first, int del_num, int del_bytes);
-void leaf_insert_into_buf (struct buffer_info * bi, int before,
- struct item_head * inserted_item_ih, const char * inserted_item_body, int zeros_number);
-void leaf_paste_in_buffer (struct buffer_info * bi, int pasted_item_num,
- int pos_in_item, int paste_size, const char * body, int zeros_number);
-void leaf_cut_from_buffer (struct buffer_info * bi, int cut_item_num, int pos_in_item,
- int cut_size);
-void leaf_paste_entries (struct buffer_head * bh, int item_num, int before,
- int new_entry_count, struct reiserfs_de_head * new_dehs, const char * records, int paste_size);
+int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num,
+ int mov_bytes, struct buffer_head *Snew);
+int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes);
+int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes);
+void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first,
+ int del_num, int del_bytes);
+void leaf_insert_into_buf(struct buffer_info *bi, int before,
+ struct item_head *inserted_item_ih,
+ const char *inserted_item_body, int zeros_number);
+void leaf_paste_in_buffer(struct buffer_info *bi, int pasted_item_num,
+ int pos_in_item, int paste_size, const char *body,
+ int zeros_number);
+void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
+ int pos_in_item, int cut_size);
+void leaf_paste_entries(struct buffer_head *bh, int item_num, int before,
+ int new_entry_count, struct reiserfs_de_head *new_dehs,
+ const char *records, int paste_size);
/* ibalance.c */
-int balance_internal (struct tree_balance * , int, int, struct item_head * ,
- struct buffer_head **);
+int balance_internal(struct tree_balance *, int, int, struct item_head *,
+ struct buffer_head **);
/* do_balance.c */
-void do_balance_mark_leaf_dirty (struct tree_balance * tb,
- struct buffer_head * bh, int flag);
+void do_balance_mark_leaf_dirty(struct tree_balance *tb,
+ struct buffer_head *bh, int flag);
#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
-void do_balance (struct tree_balance * tb, struct item_head * ih,
- const char * body, int flag);
-void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh);
+void do_balance(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag);
+void reiserfs_invalidate_buffer(struct tree_balance *tb,
+ struct buffer_head *bh);
-int get_left_neighbor_position (struct tree_balance * tb, int h);
-int get_right_neighbor_position (struct tree_balance * tb, int h);
-void replace_key (struct tree_balance * tb, struct buffer_head *, int, struct buffer_head *, int);
-void make_empty_node (struct buffer_info *);
-struct buffer_head * get_FEB (struct tree_balance *);
+int get_left_neighbor_position(struct tree_balance *tb, int h);
+int get_right_neighbor_position(struct tree_balance *tb, int h);
+void replace_key(struct tree_balance *tb, struct buffer_head *, int,
+ struct buffer_head *, int);
+void make_empty_node(struct buffer_info *);
+struct buffer_head *get_FEB(struct tree_balance *);
/* bitmap.c */
/* structure contains hints for block allocator, and it is a container for
* arguments, such as node, search path, transaction_handle, etc. */
- struct __reiserfs_blocknr_hint {
- struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */
- long block; /* file offset, in blocks */
- struct in_core_key key;
- struct path * path; /* search path, used by allocator to deternine search_start by
- * various ways */
- struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and
- * bitmap blocks changes */
- b_blocknr_t beg, end;
- b_blocknr_t search_start; /* a field used to transfer search start value (block number)
+struct __reiserfs_blocknr_hint {
+ struct inode *inode; /* inode passed to allocator, if we allocate unf. nodes */
+ long block; /* file offset, in blocks */
+ struct in_core_key key;
+ struct path *path; /* search path, used by allocator to deternine search_start by
+ * various ways */
+ struct reiserfs_transaction_handle *th; /* transaction handle is needed to log super blocks and
+ * bitmap blocks changes */
+ b_blocknr_t beg, end;
+ b_blocknr_t search_start; /* a field used to transfer search start value (block number)
* between different block allocator procedures
* (determine_search_start() and others) */
- int prealloc_size; /* is set in determine_prealloc_size() function, used by underlayed
- * function that do actual allocation */
+ int prealloc_size; /* is set in determine_prealloc_size() function, used by underlayed
+ * function that do actual allocation */
- unsigned formatted_node:1; /* the allocator uses different polices for getting disk space for
+ unsigned formatted_node:1; /* the allocator uses different polices for getting disk space for
* formatted/unformatted blocks with/without preallocation */
- unsigned preallocate:1;
+ unsigned preallocate:1;
};
typedef struct __reiserfs_blocknr_hint reiserfs_blocknr_hint_t;
-int reiserfs_parse_alloc_options (struct super_block *, char *);
-void reiserfs_init_alloc_options (struct super_block *s);
+int reiserfs_parse_alloc_options(struct super_block *, char *);
+void reiserfs_init_alloc_options(struct super_block *s);
/*
* given a directory, this will tell you what packing locality
@@ -2118,68 +2092,72 @@ void reiserfs_init_alloc_options (struct super_block *s);
*/
__le32 reiserfs_choose_packing(struct inode *dir);
-int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value);
-void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted);
-int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t * , int, int);
-extern inline int reiserfs_new_form_blocknrs (struct tree_balance * tb,
- b_blocknr_t *new_blocknrs, int amount_needed)
+int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value);
+void reiserfs_free_block(struct reiserfs_transaction_handle *th, struct inode *,
+ b_blocknr_t, int for_unformatted);
+int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int,
+ int);
+extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb,
+ b_blocknr_t * new_blocknrs,
+ int amount_needed)
{
- reiserfs_blocknr_hint_t hint = {
- .th = tb->transaction_handle,
- .path = tb->tb_path,
- .inode = NULL,
- .key = tb->key,
- .block = 0,
- .formatted_node = 1
- };
- return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed, 0);
+ reiserfs_blocknr_hint_t hint = {
+ .th = tb->transaction_handle,
+ .path = tb->tb_path,
+ .inode = NULL,
+ .key = tb->key,
+ .block = 0,
+ .formatted_node = 1
+ };
+ return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed,
+ 0);
}
-extern inline int reiserfs_new_unf_blocknrs (struct reiserfs_transaction_handle *th,
- struct inode *inode,
- b_blocknr_t *new_blocknrs,
- struct path * path, long block)
+extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle
+ *th, struct inode *inode,
+ b_blocknr_t * new_blocknrs,
+ struct path *path, long block)
{
- reiserfs_blocknr_hint_t hint = {
- .th = th,
- .path = path,
- .inode = inode,
- .block = block,
- .formatted_node = 0,
- .preallocate = 0
- };
- return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
+ reiserfs_blocknr_hint_t hint = {
+ .th = th,
+ .path = path,
+ .inode = inode,
+ .block = block,
+ .formatted_node = 0,
+ .preallocate = 0
+ };
+ return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
}
#ifdef REISERFS_PREALLOCATE
-extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle *th,
- struct inode * inode,
- b_blocknr_t *new_blocknrs,
- struct path * path, long block)
+extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle
+ *th, struct inode *inode,
+ b_blocknr_t * new_blocknrs,
+ struct path *path, long block)
{
- reiserfs_blocknr_hint_t hint = {
- .th = th,
- .path = path,
- .inode = inode,
- .block = block,
- .formatted_node = 0,
- .preallocate = 1
- };
- return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
+ reiserfs_blocknr_hint_t hint = {
+ .th = th,
+ .path = path,
+ .inode = inode,
+ .block = block,
+ .formatted_node = 0,
+ .preallocate = 1
+ };
+ return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
}
-void reiserfs_discard_prealloc (struct reiserfs_transaction_handle *th,
- struct inode * inode);
-void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th);
+void reiserfs_discard_prealloc(struct reiserfs_transaction_handle *th,
+ struct inode *inode);
+void reiserfs_discard_all_prealloc(struct reiserfs_transaction_handle *th);
#endif
-void reiserfs_claim_blocks_to_be_allocated( struct super_block *sb, int blocks);
-void reiserfs_release_claimed_blocks( struct super_block *sb, int blocks);
+void reiserfs_claim_blocks_to_be_allocated(struct super_block *sb, int blocks);
+void reiserfs_release_claimed_blocks(struct super_block *sb, int blocks);
int reiserfs_can_fit_pages(struct super_block *sb);
/* hashes.c */
-__u32 keyed_hash (const signed char *msg, int len);
-__u32 yura_hash (const signed char *msg, int len);
-__u32 r5_hash (const signed char *msg, int len);
+__u32 keyed_hash(const signed char *msg, int len);
+__u32 yura_hash(const signed char *msg, int len);
+__u32 r5_hash(const signed char *msg, int len);
/* the ext2 bit routines adjust for big or little endian as
** appropriate for the arch, so in our laziness we use them rather
@@ -2199,11 +2177,10 @@ __u32 r5_hash (const signed char *msg, int len);
absolutely safe */
#define SPARE_SPACE 500
-
/* prototypes from ioctl.c */
-int reiserfs_ioctl (struct inode * inode, struct file * filp,
- unsigned int cmd, unsigned long arg);
-
+int reiserfs_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
/* ioctl's command */
#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
/* define following flags to be the same as in ext2, so that chattr(1),
@@ -2218,10 +2195,8 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp,
would evolve into real per-fs locks */
#define reiserfs_write_lock( sb ) lock_kernel()
#define reiserfs_write_unlock( sb ) unlock_kernel()
-
+
/* xattr stuff */
#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
-#endif /* _LINUX_REISER_FS_H */
-
-
+#endif /* _LINUX_REISER_FS_H */
diff --git a/include/linux/reiserfs_fs_i.h b/include/linux/reiserfs_fs_i.h
index e321eb050d6..149be8d9a0c 100644
--- a/include/linux/reiserfs_fs_i.h
+++ b/include/linux/reiserfs_fs_i.h
@@ -10,54 +10,53 @@ typedef enum {
/** this says what format of key do all items (but stat data) of
an object have. If this is set, that format is 3.6 otherwise
- 3.5 */
- i_item_key_version_mask = 0x0001,
+ i_item_key_version_mask = 0x0001,
/** If this is unset, object has 3.5 stat data, otherwise, it has
3.6 stat data with 64bit size, 32bit nlink etc. */
- i_stat_data_version_mask = 0x0002,
+ i_stat_data_version_mask = 0x0002,
/** file might need tail packing on close */
- i_pack_on_close_mask = 0x0004,
+ i_pack_on_close_mask = 0x0004,
/** don't pack tail of file */
- i_nopack_mask = 0x0008,
+ i_nopack_mask = 0x0008,
/** If those is set, "safe link" was created for this file during
truncate or unlink. Safe link is used to avoid leakage of disk
space on crash with some files open, but unlinked. */
- i_link_saved_unlink_mask = 0x0010,
- i_link_saved_truncate_mask = 0x0020,
- i_has_xattr_dir = 0x0040,
- i_data_log = 0x0080,
+ i_link_saved_unlink_mask = 0x0010,
+ i_link_saved_truncate_mask = 0x0020,
+ i_has_xattr_dir = 0x0040,
+ i_data_log = 0x0080,
} reiserfs_inode_flags;
-
struct reiserfs_inode_info {
- __u32 i_key [4];/* key is still 4 32 bit integers */
+ __u32 i_key[4]; /* key is still 4 32 bit integers */
/** transient inode flags that are never stored on disk. Bitmasks
for this field are defined above. */
- __u32 i_flags;
+ __u32 i_flags;
- __u32 i_first_direct_byte; // offset of first byte stored in direct item.
+ __u32 i_first_direct_byte; // offset of first byte stored in direct item.
- /* copy of persistent inode flags read from sd_attrs. */
- __u32 i_attrs;
+ /* copy of persistent inode flags read from sd_attrs. */
+ __u32 i_attrs;
- int i_prealloc_block; /* first unused block of a sequence of unused blocks */
- int i_prealloc_count; /* length of that sequence */
- struct list_head i_prealloc_list; /* per-transaction list of inodes which
- * have preallocated blocks */
+ int i_prealloc_block; /* first unused block of a sequence of unused blocks */
+ int i_prealloc_count; /* length of that sequence */
+ struct list_head i_prealloc_list; /* per-transaction list of inodes which
+ * have preallocated blocks */
- unsigned new_packing_locality:1; /* new_packig_locality is created; new blocks
- * for the contents of this directory should be
- * displaced */
+ unsigned new_packing_locality:1; /* new_packig_locality is created; new blocks
+ * for the contents of this directory should be
+ * displaced */
- /* we use these for fsync or O_SYNC to decide which transaction
- ** needs to be committed in order for this inode to be properly
- ** flushed */
- unsigned long i_trans_id ;
- struct reiserfs_journal_list *i_jl;
+ /* we use these for fsync or O_SYNC to decide which transaction
+ ** needs to be committed in order for this inode to be properly
+ ** flushed */
+ unsigned long i_trans_id;
+ struct reiserfs_journal_list *i_jl;
- struct posix_acl *i_acl_access;
- struct posix_acl *i_acl_default;
- struct rw_semaphore xattr_sem;
- struct inode vfs_inode;
+ struct posix_acl *i_acl_access;
+ struct posix_acl *i_acl_default;
+ struct rw_semaphore xattr_sem;
+ struct inode vfs_inode;
};
#endif
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 31c709d0fe1..3e68592e52e 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -10,7 +10,7 @@
#endif
typedef enum {
- reiserfs_attrs_cleared = 0x00000001,
+ reiserfs_attrs_cleared = 0x00000001,
} reiserfs_super_block_flags;
/* struct reiserfs_super_block accessors/mutators
@@ -61,7 +61,7 @@ typedef enum {
#define sb_umount_state(sbp) (le16_to_cpu((sbp)->s_v1.s_umount_state))
#define set_sb_umount_state(sbp,v) ((sbp)->s_v1.s_umount_state = cpu_to_le16(v))
#define sb_fs_state(sbp) (le16_to_cpu((sbp)->s_v1.s_fs_state))
-#define set_sb_fs_state(sbp,v) ((sbp)->s_v1.s_fs_state = cpu_to_le16(v))
+#define set_sb_fs_state(sbp,v) ((sbp)->s_v1.s_fs_state = cpu_to_le16(v))
#define sb_hash_function_code(sbp) \
(le32_to_cpu((sbp)->s_v1.s_hash_function_code))
#define set_sb_hash_function_code(sbp,v) \
@@ -103,10 +103,10 @@ typedef enum {
/* don't mess with these for a while */
/* we have a node size define somewhere in reiserfs_fs.h. -Hans */
-#define JOURNAL_BLOCK_SIZE 4096 /* BUG gotta get rid of this */
-#define JOURNAL_MAX_CNODE 1500 /* max cnodes to allocate. */
-#define JOURNAL_HASH_SIZE 8192
-#define JOURNAL_NUM_BITMAPS 5 /* number of copies of the bitmaps to have floating. Must be >= 2 */
+#define JOURNAL_BLOCK_SIZE 4096 /* BUG gotta get rid of this */
+#define JOURNAL_MAX_CNODE 1500 /* max cnodes to allocate. */
+#define JOURNAL_HASH_SIZE 8192
+#define JOURNAL_NUM_BITMAPS 5 /* number of copies of the bitmaps to have floating. Must be >= 2 */
/* One of these for every block in every transaction
** Each one is in two hash tables. First, a hash of the current transaction, and after journal_end, a
@@ -117,27 +117,27 @@ typedef enum {
** to a given transaction.
*/
struct reiserfs_journal_cnode {
- struct buffer_head *bh ; /* real buffer head */
- struct super_block *sb ; /* dev of real buffer head */
- __u32 blocknr ; /* block number of real buffer head, == 0 when buffer on disk */
- long state ;
- struct reiserfs_journal_list *jlist ; /* journal list this cnode lives in */
- struct reiserfs_journal_cnode *next ; /* next in transaction list */
- struct reiserfs_journal_cnode *prev ; /* prev in transaction list */
- struct reiserfs_journal_cnode *hprev ; /* prev in hash list */
- struct reiserfs_journal_cnode *hnext ; /* next in hash list */
+ struct buffer_head *bh; /* real buffer head */
+ struct super_block *sb; /* dev of real buffer head */
+ __u32 blocknr; /* block number of real buffer head, == 0 when buffer on disk */
+ long state;
+ struct reiserfs_journal_list *jlist; /* journal list this cnode lives in */
+ struct reiserfs_journal_cnode *next; /* next in transaction list */
+ struct reiserfs_journal_cnode *prev; /* prev in transaction list */
+ struct reiserfs_journal_cnode *hprev; /* prev in hash list */
+ struct reiserfs_journal_cnode *hnext; /* next in hash list */
};
struct reiserfs_bitmap_node {
- int id ;
- char *data ;
- struct list_head list ;
-} ;
+ int id;
+ char *data;
+ struct list_head list;
+};
struct reiserfs_list_bitmap {
- struct reiserfs_journal_list *journal_list ;
- struct reiserfs_bitmap_node **bitmaps ;
-} ;
+ struct reiserfs_journal_list *journal_list;
+ struct reiserfs_bitmap_node **bitmaps;
+};
/*
** one of these for each transaction. The most important part here is the j_realblock.
@@ -146,273 +146,269 @@ struct reiserfs_list_bitmap {
** and to make sure every real block in a transaction is on disk before allowing the log area
** to be overwritten */
struct reiserfs_journal_list {
- unsigned long j_start ;
- unsigned long j_state;
- unsigned long j_len ;
- atomic_t j_nonzerolen ;
- atomic_t j_commit_left ;
- atomic_t j_older_commits_done ; /* all commits older than this on disk*/
- struct semaphore j_commit_lock;
- unsigned long j_trans_id ;
- time_t j_timestamp ;
- struct reiserfs_list_bitmap *j_list_bitmap ;
- struct buffer_head *j_commit_bh ; /* commit buffer head */
- struct reiserfs_journal_cnode *j_realblock ;
- struct reiserfs_journal_cnode *j_freedlist ; /* list of buffers that were freed during this trans. free each of these on flush */
- /* time ordered list of all active transactions */
- struct list_head j_list;
-
- /* time ordered list of all transactions we haven't tried to flush yet */
- struct list_head j_working_list;
-
- /* list of tail conversion targets in need of flush before commit */
- struct list_head j_tail_bh_list;
- /* list of data=ordered buffers in need of flush before commit */
- struct list_head j_bh_list;
- int j_refcount;
-} ;
+ unsigned long j_start;
+ unsigned long j_state;
+ unsigned long j_len;
+ atomic_t j_nonzerolen;
+ atomic_t j_commit_left;
+ atomic_t j_older_commits_done; /* all commits older than this on disk */
+ struct semaphore j_commit_lock;
+ unsigned long j_trans_id;
+ time_t j_timestamp;
+ struct reiserfs_list_bitmap *j_list_bitmap;
+ struct buffer_head *j_commit_bh; /* commit buffer head */
+ struct reiserfs_journal_cnode *j_realblock;
+ struct reiserfs_journal_cnode *j_freedlist; /* list of buffers that were freed during this trans. free each of these on flush */
+ /* time ordered list of all active transactions */
+ struct list_head j_list;
+
+ /* time ordered list of all transactions we haven't tried to flush yet */
+ struct list_head j_working_list;
+
+ /* list of tail conversion targets in need of flush before commit */
+ struct list_head j_tail_bh_list;
+ /* list of data=ordered buffers in need of flush before commit */
+ struct list_head j_bh_list;
+ int j_refcount;
+};
struct reiserfs_journal {
- struct buffer_head ** j_ap_blocks ; /* journal blocks on disk */
- struct reiserfs_journal_cnode *j_last ; /* newest journal block */
- struct reiserfs_journal_cnode *j_first ; /* oldest journal block. start here for traverse */
-
- struct file *j_dev_file;
- struct block_device *j_dev_bd;
- int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
-
- long j_state ;
- unsigned long j_trans_id ;
- unsigned long j_mount_id ;
- unsigned long j_start ; /* start of current waiting commit (index into j_ap_blocks) */
- unsigned long j_len ; /* lenght of current waiting commit */
- unsigned long j_len_alloc ; /* number of buffers requested by journal_begin() */
- atomic_t j_wcount ; /* count of writers for current commit */
- unsigned long j_bcount ; /* batch count. allows turning X transactions into 1 */
- unsigned long j_first_unflushed_offset ; /* first unflushed transactions offset */
- unsigned long j_last_flush_trans_id ; /* last fully flushed journal timestamp */
- struct buffer_head *j_header_bh ;
-
- time_t j_trans_start_time ; /* time this transaction started */
- struct semaphore j_lock;
- struct semaphore j_flush_sem;
- wait_queue_head_t j_join_wait ; /* wait for current transaction to finish before starting new one */
- atomic_t j_jlock ; /* lock for j_join_wait */
- int j_list_bitmap_index ; /* number of next list bitmap to use */
- int j_must_wait ; /* no more journal begins allowed. MUST sleep on j_join_wait */
- int j_next_full_flush ; /* next journal_end will flush all journal list */
- int j_next_async_flush ; /* next journal_end will flush all async commits */
-
- int j_cnode_used ; /* number of cnodes on the used list */
- int j_cnode_free ; /* number of cnodes on the free list */
-
- unsigned int j_trans_max ; /* max number of blocks in a transaction. */
- unsigned int j_max_batch ; /* max number of blocks to batch into a trans */
- unsigned int j_max_commit_age ; /* in seconds, how old can an async commit be */
- unsigned int j_max_trans_age ; /* in seconds, how old can a transaction be */
- unsigned int j_default_max_commit_age ; /* the default for the max commit age */
-
- struct reiserfs_journal_cnode *j_cnode_free_list ;
- struct reiserfs_journal_cnode *j_cnode_free_orig ; /* orig pointer returned from vmalloc */
-
- struct reiserfs_journal_list *j_current_jl;
- int j_free_bitmap_nodes ;
- int j_used_bitmap_nodes ;
-
- int j_num_lists; /* total number of active transactions */
- int j_num_work_lists; /* number that need attention from kreiserfsd */
-
- /* debugging to make sure things are flushed in order */
- int j_last_flush_id;
-
- /* debugging to make sure things are committed in order */
- int j_last_commit_id;
-
- struct list_head j_bitmap_nodes ;
- struct list_head j_dirty_buffers ;
- spinlock_t j_dirty_buffers_lock ; /* protects j_dirty_buffers */
-
- /* list of all active transactions */
- struct list_head j_journal_list;
- /* lists that haven't been touched by writeback attempts */
- struct list_head j_working_list;
-
- struct reiserfs_list_bitmap j_list_bitmap[JOURNAL_NUM_BITMAPS] ; /* array of bitmaps to record the deleted blocks */
- struct reiserfs_journal_cnode *j_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for real buffer heads in current trans */
- struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE] ; /* hash table for all the real buffer heads in all
- the transactions */
- struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */
- int j_persistent_trans;
- unsigned long j_max_trans_size ;
- unsigned long j_max_batch_size ;
-
- int j_errno;
-
- /* when flushing ordered buffers, throttle new ordered writers */
- struct work_struct j_work;
- atomic_t j_async_throttle;
+ struct buffer_head **j_ap_blocks; /* journal blocks on disk */
+ struct reiserfs_journal_cnode *j_last; /* newest journal block */
+ struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */
+
+ struct file *j_dev_file;
+ struct block_device *j_dev_bd;
+ int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
+
+ long j_state;
+ unsigned long j_trans_id;
+ unsigned long j_mount_id;
+ unsigned long j_start; /* start of current waiting commit (index into j_ap_blocks) */
+ unsigned long j_len; /* lenght of current waiting commit */
+ unsigned long j_len_alloc; /* number of buffers requested by journal_begin() */
+ atomic_t j_wcount; /* count of writers for current commit */
+ unsigned long j_bcount; /* batch count. allows turning X transactions into 1 */
+ unsigned long j_first_unflushed_offset; /* first unflushed transactions offset */
+ unsigned long j_last_flush_trans_id; /* last fully flushed journal timestamp */
+ struct buffer_head *j_header_bh;
+
+ time_t j_trans_start_time; /* time this transaction started */
+ struct semaphore j_lock;
+ struct semaphore j_flush_sem;
+ wait_queue_head_t j_join_wait; /* wait for current transaction to finish before starting new one */
+ atomic_t j_jlock; /* lock for j_join_wait */
+ int j_list_bitmap_index; /* number of next list bitmap to use */
+ int j_must_wait; /* no more journal begins allowed. MUST sleep on j_join_wait */
+ int j_next_full_flush; /* next journal_end will flush all journal list */
+ int j_next_async_flush; /* next journal_end will flush all async commits */
+
+ int j_cnode_used; /* number of cnodes on the used list */
+ int j_cnode_free; /* number of cnodes on the free list */
+
+ unsigned int j_trans_max; /* max number of blocks in a transaction. */
+ unsigned int j_max_batch; /* max number of blocks to batch into a trans */
+ unsigned int j_max_commit_age; /* in seconds, how old can an async commit be */
+ unsigned int j_max_trans_age; /* in seconds, how old can a transaction be */
+ unsigned int j_default_max_commit_age; /* the default for the max commit age */
+
+ struct reiserfs_journal_cnode *j_cnode_free_list;
+ struct reiserfs_journal_cnode *j_cnode_free_orig; /* orig pointer returned from vmalloc */
+
+ struct reiserfs_journal_list *j_current_jl;
+ int j_free_bitmap_nodes;
+ int j_used_bitmap_nodes;
+
+ int j_num_lists; /* total number of active transactions */
+ int j_num_work_lists; /* number that need attention from kreiserfsd */
+
+ /* debugging to make sure things are flushed in order */
+ int j_last_flush_id;
+
+ /* debugging to make sure things are committed in order */
+ int j_last_commit_id;
+
+ struct list_head j_bitmap_nodes;
+ struct list_head j_dirty_buffers;
+ spinlock_t j_dirty_buffers_lock; /* protects j_dirty_buffers */
+
+ /* list of all active transactions */
+ struct list_head j_journal_list;
+ /* lists that haven't been touched by writeback attempts */
+ struct list_head j_working_list;
+
+ struct reiserfs_list_bitmap j_list_bitmap[JOURNAL_NUM_BITMAPS]; /* array of bitmaps to record the deleted blocks */
+ struct reiserfs_journal_cnode *j_hash_table[JOURNAL_HASH_SIZE]; /* hash table for real buffer heads in current trans */
+ struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE]; /* hash table for all the real buffer heads in all
+ the transactions */
+ struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */
+ int j_persistent_trans;
+ unsigned long j_max_trans_size;
+ unsigned long j_max_batch_size;
+
+ int j_errno;
+
+ /* when flushing ordered buffers, throttle new ordered writers */
+ struct work_struct j_work;
+ atomic_t j_async_throttle;
};
enum journal_state_bits {
- J_WRITERS_BLOCKED = 1, /* set when new writers not allowed */
- J_WRITERS_QUEUED, /* set when log is full due to too many writers */
- J_ABORTED, /* set when log is aborted */
+ J_WRITERS_BLOCKED = 1, /* set when new writers not allowed */
+ J_WRITERS_QUEUED, /* set when log is full due to too many writers */
+ J_ABORTED, /* set when log is aborted */
};
+#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */
-#define JOURNAL_DESC_MAGIC "ReIsErLB" /* ick. magic string to find desc blocks in the journal */
+typedef __u32(*hashf_t) (const signed char *, int);
-typedef __u32 (*hashf_t) (const signed char *, int);
-
-struct reiserfs_bitmap_info
-{
- // FIXME: Won't work with block sizes > 8K
- __u16 first_zero_hint;
- __u16 free_count;
- struct buffer_head *bh; /* the actual bitmap */
+struct reiserfs_bitmap_info {
+ // FIXME: Won't work with block sizes > 8K
+ __u16 first_zero_hint;
+ __u16 free_count;
+ struct buffer_head *bh; /* the actual bitmap */
};
struct proc_dir_entry;
#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
typedef unsigned long int stat_cnt_t;
-typedef struct reiserfs_proc_info_data
-{
- spinlock_t lock;
- int exiting;
- int max_hash_collisions;
-
- stat_cnt_t breads;
- stat_cnt_t bread_miss;
- stat_cnt_t search_by_key;
- stat_cnt_t search_by_key_fs_changed;
- stat_cnt_t search_by_key_restarted;
-
- stat_cnt_t insert_item_restarted;
- stat_cnt_t paste_into_item_restarted;
- stat_cnt_t cut_from_item_restarted;
- stat_cnt_t delete_solid_item_restarted;
- stat_cnt_t delete_item_restarted;
-
- stat_cnt_t leaked_oid;
- stat_cnt_t leaves_removable;
-
- /* balances per level. Use explicit 5 as MAX_HEIGHT is not visible yet. */
- stat_cnt_t balance_at[ 5 ]; /* XXX */
- /* sbk == search_by_key */
- stat_cnt_t sbk_read_at[ 5 ]; /* XXX */
- stat_cnt_t sbk_fs_changed[ 5 ];
- stat_cnt_t sbk_restarted[ 5 ];
- stat_cnt_t items_at[ 5 ]; /* XXX */
- stat_cnt_t free_at[ 5 ]; /* XXX */
- stat_cnt_t can_node_be_removed[ 5 ]; /* XXX */
- long int lnum[ 5 ]; /* XXX */
- long int rnum[ 5 ]; /* XXX */
- long int lbytes[ 5 ]; /* XXX */
- long int rbytes[ 5 ]; /* XXX */
- stat_cnt_t get_neighbors[ 5 ];
- stat_cnt_t get_neighbors_restart[ 5 ];
- stat_cnt_t need_l_neighbor[ 5 ];
- stat_cnt_t need_r_neighbor[ 5 ];
-
- stat_cnt_t free_block;
- struct __scan_bitmap_stats {
- stat_cnt_t call;
- stat_cnt_t wait;
- stat_cnt_t bmap;
- stat_cnt_t retry;
- stat_cnt_t in_journal_hint;
- stat_cnt_t in_journal_nohint;
- stat_cnt_t stolen;
- } scan_bitmap;
- struct __journal_stats {
- stat_cnt_t in_journal;
- stat_cnt_t in_journal_bitmap;
- stat_cnt_t in_journal_reusable;
- stat_cnt_t lock_journal;
- stat_cnt_t lock_journal_wait;
- stat_cnt_t journal_being;
- stat_cnt_t journal_relock_writers;
- stat_cnt_t journal_relock_wcount;
- stat_cnt_t mark_dirty;
- stat_cnt_t mark_dirty_already;
- stat_cnt_t mark_dirty_notjournal;
- stat_cnt_t restore_prepared;
- stat_cnt_t prepare;
- stat_cnt_t prepare_retry;
- } journal;
+typedef struct reiserfs_proc_info_data {
+ spinlock_t lock;
+ int exiting;
+ int max_hash_collisions;
+
+ stat_cnt_t breads;
+ stat_cnt_t bread_miss;
+ stat_cnt_t search_by_key;
+ stat_cnt_t search_by_key_fs_changed;
+ stat_cnt_t search_by_key_restarted;
+
+ stat_cnt_t insert_item_restarted;
+ stat_cnt_t paste_into_item_restarted;
+ stat_cnt_t cut_from_item_restarted;
+ stat_cnt_t delete_solid_item_restarted;
+ stat_cnt_t delete_item_restarted;
+
+ stat_cnt_t leaked_oid;
+ stat_cnt_t leaves_removable;
+
+ /* balances per level. Use explicit 5 as MAX_HEIGHT is not visible yet. */
+ stat_cnt_t balance_at[5]; /* XXX */
+ /* sbk == search_by_key */
+ stat_cnt_t sbk_read_at[5]; /* XXX */
+ stat_cnt_t sbk_fs_changed[5];
+ stat_cnt_t sbk_restarted[5];
+ stat_cnt_t items_at[5]; /* XXX */
+ stat_cnt_t free_at[5]; /* XXX */
+ stat_cnt_t can_node_be_removed[5]; /* XXX */
+ long int lnum[5]; /* XXX */
+ long int rnum[5]; /* XXX */
+ long int lbytes[5]; /* XXX */
+ long int rbytes[5]; /* XXX */
+ stat_cnt_t get_neighbors[5];
+ stat_cnt_t get_neighbors_restart[5];
+ stat_cnt_t need_l_neighbor[5];
+ stat_cnt_t need_r_neighbor[5];
+
+ stat_cnt_t free_block;
+ struct __scan_bitmap_stats {
+ stat_cnt_t call;
+ stat_cnt_t wait;
+ stat_cnt_t bmap;
+ stat_cnt_t retry;
+ stat_cnt_t in_journal_hint;
+ stat_cnt_t in_journal_nohint;
+ stat_cnt_t stolen;
+ } scan_bitmap;
+ struct __journal_stats {
+ stat_cnt_t in_journal;
+ stat_cnt_t in_journal_bitmap;
+ stat_cnt_t in_journal_reusable;
+ stat_cnt_t lock_journal;
+ stat_cnt_t lock_journal_wait;
+ stat_cnt_t journal_being;
+ stat_cnt_t journal_relock_writers;
+ stat_cnt_t journal_relock_wcount;
+ stat_cnt_t mark_dirty;
+ stat_cnt_t mark_dirty_already;
+ stat_cnt_t mark_dirty_notjournal;
+ stat_cnt_t restore_prepared;
+ stat_cnt_t prepare;
+ stat_cnt_t prepare_retry;
+ } journal;
} reiserfs_proc_info_data_t;
#else
-typedef struct reiserfs_proc_info_data
-{} reiserfs_proc_info_data_t;
+typedef struct reiserfs_proc_info_data {
+} reiserfs_proc_info_data_t;
#endif
/* reiserfs union of in-core super block data */
-struct reiserfs_sb_info
-{
- struct buffer_head * s_sbh; /* Buffer containing the super block */
- /* both the comment and the choice of
- name are unclear for s_rs -Hans */
- struct reiserfs_super_block * s_rs; /* Pointer to the super block in the buffer */
- struct reiserfs_bitmap_info * s_ap_bitmap;
- struct reiserfs_journal *s_journal ; /* pointer to journal information */
- unsigned short s_mount_state; /* reiserfs state (valid, invalid) */
-
- /* Comment? -Hans */
- void (*end_io_handler)(struct buffer_head *, int);
- hashf_t s_hash_function; /* pointer to function which is used
- to sort names in directory. Set on
- mount */
- unsigned long s_mount_opt; /* reiserfs's mount options are set
- here (currently - NOTAIL, NOLOG,
- REPLAYONLY) */
-
- struct { /* This is a structure that describes block allocator options */
- unsigned long bits; /* Bitfield for enable/disable kind of options */
- unsigned long large_file_size; /* size started from which we consider file to be a large one(in blocks) */
- int border; /* percentage of disk, border takes */
- int preallocmin; /* Minimal file size (in blocks) starting from which we do preallocations */
- int preallocsize; /* Number of blocks we try to prealloc when file
- reaches preallocmin size (in blocks) or
- prealloc_list is empty. */
- } s_alloc_options;
-
- /* Comment? -Hans */
- wait_queue_head_t s_wait;
- /* To be obsoleted soon by per buffer seals.. -Hans */
- atomic_t s_generation_counter; // increased by one every time the
- // tree gets re-balanced
- unsigned long s_properties; /* File system properties. Currently holds
- on-disk FS format */
-
- /* session statistics */
- int s_kmallocs;
- int s_disk_reads;
- int s_disk_writes;
- int s_fix_nodes;
- int s_do_balance;
- int s_unneeded_left_neighbor;
- int s_good_search_by_key_reada;
- int s_bmaps;
- int s_bmaps_without_search;
- int s_direct2indirect;
- int s_indirect2direct;
+struct reiserfs_sb_info {
+ struct buffer_head *s_sbh; /* Buffer containing the super block */
+ /* both the comment and the choice of
+ name are unclear for s_rs -Hans */
+ struct reiserfs_super_block *s_rs; /* Pointer to the super block in the buffer */
+ struct reiserfs_bitmap_info *s_ap_bitmap;
+ struct reiserfs_journal *s_journal; /* pointer to journal information */
+ unsigned short s_mount_state; /* reiserfs state (valid, invalid) */
+
+ /* Comment? -Hans */
+ void (*end_io_handler) (struct buffer_head *, int);
+ hashf_t s_hash_function; /* pointer to function which is used
+ to sort names in directory. Set on
+ mount */
+ unsigned long s_mount_opt; /* reiserfs's mount options are set
+ here (currently - NOTAIL, NOLOG,
+ REPLAYONLY) */
+
+ struct { /* This is a structure that describes block allocator options */
+ unsigned long bits; /* Bitfield for enable/disable kind of options */
+ unsigned long large_file_size; /* size started from which we consider file to be a large one(in blocks) */
+ int border; /* percentage of disk, border takes */
+ int preallocmin; /* Minimal file size (in blocks) starting from which we do preallocations */
+ int preallocsize; /* Number of blocks we try to prealloc when file
+ reaches preallocmin size (in blocks) or
+ prealloc_list is empty. */
+ } s_alloc_options;
+
+ /* Comment? -Hans */
+ wait_queue_head_t s_wait;
+ /* To be obsoleted soon by per buffer seals.. -Hans */
+ atomic_t s_generation_counter; // increased by one every time the
+ // tree gets re-balanced
+ unsigned long s_properties; /* File system properties. Currently holds
+ on-disk FS format */
+
+ /* session statistics */
+ int s_kmallocs;
+ int s_disk_reads;
+ int s_disk_writes;
+ int s_fix_nodes;
+ int s_do_balance;
+ int s_unneeded_left_neighbor;
+ int s_good_search_by_key_reada;
+ int s_bmaps;
+ int s_bmaps_without_search;
+ int s_direct2indirect;
+ int s_indirect2direct;
/* set up when it's ok for reiserfs_read_inode2() to read from
disk inode with nlink==0. Currently this is only used during
finish_unfinished() processing at mount time */
- int s_is_unlinked_ok;
- reiserfs_proc_info_data_t s_proc_info_data;
- struct proc_dir_entry *procdir;
- int reserved_blocks; /* amount of blocks reserved for further allocations */
- spinlock_t bitmap_lock; /* this lock on now only used to protect reserved_blocks variable */
- struct dentry *priv_root; /* root of /.reiserfs_priv */
- struct dentry *xattr_root; /* root of /.reiserfs_priv/.xa */
- struct rw_semaphore xattr_dir_sem;
-
- int j_errno;
+ int s_is_unlinked_ok;
+ reiserfs_proc_info_data_t s_proc_info_data;
+ struct proc_dir_entry *procdir;
+ int reserved_blocks; /* amount of blocks reserved for further allocations */
+ spinlock_t bitmap_lock; /* this lock on now only used to protect reserved_blocks variable */
+ struct dentry *priv_root; /* root of /.reiserfs_priv */
+ struct dentry *xattr_root; /* root of /.reiserfs_priv/.xa */
+ struct rw_semaphore xattr_dir_sem;
+
+ int j_errno;
#ifdef CONFIG_QUOTA
- char *s_qf_names[MAXQUOTAS];
- int s_jquota_fmt;
+ char *s_qf_names[MAXQUOTAS];
+ int s_jquota_fmt;
#endif
};
@@ -422,14 +418,14 @@ struct reiserfs_sb_info
enum reiserfs_mount_options {
/* Mount options */
- REISERFS_LARGETAIL, /* large tails will be created in a session */
- REISERFS_SMALLTAIL, /* small (for files less than block size) tails will be created in a session */
- REPLAYONLY, /* replay journal and return 0. Use by fsck */
- REISERFS_CONVERT, /* -o conv: causes conversion of old
- format super block to the new
- format. If not specified - old
- partition will be dealt with in a
- manner of 3.5.x */
+ REISERFS_LARGETAIL, /* large tails will be created in a session */
+ REISERFS_SMALLTAIL, /* small (for files less than block size) tails will be created in a session */
+ REPLAYONLY, /* replay journal and return 0. Use by fsck */
+ REISERFS_CONVERT, /* -o conv: causes conversion of old
+ format super block to the new
+ format. If not specified - old
+ partition will be dealt with in a
+ manner of 3.5.x */
/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting
** reiserfs disks from 3.5.19 or earlier. 99% of the time, this option
@@ -439,41 +435,41 @@ enum reiserfs_mount_options {
** the existing hash on the FS, so if you have a tea hash disk, and mount
** with -o hash=rupasov, the mount will fail.
*/
- FORCE_TEA_HASH, /* try to force tea hash on mount */
- FORCE_RUPASOV_HASH, /* try to force rupasov hash on mount */
- FORCE_R5_HASH, /* try to force rupasov hash on mount */
- FORCE_HASH_DETECT, /* try to detect hash function on mount */
+ FORCE_TEA_HASH, /* try to force tea hash on mount */
+ FORCE_RUPASOV_HASH, /* try to force rupasov hash on mount */
+ FORCE_R5_HASH, /* try to force rupasov hash on mount */
+ FORCE_HASH_DETECT, /* try to detect hash function on mount */
- REISERFS_DATA_LOG,
- REISERFS_DATA_ORDERED,
- REISERFS_DATA_WRITEBACK,
+ REISERFS_DATA_LOG,
+ REISERFS_DATA_ORDERED,
+ REISERFS_DATA_WRITEBACK,
/* used for testing experimental features, makes benchmarking new
features with and without more convenient, should never be used by
users in any code shipped to users (ideally) */
- REISERFS_NO_BORDER,
- REISERFS_NO_UNHASHED_RELOCATION,
- REISERFS_HASHED_RELOCATION,
- REISERFS_ATTRS,
- REISERFS_XATTRS,
- REISERFS_XATTRS_USER,
- REISERFS_POSIXACL,
- REISERFS_BARRIER_NONE,
- REISERFS_BARRIER_FLUSH,
-
- /* Actions on error */
- REISERFS_ERROR_PANIC,
- REISERFS_ERROR_RO,
- REISERFS_ERROR_CONTINUE,
-
- REISERFS_QUOTA, /* Some quota option specified */
-
- REISERFS_TEST1,
- REISERFS_TEST2,
- REISERFS_TEST3,
- REISERFS_TEST4,
- REISERFS_UNSUPPORTED_OPT,
+ REISERFS_NO_BORDER,
+ REISERFS_NO_UNHASHED_RELOCATION,
+ REISERFS_HASHED_RELOCATION,
+ REISERFS_ATTRS,
+ REISERFS_XATTRS,
+ REISERFS_XATTRS_USER,
+ REISERFS_POSIXACL,
+ REISERFS_BARRIER_NONE,
+ REISERFS_BARRIER_FLUSH,
+
+ /* Actions on error */
+ REISERFS_ERROR_PANIC,
+ REISERFS_ERROR_RO,
+ REISERFS_ERROR_CONTINUE,
+
+ REISERFS_QUOTA, /* Some quota option specified */
+
+ REISERFS_TEST1,
+ REISERFS_TEST2,
+ REISERFS_TEST3,
+ REISERFS_TEST4,
+ REISERFS_UNSUPPORTED_OPT,
};
#define reiserfs_r5_hash(s) (REISERFS_SB(s)->s_mount_opt & (1 << FORCE_R5_HASH))
@@ -504,18 +500,17 @@ enum reiserfs_mount_options {
#define reiserfs_error_panic(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_PANIC))
#define reiserfs_error_ro(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_ERROR_RO))
-void reiserfs_file_buffer (struct buffer_head * bh, int list);
+void reiserfs_file_buffer(struct buffer_head *bh, int list);
extern struct file_system_type reiserfs_fs_type;
-int reiserfs_resize(struct super_block *, unsigned long) ;
+int reiserfs_resize(struct super_block *, unsigned long);
#define CARRY_ON 0
#define SCHEDULE_OCCURRED 1
-
#define SB_BUFFER_WITH_SB(s) (REISERFS_SB(s)->s_sbh)
#define SB_JOURNAL(s) (REISERFS_SB(s)->s_journal)
#define SB_JOURNAL_1st_RESERVED_BLOCK(s) (SB_JOURNAL(s)->j_1st_reserved_block)
-#define SB_JOURNAL_LEN_FREE(s) (SB_JOURNAL(s)->j_journal_len_free)
+#define SB_JOURNAL_LEN_FREE(s) (SB_JOURNAL(s)->j_journal_len_free)
#define SB_AP_BITMAP(s) (REISERFS_SB(s)->s_ap_bitmap)
#define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->)
@@ -525,13 +520,14 @@ int reiserfs_resize(struct super_block *, unsigned long) ;
*/
static inline char *reiserfs_bdevname(struct super_block *s)
{
- return (s == NULL) ? "Null superblock" : s -> s_id;
+ return (s == NULL) ? "Null superblock" : s->s_id;
}
#define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal)))
-static inline int __reiserfs_is_journal_aborted (struct reiserfs_journal *journal)
+static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal
+ *journal)
{
- return test_bit (J_ABORTED, &journal->j_state);
+ return test_bit(J_ABORTED, &journal->j_state);
}
-#endif /* _LINUX_REISER_FS_SB */
+#endif /* _LINUX_REISER_FS_SB */
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 9244c574882..c84354e8374 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -7,48 +7,48 @@
#include <linux/xattr.h>
/* Magic value in header */
-#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
+#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
struct reiserfs_xattr_header {
- __le32 h_magic; /* magic number for identification */
- __le32 h_hash; /* hash of the value */
+ __le32 h_magic; /* magic number for identification */
+ __le32 h_hash; /* hash of the value */
};
#ifdef __KERNEL__
struct reiserfs_xattr_handler {
char *prefix;
- int (*init)(void);
- void (*exit)(void);
- int (*get)(struct inode *inode, const char *name, void *buffer,
- size_t size);
- int (*set)(struct inode *inode, const char *name, const void *buffer,
- size_t size, int flags);
- int (*del)(struct inode *inode, const char *name);
- int (*list)(struct inode *inode, const char *name, int namelen, char *out);
- struct list_head handlers;
+ int (*init) (void);
+ void (*exit) (void);
+ int (*get) (struct inode * inode, const char *name, void *buffer,
+ size_t size);
+ int (*set) (struct inode * inode, const char *name, const void *buffer,
+ size_t size, int flags);
+ int (*del) (struct inode * inode, const char *name);
+ int (*list) (struct inode * inode, const char *name, int namelen,
+ char *out);
+ struct list_head handlers;
};
-
#ifdef CONFIG_REISERFS_FS_XATTR
#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
-ssize_t reiserfs_getxattr (struct dentry *dentry, const char *name,
- void *buffer, size_t size);
-int reiserfs_setxattr (struct dentry *dentry, const char *name,
- const void *value, size_t size, int flags);
-ssize_t reiserfs_listxattr (struct dentry *dentry, char *buffer, size_t size);
-int reiserfs_removexattr (struct dentry *dentry, const char *name);
-int reiserfs_delete_xattrs (struct inode *inode);
-int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs);
-int reiserfs_xattr_init (struct super_block *sb, int mount_flags);
-int reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd);
-int reiserfs_permission_locked (struct inode *inode, int mask, struct nameidata *nd);
-
-int reiserfs_xattr_del (struct inode *, const char *);
-int reiserfs_xattr_get (const struct inode *, const char *, void *, size_t);
-int reiserfs_xattr_set (struct inode *, const char *, const void *,
- size_t, int);
+ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
+ void *buffer, size_t size);
+int reiserfs_setxattr(struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags);
+ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
+int reiserfs_removexattr(struct dentry *dentry, const char *name);
+int reiserfs_delete_xattrs(struct inode *inode);
+int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
+int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
+int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
+int reiserfs_permission_locked(struct inode *inode, int mask,
+ struct nameidata *nd);
+
+int reiserfs_xattr_del(struct inode *, const char *);
+int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
+int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
extern struct reiserfs_xattr_handler user_handler;
extern struct reiserfs_xattr_handler trusted_handler;
@@ -56,57 +56,48 @@ extern struct reiserfs_xattr_handler trusted_handler;
extern struct reiserfs_xattr_handler security_handler;
#endif
-int reiserfs_xattr_register_handlers (void) __init;
-void reiserfs_xattr_unregister_handlers (void);
+int reiserfs_xattr_register_handlers(void) __init;
+void reiserfs_xattr_unregister_handlers(void);
-static inline void
-reiserfs_write_lock_xattrs(struct super_block *sb)
+static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
{
- down_write (&REISERFS_XATTR_DIR_SEM(sb));
+ down_write(&REISERFS_XATTR_DIR_SEM(sb));
}
-static inline void
-reiserfs_write_unlock_xattrs(struct super_block *sb)
+static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
{
- up_write (&REISERFS_XATTR_DIR_SEM(sb));
+ up_write(&REISERFS_XATTR_DIR_SEM(sb));
}
-static inline void
-reiserfs_read_lock_xattrs(struct super_block *sb)
+static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
{
- down_read (&REISERFS_XATTR_DIR_SEM(sb));
+ down_read(&REISERFS_XATTR_DIR_SEM(sb));
}
-static inline void
-reiserfs_read_unlock_xattrs(struct super_block *sb)
+static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
{
- up_read (&REISERFS_XATTR_DIR_SEM(sb));
+ up_read(&REISERFS_XATTR_DIR_SEM(sb));
}
-static inline void
-reiserfs_write_lock_xattr_i(struct inode *inode)
+static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
{
- down_write (&REISERFS_I(inode)->xattr_sem);
+ down_write(&REISERFS_I(inode)->xattr_sem);
}
-static inline void
-reiserfs_write_unlock_xattr_i(struct inode *inode)
+static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
{
- up_write (&REISERFS_I(inode)->xattr_sem);
+ up_write(&REISERFS_I(inode)->xattr_sem);
}
-static inline void
-reiserfs_read_lock_xattr_i(struct inode *inode)
+static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
{
- down_read (&REISERFS_I(inode)->xattr_sem);
+ down_read(&REISERFS_I(inode)->xattr_sem);
}
-static inline void
-reiserfs_read_unlock_xattr_i(struct inode *inode)
+static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
{
- up_read (&REISERFS_I(inode)->xattr_sem);
+ up_read(&REISERFS_I(inode)->xattr_sem);
}
-static inline void
-reiserfs_mark_inode_private(struct inode *inode)
+static inline void reiserfs_mark_inode_private(struct inode *inode)
{
- inode->i_flags |= S_PRIVATE;
+ inode->i_flags |= S_PRIVATE;
}
#else
@@ -127,13 +118,20 @@ reiserfs_mark_inode_private(struct inode *inode)
#define reiserfs_xattr_register_handlers() 0
#define reiserfs_xattr_unregister_handlers()
-static inline int reiserfs_delete_xattrs (struct inode *inode) { return 0; };
-static inline int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs) { return 0; };
-static inline int reiserfs_xattr_init (struct super_block *sb, int mount_flags)
+static inline int reiserfs_delete_xattrs(struct inode *inode)
+{
+ return 0;
+};
+static inline int reiserfs_chown_xattrs(struct inode *inode,
+ struct iattr *attrs)
+{
+ return 0;
+};
+static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
{
- sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */
- return 0;
+ sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */
+ return 0;
};
#endif
-#endif /* __KERNEL__ */
+#endif /* __KERNEL__ */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ff48815bd3a..dec5827c774 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -410,6 +410,10 @@ struct user_struct {
atomic_t processes; /* How many processes does this user have? */
atomic_t files; /* How many open files does this user have? */
atomic_t sigpending; /* How many pending signals does this user have? */
+#ifdef CONFIG_INOTIFY
+ atomic_t inotify_watches; /* How many inotify watches does this user have? */
+ atomic_t inotify_devs; /* How many inotify devs does this user have opened? */
+#endif
/* protected by mq_lock */
unsigned long mq_bytes; /* How many bytes can be allocated to mqueue? */
unsigned long locked_shm; /* How many pages of mlocked shm ? */
diff --git a/include/linux/swap.h b/include/linux/swap.h
index c75954f2d86..239f520cc49 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -7,6 +7,8 @@
#include <linux/mmzone.h>
#include <linux/list.h>
#include <linux/sched.h>
+#include <linux/pagemap.h>
+
#include <asm/atomic.h>
#include <asm/page.h>
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 5b5f434ac9a..ce19a2aa0b2 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -61,7 +61,8 @@ enum
CTL_DEV=7, /* Devices */
CTL_BUS=8, /* Busses */
CTL_ABI=9, /* Binary emulation */
- CTL_CPU=10 /* CPU stuff (speed scaling, etc) */
+ CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
+ CTL_INOTIFY=11 /* Inotify */
};
/* CTL_BUS names: */
@@ -70,6 +71,14 @@ enum
CTL_BUS_ISA=1 /* ISA */
};
+/* CTL_INOTIFY names: */
+enum
+{
+ INOTIFY_MAX_USER_DEVICES=1, /* max number of inotify device instances per user */
+ INOTIFY_MAX_USER_WATCHES=2, /* max number of inotify watches per user */
+ INOTIFY_MAX_QUEUED_EVENTS=3 /* Max number of queued events per inotify device instance */
+};
+
/* CTL_KERN names: */
enum
{
diff --git a/include/linux/usb.h b/include/linux/usb.h
index eb282b58154..72463779299 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -938,17 +938,17 @@ static inline void usb_fill_int_urb (struct urb *urb,
}
extern void usb_init_urb(struct urb *urb);
-extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
+extern struct urb *usb_alloc_urb(int iso_packets, unsigned mem_flags);
extern void usb_free_urb(struct urb *urb);
#define usb_put_urb usb_free_urb
extern struct urb *usb_get_urb(struct urb *urb);
-extern int usb_submit_urb(struct urb *urb, int mem_flags);
+extern int usb_submit_urb(struct urb *urb, unsigned mem_flags);
extern int usb_unlink_urb(struct urb *urb);
extern void usb_kill_urb(struct urb *urb);
#define HAVE_USB_BUFFERS
void *usb_buffer_alloc (struct usb_device *dev, size_t size,
- int mem_flags, dma_addr_t *dma);
+ unsigned mem_flags, dma_addr_t *dma);
void usb_buffer_free (struct usb_device *dev, size_t size,
void *addr, dma_addr_t dma);
@@ -1055,7 +1055,7 @@ int usb_sg_init (
struct scatterlist *sg,
int nents,
size_t length,
- int mem_flags
+ unsigned mem_flags
);
void usb_sg_cancel (struct usb_sg_request *io);
void usb_sg_wait (struct usb_sg_request *io);
diff --git a/include/linux/usb_cdc.h b/include/linux/usb_cdc.h
index f22d6beecc7..ba617c37245 100644
--- a/include/linux/usb_cdc.h
+++ b/include/linux/usb_cdc.h
@@ -34,6 +34,7 @@
#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
#define USB_CDC_COUNTRY_TYPE 0x07
+#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
#define USB_CDC_WHCM_TYPE 0x11
#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
@@ -83,6 +84,18 @@ struct usb_cdc_union_desc {
/* ... and there could be other slave interfaces */
} __attribute__ ((packed));
+/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
+struct usb_cdc_network_terminal_desc {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDescriptorSubType;
+
+ __u8 bEntityId;
+ __u8 iName;
+ __u8 bChannelIndex;
+ __u8 bPhysicalInterface;
+} __attribute__ ((packed));
+
/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
struct usb_cdc_ether_desc {
__u8 bLength;
diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h
index b00f127cb44..71e60860732 100644
--- a/include/linux/usb_gadget.h
+++ b/include/linux/usb_gadget.h
@@ -107,18 +107,18 @@ struct usb_ep_ops {
int (*disable) (struct usb_ep *ep);
struct usb_request *(*alloc_request) (struct usb_ep *ep,
- int gfp_flags);
+ unsigned gfp_flags);
void (*free_request) (struct usb_ep *ep, struct usb_request *req);
void *(*alloc_buffer) (struct usb_ep *ep, unsigned bytes,
- dma_addr_t *dma, int gfp_flags);
+ dma_addr_t *dma, unsigned gfp_flags);
void (*free_buffer) (struct usb_ep *ep, void *buf, dma_addr_t dma,
unsigned bytes);
// NOTE: on 2.6, drivers may also use dma_map() and
// dma_sync_single_*() to directly manage dma overhead.
int (*queue) (struct usb_ep *ep, struct usb_request *req,
- int gfp_flags);
+ unsigned gfp_flags);
int (*dequeue) (struct usb_ep *ep, struct usb_request *req);
int (*set_halt) (struct usb_ep *ep, int value);
@@ -214,7 +214,7 @@ usb_ep_disable (struct usb_ep *ep)
* Returns the request, or null if one could not be allocated.
*/
static inline struct usb_request *
-usb_ep_alloc_request (struct usb_ep *ep, int gfp_flags)
+usb_ep_alloc_request (struct usb_ep *ep, unsigned gfp_flags)
{
return ep->ops->alloc_request (ep, gfp_flags);
}
@@ -254,7 +254,7 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
*/
static inline void *
usb_ep_alloc_buffer (struct usb_ep *ep, unsigned len, dma_addr_t *dma,
- int gfp_flags)
+ unsigned gfp_flags)
{
return ep->ops->alloc_buffer (ep, len, dma, gfp_flags);
}
@@ -330,7 +330,7 @@ usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len)
* reported when the usb peripheral is disconnected.
*/
static inline int
-usb_ep_queue (struct usb_ep *ep, struct usb_request *req, int gfp_flags)
+usb_ep_queue (struct usb_ep *ep, struct usb_request *req, unsigned gfp_flags)
{
return ep->ops->queue (ep, req, gfp_flags);
}
diff --git a/include/linux/wanrouter.h b/include/linux/wanrouter.h
index 3e89f0f15f4..1b6b76a4eb5 100644
--- a/include/linux/wanrouter.h
+++ b/include/linux/wanrouter.h
@@ -516,8 +516,7 @@ struct wan_device {
/* Public functions available for device drivers */
extern int register_wan_device(struct wan_device *wandev);
extern int unregister_wan_device(char *name);
-unsigned short wanrouter_type_trans(struct sk_buff *skb,
- struct net_device *dev);
+__be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev);
int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
unsigned short type);
diff --git a/include/media/audiochip.h b/include/media/audiochip.h
index f345a61c3bd..cd831168fdc 100644
--- a/include/media/audiochip.h
+++ b/include/media/audiochip.h
@@ -1,5 +1,5 @@
/*
- * $Id: audiochip.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $
+ * $Id: audiochip.h,v 1.5 2005/06/16 22:59:16 hhackmann Exp $
*/
#ifndef AUDIOCHIP_H
@@ -35,5 +35,4 @@
/* misc stuff to pass around config info to i2c chips */
#define AUDC_CONFIG_PINNACLE _IOW('m',32,int)
-
#endif /* AUDIOCHIP_H */
diff --git a/include/media/saa6752hs.h b/include/media/saa6752hs.h
index 791bad2b86e..3b8686ead80 100644
--- a/include/media/saa6752hs.h
+++ b/include/media/saa6752hs.h
@@ -18,55 +18,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#if 0 /* ndef _SAA6752HS_H */
-#define _SAA6752HS_H
-
-enum mpeg_video_bitrate_mode {
- MPEG_VIDEO_BITRATE_MODE_VBR = 0, /* Variable bitrate */
- MPEG_VIDEO_BITRATE_MODE_CBR = 1, /* Constant bitrate */
-
- MPEG_VIDEO_BITRATE_MODE_MAX
-};
-
-enum mpeg_audio_bitrate {
- MPEG_AUDIO_BITRATE_256 = 0, /* 256 kBit/sec */
- MPEG_AUDIO_BITRATE_384 = 1, /* 384 kBit/sec */
-
- MPEG_AUDIO_BITRATE_MAX
-};
-
-enum mpeg_video_format {
- MPEG_VIDEO_FORMAT_D1 = 0,
- MPEG_VIDEO_FORMAT_2_3_D1 = 1,
- MPEG_VIDEO_FORMAT_1_2_D1 = 2,
- MPEG_VIDEO_FORMAT_SIF = 3,
-
- MPEG_VIDEO_FORMAT_MAX
-};
-
-#define MPEG_VIDEO_TARGET_BITRATE_MAX 27000
-#define MPEG_VIDEO_MAX_BITRATE_MAX 27000
-#define MPEG_TOTAL_BITRATE_MAX 27000
-#define MPEG_PID_MAX ((1 << 14) - 1)
-
-struct mpeg_params {
- enum mpeg_video_bitrate_mode video_bitrate_mode;
- unsigned int video_target_bitrate;
- unsigned int video_max_bitrate; // only used for VBR
- enum mpeg_audio_bitrate audio_bitrate;
- unsigned int total_bitrate;
-
- unsigned int pmt_pid;
- unsigned int video_pid;
- unsigned int audio_pid;
- unsigned int pcr_pid;
-
- enum mpeg_video_format video_format;
-};
-
-#define MPEG_SETPARAMS _IOW('6',100,struct mpeg_params)
-
-#endif // _SAA6752HS_H
/*
* Local variables:
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 4794c563236..d8c0a556328 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -1,5 +1,5 @@
-/* $Id: tuner.h,v 1.33 2005/06/21 14:58:08 mkrufky Exp $
+/* $Id: tuner.h,v 1.42 2005/07/06 09:42:19 mchehab Exp $
*
tuner.h - definition for different tuners
@@ -26,8 +26,6 @@
#include <linux/videodev2.h>
-#include "id.h"
-
#define ADDR_UNSET (255)
#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */
@@ -111,8 +109,6 @@
#define TUNER_TEA5767 62 /* Only FM Radio Tuner */
#define TUNER_PHILIPS_FMD1216ME_MK3 63
-#define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio"
-
#define NOTUNER 0
#define PAL 1 /* PAL_BG */
#define PAL_I 2
@@ -135,19 +131,8 @@
#define TCL 11
#define THOMSON 12
-enum v4l_radio_tuner {
- TEA5767_LOW_LO_32768 = 0,
- TEA5767_HIGH_LO_32768 = 1,
- TEA5767_LOW_LO_13MHz = 2,
- TEA5767_HIGH_LO_13MHz = 3,
-};
-
-
-#define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */
-#define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */
-#define TUNER_SET_TYPE_ADDR _IOW('T',3,int) /* set tuner type and I2C addr */
-
-#define TDA9887_SET_CONFIG _IOW('t',5,int)
+#define TUNER_SET_TYPE_ADDR _IOW('T',3,int)
+#define TDA9887_SET_CONFIG _IOW('t',5,int)
/* tv card specific */
# define TDA9887_PRESENT (1<<0)
@@ -169,25 +154,34 @@ enum v4l_radio_tuner {
#define I2C_ADDR_TDA8290 0x4b
#define I2C_ADDR_TDA8275 0x61
-struct tuner_addr {
- enum v4l2_tuner_type v4l2_tuner;
- unsigned int type;
+enum tuner_mode {
+ T_UNINITIALIZED = 0,
+ T_RADIO = 1 << V4L2_TUNER_RADIO,
+ T_ANALOG_TV = 1 << V4L2_TUNER_ANALOG_TV,
+ T_DIGITAL_TV = 1 << V4L2_TUNER_DIGITAL_TV,
+ T_STANDBY = 1 << 31
+};
+
+struct tuner_setup {
unsigned short addr;
+ unsigned int type;
+ unsigned int mode_mask;
};
struct tuner {
/* device */
struct i2c_client i2c;
- /* state + config */
- unsigned int initialized;
unsigned int type; /* chip type */
+
+ unsigned int mode;
+ unsigned int mode_mask; /* Combination of allowable modes */
+
unsigned int freq; /* keep track of the current settings */
+ unsigned int audmode;
v4l2_std_id std;
- int using_v4l2;
- enum v4l2_tuner_type mode;
- unsigned int input;
+ int using_v4l2;
/* used by MT2032 */
unsigned int xogc;
@@ -197,15 +191,11 @@ struct tuner {
unsigned char i2c_easy_mode[2];
unsigned char i2c_set_freq[8];
- /* used to keep track of audmode */
- unsigned int audmode;
-
/* function ptrs */
void (*tv_freq)(struct i2c_client *c, unsigned int freq);
void (*radio_freq)(struct i2c_client *c, unsigned int freq);
int (*has_signal)(struct i2c_client *c);
int (*is_stereo)(struct i2c_client *c);
- int (*set_tuner)(struct i2c_client *c, struct v4l2_tuner *v);
};
extern unsigned int tuner_debug;
@@ -215,6 +205,7 @@ extern int microtune_init(struct i2c_client *c);
extern int tda8290_init(struct i2c_client *c);
extern int tea5767_tuner_init(struct i2c_client *c);
extern int default_tuner_init(struct i2c_client *c);
+extern int tea5767_autodetection(struct i2c_client *c);
#define tuner_warn(fmt, arg...) \
dev_printk(KERN_WARNING , &t->i2c.dev , fmt , ## arg)
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index ef2738159ab..4a26adfaed7 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -125,7 +125,8 @@
*/
extern struct sock *sctp_get_ctl_sock(void);
extern int sctp_copy_local_addr_list(struct sctp_bind_addr *,
- sctp_scope_t, int gfp, int flags);
+ sctp_scope_t, unsigned int __nocast gfp,
+ int flags);
extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 88d9fe5975d..58462164d96 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -181,17 +181,17 @@ const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t,
int sctp_chunk_iif(const struct sctp_chunk *);
struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *,
struct sctp_chunk *,
- int gfp);
+ unsigned int __nocast gfp);
__u32 sctp_generate_verification_tag(void);
void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
/* Prototypes for chunk-building functions. */
struct sctp_chunk *sctp_make_init(const struct sctp_association *,
const struct sctp_bind_addr *,
- int gfp, int vparam_len);
+ unsigned int __nocast gfp, int vparam_len);
struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *,
const struct sctp_chunk *,
- const int gfp,
+ const unsigned int __nocast gfp,
const int unkparam_len);
struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *,
const struct sctp_chunk *);
@@ -265,7 +265,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
struct sctp_endpoint *,
struct sctp_association *asoc,
void *event_arg,
- int gfp);
+ unsigned int __nocast gfp);
/* 2nd level prototypes */
void sctp_generate_t3_rtx_event(unsigned long peer);
@@ -275,7 +275,8 @@ void sctp_ootb_pkt_free(struct sctp_packet *);
struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *,
const struct sctp_association *,
- struct sctp_chunk *, int gfp, int *err,
+ struct sctp_chunk *,
+ unsigned int __nocast gfp, int *err,
struct sctp_chunk **err_chk_p);
int sctp_addip_addr_config(struct sctp_association *, sctp_param_t,
struct sockaddr_storage*, int);
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 7435528a174..994009bbe3b 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -445,7 +445,8 @@ struct sctp_ssnmap {
int malloced;
};
-struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, int gfp);
+struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
+ unsigned int __nocast gfp);
void sctp_ssnmap_free(struct sctp_ssnmap *map);
void sctp_ssnmap_clear(struct sctp_ssnmap *map);
@@ -945,7 +946,8 @@ struct sctp_transport {
} cacc;
};
-struct sctp_transport *sctp_transport_new(const union sctp_addr *, int);
+struct sctp_transport *sctp_transport_new(const union sctp_addr *,
+ unsigned int __nocast);
void sctp_transport_set_owner(struct sctp_transport *,
struct sctp_association *);
void sctp_transport_route(struct sctp_transport *, union sctp_addr *,
@@ -1093,9 +1095,10 @@ void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);
void sctp_bind_addr_free(struct sctp_bind_addr *);
int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
const struct sctp_bind_addr *src,
- sctp_scope_t scope, int gfp,int flags);
+ sctp_scope_t scope, unsigned int __nocast gfp,
+ int flags);
int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
- int gfp);
+ unsigned int __nocast gfp);
int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
struct sctp_sock *);
@@ -1104,9 +1107,10 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
int addrcnt,
struct sctp_sock *opt);
union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
- int *addrs_len, int gfp);
+ int *addrs_len,
+ unsigned int __nocast gfp);
int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
- __u16 port, int gfp);
+ __u16 port, unsigned int __nocast gfp);
sctp_scope_t sctp_scope(const union sctp_addr *);
int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
@@ -1235,7 +1239,7 @@ static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base)
}
/* These are function signatures for manipulating endpoints. */
-struct sctp_endpoint *sctp_endpoint_new(struct sock *, int);
+struct sctp_endpoint *sctp_endpoint_new(struct sock *, unsigned int __nocast);
void sctp_endpoint_free(struct sctp_endpoint *);
void sctp_endpoint_put(struct sctp_endpoint *);
void sctp_endpoint_hold(struct sctp_endpoint *);
@@ -1256,7 +1260,7 @@ int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,
struct sctp_chunk **err_chunk);
int sctp_process_init(struct sctp_association *, sctp_cid_t cid,
const union sctp_addr *peer,
- sctp_init_chunk_t *init, int gfp);
+ sctp_init_chunk_t *init, unsigned int __nocast gfp);
__u32 sctp_generate_tag(const struct sctp_endpoint *);
__u32 sctp_generate_tsn(const struct sctp_endpoint *);
@@ -1719,7 +1723,7 @@ static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base)
struct sctp_association *
sctp_association_new(const struct sctp_endpoint *, const struct sock *,
- sctp_scope_t scope, int gfp);
+ sctp_scope_t scope, unsigned int __nocast gfp);
void sctp_association_free(struct sctp_association *);
void sctp_association_put(struct sctp_association *);
void sctp_association_hold(struct sctp_association *);
@@ -1735,7 +1739,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc,
const union sctp_addr *laddr);
struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *,
const union sctp_addr *address,
- const int gfp,
+ const unsigned int __nocast gfp,
const int peer_state);
void sctp_assoc_del_peer(struct sctp_association *asoc,
const union sctp_addr *addr);
@@ -1759,9 +1763,11 @@ void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned);
void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned);
void sctp_assoc_set_primary(struct sctp_association *,
struct sctp_transport *);
-int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, int);
+int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *,
+ unsigned int __nocast);
int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
- struct sctp_cookie*, int gfp);
+ struct sctp_cookie*,
+ unsigned int __nocast gfp);
int sctp_cmp_addr_exact(const union sctp_addr *ss1,
const union sctp_addr *ss2);
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 1019d83a580..90fe4bf6754 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -88,7 +88,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
__u16 error,
__u16 outbound,
__u16 inbound,
- int gfp);
+ unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
const struct sctp_association *asoc,
@@ -96,35 +96,35 @@ struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
int flags,
int state,
int error,
- int gfp);
+ unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
const struct sctp_association *asoc,
struct sctp_chunk *chunk,
__u16 flags,
- int gfp);
+ unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
const struct sctp_association *asoc,
struct sctp_chunk *chunk,
__u16 flags,
__u32 error,
- int gfp);
+ unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
const struct sctp_association *asoc,
__u16 flags,
- int gfp);
+ unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
const struct sctp_association *asoc,
- __u32 indication, int gfp);
+ __u32 indication, unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
- const struct sctp_association *asoc, int gfp);
+ const struct sctp_association *asoc, unsigned int __nocast gfp);
struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
struct sctp_chunk *chunk,
- int gfp);
+ unsigned int __nocast gfp);
void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
struct msghdr *);
diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h
index 961736d29d2..1a60c6d943c 100644
--- a/include/net/sctp/ulpqueue.h
+++ b/include/net/sctp/ulpqueue.h
@@ -62,19 +62,22 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *,
void sctp_ulpq_free(struct sctp_ulpq *);
/* Add a new DATA chunk for processing. */
-int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *, int);
+int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *,
+ unsigned int __nocast);
/* Add a new event for propagation to the ULP. */
int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev);
/* Renege previously received chunks. */
-void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, int);
+void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *,
+ unsigned int __nocast);
/* Perform partial delivery. */
-void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, int);
+void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *,
+ unsigned int __nocast);
/* Abort the partial delivery. */
-void sctp_ulpq_abort_pd(struct sctp_ulpq *, int);
+void sctp_ulpq_abort_pd(struct sctp_ulpq *, unsigned int __nocast);
/* Clear the partial data delivery condition on this socket. */
int sctp_clear_pd(struct sock *sk);
diff --git a/include/net/x25device.h b/include/net/x25device.h
index cf36a20ea3c..d45ae883bd1 100644
--- a/include/net/x25device.h
+++ b/include/net/x25device.h
@@ -5,8 +5,7 @@
#include <linux/if_packet.h>
#include <linux/skbuff.h>
-static inline unsigned short x25_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static inline __be16 x25_type_trans(struct sk_buff *skb, struct net_device *dev)
{
skb->mac.raw = skb->data;
skb->input_dev = skb->dev = dev;
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 0190e766e1a..b707a603351 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -16,10 +16,13 @@
#ifndef _LINUX_DS_H
#define _LINUX_DS_H
+#ifdef __KERNEL__
+#include <linux/mod_devicetable.h>
+#endif
+
#include <pcmcia/bulkmem.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/device_id.h>
-#include <linux/mod_devicetable.h>
typedef struct tuple_parse_t {
tuple_t tuple;
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b7570c074d0..1b02be734cc 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -7,6 +7,7 @@
#include <linux/root_dev.h>
#include <linux/security.h>
#include <linux/delay.h>
+#include <linux/mount.h>
#include <linux/nfs_fs.h>
#include <linux/nfs_fs_sb.h>
diff --git a/init/do_mounts.h b/init/do_mounts.h
index de92bee4f35..e0a7ac9649e 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -9,7 +9,6 @@
#include <linux/major.h>
#include <linux/root_dev.h>
-dev_t name_to_dev_t(char *name);
void change_floppy(char *fmt, ...);
void mount_block_root(char *name, int flags);
void mount_root(void);
diff --git a/ipc/util.h b/ipc/util.h
index 07d68945236..44348ca5a70 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -67,7 +67,7 @@ int ipc_checkid(struct ipc_ids* ids, struct kern_ipc_perm* ipcp, int uid);
void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out);
void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out);
-#if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__)
+#if defined(__ia64__) || defined(__x86_64__) || defined(__hppa__) || defined(__XTENSA__)
/* On IA-64, we always use the "64-bit version" of the IPC structures. */
# define ipc_parse_version(cmd) IPC_64
#else
diff --git a/kernel/fork.c b/kernel/fork.c
index cdef6cea890..b65187f0c74 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -208,8 +208,10 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
struct file *file;
if (mpnt->vm_flags & VM_DONTCOPY) {
+ long pages = vma_pages(mpnt);
+ mm->total_vm -= pages;
__vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
- -vma_pages(mpnt));
+ -pages);
continue;
}
charge = 0;
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index c51a4d96d4e..3ec789c6b53 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -16,6 +16,8 @@
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/fs.h>
+#include <linux/mount.h>
+
#include "power.h"
diff --git a/kernel/power/main.c b/kernel/power/main.c
index c94cb9e9509..71aa0fd2200 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -19,6 +19,9 @@
#include "power.h"
+/*This is just an arbitrary number */
+#define FREE_PAGE_NUMBER (100)
+
DECLARE_MUTEX(pm_sem);
struct pm_ops * pm_ops = NULL;
@@ -49,6 +52,7 @@ void pm_set_ops(struct pm_ops * ops)
static int suspend_prepare(suspend_state_t state)
{
int error = 0;
+ unsigned int free_pages;
if (!pm_ops || !pm_ops->enter)
return -EPERM;
@@ -67,6 +71,16 @@ static int suspend_prepare(suspend_state_t state)
goto Thaw;
}
+ if ((free_pages = nr_free_pages()) < FREE_PAGE_NUMBER) {
+ pr_debug("PM: free some memory\n");
+ shrink_all_memory(FREE_PAGE_NUMBER - free_pages);
+ if (nr_free_pages() < FREE_PAGE_NUMBER) {
+ error = -ENOMEM;
+ printk(KERN_ERR "PM: No enough memory\n");
+ goto Thaw;
+ }
+ }
+
if (pm_ops->prepare) {
if ((error = pm_ops->prepare(state)))
goto Thaw;
@@ -194,7 +208,7 @@ int software_suspend(void)
int pm_suspend(suspend_state_t state)
{
- if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX)
+ if (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX)
return enter_state(state);
return -EINVAL;
}
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 7d7801cd01f..f2bc71b9fe8 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -63,6 +63,7 @@
#include <linux/console.h>
#include <linux/highmem.h>
#include <linux/bio.h>
+#include <linux/mount.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@ -1260,8 +1261,6 @@ static int data_read(struct pbe *pblist)
return error;
}
-extern dev_t name_to_dev_t(const char *line);
-
/**
* read_pagedir - Read page backup list pages from swap
*/
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 29196ce9b40..42b40ae5ead 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -80,6 +80,9 @@ cond_syscall(sys_keyctl);
cond_syscall(compat_sys_keyctl);
cond_syscall(compat_sys_socketcall);
cond_syscall(sys_set_zone_reclaim);
+cond_syscall(sys_inotify_init);
+cond_syscall(sys_inotify_add_watch);
+cond_syscall(sys_inotify_rm_watch);
/* arch-specific weak syscall entries */
cond_syscall(sys_pciconfig_read);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 270ee7fadbd..b240e2cb86f 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -67,6 +67,12 @@ extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst;
extern int pid_max_min, pid_max_max;
+#ifdef CONFIG_INOTIFY
+extern int inotify_max_user_devices;
+extern int inotify_max_user_watches;
+extern int inotify_max_queued_events;
+#endif
+
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
int unknown_nmi_panic;
extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
@@ -218,6 +224,7 @@ static ctl_table root_table[] = {
.mode = 0555,
.child = dev_table,
},
+
{ .ctl_name = 0 }
};
@@ -959,6 +966,40 @@ static ctl_table fs_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
+#ifdef CONFIG_INOTIFY
+ {
+ .ctl_name = INOTIFY_MAX_USER_DEVICES,
+ .procname = "max_user_devices",
+ .data = &inotify_max_user_devices,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ },
+
+ {
+ .ctl_name = INOTIFY_MAX_USER_WATCHES,
+ .procname = "max_user_watches",
+ .data = &inotify_max_user_watches,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero,
+ },
+
+ {
+ .ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
+ .procname = "max_queued_events",
+ .data = &inotify_max_queued_events,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec_minmax,
+ .strategy = &sysctl_intvec,
+ .extra1 = &zero
+ },
+#endif
{ .ctl_name = 0 }
};
@@ -968,7 +1009,7 @@ static ctl_table debug_table[] = {
static ctl_table dev_table[] = {
{ .ctl_name = 0 }
-};
+};
extern void init_irq_proc (void);
diff --git a/kernel/user.c b/kernel/user.c
index 734575d5576..89e562feb1b 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -120,6 +120,10 @@ struct user_struct * alloc_uid(uid_t uid)
atomic_set(&new->processes, 0);
atomic_set(&new->files, 0);
atomic_set(&new->sigpending, 0);
+#ifdef CONFIG_INOTIFY
+ atomic_set(&new->inotify_watches, 0);
+ atomic_set(&new->inotify_devs, 0);
+#endif
new->mq_bytes = 0;
new->locked_shm = 0;
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 3b6e384b98a..4553b2c5aab 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -191,7 +191,7 @@ __xip_unmap (struct address_space * mapping,
address);
if (!IS_ERR(pte)) {
/* Nuke the page table entry. */
- flush_cache_page(vma, address, pte_pfn(pte));
+ flush_cache_page(vma, address, pte_pfn(*pte));
pteval = ptep_clear_flush(vma, address, pte);
BUG_ON(pte_dirty(pteval));
pte_unmap(pte);
diff --git a/net/802/fddi.c b/net/802/fddi.c
index ebcf4830d6f..5ce24c4bb84 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -122,10 +122,10 @@ static int fddi_rebuild_header(struct sk_buff *skb)
* the proper pointer to the start of packet data (skb->data).
*/
-unsigned short fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
+__be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct fddihdr *fddi = (struct fddihdr *)skb->data;
- unsigned short type;
+ __be16 type;
/*
* Set mac.raw field to point to FC byte, set data field to point
diff --git a/net/8021q/Kconfig b/net/8021q/Kconfig
new file mode 100644
index 00000000000..c4a382e450e
--- /dev/null
+++ b/net/8021q/Kconfig
@@ -0,0 +1,19 @@
+#
+# Configuration for 802.1Q VLAN support
+#
+
+config VLAN_8021Q
+ tristate "802.1Q VLAN Support"
+ ---help---
+ Select this and you will be able to create 802.1Q VLAN interfaces
+ on your ethernet interfaces. 802.1Q VLAN supports almost
+ everything a regular ethernet interface does, including
+ firewalling, bridging, and of course IP traffic. You will need
+ the 'vconfig' tool from the VLAN project in order to effectively
+ use VLANs. See the VLAN web page for more information:
+ <http://www.candelatech.com/~greear/vlan.html>
+
+ To compile this code as a module, choose M here: the module
+ will be called 8021q.
+
+ If unsure, say N.
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 1f6d31670bc..91e412b0ab0 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -578,6 +578,14 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
if (!vlandev)
continue;
+ if (netif_carrier_ok(dev)) {
+ if (!netif_carrier_ok(vlandev))
+ netif_carrier_on(vlandev);
+ } else {
+ if (netif_carrier_ok(vlandev))
+ netif_carrier_off(vlandev);
+ }
+
if ((vlandev->state & VLAN_LINK_STATE_MASK) != flgs) {
vlandev->state = (vlandev->state &~ VLAN_LINK_STATE_MASK)
| flgs;
diff --git a/net/Kconfig b/net/Kconfig
index 9251b28e8d5..2684e809a64 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -2,7 +2,7 @@
# Network configuration
#
-menu "Networking support"
+menu "Networking"
config NET
bool "Networking support"
@@ -10,7 +10,9 @@ config NET
Unless you really know what you are doing, you should say Y here.
The reason is that some programs need kernel networking support even
when running on a stand-alone machine that isn't connected to any
- other computer. If you are upgrading from an older kernel, you
+ other computer.
+
+ If you are upgrading from an older kernel, you
should consider updating your networking tools too because changes
in the kernel and the tools often go hand in hand. The tools are
contained in the package net-tools, the location and version number
@@ -20,57 +22,14 @@ config NET
recommended to read the NET-HOWTO, available from
<http://www.tldp.org/docs.html#howto>.
-menu "Networking options"
- depends on NET
-
-config PACKET
- tristate "Packet socket"
- ---help---
- The Packet protocol is used by applications which communicate
- directly with network devices without an intermediate network
- protocol implemented in the kernel, e.g. tcpdump. If you want them
- to work, choose Y.
+# Make sure that all config symbols are dependent on NET
+if NET
- To compile this driver as a module, choose M here: the module will
- be called af_packet.
-
- If unsure, say Y.
-
-config PACKET_MMAP
- bool "Packet socket: mmapped IO"
- depends on PACKET
- help
- If you say Y here, the Packet protocol driver will use an IO
- mechanism that results in faster communication.
-
- If unsure, say N.
-
-config UNIX
- tristate "Unix domain sockets"
- ---help---
- If you say Y here, you will include support for Unix domain sockets;
- sockets are the standard Unix mechanism for establishing and
- accessing network connections. Many commonly used programs such as
- the X Window system and syslog use these sockets even if your
- machine is not connected to any network. Unless you are working on
- an embedded system or something similar, you therefore definitely
- want to say Y here.
-
- To compile this driver as a module, choose M here: the module will be
- called unix. Note that several important services won't work
- correctly if you say M here and then neglect to load the module.
-
- Say Y unless you know what you are doing.
-
-config NET_KEY
- tristate "PF_KEY sockets"
- select XFRM
- ---help---
- PF_KEYv2 socket family, compatible to KAME ones.
- They are required if you are going to use IPsec tools ported
- from KAME.
+menu "Networking options"
- Say Y unless you know what you are doing.
+source "net/packet/Kconfig"
+source "net/unix/Kconfig"
+source "net/xfrm/Kconfig"
config INET
bool "TCP/IP networking"
@@ -94,30 +53,12 @@ config INET
Short answer: say Y.
+if INET
source "net/ipv4/Kconfig"
-
-# IPv6 as module will cause a CRASH if you try to unload it
-config IPV6
- tristate "The IPv6 protocol"
- depends on INET
- default m
- select CRYPTO if IPV6_PRIVACY
- select CRYPTO_MD5 if IPV6_PRIVACY
- ---help---
- This is complemental support for the IP version 6.
- You will still be able to do traditional IPv4 networking as well.
-
- For general information about IPv6, see
- <http://playground.sun.com/pub/ipng/html/ipng-main.html>.
- For Linux IPv6 development information, see <http://www.linux-ipv6.org>.
- For specific information about IPv6 under Linux, read the HOWTO at
- <http://www.bieringer.de/linux/IPv6/>.
-
- To compile this protocol support as a module, choose M here: the
- module will be called ipv6.
-
source "net/ipv6/Kconfig"
+endif # if INET
+
menuconfig NETFILTER
bool "Network packet filtering (replaces ipchains)"
---help---
@@ -206,269 +147,16 @@ source "net/bridge/netfilter/Kconfig"
endif
-config XFRM
- bool
- depends on NET
-
-source "net/xfrm/Kconfig"
-
source "net/sctp/Kconfig"
-
-config ATM
- tristate "Asynchronous Transfer Mode (ATM) (EXPERIMENTAL)"
- depends on EXPERIMENTAL
- ---help---
- ATM is a high-speed networking technology for Local Area Networks
- and Wide Area Networks. It uses a fixed packet size and is
- connection oriented, allowing for the negotiation of minimum
- bandwidth requirements.
-
- In order to participate in an ATM network, your Linux box needs an
- ATM networking card. If you have that, say Y here and to the driver
- of your ATM card below.
-
- Note that you need a set of user-space programs to actually make use
- of ATM. See the file <file:Documentation/networking/atm.txt> for
- further details.
-
-config ATM_CLIP
- tristate "Classical IP over ATM (EXPERIMENTAL)"
- depends on ATM && INET
- help
- Classical IP over ATM for PVCs and SVCs, supporting InARP and
- ATMARP. If you want to communication with other IP hosts on your ATM
- network, you will typically either say Y here or to "LAN Emulation
- (LANE)" below.
-
-config ATM_CLIP_NO_ICMP
- bool "Do NOT send ICMP if no neighbour (EXPERIMENTAL)"
- depends on ATM_CLIP
- help
- Normally, an "ICMP host unreachable" message is sent if a neighbour
- cannot be reached because there is no VC to it in the kernel's
- ATMARP table. This may cause problems when ATMARP table entries are
- briefly removed during revalidation. If you say Y here, packets to
- such neighbours are silently discarded instead.
-
-config ATM_LANE
- tristate "LAN Emulation (LANE) support (EXPERIMENTAL)"
- depends on ATM
- help
- LAN Emulation emulates services of existing LANs across an ATM
- network. Besides operating as a normal ATM end station client, Linux
- LANE client can also act as an proxy client bridging packets between
- ELAN and Ethernet segments. You need LANE if you want to try MPOA.
-
-config ATM_MPOA
- tristate "Multi-Protocol Over ATM (MPOA) support (EXPERIMENTAL)"
- depends on ATM && INET && ATM_LANE!=n
- help
- Multi-Protocol Over ATM allows ATM edge devices such as routers,
- bridges and ATM attached hosts establish direct ATM VCs across
- subnetwork boundaries. These shortcut connections bypass routers
- enhancing overall network performance.
-
-config ATM_BR2684
- tristate "RFC1483/2684 Bridged protocols"
- depends on ATM && INET
- help
- ATM PVCs can carry ethernet PDUs according to rfc2684 (formerly 1483)
- This device will act like an ethernet from the kernels point of view,
- with the traffic being carried by ATM PVCs (currently 1 PVC/device).
- This is sometimes used over DSL lines. If in doubt, say N.
-
-config ATM_BR2684_IPFILTER
- bool "Per-VC IP filter kludge"
- depends on ATM_BR2684
- help
- This is an experimental mechanism for users who need to terminating a
- large number of IP-only vcc's. Do not enable this unless you are sure
- you know what you are doing.
-
-config BRIDGE
- tristate "802.1d Ethernet Bridging"
- ---help---
- If you say Y here, then your Linux box will be able to act as an
- Ethernet bridge, which means that the different Ethernet segments it
- is connected to will appear as one Ethernet to the participants.
- Several such bridges can work together to create even larger
- networks of Ethernets using the IEEE 802.1 spanning tree algorithm.
- As this is a standard, Linux bridges will cooperate properly with
- other third party bridge products.
-
- In order to use the Ethernet bridge, you'll need the bridge
- configuration tools; see <file:Documentation/networking/bridge.txt>
- for location. Please read the Bridge mini-HOWTO for more
- information.
-
- If you enable iptables support along with the bridge support then you
- turn your bridge into a bridging IP firewall.
- iptables will then see the IP packets being bridged, so you need to
- take this into account when setting up your firewall rules.
- Enabling arptables support when bridging will let arptables see
- bridged ARP traffic in the arptables FORWARD chain.
-
- To compile this code as a module, choose M here: the module
- will be called bridge.
-
- If unsure, say N.
-
-config VLAN_8021Q
- tristate "802.1Q VLAN Support"
- ---help---
- Select this and you will be able to create 802.1Q VLAN interfaces
- on your ethernet interfaces. 802.1Q VLAN supports almost
- everything a regular ethernet interface does, including
- firewalling, bridging, and of course IP traffic. You will need
- the 'vconfig' tool from the VLAN project in order to effectively
- use VLANs. See the VLAN web page for more information:
- <http://www.candelatech.com/~greear/vlan.html>
-
- To compile this code as a module, choose M here: the module
- will be called 8021q.
-
- If unsure, say N.
-
-config DECNET
- tristate "DECnet Support"
- ---help---
- The DECnet networking protocol was used in many products made by
- Digital (now Compaq). It provides reliable stream and sequenced
- packet communications over which run a variety of services similar
- to those which run over TCP/IP.
-
- To find some tools to use with the kernel layer support, please
- look at Patrick Caulfield's web site:
- <http://linux-decnet.sourceforge.net/>.
-
- More detailed documentation is available in
- <file:Documentation/networking/decnet.txt>.
-
- Be sure to say Y to "/proc file system support" and "Sysctl support"
- below when using DECnet, since you will need sysctl support to aid
- in configuration at run time.
-
- The DECnet code is also available as a module ( = code which can be
- inserted in and removed from the running kernel whenever you want).
- The module is called decnet.
-
+source "net/atm/Kconfig"
+source "net/bridge/Kconfig"
+source "net/8021q/Kconfig"
source "net/decnet/Kconfig"
-
source "net/llc/Kconfig"
-
-config IPX
- tristate "The IPX protocol"
- select LLC
- ---help---
- This is support for the Novell networking protocol, IPX, commonly
- used for local networks of Windows machines. You need it if you
- want to access Novell NetWare file or print servers using the Linux
- Novell client ncpfs (available from
- <ftp://platan.vc.cvut.cz/pub/linux/ncpfs/>) or from
- within the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO,
- available from <http://www.tldp.org/docs.html#howto>). In order
- to do the former, you'll also have to say Y to "NCP file system
- support", below.
-
- IPX is similar in scope to IP, while SPX, which runs on top of IPX,
- is similar to TCP. There is also experimental support for SPX in
- Linux (see "SPX networking", below).
-
- To turn your Linux box into a fully featured NetWare file server and
- IPX router, say Y here and fetch either lwared from
- <ftp://ibiblio.org/pub/Linux/system/network/daemons/> or
- mars_nwe from <ftp://www.compu-art.de/mars_nwe/>. For more
- information, read the IPX-HOWTO available from
- <http://www.tldp.org/docs.html#howto>.
-
- General information about how to connect Linux, Windows machines and
- Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>.
-
- The IPX driver would enlarge your kernel by about 16 KB. To compile
- this driver as a module, choose M here: the module will be called ipx.
- Unless you want to integrate your Linux box with a local Novell
- network, say N.
-
source "net/ipx/Kconfig"
-
-config ATALK
- tristate "Appletalk protocol support"
- select LLC
- ---help---
- AppleTalk is the protocol that Apple computers can use to communicate
- on a network. If your Linux box is connected to such a network and you
- wish to connect to it, say Y. You will need to use the netatalk package
- so that your Linux box can act as a print and file server for Macs as
- well as access AppleTalk printers. Check out
- <http://www.zettabyte.net/netatalk/> on the WWW for details.
- EtherTalk is the name used for AppleTalk over Ethernet and the
- cheaper and slower LocalTalk is AppleTalk over a proprietary Apple
- network using serial links. EtherTalk and LocalTalk are fully
- supported by Linux.
-
- General information about how to connect Linux, Windows machines and
- Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>. The
- NET-3-HOWTO, available from
- <http://www.tldp.org/docs.html#howto>, contains valuable
- information as well.
-
- To compile this driver as a module, choose M here: the module will be
- called appletalk. You almost certainly want to compile it as a
- module so you can restart your AppleTalk stack without rebooting
- your machine. I hear that the GNU boycott of Apple is over, so
- even politically correct people are allowed to say Y here.
-
source "drivers/net/appletalk/Kconfig"
-
-config X25
- tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)"
- depends on EXPERIMENTAL
- ---help---
- X.25 is a set of standardized network protocols, similar in scope to
- frame relay; the one physical line from your box to the X.25 network
- entry point can carry several logical point-to-point connections
- (called "virtual circuits") to other computers connected to the X.25
- network. Governments, banks, and other organizations tend to use it
- to connect to each other or to form Wide Area Networks (WANs). Many
- countries have public X.25 networks. X.25 consists of two
- protocols: the higher level Packet Layer Protocol (PLP) (say Y here
- if you want that) and the lower level data link layer protocol LAPB
- (say Y to "LAPB Data Link Driver" below if you want that).
-
- You can read more about X.25 at <http://www.sangoma.com/x25.htm> and
- <http://www.cisco.com/univercd/cc/td/doc/product/software/ios11/cbook/cx25.htm>.
- Information about X.25 for Linux is contained in the files
- <file:Documentation/networking/x25.txt> and
- <file:Documentation/networking/x25-iface.txt>.
-
- One connects to an X.25 network either with a dedicated network card
- using the X.21 protocol (not yet supported by Linux) or one can do
- X.25 over a standard telephone line using an ordinary modem (say Y
- to "X.25 async driver" below) or over Ethernet using an ordinary
- Ethernet card and the LAPB over Ethernet (say Y to "LAPB Data Link
- Driver" and "LAPB over Ethernet driver" below).
-
- To compile this driver as a module, choose M here: the module
- will be called x25. If unsure, say N.
-
-config LAPB
- tristate "LAPB Data Link Driver (EXPERIMENTAL)"
- depends on EXPERIMENTAL
- ---help---
- Link Access Procedure, Balanced (LAPB) is the data link layer (i.e.
- the lower) part of the X.25 protocol. It offers a reliable
- connection service to exchange data frames with one other host, and
- it is used to transport higher level protocols (mostly X.25 Packet
- Layer, the higher part of X.25, but others are possible as well).
- Usually, LAPB is used with specialized X.21 network cards, but Linux
- currently supports LAPB only over Ethernet connections. If you want
- to use LAPB connections over Ethernet, say Y here and to "LAPB over
- Ethernet driver" below. Read
- <file:Documentation/networking/lapb-module.txt> for technical
- details.
-
- To compile this driver as a module, choose M here: the
- module will be called lapb. If unsure, say N.
+source "net/x25/Kconfig"
+source "net/lapb/Kconfig"
config NET_DIVERT
bool "Frame Diverter (EXPERIMENTAL)"
@@ -496,107 +184,10 @@ config NET_DIVERT
If unsure, say N.
-config ECONET
- tristate "Acorn Econet/AUN protocols (EXPERIMENTAL)"
- depends on EXPERIMENTAL && INET
- ---help---
- Econet is a fairly old and slow networking protocol mainly used by
- Acorn computers to access file and print servers. It uses native
- Econet network cards. AUN is an implementation of the higher level
- parts of Econet that runs over ordinary Ethernet connections, on
- top of the UDP packet protocol, which in turn runs on top of the
- Internet protocol IP.
-
- If you say Y here, you can choose with the next two options whether
- to send Econet/AUN traffic over a UDP Ethernet connection or over
- a native Econet network card.
-
- To compile this driver as a module, choose M here: the module
- will be called econet.
-
-config ECONET_AUNUDP
- bool "AUN over UDP"
- depends on ECONET
- help
- Say Y here if you want to send Econet/AUN traffic over a UDP
- connection (UDP is a packet based protocol that runs on top of the
- Internet protocol IP) using an ordinary Ethernet network card.
-
-config ECONET_NATIVE
- bool "Native Econet"
- depends on ECONET
- help
- Say Y here if you have a native Econet network card installed in
- your computer.
-
-config WAN_ROUTER
- tristate "WAN router"
- depends on EXPERIMENTAL
- ---help---
- Wide Area Networks (WANs), such as X.25, frame relay and leased
- lines, are used to interconnect Local Area Networks (LANs) over vast
- distances with data transfer rates significantly higher than those
- achievable with commonly used asynchronous modem connections.
- Usually, a quite expensive external device called a `WAN router' is
- needed to connect to a WAN.
-
- As an alternative, WAN routing can be built into the Linux kernel.
- With relatively inexpensive WAN interface cards available on the
- market, a perfectly usable router can be built for less than half
- the price of an external router. If you have one of those cards and
- wish to use your Linux box as a WAN router, say Y here and also to
- the WAN driver for your card, below. You will then need the
- wan-tools package which is available from <ftp://ftp.sangoma.com/>.
- Read <file:Documentation/networking/wan-router.txt> for more
- information.
-
- To compile WAN routing support as a module, choose M here: the
- module will be called wanrouter.
-
- If unsure, say N.
-
-menu "QoS and/or fair queueing"
-
-config NET_SCHED
- bool "QoS and/or fair queueing"
- ---help---
- When the kernel has several packets to send out over a network
- device, it has to decide which ones to send first, which ones to
- delay, and which ones to drop. This is the job of the packet
- scheduler, and several different algorithms for how to do this
- "fairly" have been proposed.
-
- If you say N here, you will get the standard packet scheduler, which
- is a FIFO (first come, first served). If you say Y here, you will be
- able to choose from among several alternative algorithms which can
- then be attached to different network devices. This is useful for
- example if some of your network devices are real time devices that
- need a certain minimum data flow rate, or if you need to limit the
- maximum data flow rate for traffic which matches specified criteria.
- This code is considered to be experimental.
-
- To administer these schedulers, you'll need the user-level utilities
- from the package iproute2+tc at <ftp://ftp.tux.org/pub/net/ip-routing/>.
- That package also contains some documentation; for more, check out
- <http://snafu.freedom.org/linux2.2/iproute-notes.html>.
-
- This Quality of Service (QoS) support will enable you to use
- Differentiated Services (diffserv) and Resource Reservation Protocol
- (RSVP) on your Linux router if you also say Y to "QoS support",
- "Packet classifier API" and to some classifiers below. Documentation
- and software is at <http://diffserv.sourceforge.net/>.
-
- If you say Y here and to "/proc file system" below, you will be able
- to read status information about packet schedulers from the file
- /proc/net/psched.
-
- The available schedulers are listed in the following questions; you
- can say Y to as many as you like. If unsure, say N now.
-
+source "net/econet/Kconfig"
+source "net/wanrouter/Kconfig"
source "net/sched/Kconfig"
-endmenu
-
menu "Network testing"
config NET_PKTGEN
@@ -635,12 +226,9 @@ config NET_POLL_CONTROLLER
def_bool NETPOLL
source "net/ax25/Kconfig"
-
source "net/irda/Kconfig"
-
source "net/bluetooth/Kconfig"
-source "drivers/net/Kconfig"
-
-endmenu
+endif # if NET
+endmenu # Networking
diff --git a/net/atm/Kconfig b/net/atm/Kconfig
new file mode 100644
index 00000000000..bea2426229b
--- /dev/null
+++ b/net/atm/Kconfig
@@ -0,0 +1,74 @@
+#
+# Asynchronous Transfer Mode (ATM) (EXPERIMENTAL)
+#
+
+config ATM
+ tristate "Asynchronous Transfer Mode (ATM) (EXPERIMENTAL)"
+ depends on EXPERIMENTAL
+ ---help---
+ ATM is a high-speed networking technology for Local Area Networks
+ and Wide Area Networks. It uses a fixed packet size and is
+ connection oriented, allowing for the negotiation of minimum
+ bandwidth requirements.
+
+ In order to participate in an ATM network, your Linux box needs an
+ ATM networking card. If you have that, say Y here and to the driver
+ of your ATM card below.
+
+ Note that you need a set of user-space programs to actually make use
+ of ATM. See the file <file:Documentation/networking/atm.txt> for
+ further details.
+
+config ATM_CLIP
+ tristate "Classical IP over ATM (EXPERIMENTAL)"
+ depends on ATM && INET
+ help
+ Classical IP over ATM for PVCs and SVCs, supporting InARP and
+ ATMARP. If you want to communication with other IP hosts on your ATM
+ network, you will typically either say Y here or to "LAN Emulation
+ (LANE)" below.
+
+config ATM_CLIP_NO_ICMP
+ bool "Do NOT send ICMP if no neighbour (EXPERIMENTAL)"
+ depends on ATM_CLIP
+ help
+ Normally, an "ICMP host unreachable" message is sent if a neighbour
+ cannot be reached because there is no VC to it in the kernel's
+ ATMARP table. This may cause problems when ATMARP table entries are
+ briefly removed during revalidation. If you say Y here, packets to
+ such neighbours are silently discarded instead.
+
+config ATM_LANE
+ tristate "LAN Emulation (LANE) support (EXPERIMENTAL)"
+ depends on ATM
+ help
+ LAN Emulation emulates services of existing LANs across an ATM
+ network. Besides operating as a normal ATM end station client, Linux
+ LANE client can also act as an proxy client bridging packets between
+ ELAN and Ethernet segments. You need LANE if you want to try MPOA.
+
+config ATM_MPOA
+ tristate "Multi-Protocol Over ATM (MPOA) support (EXPERIMENTAL)"
+ depends on ATM && INET && ATM_LANE!=n
+ help
+ Multi-Protocol Over ATM allows ATM edge devices such as routers,
+ bridges and ATM attached hosts establish direct ATM VCs across
+ subnetwork boundaries. These shortcut connections bypass routers
+ enhancing overall network performance.
+
+config ATM_BR2684
+ tristate "RFC1483/2684 Bridged protocols"
+ depends on ATM && INET
+ help
+ ATM PVCs can carry ethernet PDUs according to rfc2684 (formerly 1483)
+ This device will act like an ethernet from the kernels point of view,
+ with the traffic being carried by ATM PVCs (currently 1 PVC/device).
+ This is sometimes used over DSL lines. If in doubt, say N.
+
+config ATM_BR2684_IPFILTER
+ bool "Per-VC IP filter kludge"
+ depends on ATM_BR2684
+ help
+ This is an experimental mechanism for users who need to terminating a
+ large number of IP-only vcc's. Do not enable this unless you are sure
+ you know what you are doing.
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index e6954cf1459..289956c4dd3 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -289,8 +289,7 @@ xmit will add the additional header part in that case */
* This is similar to eth_type_trans, which cannot be used because of
* our dev->hard_header_len
*/
-static inline unsigned short br_type_trans(struct sk_buff *skb,
- struct net_device *dev)
+static inline __be16 br_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct ethhdr *eth;
unsigned char *rawp;
diff --git a/net/bridge/Kconfig b/net/bridge/Kconfig
new file mode 100644
index 00000000000..db23d59746c
--- /dev/null
+++ b/net/bridge/Kconfig
@@ -0,0 +1,31 @@
+#
+# 802.1d Ethernet Bridging
+#
+
+config BRIDGE
+ tristate "802.1d Ethernet Bridging"
+ ---help---
+ If you say Y here, then your Linux box will be able to act as an
+ Ethernet bridge, which means that the different Ethernet segments it
+ is connected to will appear as one Ethernet to the participants.
+ Several such bridges can work together to create even larger
+ networks of Ethernets using the IEEE 802.1 spanning tree algorithm.
+ As this is a standard, Linux bridges will cooperate properly with
+ other third party bridge products.
+
+ In order to use the Ethernet bridge, you'll need the bridge
+ configuration tools; see <file:Documentation/networking/bridge.txt>
+ for location. Please read the Bridge mini-HOWTO for more
+ information.
+
+ If you enable iptables support along with the bridge support then you
+ turn your bridge into a bridging IP firewall.
+ iptables will then see the IP packets being bridged, so you need to
+ take this into account when setting up your firewall rules.
+ Enabling arptables support when bridging will let arptables see
+ bridged ARP traffic in the arptables FORWARD chain.
+
+ To compile this code as a module, choose M here: the module
+ will be called bridge.
+
+ If unsure, say N.
diff --git a/net/decnet/Kconfig b/net/decnet/Kconfig
index 2101da542ba..92f2ec46fd2 100644
--- a/net/decnet/Kconfig
+++ b/net/decnet/Kconfig
@@ -1,6 +1,29 @@
#
# DECnet configuration
#
+config DECNET
+ tristate "DECnet Support"
+ ---help---
+ The DECnet networking protocol was used in many products made by
+ Digital (now Compaq). It provides reliable stream and sequenced
+ packet communications over which run a variety of services similar
+ to those which run over TCP/IP.
+
+ To find some tools to use with the kernel layer support, please
+ look at Patrick Caulfield's web site:
+ <http://linux-decnet.sourceforge.net/>.
+
+ More detailed documentation is available in
+ <file:Documentation/networking/decnet.txt>.
+
+ Be sure to say Y to "/proc file system support" and "Sysctl support"
+ below when using DECnet, since you will need sysctl support to aid
+ in configuration at run time.
+
+ The DECnet code is also available as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want).
+ The module is called decnet.
+
config DECNET_ROUTER
bool "DECnet: router support (EXPERIMENTAL)"
depends on DECNET && EXPERIMENTAL
diff --git a/net/econet/Kconfig b/net/econet/Kconfig
new file mode 100644
index 00000000000..39a2d2975e0
--- /dev/null
+++ b/net/econet/Kconfig
@@ -0,0 +1,36 @@
+#
+# Acorn Econet/AUN protocols
+#
+
+config ECONET
+ tristate "Acorn Econet/AUN protocols (EXPERIMENTAL)"
+ depends on EXPERIMENTAL && INET
+ ---help---
+ Econet is a fairly old and slow networking protocol mainly used by
+ Acorn computers to access file and print servers. It uses native
+ Econet network cards. AUN is an implementation of the higher level
+ parts of Econet that runs over ordinary Ethernet connections, on
+ top of the UDP packet protocol, which in turn runs on top of the
+ Internet protocol IP.
+
+ If you say Y here, you can choose with the next two options whether
+ to send Econet/AUN traffic over a UDP Ethernet connection or over
+ a native Econet network card.
+
+ To compile this driver as a module, choose M here: the module
+ will be called econet.
+
+config ECONET_AUNUDP
+ bool "AUN over UDP"
+ depends on ECONET
+ help
+ Say Y here if you want to send Econet/AUN traffic over a UDP
+ connection (UDP is a packet based protocol that runs on top of the
+ Internet protocol IP) using an ordinary Ethernet network card.
+
+config ECONET_NATIVE
+ bool "Native Econet"
+ depends on ECONET
+ help
+ Say Y here if you have a native Econet network card installed in
+ your computer.
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index ab60ea63688..f6dbfb99b14 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -155,7 +155,7 @@ int eth_rebuild_header(struct sk_buff *skb)
* This is normal practice and works for any 'now in use' protocol.
*/
-unsigned short eth_type_trans(struct sk_buff *skb, struct net_device *dev)
+__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct ethhdr *eth;
unsigned char *rawp;
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 3e63123f7bb..df5386885a9 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -3,7 +3,6 @@
#
config IP_MULTICAST
bool "IP: multicasting"
- depends on INET
help
This is code for addressing several networked computers at once,
enlarging your kernel by about 2 KB. You need multicasting if you
@@ -17,7 +16,6 @@ config IP_MULTICAST
config IP_ADVANCED_ROUTER
bool "IP: advanced router"
- depends on INET
---help---
If you intend to run your Linux box mostly as a router, i.e. as a
computer that forwards and redistributes network packets, say Y; you
@@ -183,7 +181,6 @@ config IP_ROUTE_VERBOSE
config IP_PNP
bool "IP: kernel level autoconfiguration"
- depends on INET
help
This enables automatic configuration of IP addresses of devices and
of the routing table during kernel boot, based on either information
@@ -242,7 +239,6 @@ config IP_PNP_RARP
# bool ' IP: ARP support' CONFIG_IP_PNP_ARP
config NET_IPIP
tristate "IP: tunneling"
- depends on INET
select INET_TUNNEL
---help---
Tunneling means encapsulating data of one protocol type within
@@ -260,7 +256,6 @@ config NET_IPIP
config NET_IPGRE
tristate "IP: GRE tunnels over IP"
- depends on INET
select XFRM
help
Tunneling means encapsulating data of one protocol type within
@@ -319,7 +314,7 @@ config IP_PIMSM_V2
config ARPD
bool "IP: ARP daemon support (EXPERIMENTAL)"
- depends on INET && EXPERIMENTAL
+ depends on EXPERIMENTAL
---help---
Normally, the kernel maintains an internal cache which maps IP
addresses to hardware addresses on the local network, so that
@@ -344,7 +339,6 @@ config ARPD
config SYN_COOKIES
bool "IP: TCP syncookie support (disabled per default)"
- depends on INET
---help---
Normal TCP/IP networking is open to an attack known as "SYN
flooding". This denial-of-service attack prevents legitimate remote
@@ -381,7 +375,6 @@ config SYN_COOKIES
config INET_AH
tristate "IP: AH transformation"
- depends on INET
select XFRM
select CRYPTO
select CRYPTO_HMAC
@@ -394,7 +387,6 @@ config INET_AH
config INET_ESP
tristate "IP: ESP transformation"
- depends on INET
select XFRM
select CRYPTO
select CRYPTO_HMAC
@@ -408,7 +400,6 @@ config INET_ESP
config INET_IPCOMP
tristate "IP: IPComp transformation"
- depends on INET
select XFRM
select INET_TUNNEL
select CRYPTO
@@ -421,7 +412,6 @@ config INET_IPCOMP
config INET_TUNNEL
tristate "IP: tunnel transformation"
- depends on INET
select XFRM
---help---
Support for generic IP tunnel transformation, which is required by
@@ -431,7 +421,6 @@ config INET_TUNNEL
config IP_TCPDIAG
tristate "IP: TCP socket monitoring interface"
- depends on INET
default y
---help---
Support for TCP socket monitoring interface used by native Linux
@@ -447,7 +436,6 @@ config IP_TCPDIAG_IPV6
config TCP_CONG_ADVANCED
bool "TCP: advanced congestion control"
- depends on INET
---help---
Support for selection of various TCP congestion control
modules.
@@ -463,7 +451,6 @@ menu "TCP congestion control"
config TCP_CONG_BIC
tristate "Binary Increase Congestion (BIC) control"
- depends on INET
default y
---help---
BIC-TCP is a sender-side only change that ensures a linear RTT
@@ -478,7 +465,6 @@ config TCP_CONG_BIC
config TCP_CONG_WESTWOOD
tristate "TCP Westwood+"
- depends on INET
default m
---help---
TCP Westwood+ is a sender-side only modification of the TCP Reno
@@ -493,7 +479,6 @@ config TCP_CONG_WESTWOOD
config TCP_CONG_HTCP
tristate "H-TCP"
- depends on INET
default m
---help---
H-TCP is a send-side only modifications of the TCP Reno
@@ -505,7 +490,7 @@ config TCP_CONG_HTCP
config TCP_CONG_HSTCP
tristate "High Speed TCP"
- depends on INET && EXPERIMENTAL
+ depends on EXPERIMENTAL
default n
---help---
Sally Floyd's High Speed TCP (RFC 3649) congestion control.
@@ -516,7 +501,7 @@ config TCP_CONG_HSTCP
config TCP_CONG_HYBLA
tristate "TCP-Hybla congestion control algorithm"
- depends on INET && EXPERIMENTAL
+ depends on EXPERIMENTAL
default n
---help---
TCP-Hybla is a sender-side only change that eliminates penalization of
@@ -526,7 +511,7 @@ config TCP_CONG_HYBLA
config TCP_CONG_VEGAS
tristate "TCP Vegas"
- depends on INET && EXPERIMENTAL
+ depends on EXPERIMENTAL
default n
---help---
TCP Vegas is a sender-side only change to TCP that anticipates
@@ -537,7 +522,7 @@ config TCP_CONG_VEGAS
config TCP_CONG_SCALABLE
tristate "Scalable TCP"
- depends on INET && EXPERIMENTAL
+ depends on EXPERIMENTAL
default n
---help---
Scalable TCP is a sender-side only change to TCP which uses a
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 9de83e6e0f1..80d13103b2b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -107,7 +107,6 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb)
newskb->pkt_type = PACKET_LOOPBACK;
newskb->ip_summed = CHECKSUM_UNNECESSARY;
BUG_TRAP(newskb->dst);
- nf_reset(newskb);
netif_rx(newskb);
return 0;
}
@@ -188,14 +187,6 @@ static inline int ip_finish_output2(struct sk_buff *skb)
skb = skb2;
}
-#ifdef CONFIG_BRIDGE_NETFILTER
- /* bridge-netfilter defers calling some IP hooks to the bridge layer
- * and still needs the conntrack reference.
- */
- if (skb->nf_bridge == NULL)
-#endif
- nf_reset(skb);
-
if (hh) {
int hh_alen;
diff --git a/net/ipv4/ipvs/Kconfig b/net/ipv4/ipvs/Kconfig
index 63a82b4b64b..c9820bfc493 100644
--- a/net/ipv4/ipvs/Kconfig
+++ b/net/ipv4/ipvs/Kconfig
@@ -2,11 +2,11 @@
# IP Virtual Server configuration
#
menu "IP: Virtual Server Configuration"
- depends on INET && NETFILTER
+ depends on NETFILTER
config IP_VS
tristate "IP virtual server support (EXPERIMENTAL)"
- depends on INET && NETFILTER
+ depends on NETFILTER
---help---
IP Virtual Server support will let you build a high-performance
virtual server based on cluster of two or more real servers. This
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 9f16ab30910..d0145a8b155 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -758,7 +758,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
return 1;
}
-
+/* Called from keventd and must protect itself from softirqs */
void ip_vs_random_dropentry(void)
{
int idx;
@@ -773,7 +773,7 @@ void ip_vs_random_dropentry(void)
/*
* Lock is actually needed in this loop.
*/
- ct_write_lock(hash);
+ ct_write_lock_bh(hash);
list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
if (!cp->cport && !(cp->flags & IP_VS_CONN_F_NO_CPORT))
@@ -806,7 +806,7 @@ void ip_vs_random_dropentry(void)
ip_vs_conn_expire_now(cp->control);
}
}
- ct_write_unlock(hash);
+ ct_write_unlock_bh(hash);
}
}
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index 12a82e91d22..7d99ede2ef7 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -90,7 +90,8 @@ int ip_vs_get_debug_level(void)
#endif
/*
- * update_defense_level is called from keventd and from sysctl.
+ * update_defense_level is called from keventd and from sysctl,
+ * so it needs to protect itself from softirqs
*/
static void update_defense_level(void)
{
@@ -110,6 +111,8 @@ static void update_defense_level(void)
nomem = (availmem < sysctl_ip_vs_amemthresh);
+ local_bh_disable();
+
/* drop_entry */
spin_lock(&__ip_vs_dropentry_lock);
switch (sysctl_ip_vs_drop_entry) {
@@ -206,6 +209,8 @@ static void update_defense_level(void)
if (to_change >= 0)
ip_vs_protocol_timeout_change(sysctl_ip_vs_secure_tcp>1);
write_unlock(&__ip_vs_securetcp_lock);
+
+ local_bh_enable();
}
@@ -1360,9 +1365,7 @@ proc_do_defense_mode(ctl_table *table, int write, struct file * filp,
/* Restore the correct value */
*valp = val;
} else {
- local_bh_disable();
update_defense_level();
- local_bh_enable();
}
}
return rc;
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 42dc9510287..1dd824f3cf0 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -432,6 +432,13 @@ static unsigned int ip_conntrack_defrag(unsigned int hooknum,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
+#if !defined(CONFIG_IP_NF_NAT) && !defined(CONFIG_IP_NF_NAT_MODULE)
+ /* Previously seen (loopback)? Ignore. Do this before
+ fragment check. */
+ if ((*pskb)->nfct)
+ return NF_ACCEPT;
+#endif
+
/* Gather fragments. */
if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
*pskb = ip_ct_gather_frags(*pskb,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 726ea5e8180..d675ff80b04 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1685,7 +1685,7 @@ static void ip_handle_martian_source(struct net_device *dev,
printk(KERN_WARNING "martian source %u.%u.%u.%u from "
"%u.%u.%u.%u, on dev %s\n",
NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
- if (dev->hard_header_len) {
+ if (dev->hard_header_len && skb->mac.raw) {
int i;
unsigned char *p = skb->mac.raw;
printk(KERN_WARNING "ll header: ");
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index e66ca9381cf..95163cd52ae 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -1,6 +1,26 @@
#
# IPv6 configuration
-#
+#
+
+# IPv6 as module will cause a CRASH if you try to unload it
+config IPV6
+ tristate "The IPv6 protocol"
+ default m
+ select CRYPTO if IPV6_PRIVACY
+ select CRYPTO_MD5 if IPV6_PRIVACY
+ ---help---
+ This is complemental support for the IP version 6.
+ You will still be able to do traditional IPv4 networking as well.
+
+ For general information about IPv6, see
+ <http://playground.sun.com/pub/ipng/html/ipng-main.html>.
+ For Linux IPv6 development information, see <http://www.linux-ipv6.org>.
+ For specific information about IPv6 under Linux, read the HOWTO at
+ <http://www.bieringer.de/linux/IPv6/>.
+
+ To compile this protocol support as a module, choose M here: the
+ module will be called ipv6.
+
config IPV6_PRIVACY
bool "IPv6: Privacy Extensions (RFC 3041) support"
depends on IPV6
diff --git a/net/ipx/Kconfig b/net/ipx/Kconfig
index a16237c0e78..980a826f5d0 100644
--- a/net/ipx/Kconfig
+++ b/net/ipx/Kconfig
@@ -1,6 +1,39 @@
#
# IPX configuration
#
+config IPX
+ tristate "The IPX protocol"
+ select LLC
+ ---help---
+ This is support for the Novell networking protocol, IPX, commonly
+ used for local networks of Windows machines. You need it if you
+ want to access Novell NetWare file or print servers using the Linux
+ Novell client ncpfs (available from
+ <ftp://platan.vc.cvut.cz/pub/linux/ncpfs/>) or from
+ within the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO,
+ available from <http://www.tldp.org/docs.html#howto>). In order
+ to do the former, you'll also have to say Y to "NCP file system
+ support", below.
+
+ IPX is similar in scope to IP, while SPX, which runs on top of IPX,
+ is similar to TCP. There is also experimental support for SPX in
+ Linux (see "SPX networking", below).
+
+ To turn your Linux box into a fully featured NetWare file server and
+ IPX router, say Y here and fetch either lwared from
+ <ftp://ibiblio.org/pub/Linux/system/network/daemons/> or
+ mars_nwe from <ftp://www.compu-art.de/mars_nwe/>. For more
+ information, read the IPX-HOWTO available from
+ <http://www.tldp.org/docs.html#howto>.
+
+ General information about how to connect Linux, Windows machines and
+ Macs is on the WWW at <http://www.eats.com/linux_mac_win.html>.
+
+ The IPX driver would enlarge your kernel by about 16 KB. To compile
+ this driver as a module, choose M here: the module will be called ipx.
+ Unless you want to integrate your Linux box with a local Novell
+ network, say N.
+
config IPX_INTERN
bool "IPX: Full internal IPX network"
depends on IPX
diff --git a/net/lapb/Kconfig b/net/lapb/Kconfig
new file mode 100644
index 00000000000..f0b5efb31a0
--- /dev/null
+++ b/net/lapb/Kconfig
@@ -0,0 +1,22 @@
+#
+# LAPB Data Link Drive
+#
+
+config LAPB
+ tristate "LAPB Data Link Driver (EXPERIMENTAL)"
+ depends on EXPERIMENTAL
+ ---help---
+ Link Access Procedure, Balanced (LAPB) is the data link layer (i.e.
+ the lower) part of the X.25 protocol. It offers a reliable
+ connection service to exchange data frames with one other host, and
+ it is used to transport higher level protocols (mostly X.25 Packet
+ Layer, the higher part of X.25, but others are possible as well).
+ Usually, LAPB is used with specialized X.21 network cards, but Linux
+ currently supports LAPB only over Ethernet connections. If you want
+ to use LAPB connections over Ethernet, say Y here and to "LAPB over
+ Ethernet driver" below. Read
+ <file:Documentation/networking/lapb-module.txt> for technical
+ details.
+
+ To compile this driver as a module, choose M here: the
+ module will be called lapb. If unsure, say N.
diff --git a/net/packet/Kconfig b/net/packet/Kconfig
new file mode 100644
index 00000000000..34ff93ff894
--- /dev/null
+++ b/net/packet/Kconfig
@@ -0,0 +1,26 @@
+#
+# Packet configuration
+#
+
+config PACKET
+ tristate "Packet socket"
+ ---help---
+ The Packet protocol is used by applications which communicate
+ directly with network devices without an intermediate network
+ protocol implemented in the kernel, e.g. tcpdump. If you want them
+ to work, choose Y.
+
+ To compile this driver as a module, choose M here: the module will
+ be called af_packet.
+
+ If unsure, say Y.
+
+config PACKET_MMAP
+ bool "Packet socket: mmapped IO"
+ depends on PACKET
+ help
+ If you say Y here, the Packet protocol driver will use an IO
+ mechanism that results in faster communication.
+
+ If unsure, say N.
+
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 0269616e75a..c9d5980aa4d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -274,6 +274,9 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct
dst_release(skb->dst);
skb->dst = NULL;
+ /* drop conntrack reference */
+ nf_reset(skb);
+
spkt = (struct sockaddr_pkt*)skb->cb;
skb_push(skb, skb->data-skb->mac.raw);
@@ -517,6 +520,9 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
dst_release(skb->dst);
skb->dst = NULL;
+ /* drop conntrack reference */
+ nf_reset(skb);
+
spin_lock(&sk->sk_receive_queue.lock);
po->stats.tp_packets++;
__skb_queue_tail(&sk->sk_receive_queue, skb);
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 7bac249258e..59d3e71f8b8 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -1,6 +1,43 @@
#
# Traffic control configuration.
#
+
+menuconfig NET_SCHED
+ bool "QoS and/or fair queueing"
+ ---help---
+ When the kernel has several packets to send out over a network
+ device, it has to decide which ones to send first, which ones to
+ delay, and which ones to drop. This is the job of the packet
+ scheduler, and several different algorithms for how to do this
+ "fairly" have been proposed.
+
+ If you say N here, you will get the standard packet scheduler, which
+ is a FIFO (first come, first served). If you say Y here, you will be
+ able to choose from among several alternative algorithms which can
+ then be attached to different network devices. This is useful for
+ example if some of your network devices are real time devices that
+ need a certain minimum data flow rate, or if you need to limit the
+ maximum data flow rate for traffic which matches specified criteria.
+ This code is considered to be experimental.
+
+ To administer these schedulers, you'll need the user-level utilities
+ from the package iproute2+tc at <ftp://ftp.tux.org/pub/net/ip-routing/>.
+ That package also contains some documentation; for more, check out
+ <http://snafu.freedom.org/linux2.2/iproute-notes.html>.
+
+ This Quality of Service (QoS) support will enable you to use
+ Differentiated Services (diffserv) and Resource Reservation Protocol
+ (RSVP) on your Linux router if you also say Y to "QoS support",
+ "Packet classifier API" and to some classifiers below. Documentation
+ and software is at <http://diffserv.sourceforge.net/>.
+
+ If you say Y here and to "/proc file system" below, you will be able
+ to read status information about packet schedulers from the file
+ /proc/net/psched.
+
+ The available schedulers are listed in the following questions; you
+ can say Y to as many as you like. If unsure, say N now.
+
choice
prompt "Packet scheduler clock source"
depends on NET_SCHED
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 4b47dd6f248..5b24ae0650d 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -71,7 +71,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
const struct sctp_endpoint *ep,
const struct sock *sk,
sctp_scope_t scope,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sctp_sock *sp;
int i;
@@ -272,7 +272,8 @@ fail_init:
/* Allocate and initialize a new association */
struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep,
const struct sock *sk,
- sctp_scope_t scope, int gfp)
+ sctp_scope_t scope,
+ unsigned int __nocast gfp)
{
struct sctp_association *asoc;
@@ -478,7 +479,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
/* Add a transport address to an association. */
struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
const union sctp_addr *addr,
- const int gfp,
+ const unsigned int __nocast gfp,
const int peer_state)
{
struct sctp_transport *peer;
@@ -1229,7 +1230,8 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len)
/* Build the bind address list for the association based on info from the
* local endpoint and the remote peer.
*/
-int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, int gfp)
+int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc,
+ unsigned int __nocast gfp)
{
sctp_scope_t scope;
int flags;
@@ -1251,7 +1253,8 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, int gfp)
/* Build the association's bind address list from the cookie. */
int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
- struct sctp_cookie *cookie, int gfp)
+ struct sctp_cookie *cookie,
+ unsigned int __nocast gfp)
{
int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length);
int var_size3 = cookie->raw_addr_list_len;
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index f90eadfb60a..f71549710f2 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -53,7 +53,8 @@
/* Forward declarations for internal helpers. */
static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *,
- sctp_scope_t scope, int gfp, int flags);
+ sctp_scope_t scope, unsigned int __nocast gfp,
+ int flags);
static void sctp_bind_addr_clean(struct sctp_bind_addr *);
/* First Level Abstractions. */
@@ -63,7 +64,8 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *);
*/
int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
const struct sctp_bind_addr *src,
- sctp_scope_t scope, int gfp, int flags)
+ sctp_scope_t scope, unsigned int __nocast gfp,
+ int flags)
{
struct sctp_sockaddr_entry *addr;
struct list_head *pos;
@@ -144,7 +146,7 @@ void sctp_bind_addr_free(struct sctp_bind_addr *bp)
/* Add an address to the bind address list in the SCTP_bind_addr structure. */
int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sctp_sockaddr_entry *addr;
@@ -197,7 +199,8 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
* The second argument is the return value for the length.
*/
union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
- int *addrs_len, int gfp)
+ int *addrs_len,
+ unsigned int __nocast gfp)
{
union sctp_params addrparms;
union sctp_params retval;
@@ -249,7 +252,7 @@ end_raw:
* address parameters).
*/
int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
- int addrs_len, __u16 port, int gfp)
+ int addrs_len, __u16 port, unsigned int __nocast gfp)
{
union sctp_addr_param *rawaddr;
struct sctp_paramhdr *param;
@@ -347,7 +350,8 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
/* Copy out addresses from the global local address list. */
static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
union sctp_addr *addr,
- sctp_scope_t scope, int gfp, int flags)
+ sctp_scope_t scope, unsigned int __nocast gfp,
+ int flags)
{
int error = 0;
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 0c2ab788505..61da2937e64 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -62,7 +62,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg)
}
/* Allocate and initialize datamsg. */
-SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(int gfp)
+SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(unsigned int __nocast gfp)
{
struct sctp_datamsg *msg;
msg = kmalloc(sizeof(struct sctp_datamsg), gfp);
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index c44bf4165c6..e47ac0d1a6d 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -67,7 +67,8 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep);
* Initialize the base fields of the endpoint structure.
*/
static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
- struct sock *sk, int gfp)
+ struct sock *sk,
+ unsigned int __nocast gfp)
{
struct sctp_sock *sp = sctp_sk(sk);
memset(ep, 0, sizeof(struct sctp_endpoint));
@@ -137,7 +138,8 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
/* Create a sctp_endpoint with all that boring stuff initialized.
* Returns NULL if there isn't enough memory.
*/
-struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, int gfp)
+struct sctp_endpoint *sctp_endpoint_new(struct sock *sk,
+ unsigned int __nocast gfp)
{
struct sctp_endpoint *ep;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index e7f37faba7c..ce9245e71fc 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -219,7 +219,7 @@ static void sctp_free_local_addr_list(void)
/* Copy the local addresses which are valid for 'scope' into 'bp'. */
int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
- int gfp, int copy_flags)
+ unsigned int __nocast gfp, int copy_flags)
{
struct sctp_sockaddr_entry *addr;
int error = 0;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 773cd93fa3d..00d32b7c826 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -78,7 +78,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
static int sctp_process_param(struct sctp_association *asoc,
union sctp_params param,
const union sctp_addr *peer_addr,
- int gfp);
+ unsigned int __nocast gfp);
/* What was the inbound interface for this chunk? */
int sctp_chunk_iif(const struct sctp_chunk *chunk)
@@ -174,7 +174,7 @@ void sctp_init_cause(struct sctp_chunk *chunk, __u16 cause_code,
*/
struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
const struct sctp_bind_addr *bp,
- int gfp, int vparam_len)
+ unsigned int __nocast gfp, int vparam_len)
{
sctp_inithdr_t init;
union sctp_params addrs;
@@ -261,7 +261,7 @@ nodata:
struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
const struct sctp_chunk *chunk,
- int gfp, int unkparam_len)
+ unsigned int __nocast gfp, int unkparam_len)
{
sctp_inithdr_t initack;
struct sctp_chunk *retval;
@@ -1233,7 +1233,8 @@ void sctp_chunk_assign_tsn(struct sctp_chunk *chunk)
/* Create a CLOSED association to use with an incoming packet. */
struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep,
- struct sctp_chunk *chunk, int gfp)
+ struct sctp_chunk *chunk,
+ unsigned int __nocast gfp)
{
struct sctp_association *asoc;
struct sk_buff *skb;
@@ -1348,7 +1349,7 @@ nodata:
struct sctp_association *sctp_unpack_cookie(
const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
- struct sctp_chunk *chunk, int gfp,
+ struct sctp_chunk *chunk, unsigned int __nocast gfp,
int *error, struct sctp_chunk **errp)
{
struct sctp_association *retval = NULL;
@@ -1812,7 +1813,7 @@ int sctp_verify_init(const struct sctp_association *asoc,
*/
int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
const union sctp_addr *peer_addr,
- sctp_init_chunk_t *peer_init, int gfp)
+ sctp_init_chunk_t *peer_init, unsigned int __nocast gfp)
{
union sctp_params param;
struct sctp_transport *transport;
@@ -1983,7 +1984,7 @@ nomem:
static int sctp_process_param(struct sctp_association *asoc,
union sctp_params param,
const union sctp_addr *peer_addr,
- int gfp)
+ unsigned int __nocast gfp)
{
union sctp_addr addr;
int i;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 778639db125..39c970b5b19 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -63,7 +63,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
- int gfp);
+ unsigned int __nocast gfp);
static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
sctp_state_t state,
struct sctp_endpoint *ep,
@@ -71,7 +71,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
- int gfp);
+ unsigned int __nocast gfp);
/********************************************************************
* Helper functions
@@ -497,7 +497,8 @@ static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
static int sctp_cmd_process_init(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
struct sctp_chunk *chunk,
- sctp_init_chunk_t *peer_init, int gfp)
+ sctp_init_chunk_t *peer_init,
+ unsigned int __nocast gfp)
{
int error;
@@ -852,7 +853,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
struct sctp_endpoint *ep,
struct sctp_association *asoc,
void *event_arg,
- int gfp)
+ unsigned int __nocast gfp)
{
sctp_cmd_seq_t commands;
const sctp_sm_table_entry_t *state_fn;
@@ -897,7 +898,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
- int gfp)
+ unsigned int __nocast gfp)
{
int error;
@@ -985,7 +986,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
- int gfp)
+ unsigned int __nocast gfp)
{
int error = 0;
int force;
diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
index e627d2b451b..25037daf3fa 100644
--- a/net/sctp/ssnmap.c
+++ b/net/sctp/ssnmap.c
@@ -57,7 +57,8 @@ static inline size_t sctp_ssnmap_size(__u16 in, __u16 out)
/* Create a new sctp_ssnmap.
* Allocate room to store at least 'len' contiguous TSNs.
*/
-struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, int gfp)
+struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
+ unsigned int __nocast gfp)
{
struct sctp_ssnmap *retval;
int size;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index a63b6917960..d2f04ebe508 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -57,7 +57,7 @@
/* Initialize a new transport from provided memory. */
static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
const union sctp_addr *addr,
- int gfp)
+ unsigned int __nocast gfp)
{
/* Copy in the address. */
peer->ipaddr = *addr;
@@ -121,7 +121,8 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
}
/* Allocate and initialize a new transport. */
-struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, int gfp)
+struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
+ unsigned int __nocast gfp)
{
struct sctp_transport *transport;
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 17d0ff53473..0abd5101107 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -74,7 +74,7 @@ SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags)
/* Create a new sctp_ulpevent. */
SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sk_buff *skb;
@@ -136,7 +136,7 @@ static inline void sctp_ulpevent_release_owner(struct sctp_ulpevent *event)
struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
const struct sctp_association *asoc,
__u16 flags, __u16 state, __u16 error, __u16 outbound,
- __u16 inbound, int gfp)
+ __u16 inbound, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_assoc_change *sac;
@@ -237,7 +237,7 @@ fail:
struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
const struct sctp_association *asoc,
const struct sockaddr_storage *aaddr,
- int flags, int state, int error, int gfp)
+ int flags, int state, int error, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_paddr_change *spc;
@@ -350,7 +350,7 @@ fail:
*/
struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
const struct sctp_association *asoc, struct sctp_chunk *chunk,
- __u16 flags, int gfp)
+ __u16 flags, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_remote_error *sre;
@@ -448,7 +448,7 @@ fail:
*/
struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
const struct sctp_association *asoc, struct sctp_chunk *chunk,
- __u16 flags, __u32 error, int gfp)
+ __u16 flags, __u32 error, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_send_failed *ssf;
@@ -557,7 +557,7 @@ fail:
*/
struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
const struct sctp_association *asoc,
- __u16 flags, int gfp)
+ __u16 flags, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_shutdown_event *sse;
@@ -620,7 +620,7 @@ fail:
* 5.3.1.6 SCTP_ADAPTION_INDICATION
*/
struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
- const struct sctp_association *asoc, int gfp)
+ const struct sctp_association *asoc, unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_adaption_event *sai;
@@ -657,7 +657,7 @@ fail:
*/
struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
struct sctp_chunk *chunk,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sctp_ulpevent *event = NULL;
struct sk_buff *skb;
@@ -718,7 +718,8 @@ fail:
* various events.
*/
struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
- const struct sctp_association *asoc, __u32 indication, int gfp)
+ const struct sctp_association *asoc, __u32 indication,
+ unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_pdapi_event *pd;
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index d5dd2cf7ac4..8bbc279d6c9 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -100,7 +100,7 @@ void sctp_ulpq_free(struct sctp_ulpq *ulpq)
/* Process an incoming DATA chunk. */
int sctp_ulpq_tail_data(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sk_buff_head temp;
sctp_data_chunk_t *hdr;
@@ -778,7 +778,8 @@ static __u16 sctp_ulpq_renege_frags(struct sctp_ulpq *ulpq, __u16 needed)
/* Partial deliver the first message as there is pressure on rwnd. */
void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq,
- struct sctp_chunk *chunk, int gfp)
+ struct sctp_chunk *chunk,
+ unsigned int __nocast gfp)
{
struct sctp_ulpevent *event;
struct sctp_association *asoc;
@@ -802,7 +803,7 @@ void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq,
/* Renege some packets to make room for an incoming chunk. */
void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
- int gfp)
+ unsigned int __nocast gfp)
{
struct sctp_association *asoc;
__u16 needed, freed;
@@ -841,7 +842,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk,
/* Notify the application if an association is aborted and in
* partial delivery mode. Send up any pending received messages.
*/
-void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, int gfp)
+void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, unsigned int __nocast gfp)
{
struct sctp_ulpevent *ev = NULL;
struct sock *sk;
diff --git a/net/unix/Kconfig b/net/unix/Kconfig
new file mode 100644
index 00000000000..5a69733bcda
--- /dev/null
+++ b/net/unix/Kconfig
@@ -0,0 +1,21 @@
+#
+# Unix Domain Sockets
+#
+
+config UNIX
+ tristate "Unix domain sockets"
+ ---help---
+ If you say Y here, you will include support for Unix domain sockets;
+ sockets are the standard Unix mechanism for establishing and
+ accessing network connections. Many commonly used programs such as
+ the X Window system and syslog use these sockets even if your
+ machine is not connected to any network. Unless you are working on
+ an embedded system or something similar, you therefore definitely
+ want to say Y here.
+
+ To compile this driver as a module, choose M here: the module will be
+ called unix. Note that several important services won't work
+ correctly if you say M here and then neglect to load the module.
+
+ Say Y unless you know what you are doing.
+
diff --git a/net/wanrouter/Kconfig b/net/wanrouter/Kconfig
new file mode 100644
index 00000000000..1debe1cb054
--- /dev/null
+++ b/net/wanrouter/Kconfig
@@ -0,0 +1,29 @@
+#
+# Configuration for WAN router
+#
+
+config WAN_ROUTER
+ tristate "WAN router"
+ depends on EXPERIMENTAL
+ ---help---
+ Wide Area Networks (WANs), such as X.25, frame relay and leased
+ lines, are used to interconnect Local Area Networks (LANs) over vast
+ distances with data transfer rates significantly higher than those
+ achievable with commonly used asynchronous modem connections.
+ Usually, a quite expensive external device called a `WAN router' is
+ needed to connect to a WAN.
+
+ As an alternative, WAN routing can be built into the Linux kernel.
+ With relatively inexpensive WAN interface cards available on the
+ market, a perfectly usable router can be built for less than half
+ the price of an external router. If you have one of those cards and
+ wish to use your Linux box as a WAN router, say Y here and also to
+ the WAN driver for your card, below. You will then need the
+ wan-tools package which is available from <ftp://ftp.sangoma.com/>.
+ Read <file:Documentation/networking/wan-router.txt> for more
+ information.
+
+ To compile WAN routing support as a module, choose M here: the
+ module will be called wanrouter.
+
+ If unsure, say N.
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index d6844ac226f..13b650ad22e 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -358,10 +358,10 @@ int wanrouter_encapsulate(struct sk_buff *skb, struct net_device *dev,
*/
-unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
+__be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
{
int cnt = skb->data[0] ? 0 : 1; /* there may be a pad present */
- unsigned short ethertype;
+ __be16 ethertype;
switch (skb->data[cnt]) {
case NLPID_IP: /* IP datagramm */
@@ -379,7 +379,7 @@ unsigned short wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
skb->data[cnt+3], dev->name);
return 0;
}
- ethertype = *((unsigned short*)&skb->data[cnt+4]);
+ ethertype = *((__be16*)&skb->data[cnt+4]);
cnt += 6;
break;
diff --git a/net/x25/Kconfig b/net/x25/Kconfig
new file mode 100644
index 00000000000..e6759c9660b
--- /dev/null
+++ b/net/x25/Kconfig
@@ -0,0 +1,36 @@
+#
+# CCITT X.25 Packet Layer
+#
+
+config X25
+ tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)"
+ depends on EXPERIMENTAL
+ ---help---
+ X.25 is a set of standardized network protocols, similar in scope to
+ frame relay; the one physical line from your box to the X.25 network
+ entry point can carry several logical point-to-point connections
+ (called "virtual circuits") to other computers connected to the X.25
+ network. Governments, banks, and other organizations tend to use it
+ to connect to each other or to form Wide Area Networks (WANs). Many
+ countries have public X.25 networks. X.25 consists of two
+ protocols: the higher level Packet Layer Protocol (PLP) (say Y here
+ if you want that) and the lower level data link layer protocol LAPB
+ (say Y to "LAPB Data Link Driver" below if you want that).
+
+ You can read more about X.25 at <http://www.sangoma.com/x25.htm> and
+ <http://www.cisco.com/univercd/cc/td/doc/product/software/ios11/cbook/cx25.htm>.
+ Information about X.25 for Linux is contained in the files
+ <file:Documentation/networking/x25.txt> and
+ <file:Documentation/networking/x25-iface.txt>.
+
+ One connects to an X.25 network either with a dedicated network card
+ using the X.21 protocol (not yet supported by Linux) or one can do
+ X.25 over a standard telephone line using an ordinary modem (say Y
+ to "X.25 async driver" below) or over Ethernet using an ordinary
+ Ethernet card and the LAPB over Ethernet (say Y to "LAPB Data Link
+ Driver" and "LAPB over Ethernet driver" below).
+
+ To compile this driver as a module, choose M here: the module
+ will be called x25. If unsure, say N.
+
+
diff --git a/net/xfrm/Kconfig b/net/xfrm/Kconfig
index 58ca6a972c4..0c1c04322ba 100644
--- a/net/xfrm/Kconfig
+++ b/net/xfrm/Kconfig
@@ -1,6 +1,10 @@
#
# XFRM configuration
#
+config XFRM
+ bool
+ depends on NET
+
config XFRM_USER
tristate "IPsec user configuration interface"
depends on INET && XFRM
@@ -10,3 +14,14 @@ config XFRM_USER
If unsure, say Y.
+config NET_KEY
+ tristate "PF_KEY sockets"
+ select XFRM
+ ---help---
+ PF_KEYv2 socket family, compatible to KAME ones.
+ They are required if you are going to use IPsec tools ported
+ from KAME.
+
+ Say Y unless you know what you are doing.
+
+