From 3185932e694057c5f1c827af3b24624aa4fb3770 Mon Sep 17 00:00:00 2001 From: ms Date: Sun, 5 Aug 2007 17:39:37 +0000 Subject: [PATCH] Den "neuen" Kernel entfernt. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@735 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/kernel/kernel.config.i586 | 1170 +- config/kernel/kernel.config.i586.smp | 1170 +- lfs/iptables | 40 +- lfs/linux | 105 +- src/ipp2p/ipt_ipp2p.c | 10 - ....3.6-imq.diff => iptables-1.3.0-imq1.diff} | 441 +- src/patches/linux-2.6.16-imq2.diff | 885 + src/patches/linux-2.6.21-img2.diff | 840 - ....22-2.patch => reiser4-for-2.6.16-5.patch} | 18010 ++++++++-------- 9 files changed, 11397 insertions(+), 11274 deletions(-) rename src/patches/{iptables-1.3.6-imq.diff => iptables-1.3.0-imq1.diff} (84%) create mode 100644 src/patches/linux-2.6.16-imq2.diff delete mode 100644 src/patches/linux-2.6.21-img2.diff rename src/patches/{reiser4-for-2.6.22-2.patch => reiser4-for-2.6.16-5.patch} (87%) diff --git a/config/kernel/kernel.config.i586 b/config/kernel/kernel.config.i586 index 0eca006c2..721306909 100644 --- a/config/kernel/kernel.config.i586 +++ b/config/kernel/kernel.config.i586 @@ -1,26 +1,16 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.22.1-ipfire -# Thu Aug 2 21:46:39 2007 +# Linux kernel version: 2.6.16.50-ipfire +# Wed Aug 1 13:18:33 2007 # CONFIG_X86_32=y -CONFIG_GENERIC_TIME=y -CONFIG_CLOCKSOURCE_WATCHDOG=y -CONFIG_GENERIC_CLOCKEVENTS=y -CONFIG_LOCKDEP_SUPPORT=y -CONFIG_STACKTRACE_SUPPORT=y CONFIG_SEMAPHORE_SLEEPERS=y CONFIG_X86=y CONFIG_MMU=y -CONFIG_ZONE_DMA=y -CONFIG_QUICKLIST=y CONFIG_GENERIC_ISA_DMA=y CONFIG_GENERIC_IOMAP=y -CONFIG_GENERIC_BUG=y -CONFIG_GENERIC_HWEIGHT=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_DMI=y -CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" # # Code maturity level options @@ -36,25 +26,17 @@ CONFIG_LOCALVERSION="" # CONFIG_LOCALVERSION_AUTO is not set CONFIG_SWAP=y CONFIG_SYSVIPC=y -# CONFIG_IPC_NS is not set -CONFIG_SYSVIPC_SYSCTL=y CONFIG_POSIX_MQUEUE=y # CONFIG_BSD_PROCESS_ACCT is not set -# CONFIG_TASKSTATS is not set -# CONFIG_UTS_NS is not set +CONFIG_SYSCTL=y CONFIG_AUDIT=y CONFIG_AUDITSYSCALL=y # CONFIG_IKCONFIG is not set -CONFIG_LOG_BUF_SHIFT=14 -CONFIG_SYSFS_DEPRECATED=y -CONFIG_RELAY=y -CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" +CONFIG_UID16=y +CONFIG_VM86=y CONFIG_CC_OPTIMIZE_FOR_SIZE=y -CONFIG_SYSCTL=y # CONFIG_EMBEDDED is not set -CONFIG_UID16=y -CONFIG_SYSCTL_SYSCALL=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_EXTRA_PASS is not set CONFIG_HOTPLUG=y @@ -63,20 +45,16 @@ CONFIG_BUG=y CONFIG_ELF_CORE=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y -CONFIG_ANON_INODES=y CONFIG_EPOLL=y -CONFIG_SIGNALFD=y -CONFIG_TIMERFD=y -CONFIG_EVENTFD=y CONFIG_SHMEM=y -CONFIG_VM_EVENT_COUNTERS=y -CONFIG_SLUB_DEBUG=y -# CONFIG_SLAB is not set -CONFIG_SLUB=y -# CONFIG_SLOB is not set -CONFIG_RT_MUTEXES=y +CONFIG_CC_ALIGN_FUNCTIONS=0 +CONFIG_CC_ALIGN_LABELS=0 +CONFIG_CC_ALIGN_LOOPS=0 +CONFIG_CC_ALIGN_JUMPS=0 +CONFIG_SLAB=y # CONFIG_TINY_SHMEM is not set CONFIG_BASE_SMALL=0 +# CONFIG_SLOB is not set # # Loadable module support @@ -84,17 +62,15 @@ CONFIG_BASE_SMALL=0 CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y -CONFIG_MODVERSIONS=y +CONFIG_OBSOLETE_MODPARM=y +# CONFIG_MODVERSIONS is not set # CONFIG_MODULE_SRCVERSION_ALL is not set CONFIG_KMOD=y # # Block layer # -CONFIG_BLOCK=y -CONFIG_LBD=y -CONFIG_BLK_DEV_IO_TRACE=y -CONFIG_LSF=y +# CONFIG_LBD is not set # # IO Schedulers @@ -112,10 +88,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory" # # Processor type and features # -CONFIG_TICK_ONESHOT=y -CONFIG_NO_HZ=y -CONFIG_HIGH_RES_TIMERS=y -# CONFIG_SMP is not set CONFIG_X86_PC=y # CONFIG_X86_ELAN is not set # CONFIG_X86_VOYAGER is not set @@ -125,7 +97,6 @@ CONFIG_X86_PC=y # CONFIG_X86_VISWS is not set # CONFIG_X86_GENERICARCH is not set # CONFIG_X86_ES7000 is not set -# CONFIG_PARAVIRT is not set # CONFIG_M386 is not set # CONFIG_M486 is not set CONFIG_M586=y @@ -135,7 +106,6 @@ CONFIG_M586=y # CONFIG_MPENTIUMII is not set # CONFIG_MPENTIUMIII is not set # CONFIG_MPENTIUMM is not set -# CONFIG_MCORE2 is not set # CONFIG_MPENTIUM4 is not set # CONFIG_MK6 is not set # CONFIG_MK7 is not set @@ -149,14 +119,11 @@ CONFIG_M586=y # CONFIG_MGEODE_LX is not set # CONFIG_MCYRIXIII is not set # CONFIG_MVIAC3_2 is not set -# CONFIG_MVIAC7 is not set CONFIG_X86_GENERIC=y CONFIG_X86_CMPXCHG=y -CONFIG_X86_L1_CACHE_SHIFT=7 CONFIG_X86_XADD=y +CONFIG_X86_L1_CACHE_SHIFT=7 CONFIG_RWSEM_XCHGADD_ALGORITHM=y -# CONFIG_ARCH_HAS_ILOG2_U32 is not set -# CONFIG_ARCH_HAS_ILOG2_U64 is not set CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_X86_PPRO_FENCE=y CONFIG_X86_F00F_BUG=y @@ -164,18 +131,18 @@ CONFIG_X86_WP_WORKS_OK=y CONFIG_X86_INVLPG=y CONFIG_X86_BSWAP=y CONFIG_X86_POPAD_OK=y +CONFIG_X86_CMPXCHG64=y CONFIG_X86_ALIGNMENT_16=y CONFIG_X86_INTEL_USERCOPY=y -CONFIG_X86_MINIMUM_CPU_MODEL=4 CONFIG_HPET_TIMER=y CONFIG_HPET_EMULATE_RTC=y +# CONFIG_SMP is not set CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set # CONFIG_PREEMPT is not set # CONFIG_X86_UP_APIC is not set CONFIG_X86_MCE=y CONFIG_X86_MCE_NONFATAL=m -CONFIG_VM86=y # CONFIG_TOSHIBA is not set # CONFIG_I8K is not set CONFIG_X86_REBOOTFIXUPS=y @@ -192,12 +159,15 @@ CONFIG_X86_CPUID=y # CONFIG_NOHIGHMEM is not set CONFIG_HIGHMEM4G=y # CONFIG_HIGHMEM64G is not set +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_3G_OPT is not set +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set CONFIG_PAGE_OFFSET=0xC0000000 CONFIG_HIGHMEM=y CONFIG_ARCH_FLATMEM_ENABLE=y CONFIG_ARCH_SPARSEMEM_ENABLE=y CONFIG_ARCH_SELECT_MEMORY_MODEL=y -CONFIG_ARCH_POPULATES_NODE_MAP=y CONFIG_SELECT_MEMORY_MODEL=y CONFIG_FLATMEM_MANUAL=y # CONFIG_DISCONTIGMEM_MANUAL is not set @@ -206,25 +176,20 @@ CONFIG_FLATMEM=y CONFIG_FLAT_NODE_MEM_MAP=y CONFIG_SPARSEMEM_STATIC=y CONFIG_SPLIT_PTLOCK_CPUS=4 -# CONFIG_RESOURCES_64BIT is not set -CONFIG_ZONE_DMA_FLAG=1 -CONFIG_NR_QUICK=1 # CONFIG_HIGHPTE is not set CONFIG_MATH_EMULATION=y # CONFIG_MTRR is not set # CONFIG_EFI is not set +# CONFIG_REGPARM is not set CONFIG_SECCOMP=y CONFIG_HZ_100=y # CONFIG_HZ_250 is not set -# CONFIG_HZ_300 is not set # CONFIG_HZ_1000 is not set CONFIG_HZ=100 # CONFIG_KEXEC is not set # CONFIG_CRASH_DUMP is not set CONFIG_PHYSICAL_START=0x100000 -# CONFIG_RELOCATABLE is not set -CONFIG_PHYSICAL_ALIGN=0x100000 -# CONFIG_COMPAT_VDSO is not set +CONFIG_DOUBLEFAULT=y CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y # @@ -233,7 +198,6 @@ CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y CONFIG_PM=y CONFIG_PM_LEGACY=y # CONFIG_PM_DEBUG is not set -# CONFIG_PM_SYSFS_DEPRECATED is not set # CONFIG_SOFTWARE_SUSPEND is not set # @@ -243,18 +207,17 @@ CONFIG_ACPI=y CONFIG_ACPI_SLEEP=y CONFIG_ACPI_SLEEP_PROC_FS=y # CONFIG_ACPI_SLEEP_PROC_SLEEP is not set -# CONFIG_ACPI_PROCFS is not set CONFIG_ACPI_AC=m CONFIG_ACPI_BATTERY=m CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m +# CONFIG_ACPI_HOTKEY is not set CONFIG_ACPI_FAN=m -CONFIG_ACPI_DOCK=m -# CONFIG_ACPI_BAY is not set CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m -CONFIG_ACPI_ASUS=m -CONFIG_ACPI_TOSHIBA=m +# CONFIG_ACPI_ASUS is not set +# CONFIG_ACPI_IBM is not set +# CONFIG_ACPI_TOSHIBA is not set # CONFIG_ACPI_CUSTOM_DSDT is not set CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set @@ -263,12 +226,16 @@ CONFIG_ACPI_POWER=y CONFIG_ACPI_SYSTEM=y CONFIG_X86_PM_TIMER=y # CONFIG_ACPI_CONTAINER is not set -# CONFIG_ACPI_SBS is not set + +# +# APM (Advanced Power Management) BIOS Support +# CONFIG_APM=m CONFIG_APM_IGNORE_USER_SUSPEND=y # CONFIG_APM_DO_ENABLE is not set # CONFIG_APM_CPU_IDLE is not set # CONFIG_APM_DISPLAY_BLANK is not set +CONFIG_APM_RTC_IS_GMT=y # CONFIG_APM_ALLOW_INTS is not set # CONFIG_APM_REAL_MODE_POWER_OFF is not set @@ -306,8 +273,6 @@ CONFIG_X86_SPEEDSTEP_SMI=m CONFIG_X86_P4_CLOCKMOD=m CONFIG_X86_CPUFREQ_NFORCE2=m CONFIG_X86_LONGRUN=m -CONFIG_X86_LONGHAUL=m -CONFIG_X86_E_POWERSAVER=m # # shared options @@ -328,17 +293,27 @@ CONFIG_PCI_BIOS=y CONFIG_PCI_DIRECT=y CONFIG_PCI_MMCONFIG=y CONFIG_PCIEPORTBUS=y -CONFIG_PCIEAER=y -# CONFIG_ARCH_SUPPORTS_MSI is not set +CONFIG_PCI_LEGACY_PROC=y CONFIG_ISA_DMA_API=y -# CONFIG_ISA is not set -# CONFIG_MCA is not set +CONFIG_ISA=y +CONFIG_EISA=y +CONFIG_EISA_VLB_PRIMING=y +CONFIG_EISA_PCI_EISA=y +CONFIG_EISA_VIRTUAL_ROOT=y +CONFIG_EISA_NAMES=y +CONFIG_MCA=y +CONFIG_MCA_LEGACY=y +# CONFIG_MCA_PROC_FS is not set # CONFIG_SCx200 is not set # # PCCARD (PCMCIA/CardBus) support # # CONFIG_PCCARD is not set + +# +# PCI Hotplug Support +# # CONFIG_HOTPLUG_PCI is not set # @@ -356,15 +331,13 @@ CONFIG_NET=y # # Networking options # +# CONFIG_NETDEBUG is not set CONFIG_PACKET=y CONFIG_PACKET_MMAP=y CONFIG_UNIX=y CONFIG_XFRM=y CONFIG_XFRM_USER=m -# CONFIG_XFRM_SUB_POLICY is not set -# CONFIG_XFRM_MIGRATE is not set CONFIG_NET_KEY=m -# CONFIG_NET_KEY_MIGRATE is not set CONFIG_INET=y CONFIG_IP_MULTICAST=y CONFIG_IP_ADVANCED_ROUTER=y @@ -372,6 +345,7 @@ CONFIG_ASK_IP_FIB_HASH=y # CONFIG_IP_FIB_TRIE is not set CONFIG_IP_FIB_HASH=y CONFIG_IP_MULTIPLE_TABLES=y +# CONFIG_IP_ROUTE_FWMARK is not set CONFIG_IP_ROUTE_MULTIPATH=y # CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set CONFIG_IP_ROUTE_VERBOSE=y @@ -384,17 +358,18 @@ CONFIG_IP_PIMSM_V1=y CONFIG_IP_PIMSM_V2=y CONFIG_ARPD=y CONFIG_SYN_COOKIES=y +CONFIG_IPSEC_NAT_TRAVERSAL=y CONFIG_INET_AH=m CONFIG_INET_ESP=m CONFIG_INET_IPCOMP=m -CONFIG_INET_XFRM_TUNNEL=m CONFIG_INET_TUNNEL=m -CONFIG_INET_XFRM_MODE_TRANSPORT=m -CONFIG_INET_XFRM_MODE_TUNNEL=m -CONFIG_INET_XFRM_MODE_BEET=m CONFIG_INET_DIAG=m CONFIG_INET_TCP_DIAG=m CONFIG_TCP_CONG_ADVANCED=y + +# +# TCP congestion control +# CONFIG_TCP_CONG_BIC=m CONFIG_TCP_CONG_CUBIC=m CONFIG_TCP_CONG_WESTWOOD=m @@ -403,23 +378,12 @@ CONFIG_TCP_CONG_HSTCP=m CONFIG_TCP_CONG_HYBLA=m CONFIG_TCP_CONG_VEGAS=m CONFIG_TCP_CONG_SCALABLE=m -CONFIG_TCP_CONG_LP=m -CONFIG_TCP_CONG_VENO=m -CONFIG_TCP_CONG_YEAH=m -CONFIG_TCP_CONG_ILLINOIS=m -# CONFIG_DEFAULT_BIC is not set -# CONFIG_DEFAULT_CUBIC is not set -# CONFIG_DEFAULT_HTCP is not set -# CONFIG_DEFAULT_VEGAS is not set -# CONFIG_DEFAULT_WESTWOOD is not set -CONFIG_DEFAULT_RENO=y -CONFIG_DEFAULT_TCP_CONG="reno" -# CONFIG_TCP_MD5SIG is not set + +# +# IP: Virtual Server Configuration +# # CONFIG_IP_VS is not set # CONFIG_IPV6 is not set -# CONFIG_INET6_XFRM_TUNNEL is not set -# CONFIG_INET6_TUNNEL is not set -CONFIG_NETWORK_SECMARK=y CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set CONFIG_BRIDGE_NETFILTER=y @@ -430,106 +394,95 @@ CONFIG_BRIDGE_NETFILTER=y CONFIG_NETFILTER_NETLINK=m CONFIG_NETFILTER_NETLINK_QUEUE=m CONFIG_NETFILTER_NETLINK_LOG=m -CONFIG_NF_CONNTRACK_ENABLED=m -CONFIG_NF_CONNTRACK=m -CONFIG_NF_CT_ACCT=y -CONFIG_NF_CONNTRACK_MARK=y -CONFIG_NF_CONNTRACK_SECMARK=y -# CONFIG_NF_CONNTRACK_EVENTS is not set -CONFIG_NF_CT_PROTO_GRE=m -# CONFIG_NF_CT_PROTO_SCTP is not set -CONFIG_NF_CONNTRACK_AMANDA=m -CONFIG_NF_CONNTRACK_FTP=m -CONFIG_NF_CONNTRACK_H323=m -CONFIG_NF_CONNTRACK_IRC=m -CONFIG_NF_CONNTRACK_NETBIOS_NS=m -CONFIG_NF_CONNTRACK_PPTP=m -# CONFIG_NF_CONNTRACK_SANE is not set -CONFIG_NF_CONNTRACK_SIP=m -CONFIG_NF_CONNTRACK_TFTP=m -CONFIG_NF_CT_NETLINK=m CONFIG_NETFILTER_XTABLES=m CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m CONFIG_NETFILTER_XT_TARGET_CONNMARK=m -# CONFIG_NETFILTER_XT_TARGET_DSCP is not set CONFIG_NETFILTER_XT_TARGET_MARK=m CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m -CONFIG_NETFILTER_XT_TARGET_NFLOG=m CONFIG_NETFILTER_XT_TARGET_NOTRACK=m -CONFIG_NETFILTER_XT_TARGET_SECMARK=m -CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m -CONFIG_NETFILTER_XT_TARGET_TCPMSS=m CONFIG_NETFILTER_XT_MATCH_COMMENT=m CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m CONFIG_NETFILTER_XT_MATCH_CONNMARK=m CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m CONFIG_NETFILTER_XT_MATCH_DCCP=m -# CONFIG_NETFILTER_XT_MATCH_DSCP is not set -CONFIG_NETFILTER_XT_MATCH_ESP=m CONFIG_NETFILTER_XT_MATCH_HELPER=m CONFIG_NETFILTER_XT_MATCH_LENGTH=m CONFIG_NETFILTER_XT_MATCH_LIMIT=m CONFIG_NETFILTER_XT_MATCH_MAC=m CONFIG_NETFILTER_XT_MATCH_MARK=m -CONFIG_NETFILTER_XT_MATCH_POLICY=m -CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m -CONFIG_NETFILTER_XT_MATCH_QUOTA=m CONFIG_NETFILTER_XT_MATCH_REALM=m CONFIG_NETFILTER_XT_MATCH_SCTP=m CONFIG_NETFILTER_XT_MATCH_STATE=m -CONFIG_NETFILTER_XT_MATCH_LAYER7=m -# CONFIG_NETFILTER_XT_MATCH_LAYER7_DEBUG is not set -CONFIG_NETFILTER_XT_MATCH_STATISTIC=m CONFIG_NETFILTER_XT_MATCH_STRING=m CONFIG_NETFILTER_XT_MATCH_TCPMSS=m -CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m # # IP: Netfilter Configuration # -CONFIG_NF_CONNTRACK_IPV4=m -CONFIG_NF_CONNTRACK_PROC_COMPAT=y +CONFIG_IP_NF_CONNTRACK=m +CONFIG_IP_NF_CT_ACCT=y +CONFIG_IP_NF_CONNTRACK_MARK=y +CONFIG_IP_NF_CONNTRACK_EVENTS=y +CONFIG_IP_NF_CONNTRACK_NETLINK=m +CONFIG_IP_NF_CT_PROTO_SCTP=m +CONFIG_IP_NF_FTP=m +CONFIG_IP_NF_IRC=m +CONFIG_IP_NF_NETBIOS_NS=m +CONFIG_IP_NF_TFTP=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_PPTP=m +CONFIG_IP_NF_H323=m CONFIG_IP_NF_QUEUE=m CONFIG_IP_NF_IPTABLES=m CONFIG_IP_NF_MATCH_IPRANGE=m +CONFIG_IP_NF_MATCH_LAYER7=m +# CONFIG_IP_NF_MATCH_LAYER7_DEBUG is not set +CONFIG_IP_NF_MATCH_MULTIPORT=m CONFIG_IP_NF_MATCH_TOS=m CONFIG_IP_NF_MATCH_RECENT=m CONFIG_IP_NF_MATCH_ECN=m -CONFIG_IP_NF_MATCH_AH=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m CONFIG_IP_NF_MATCH_TTL=m CONFIG_IP_NF_MATCH_OWNER=m CONFIG_IP_NF_MATCH_ADDRTYPE=m +CONFIG_IP_NF_MATCH_HASHLIMIT=m +CONFIG_IP_NF_MATCH_POLICY=m CONFIG_IP_NF_FILTER=m CONFIG_IP_NF_TARGET_REJECT=m CONFIG_IP_NF_TARGET_LOG=m CONFIG_IP_NF_TARGET_ULOG=m -CONFIG_NF_NAT=m -CONFIG_NF_NAT_NEEDED=y +CONFIG_IP_NF_TARGET_TCPMSS=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_NAT_NEEDED=y CONFIG_IP_NF_TARGET_MASQUERADE=m CONFIG_IP_NF_TARGET_REDIRECT=m CONFIG_IP_NF_TARGET_NETMAP=m CONFIG_IP_NF_TARGET_SAME=m -CONFIG_NF_NAT_SNMP_BASIC=m -CONFIG_NF_NAT_PROTO_GRE=m -CONFIG_NF_NAT_FTP=m -CONFIG_NF_NAT_IRC=m -CONFIG_NF_NAT_TFTP=m -CONFIG_NF_NAT_AMANDA=m -CONFIG_NF_NAT_PPTP=m -CONFIG_NF_NAT_H323=m -CONFIG_NF_NAT_SIP=m +CONFIG_IP_NF_NAT_SNMP_BASIC=m +CONFIG_IP_NF_NAT_IRC=m +CONFIG_IP_NF_NAT_FTP=m +CONFIG_IP_NF_NAT_TFTP=m +CONFIG_IP_NF_NAT_AMANDA=m +CONFIG_IP_NF_NAT_PPTP=m +CONFIG_IP_NF_NAT_H323=m CONFIG_IP_NF_MANGLE=m CONFIG_IP_NF_TARGET_IMQ=m CONFIG_IP_NF_TARGET_TOS=m CONFIG_IP_NF_TARGET_ECN=m +CONFIG_IP_NF_TARGET_DSCP=m CONFIG_IP_NF_TARGET_TTL=m CONFIG_IP_NF_TARGET_CLUSTERIP=m CONFIG_IP_NF_RAW=m CONFIG_IP_NF_ARPTABLES=m CONFIG_IP_NF_ARPFILTER=m CONFIG_IP_NF_ARP_MANGLE=m +CONFIG_IP_NF_NAT_MMS=m +CONFIG_IP_NF_MMS=m +CONFIG_IP_NF_NAT_SIP=m +CONFIG_IP_NF_SIP=m # # Bridge: Netfilter Configuration @@ -554,13 +507,20 @@ CONFIG_BRIDGE_EBT_REDIRECT=m CONFIG_BRIDGE_EBT_SNAT=m CONFIG_BRIDGE_EBT_LOG=m # CONFIG_BRIDGE_EBT_ULOG is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# # CONFIG_IP_DCCP is not set -CONFIG_IP_SCTP=m -# CONFIG_SCTP_DBG_MSG is not set -# CONFIG_SCTP_DBG_OBJCNT is not set -# CONFIG_SCTP_HMAC_NONE is not set -# CONFIG_SCTP_HMAC_SHA1 is not set -CONFIG_SCTP_HMAC_MD5=y + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set + +# +# TIPC Configuration (EXPERIMENTAL) +# # CONFIG_TIPC is not set CONFIG_ATM=m CONFIG_ATM_CLIP=m @@ -571,12 +531,12 @@ CONFIG_ATM_BR2684=m CONFIG_BRIDGE=m CONFIG_VLAN_8021Q=m # CONFIG_DECNET is not set -CONFIG_LLC=m # CONFIG_LLC2 is not set # CONFIG_IPX is not set # CONFIG_ATALK is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -584,7 +544,9 @@ CONFIG_LLC=m # QoS and/or fair queueing # CONFIG_NET_SCHED=y -CONFIG_NET_SCH_FIFO=y +CONFIG_NET_SCH_CLK_JIFFIES=y +# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set +# CONFIG_NET_SCH_CLK_CPU is not set # # Queueing/Scheduling @@ -613,7 +575,7 @@ CONFIG_NET_CLS_ROUTE4=m CONFIG_NET_CLS_ROUTE=y CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m -CONFIG_CLS_U32_PERF=y +# CONFIG_CLS_U32_PERF is not set CONFIG_CLS_U32_MARK=y CONFIG_NET_CLS_RSVP=m CONFIG_NET_CLS_RSVP6=y @@ -625,12 +587,11 @@ CONFIG_NET_EMATCH_U32=m CONFIG_NET_EMATCH_META=m CONFIG_NET_EMATCH_TEXT=m CONFIG_NET_CLS_ACT=y -CONFIG_NET_ACT_POLICE=m -CONFIG_NET_ACT_GACT=m -CONFIG_GACT_PROB=y -CONFIG_NET_ACT_MIRRED=m -CONFIG_NET_ACT_IPT=m -CONFIG_NET_ACT_PEDIT=m +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_IPT is not set +# CONFIG_NET_ACT_PEDIT is not set # CONFIG_NET_ACT_SIMP is not set CONFIG_NET_CLS_IND=y CONFIG_NET_ESTIMATOR=y @@ -642,28 +603,11 @@ CONFIG_NET_ESTIMATOR=y # CONFIG_HAMRADIO is not set # CONFIG_IRDA is not set # CONFIG_BT is not set -CONFIG_AF_RXRPC=m -# CONFIG_AF_RXRPC_DEBUG is not set -# CONFIG_RXKAD is not set -CONFIG_FIB_RULES=y - -# -# Wireless -# -CONFIG_CFG80211=m -CONFIG_WIRELESS_EXT=y -CONFIG_MAC80211=m -CONFIG_MAC80211_LEDS=y -# CONFIG_MAC80211_DEBUGFS is not set -# CONFIG_MAC80211_DEBUG is not set CONFIG_IEEE80211=m # CONFIG_IEEE80211_DEBUG is not set CONFIG_IEEE80211_CRYPT_WEP=m -CONFIG_IEEE80211_CRYPT_CCMP=m -CONFIG_IEEE80211_CRYPT_TKIP=m -CONFIG_IEEE80211_SOFTMAC=m -# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set -# CONFIG_RFKILL is not set +# CONFIG_IEEE80211_CRYPT_CCMP is not set +# CONFIG_IEEE80211_CRYPT_TKIP is not set CONFIG_KLIPS=m # @@ -679,7 +623,7 @@ CONFIG_KLIPS_ENC_3DES=y CONFIG_KLIPS_ENC_AES=y # CONFIG_KLIPS_ENC_NULL is not set CONFIG_KLIPS_IPCOMP=y -# CONFIG_KLIPS_DEBUG is not set +CONFIG_KLIPS_DEBUG=y # # Device Drivers @@ -691,30 +635,32 @@ CONFIG_KLIPS_IPCOMP=y # CONFIG_STANDALONE is not set # CONFIG_PREVENT_FIRMWARE_BUILD is not set CONFIG_FW_LOADER=m -# CONFIG_SYS_HYPERVISOR is not set # # Connector - unified userspace <-> kernelspace linker # CONFIG_CONNECTOR=m + +# +# Memory Technology Devices (MTD) +# CONFIG_MTD=m # CONFIG_MTD_DEBUG is not set CONFIG_MTD_CONCAT=m CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y # # User Modules And Translation Layers # CONFIG_MTD_CHAR=m -CONFIG_MTD_BLKDEVS=m CONFIG_MTD_BLOCK=m # CONFIG_MTD_BLOCK_RO is not set # CONFIG_FTL is not set # CONFIG_NFTL is not set # CONFIG_INFTL is not set # CONFIG_RFD_FTL is not set -CONFIG_SSFDC=m # # RAM/ROM/Flash chip drivers @@ -734,6 +680,7 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_RAM is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_ABSENT is not set +# CONFIG_MTD_OBSOLETE_CHIPS is not set # # Mapping drivers for chip access @@ -749,6 +696,7 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_SLRAM is not set # CONFIG_MTD_PHRAM is not set # CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLKMTD is not set # CONFIG_MTD_BLOCK2MTD is not set # @@ -757,21 +705,16 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_DOC2000 is not set # CONFIG_MTD_DOC2001 is not set # CONFIG_MTD_DOC2001PLUS is not set -# CONFIG_MTD_NAND is not set -# CONFIG_MTD_ONENAND is not set # -# UBI - Unsorted block images +# NAND Flash Device Drivers # -CONFIG_MTD_UBI=m -CONFIG_MTD_UBI_WL_THRESHOLD=4096 -CONFIG_MTD_UBI_BEB_RESERVE=1 -CONFIG_MTD_UBI_GLUEBI=y +# CONFIG_MTD_NAND is not set # -# UBI debugging options +# OneNAND Flash Device Drivers # -# CONFIG_MTD_UBI_DEBUG is not set +# CONFIG_MTD_ONENAND is not set # # Parallel port support @@ -782,9 +725,7 @@ CONFIG_PARPORT_PC=m # CONFIG_PARPORT_PC_FIFO is not set # CONFIG_PARPORT_PC_SUPERIO is not set # CONFIG_PARPORT_GSC is not set -CONFIG_PARPORT_AX88796=m # CONFIG_PARPORT_1284 is not set -CONFIG_PARPORT_NOT_PC=y # # Plug and Play support @@ -795,12 +736,16 @@ CONFIG_PNP=y # # Protocols # +# CONFIG_ISAPNP is not set +CONFIG_PNPBIOS=y +CONFIG_PNPBIOS_PROC_FS=y CONFIG_PNPACPI=y # # Block devices # CONFIG_BLK_DEV_FD=m +# CONFIG_BLK_DEV_XD is not set # CONFIG_PARIDE is not set CONFIG_BLK_CPQ_DA=m CONFIG_BLK_CPQ_CISS_DA=m @@ -816,22 +761,13 @@ CONFIG_BLK_DEV_UB=m CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=8192 -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 +CONFIG_BLK_DEV_INITRD=y # CONFIG_CDROM_PKTCDVD is not set # CONFIG_ATA_OVER_ETH is not set # -# Misc devices +# ATA/ATAPI/MFM/RLL support # -# CONFIG_IBM_ASM is not set -CONFIG_PHANTOM=m -# CONFIG_SGI_IOC4 is not set -CONFIG_TIFM_CORE=m -CONFIG_TIFM_7XX1=m -# CONFIG_ASUS_LAPTOP is not set -# CONFIG_MSI_LAPTOP is not set -# CONFIG_SONY_LAPTOP is not set -# CONFIG_THINKPAD_ACPI is not set CONFIG_IDE=y CONFIG_BLK_DEV_IDE=m @@ -846,9 +782,7 @@ CONFIG_BLK_DEV_IDECD=m # CONFIG_BLK_DEV_IDETAPE is not set CONFIG_BLK_DEV_IDEFLOPPY=m # CONFIG_BLK_DEV_IDESCSI is not set -CONFIG_BLK_DEV_IDEACPI=y # CONFIG_IDE_TASK_IOCTL is not set -CONFIG_IDE_PROC_FS=y # # IDE chipset support/bugfixes @@ -859,13 +793,13 @@ CONFIG_BLK_DEV_CMD640=y CONFIG_BLK_DEV_IDEPNP=y CONFIG_BLK_DEV_IDEPCI=y CONFIG_IDEPCI_SHARE_IRQ=y -# CONFIG_IDEPCI_PCIBUS_ORDER is not set # CONFIG_BLK_DEV_OFFBOARD is not set CONFIG_BLK_DEV_GENERIC=m CONFIG_BLK_DEV_OPTI621=m CONFIG_BLK_DEV_RZ1000=m CONFIG_BLK_DEV_IDEDMA_PCI=y # CONFIG_BLK_DEV_IDEDMA_FORCED is not set +CONFIG_IDEDMA_PCI_AUTO=y # CONFIG_IDEDMA_ONLYDISK is not set CONFIG_BLK_DEV_AEC62XX=m CONFIG_BLK_DEV_ALI15X3=m @@ -881,10 +815,8 @@ CONFIG_BLK_DEV_CS5530=m CONFIG_BLK_DEV_HPT34X=m # CONFIG_HPT34X_AUTODMA is not set CONFIG_BLK_DEV_HPT366=m -CONFIG_BLK_DEV_JMICRON=m CONFIG_BLK_DEV_SC1200=m CONFIG_BLK_DEV_PIIX=m -CONFIG_BLK_DEV_IT8213=m CONFIG_BLK_DEV_IT821X=m CONFIG_BLK_DEV_NS87415=m CONFIG_BLK_DEV_PDC202XX_OLD=m @@ -896,10 +828,21 @@ CONFIG_BLK_DEV_SIS5513=m CONFIG_BLK_DEV_SLC90E66=m CONFIG_BLK_DEV_TRM290=m CONFIG_BLK_DEV_VIA82CXXX=m -CONFIG_BLK_DEV_TC86C001=m # CONFIG_IDE_ARM is not set +CONFIG_IDE_CHIPSETS=y + +# +# Note: most of these also require special kernel boot parameters +# +CONFIG_BLK_DEV_4DRIVES=y +CONFIG_BLK_DEV_ALI14XX=m +CONFIG_BLK_DEV_DTC2278=m +CONFIG_BLK_DEV_HT6560B=m +CONFIG_BLK_DEV_QD65XX=m +CONFIG_BLK_DEV_UMC8672=m CONFIG_BLK_DEV_IDEDMA=y # CONFIG_IDEDMA_IVB is not set +CONFIG_IDEDMA_AUTO=y # CONFIG_BLK_DEV_HD is not set # @@ -907,8 +850,6 @@ CONFIG_BLK_DEV_IDEDMA=y # CONFIG_RAID_ATTRS=y CONFIG_SCSI=m -CONFIG_SCSI_TGT=m -CONFIG_SCSI_NETLINK=y CONFIG_SCSI_PROC_FS=y # @@ -928,18 +869,14 @@ CONFIG_CHR_DEV_SCH=m CONFIG_SCSI_MULTI_LUN=y # CONFIG_SCSI_CONSTANTS is not set # CONFIG_SCSI_LOGGING is not set -CONFIG_SCSI_SCAN_ASYNC=y -CONFIG_SCSI_WAIT_SCAN=m # -# SCSI Transports +# SCSI Transport Attributes # CONFIG_SCSI_SPI_ATTRS=m CONFIG_SCSI_FC_ATTRS=m -CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_ISCSI_ATTRS is not set CONFIG_SCSI_SAS_ATTRS=m -CONFIG_SCSI_SAS_LIBSAS=m -# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set # # SCSI low-level drivers @@ -947,11 +884,16 @@ CONFIG_SCSI_SAS_LIBSAS=m # CONFIG_ISCSI_TCP is not set CONFIG_BLK_DEV_3W_XXXX_RAID=m CONFIG_SCSI_3W_9XXX=m +CONFIG_SCSI_7000FASST=m CONFIG_SCSI_ACARD=m +CONFIG_SCSI_AHA152X=m +CONFIG_SCSI_AHA1542=m +CONFIG_SCSI_AHA1740=m CONFIG_SCSI_AACRAID=m CONFIG_SCSI_AIC7XXX=m CONFIG_AIC7XXX_CMDS_PER_DEVICE=253 CONFIG_AIC7XXX_RESET_DELAY_MS=15000 +# CONFIG_AIC7XXX_PROBE_EISA_VL is not set # CONFIG_AIC7XXX_BUILD_FIRMWARE is not set # CONFIG_AIC7XXX_DEBUG_ENABLE is not set CONFIG_AIC7XXX_DEBUG_MASK=0 @@ -961,108 +903,98 @@ CONFIG_SCSI_AIC79XX=m CONFIG_AIC79XX_CMDS_PER_DEVICE=32 CONFIG_AIC79XX_RESET_DELAY_MS=15000 # CONFIG_AIC79XX_BUILD_FIRMWARE is not set +# CONFIG_AIC79XX_ENABLE_RD_STRM is not set # CONFIG_AIC79XX_DEBUG_ENABLE is not set CONFIG_AIC79XX_DEBUG_MASK=0 # CONFIG_AIC79XX_REG_PRETTY_PRINT is not set -CONFIG_SCSI_AIC94XX=m -# CONFIG_AIC94XX_DEBUG is not set CONFIG_SCSI_DPT_I2O=m CONFIG_SCSI_ADVANSYS=m +CONFIG_SCSI_IN2000=m CONFIG_SCSI_ARCMSR=m CONFIG_MEGARAID_NEWGEN=y CONFIG_MEGARAID_MM=m CONFIG_MEGARAID_MAILBOX=m CONFIG_MEGARAID_LEGACY=m CONFIG_MEGARAID_SAS=m +CONFIG_SCSI_SATA=m +CONFIG_SCSI_SATA_AHCI=m +CONFIG_SCSI_SATA_SVW=m +CONFIG_SCSI_ATA_PIIX=m +# CONFIG_SCSI_SATA_MV is not set +CONFIG_SCSI_SATA_NV=m +CONFIG_SCSI_PDC_ADMA=m CONFIG_SCSI_HPTIOP=m +CONFIG_SCSI_SATA_QSTOR=m +CONFIG_SCSI_SATA_PROMISE=m +CONFIG_SCSI_SATA_SX4=m +CONFIG_SCSI_SATA_SIL=m +CONFIG_SCSI_SATA_SIL24=m +CONFIG_SCSI_SATA_SIS=m +CONFIG_SCSI_SATA_ULI=m +CONFIG_SCSI_SATA_VIA=m +CONFIG_SCSI_SATA_VITESSE=m +CONFIG_SCSI_SATA_INTEL_COMBINED=y CONFIG_SCSI_BUSLOGIC=m # CONFIG_SCSI_OMIT_FLASHPOINT is not set CONFIG_SCSI_DMX3191D=m +CONFIG_SCSI_DTC3280=m CONFIG_SCSI_EATA=m CONFIG_SCSI_EATA_TAGGED_QUEUE=y CONFIG_SCSI_EATA_LINKED_COMMANDS=y CONFIG_SCSI_EATA_MAX_TAGS=16 CONFIG_SCSI_FUTURE_DOMAIN=m +CONFIG_SCSI_FD_MCS=m CONFIG_SCSI_GDTH=m +CONFIG_SCSI_GENERIC_NCR5380=m +CONFIG_SCSI_GENERIC_NCR5380_MMIO=m +CONFIG_SCSI_GENERIC_NCR53C400=y +CONFIG_SCSI_IBMMCA=m +# CONFIG_IBMMCA_SCSI_ORDER_STANDARD is not set +# CONFIG_IBMMCA_SCSI_DEV_RESET is not set CONFIG_SCSI_IPS=m CONFIG_SCSI_INITIO=m CONFIG_SCSI_INIA100=m # CONFIG_SCSI_PPA is not set # CONFIG_SCSI_IMM is not set -CONFIG_SCSI_STEX=m +CONFIG_SCSI_NCR53C406A=m +CONFIG_SCSI_NCR_D700=m CONFIG_SCSI_SYM53C8XX_2=m CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1 CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 -CONFIG_SCSI_SYM53C8XX_MMIO=y -CONFIG_SCSI_IPR=m -CONFIG_SCSI_IPR_TRACE=y -CONFIG_SCSI_IPR_DUMP=y +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set +# CONFIG_SCSI_IPR is not set +CONFIG_SCSI_NCR_Q720=m +CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 +CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 +CONFIG_SCSI_NCR53C8XX_SYNC=20 +# CONFIG_SCSI_NCR53C8XX_PROFILE is not set +# CONFIG_SCSI_MCA_53C9X is not set +CONFIG_SCSI_PAS16=m +CONFIG_SCSI_PSI240I=m +# CONFIG_SCSI_QLOGIC_FAS is not set +# CONFIG_SCSI_QLOGIC_FC is not set CONFIG_SCSI_QLOGIC_1280=m # CONFIG_SCSI_QLA_FC is not set -CONFIG_SCSI_QLA_ISCSI=m # CONFIG_SCSI_LPFC is not set +CONFIG_SCSI_SIM710=m +CONFIG_53C700_IO_MAPPED=y +CONFIG_SCSI_SYM53C416=m CONFIG_SCSI_DC395x=m CONFIG_SCSI_DC390T=m +CONFIG_SCSI_T128=m +CONFIG_SCSI_U14_34F=m +CONFIG_SCSI_U14_34F_TAGGED_QUEUE=y +CONFIG_SCSI_U14_34F_LINKED_COMMANDS=y +CONFIG_SCSI_U14_34F_MAX_TAGS=8 +CONFIG_SCSI_ULTRASTOR=m CONFIG_SCSI_NSP32=m # CONFIG_SCSI_DEBUG is not set -CONFIG_SCSI_SRP=m -CONFIG_ATA=m -# CONFIG_ATA_NONSTANDARD is not set -CONFIG_ATA_ACPI=y -CONFIG_SATA_AHCI=m -CONFIG_SATA_SVW=m -CONFIG_ATA_PIIX=m -CONFIG_SATA_MV=m -CONFIG_SATA_NV=m -CONFIG_PDC_ADMA=m -CONFIG_SATA_QSTOR=m -CONFIG_SATA_PROMISE=m -CONFIG_SATA_SX4=m -CONFIG_SATA_SIL=m -CONFIG_SATA_SIL24=m -CONFIG_SATA_SIS=m -CONFIG_SATA_ULI=m -CONFIG_SATA_VIA=m -CONFIG_SATA_VITESSE=m -CONFIG_SATA_INIC162X=m -CONFIG_PATA_ALI=m -CONFIG_PATA_AMD=m -CONFIG_PATA_ARTOP=m -CONFIG_PATA_ATIIXP=m -CONFIG_PATA_CMD640_PCI=m -CONFIG_PATA_CMD64X=m -CONFIG_PATA_CS5520=m -CONFIG_PATA_CS5530=m -CONFIG_PATA_CS5535=m -CONFIG_PATA_CYPRESS=m -CONFIG_PATA_EFAR=m -CONFIG_ATA_GENERIC=m -CONFIG_PATA_HPT366=m -CONFIG_PATA_HPT37X=m -CONFIG_PATA_HPT3X2N=m -CONFIG_PATA_HPT3X3=m -CONFIG_PATA_IT821X=m -CONFIG_PATA_IT8213=m -CONFIG_PATA_JMICRON=m -CONFIG_PATA_TRIFLEX=m -CONFIG_PATA_MARVELL=m -CONFIG_PATA_MPIIX=m -CONFIG_PATA_OLDPIIX=m -CONFIG_PATA_NETCELL=m -CONFIG_PATA_NS87410=m -CONFIG_PATA_OPTI=m -CONFIG_PATA_OPTIDMA=m -CONFIG_PATA_PDC_OLD=m -CONFIG_PATA_RADISYS=m -CONFIG_PATA_RZ1000=m -CONFIG_PATA_SC1200=m -CONFIG_PATA_SERVERWORKS=m -CONFIG_PATA_PDC2027X=m -CONFIG_PATA_SIL680=m -CONFIG_PATA_SIS=m -CONFIG_PATA_VIA=m -CONFIG_PATA_WINBOND=m + +# +# Old CD-ROM drivers (not SCSI, not IDE) +# +# CONFIG_CD_NO_IDESCSI is not set # # Multi-device support (RAID and LVM) @@ -1073,8 +1005,8 @@ CONFIG_MD_LINEAR=m CONFIG_MD_RAID0=m CONFIG_MD_RAID1=m # CONFIG_MD_RAID10 is not set -CONFIG_MD_RAID456=m -CONFIG_MD_RAID5_RESHAPE=y +CONFIG_MD_RAID5=m +# CONFIG_MD_RAID6 is not set CONFIG_MD_MULTIPATH=m # CONFIG_MD_FAULTY is not set # CONFIG_BLK_DEV_DM is not set @@ -1092,18 +1024,19 @@ CONFIG_FUSION_CTL=m # # IEEE 1394 (FireWire) support # -CONFIG_FIREWIRE=m -CONFIG_FIREWIRE_OHCI=m -CONFIG_FIREWIRE_SBP2=m CONFIG_IEEE1394=m # # Subsystem Options # # CONFIG_IEEE1394_VERBOSEDEBUG is not set +# CONFIG_IEEE1394_OUI_DB is not set +CONFIG_IEEE1394_EXTRA_CONFIG_ROMS=y +CONFIG_IEEE1394_CONFIG_ROM_IP1394=y +# CONFIG_IEEE1394_EXPORT_FULL_API is not set # -# Controllers +# Device Drivers # # @@ -1112,11 +1045,10 @@ CONFIG_IEEE1394=m CONFIG_IEEE1394_OHCI1394=m # -# Protocols +# Protocol Drivers # # CONFIG_IEEE1394_VIDEO1394 is not set # CONFIG_IEEE1394_SBP2 is not set -CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y CONFIG_IEEE1394_ETH1394=m # CONFIG_IEEE1394_DV1394 is not set # CONFIG_IEEE1394_RAWIO is not set @@ -1125,7 +1057,6 @@ CONFIG_IEEE1394_ETH1394=m # I2O device support # # CONFIG_I2O is not set -# CONFIG_MACINTOSH_DRIVERS is not set # # Network device support @@ -1143,7 +1074,15 @@ CONFIG_IMQ_BEHAVIOR_BA=y CONFIG_IMQ_NUM_DEVS=2 CONFIG_TUN=m CONFIG_NET_SB1000=m + +# +# ARCnet devices +# # CONFIG_ARCNET is not set + +# +# PHY device support +# CONFIG_PHYLIB=m # @@ -1154,12 +1093,6 @@ CONFIG_DAVICOM_PHY=m CONFIG_QSEMI_PHY=m CONFIG_LXT_PHY=m CONFIG_CICADA_PHY=m -CONFIG_VITESSE_PHY=m -CONFIG_SMSC_PHY=m -CONFIG_BROADCOM_PHY=m -CONFIG_FIXED_PHY=m -# CONFIG_FIXED_MII_10_FDX is not set -# CONFIG_FIXED_MII_100_FDX is not set # # Ethernet (10 or 100Mbit) @@ -1170,8 +1103,27 @@ CONFIG_HAPPYMEAL=m CONFIG_SUNGEM=m CONFIG_CASSINI=m CONFIG_NET_VENDOR_3COM=y +CONFIG_EL1=m +CONFIG_EL2=m +CONFIG_ELPLUS=m +CONFIG_EL16=m +CONFIG_EL3=m +CONFIG_3C515=m +CONFIG_ELMC=m +CONFIG_ELMC_II=m CONFIG_VORTEX=m CONFIG_TYPHOON=m +CONFIG_LANCE=m +CONFIG_NET_VENDOR_SMC=y +CONFIG_WD80x3=m +CONFIG_ULTRAMCA=m +CONFIG_ULTRA=m +CONFIG_ULTRA32=m +CONFIG_SMC9194=m +CONFIG_NET_VENDOR_RACAL=y +# CONFIG_NI5010 is not set +CONFIG_NI52=m +CONFIG_NI65=m # # Tulip family network device support @@ -1186,23 +1138,43 @@ CONFIG_DE4X5=m CONFIG_WINBOND_840=m CONFIG_DM9102=m CONFIG_ULI526X=m +CONFIG_AT1700=m +CONFIG_DEPCA=m CONFIG_HP100=m +CONFIG_NET_ISA=y +CONFIG_E2100=m +CONFIG_EWRK3=m +CONFIG_EEXPRESS=m +CONFIG_EEXPRESS_PRO=m +CONFIG_HPLAN_PLUS=m +CONFIG_HPLAN=m +CONFIG_LP486E=m +CONFIG_ETH16I=m +CONFIG_NE2000=m +CONFIG_ZNET=m +CONFIG_SEEQ8005=m +CONFIG_NE2_MCA=m +CONFIG_IBMLANA=m CONFIG_NET_PCI=y CONFIG_PCNET32=m -CONFIG_PCNET32_NAPI=y CONFIG_AMD8111_ETH=m CONFIG_AMD8111E_NAPI=y CONFIG_ADAPTEC_STARFIRE=m CONFIG_ADAPTEC_STARFIRE_NAPI=y +CONFIG_AC3200=m +CONFIG_APRICOT=m CONFIG_B44=m CONFIG_FORCEDETH=m -CONFIG_FORCEDETH_NAPI=y +CONFIG_CS89x0=m CONFIG_DGRS=m CONFIG_EEPRO100=m CONFIG_E100=m +CONFIG_LNE390=m CONFIG_FEALNX=m CONFIG_NATSEMI=m CONFIG_NE2K_PCI=m +CONFIG_NE3210=m +CONFIG_ES3210=m CONFIG_8139CP=m CONFIG_8139TOO=m # CONFIG_8139TOO_PIO is not set @@ -1216,13 +1188,14 @@ CONFIG_SUNDANCE_MMIO=y CONFIG_TLAN=m CONFIG_VIA_RHINE=m CONFIG_VIA_RHINE_MMIO=y -CONFIG_VIA_RHINE_NAPI=y -CONFIG_SC92031=y CONFIG_NET_POCKET=y CONFIG_ATP=m CONFIG_DE600=m CONFIG_DE620=m -CONFIG_NETDEV_1000=y + +# +# Ethernet (1000 Mbit) +# CONFIG_ACENIC=m # CONFIG_ACENIC_OMIT_TIGON_I is not set CONFIG_DL2K=m @@ -1242,40 +1215,41 @@ CONFIG_SK98LIN=m CONFIG_VIA_VELOCITY=m CONFIG_TIGON3=m CONFIG_BNX2=m -CONFIG_QLA3XXX=m -CONFIG_ATL1=m -CONFIG_NETDEV_10000=y + +# +# Ethernet (10000 Mbit) +# CONFIG_CHELSIO_T1=m -CONFIG_CHELSIO_T1_1G=y -CONFIG_CHELSIO_T1_NAPI=y -CONFIG_CHELSIO_T3=m CONFIG_IXGB=m # CONFIG_IXGB_NAPI is not set CONFIG_S2IO=m # CONFIG_S2IO_NAPI is not set -CONFIG_MYRI10GE=m -CONFIG_NETXEN_NIC=m -# CONFIG_MLX4_CORE is not set + +# +# Token Ring devices +# # CONFIG_TR is not set # -# Wireless LAN +# Wireless LAN (non-hamradio) +# +CONFIG_NET_RADIO=y + +# +# Obsolete Wireless cards support (pre-802.11) +# +# CONFIG_STRIP is not set +CONFIG_ARLAN=m +CONFIG_WAVELAN=m + +# +# Wireless 802.11b ISA/PCI cards support # -CONFIG_WLAN_PRE80211=y -CONFIG_STRIP=m -CONFIG_WLAN_80211=y CONFIG_IPW2100=m CONFIG_IPW2100_MONITOR=y # CONFIG_IPW2100_DEBUG is not set CONFIG_IPW2200=m -CONFIG_IPW2200_MONITOR=y -CONFIG_IPW2200_RADIOTAP=y -CONFIG_IPW2200_PROMISCUOUS=y -CONFIG_IPW2200_QOS=y # CONFIG_IPW2200_DEBUG is not set -CONFIG_LIBERTAS=m -CONFIG_LIBERTAS_USB=m -# CONFIG_LIBERTAS_DEBUG is not set CONFIG_AIRO=m CONFIG_HERMES=m CONFIG_PLX_HERMES=m @@ -1284,50 +1258,65 @@ CONFIG_NORTEL_HERMES=m CONFIG_PCI_HERMES=m CONFIG_ATMEL=m CONFIG_PCI_ATMEL=m + +# +# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support +# CONFIG_PRISM54=m -CONFIG_USB_ZD1201=m CONFIG_HOSTAP=m CONFIG_HOSTAP_FIRMWARE=y -CONFIG_HOSTAP_FIRMWARE_NVRAM=y +# CONFIG_HOSTAP_FIRMWARE_NVRAM is not set CONFIG_HOSTAP_PLX=m CONFIG_HOSTAP_PCI=m -CONFIG_BCM43XX=m -# CONFIG_BCM43XX_DEBUG is not set -CONFIG_BCM43XX_DMA=y -CONFIG_BCM43XX_PIO=y -CONFIG_BCM43XX_DMA_AND_PIO_MODE=y -# CONFIG_BCM43XX_DMA_MODE is not set -# CONFIG_BCM43XX_PIO_MODE is not set -CONFIG_ZD1211RW=m -# CONFIG_ZD1211RW_DEBUG is not set +CONFIG_NET_WIRELESS=y # -# USB Network Adapters +# Wan interfaces # -CONFIG_USB_CATC=m -CONFIG_USB_KAWETH=m -CONFIG_USB_PEGASUS=m -CONFIG_USB_RTL8150=m -CONFIG_USB_USBNET_MII=m -CONFIG_USB_USBNET=m -CONFIG_USB_NET_AX8817X=m -CONFIG_USB_NET_CDCETHER=m -CONFIG_USB_NET_DM9601=m -CONFIG_USB_NET_GL620A=m -CONFIG_USB_NET_NET1080=m -CONFIG_USB_NET_PLUSB=m -CONFIG_USB_NET_MCS7830=m -CONFIG_USB_NET_RNDIS_HOST=m -CONFIG_USB_NET_CDC_SUBSET=m -CONFIG_USB_ALI_M5632=y -CONFIG_USB_AN2720=y -CONFIG_USB_BELKIN=y -CONFIG_USB_ARMLINUX=y -CONFIG_USB_EPSON2888=y -CONFIG_USB_KC2190=y -CONFIG_USB_NET_ZAURUS=m # CONFIG_WAN is not set -# CONFIG_ATM_DRIVERS is not set + +# +# ATM drivers +# +# CONFIG_ATM_DUMMY is not set +CONFIG_ATM_TCP=m +CONFIG_ATM_LANAI=m +CONFIG_ATM_ENI=m +CONFIG_ATM_ENI_DEBUG=y +CONFIG_ATM_ENI_TUNE_BURST=y +CONFIG_ATM_ENI_BURST_TX_16W=y +CONFIG_ATM_ENI_BURST_TX_8W=y +CONFIG_ATM_ENI_BURST_TX_4W=y +CONFIG_ATM_ENI_BURST_TX_2W=y +CONFIG_ATM_ENI_BURST_RX_16W=y +CONFIG_ATM_ENI_BURST_RX_8W=y +CONFIG_ATM_ENI_BURST_RX_4W=y +CONFIG_ATM_ENI_BURST_RX_2W=y +CONFIG_ATM_FIRESTREAM=m +CONFIG_ATM_ZATM=m +# CONFIG_ATM_ZATM_DEBUG is not set +CONFIG_ATM_NICSTAR=m +CONFIG_ATM_NICSTAR_USE_SUNI=y +CONFIG_ATM_NICSTAR_USE_IDT77105=y +CONFIG_ATM_IDT77252=m +# CONFIG_ATM_IDT77252_DEBUG is not set +# CONFIG_ATM_IDT77252_RCV_ALL is not set +CONFIG_ATM_IDT77252_USE_SUNI=y +CONFIG_ATM_AMBASSADOR=m +# CONFIG_ATM_AMBASSADOR_DEBUG is not set +CONFIG_ATM_HORIZON=m +# CONFIG_ATM_HORIZON_DEBUG is not set +CONFIG_ATM_IA=m +# CONFIG_ATM_IA_DEBUG is not set +CONFIG_ATM_FORE200E_MAYBE=m +CONFIG_ATM_FORE200E_PCA=y +CONFIG_ATM_FORE200E_PCA_DEFAULT_FW=y +CONFIG_ATM_FORE200E_USE_TASKLET=y +CONFIG_ATM_FORE200E_TX_RETRY=16 +CONFIG_ATM_FORE200E_DEBUG=0 +CONFIG_ATM_FORE200E=m +CONFIG_ATM_HE=m +CONFIG_ATM_HE_USE_SUNI=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set # CONFIG_PLIP is not set @@ -1343,7 +1332,6 @@ CONFIG_PPPOE=m CONFIG_PPPOATM=m CONFIG_SLIP=m CONFIG_SLIP_COMPRESSED=y -CONFIG_SLHC=m CONFIG_SLIP_SMART=y CONFIG_SLIP_MODE_SLIP6=y # CONFIG_NET_FC is not set @@ -1367,7 +1355,6 @@ CONFIG_ISDN=m # CONFIG_ISDN_CAPI=m CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y -CONFIG_CAPI_TRACE=y CONFIG_ISDN_CAPI_MIDDLEWARE=y CONFIG_ISDN_CAPI_CAPI20=m CONFIG_ISDN_CAPI_CAPIFS_BOOL=y @@ -1381,8 +1368,10 @@ CONFIG_ISDN_CAPI_CAPIFS=m # Active AVM cards # CONFIG_CAPI_AVM=y +CONFIG_ISDN_DRV_AVMB1_B1ISA=m CONFIG_ISDN_DRV_AVMB1_B1PCI=m CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y +CONFIG_ISDN_DRV_AVMB1_T1ISA=m CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m CONFIG_ISDN_DRV_AVMB1_T1PCI=m CONFIG_ISDN_DRV_AVMB1_C4=m @@ -1400,12 +1389,11 @@ CONFIG_MISDN_DRV=m CONFIG_MISDN_AVM_FRITZ=y CONFIG_MISDN_NETJET=y CONFIG_MISDN_HFCPCI=y -CONFIG_MISDN_HFCMULTI=y -# CONFIG_HFCMULTI_PCIMEM is not set +# CONFIG_MISDN_HFCMULTI is not set CONFIG_MISDN_HFCUSB=y -# CONFIG_MISDN_HFCMINI is not set -# CONFIG_MISDN_XHFC is not set -# CONFIG_MISDN_SPEEDFAX is not set +CONFIG_MISDN_HFCMINI=y +CONFIG_MISDN_XHFC=y +CONFIG_MISDN_SPEEDFAX=y CONFIG_MISDN_W6692=y CONFIG_MISDN_DSP=y CONFIG_MISDN_LOOP=y @@ -1420,8 +1408,6 @@ CONFIG_MISDN_L1OIP=y # Input device support # CONFIG_INPUT=y -# CONFIG_INPUT_FF_MEMLESS is not set -# CONFIG_INPUT_POLLDEV is not set # # Userland interfaces @@ -1444,20 +1430,12 @@ CONFIG_KEYBOARD_SUNKBD=m CONFIG_KEYBOARD_LKKBD=m CONFIG_KEYBOARD_XTKBD=m CONFIG_KEYBOARD_NEWTON=m -CONFIG_KEYBOARD_STOWAWAY=m # CONFIG_INPUT_MOUSE is not set # CONFIG_INPUT_JOYSTICK is not set -# CONFIG_INPUT_TABLET is not set # CONFIG_INPUT_TOUCHSCREEN is not set CONFIG_INPUT_MISC=y CONFIG_INPUT_PCSPKR=y # CONFIG_INPUT_WISTRON_BTNS is not set -CONFIG_INPUT_ATLAS_BTNS=m -CONFIG_INPUT_ATI_REMOTE=m -CONFIG_INPUT_ATI_REMOTE2=m -# CONFIG_INPUT_KEYSPAN_REMOTE is not set -# CONFIG_INPUT_POWERMATE is not set -# CONFIG_INPUT_YEALINK is not set # CONFIG_INPUT_UINPUT is not set # @@ -1479,15 +1457,13 @@ CONFIG_SERIO_LIBPS2=y CONFIG_VT=y CONFIG_VT_CONSOLE=y CONFIG_HW_CONSOLE=y -# CONFIG_VT_HW_CONSOLE_BINDING is not set # CONFIG_SERIAL_NONSTANDARD is not set # # Serial drivers # CONFIG_SERIAL_8250=m -CONFIG_SERIAL_8250_PCI=m -CONFIG_SERIAL_8250_PNP=m +# CONFIG_SERIAL_8250_ACPI is not set CONFIG_SERIAL_8250_NR_UARTS=4 CONFIG_SERIAL_8250_RUNTIME_UARTS=4 CONFIG_SERIAL_8250_EXTENDED=y @@ -1495,6 +1471,11 @@ CONFIG_SERIAL_8250_MANY_PORTS=y CONFIG_SERIAL_8250_SHARE_IRQ=y CONFIG_SERIAL_8250_DETECT_IRQ=y CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_FOURPORT is not set +# CONFIG_SERIAL_8250_ACCENT is not set +# CONFIG_SERIAL_8250_BOCA is not set +# CONFIG_SERIAL_8250_HUB6 is not set +# CONFIG_SERIAL_8250_MCA is not set # # Non-8250 serial port support @@ -1518,6 +1499,10 @@ CONFIG_IPMI_DEVICE_INTERFACE=m CONFIG_IPMI_SI=m CONFIG_IPMI_WATCHDOG=m CONFIG_IPMI_POWEROFF=m + +# +# Watchdog Cards +# CONFIG_WATCHDOG=y # CONFIG_WATCHDOG_NOWAYOUT is not set @@ -1535,21 +1520,24 @@ CONFIG_IB700_WDT=m CONFIG_IBMASR=m CONFIG_WAFER_WDT=m CONFIG_I6300ESB_WDT=m -CONFIG_ITCO_WDT=m -# CONFIG_ITCO_VENDOR_SUPPORT is not set +CONFIG_I8XX_TCO=m CONFIG_SC1200_WDT=m -CONFIG_PC87413_WDT=m CONFIG_60XX_WDT=m CONFIG_SBC8360_WDT=m CONFIG_CPU5_WDT=m -CONFIG_SMSC37B787_WDT=m CONFIG_W83627HF_WDT=m -CONFIG_W83697HF_WDT=m CONFIG_W83877F_WDT=m CONFIG_W83977F_WDT=m CONFIG_MACHZ_WDT=m CONFIG_SBC_EPX_C3_WATCHDOG=m +# +# ISA-based Watchdog Cards +# +# CONFIG_PCWATCHDOG is not set +# CONFIG_MIXCOMWD is not set +# CONFIG_WDT is not set + # # PCI-based Watchdog Cards # @@ -1562,20 +1550,20 @@ CONFIG_WDT_501_PCI=y # CONFIG_USBPCWATCHDOG=m CONFIG_HW_RANDOM=m -CONFIG_HW_RANDOM_INTEL=m -CONFIG_HW_RANDOM_AMD=m -CONFIG_HW_RANDOM_GEODE=m -CONFIG_HW_RANDOM_VIA=m # CONFIG_NVRAM is not set CONFIG_RTC=y +# CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set # CONFIG_SONYPI is not set + +# +# Ftape, the floppy tape device driver +# +# CONFIG_FTAPE is not set # CONFIG_AGP is not set # CONFIG_DRM is not set CONFIG_MWAVE=m -CONFIG_PC8736x_GPIO=m -CONFIG_NSC_GPIO=m CONFIG_CS5535_GPIO=m # CONFIG_RAW_DRIVER is not set CONFIG_HPET=y @@ -1588,7 +1576,10 @@ CONFIG_HANGCHECK_TIMER=m # # CONFIG_TCG_TPM is not set # CONFIG_TELCLOCK is not set -CONFIG_DEVPORT=y + +# +# I2C support +# # CONFIG_I2C is not set # @@ -1601,84 +1592,54 @@ CONFIG_DEVPORT=y # Dallas's 1-wire bus # CONFIG_W1=m -CONFIG_W1_CON=y - -# -# 1-wire Bus Masters -# -CONFIG_W1_MASTER_MATROX=m -CONFIG_W1_MASTER_DS2490=m +CONFIG_W1_MATROX=m +CONFIG_W1_DS9490=m +CONFIG_W1_DS9490_BRIDGE=m +CONFIG_W1_THERM=m +CONFIG_W1_SMEM=m +CONFIG_W1_DS2433=m +CONFIG_W1_DS2433_CRC=y # -# 1-wire Slaves +# Hardware Monitoring support # -CONFIG_W1_SLAVE_THERM=m -CONFIG_W1_SLAVE_SMEM=m -CONFIG_W1_SLAVE_DS2433=m -CONFIG_W1_SLAVE_DS2433_CRC=y CONFIG_HWMON=m -CONFIG_HWMON_VID=m -CONFIG_SENSORS_ABITUGURU=m +# CONFIG_HWMON_VID is not set CONFIG_SENSORS_K8TEMP=m CONFIG_SENSORS_F71805F=m -CONFIG_SENSORS_CORETEMP=m CONFIG_SENSORS_PC87427=m -CONFIG_SENSORS_SMSC47M1=m -CONFIG_SENSORS_SMSC47B397=m -CONFIG_SENSORS_VT1211=m -CONFIG_SENSORS_W83627HF=m CONFIG_SENSORS_HDAPS=m -CONFIG_SENSORS_APPLESMC=m # CONFIG_HWMON_DEBUG_CHIP is not set # -# Multifunction device drivers +# Misc devices # -CONFIG_MFD_SM501=m +# CONFIG_IBM_ASM is not set # -# Multimedia devices +# Multimedia Capabilities Port drivers # -# CONFIG_VIDEO_DEV is not set -# CONFIG_DVB_CORE is not set -# CONFIG_DAB is not set # -# Graphics support +# Multimedia devices # -# CONFIG_BACKLIGHT_LCD_SUPPORT is not set -CONFIG_BACKLIGHT_CLASS_DEVICE=m -# CONFIG_BACKLIGHT_PROGEAR is not set +# CONFIG_VIDEO_DEV is not set # -# Display device support +# Digital Video Broadcasting Devices # -CONFIG_DISPLAY_SUPPORT=m +# CONFIG_DVB is not set # -# Display hardware drivers +# Graphics support # -# CONFIG_VGASTATE is not set CONFIG_FB=y -# CONFIG_FIRMWARE_EDID is not set -# CONFIG_FB_DDC is not set CONFIG_FB_CFB_FILLRECT=y CONFIG_FB_CFB_COPYAREA=y CONFIG_FB_CFB_IMAGEBLIT=y -CONFIG_FB_SYS_FILLRECT=m -CONFIG_FB_SYS_COPYAREA=m -CONFIG_FB_SYS_IMAGEBLIT=m -CONFIG_FB_SYS_FOPS=m -CONFIG_FB_DEFERRED_IO=y -# CONFIG_FB_SVGALIB is not set # CONFIG_FB_MACMODES is not set -# CONFIG_FB_BACKLIGHT is not set # CONFIG_FB_MODE_HELPERS is not set # CONFIG_FB_TILEBLITTING is not set - -# -# Frame buffer hardware drivers -# # CONFIG_FB_CIRRUS is not set # CONFIG_FB_PM2 is not set # CONFIG_FB_CYBER2000 is not set @@ -1687,51 +1648,49 @@ CONFIG_FB_DEFERRED_IO=y # CONFIG_FB_IMSTT is not set # CONFIG_FB_VGA16 is not set CONFIG_FB_VESA=y -# CONFIG_FB_HECUBA is not set +CONFIG_VIDEO_SELECT=y # CONFIG_FB_HGA is not set # CONFIG_FB_S1D13XXX is not set # CONFIG_FB_NVIDIA is not set # CONFIG_FB_RIVA is not set # CONFIG_FB_I810 is not set -# CONFIG_FB_LE80578 is not set # CONFIG_FB_INTEL is not set # CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON_OLD is not set # CONFIG_FB_RADEON is not set # CONFIG_FB_ATY128 is not set # CONFIG_FB_ATY is not set -# CONFIG_FB_S3 is not set # CONFIG_FB_SAVAGE is not set # CONFIG_FB_SIS is not set # CONFIG_FB_NEOMAGIC is not set # CONFIG_FB_KYRO is not set # CONFIG_FB_3DFX is not set # CONFIG_FB_VOODOO1 is not set -# CONFIG_FB_VT8623 is not set # CONFIG_FB_CYBLA is not set # CONFIG_FB_TRIDENT is not set -# CONFIG_FB_ARK is not set -# CONFIG_FB_PM3 is not set # CONFIG_FB_GEODE is not set -# CONFIG_FB_SM501 is not set # CONFIG_FB_VIRTUAL is not set # # Console display driver support # CONFIG_VGA_CONSOLE=y -CONFIG_VGACON_SOFT_SCROLLBACK=y -CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 -CONFIG_VIDEO_SELECT=y +# CONFIG_MDA_CONSOLE is not set CONFIG_DUMMY_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE=y # CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set # CONFIG_FONTS is not set CONFIG_FONT_8x8=y CONFIG_FONT_8x16=y + +# +# Logo configuration +# CONFIG_LOGO=y CONFIG_LOGO_LINUX_MONO=y CONFIG_LOGO_LINUX_VGA16=y CONFIG_LOGO_LINUX_CLUT224=y +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set # # Sound @@ -1751,13 +1710,11 @@ CONFIG_SND_SEQUENCER=m CONFIG_SND_OSSEMUL=y CONFIG_SND_MIXER_OSS=m CONFIG_SND_PCM_OSS=m -CONFIG_SND_PCM_OSS_PLUGINS=y # CONFIG_SND_SEQUENCER_OSS is not set CONFIG_SND_RTCTIMER=m CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y # CONFIG_SND_DYNAMIC_MINORS is not set # CONFIG_SND_SUPPORT_OLD_API is not set -CONFIG_SND_VERBOSE_PROCFS=y # CONFIG_SND_VERBOSE_PRINTK is not set # CONFIG_SND_DEBUG is not set @@ -1768,19 +1725,48 @@ CONFIG_SND_MPU401_UART=m CONFIG_SND_OPL3_LIB=m CONFIG_SND_VX_LIB=m CONFIG_SND_AC97_CODEC=m +CONFIG_SND_AC97_BUS=m CONFIG_SND_DUMMY=m # CONFIG_SND_VIRMIDI is not set CONFIG_SND_MTPAV=m -CONFIG_SND_MTS64=m CONFIG_SND_SERIAL_U16550=m CONFIG_SND_MPU401=m -CONFIG_SND_PORTMAN2X4=m + +# +# ISA devices +# +# CONFIG_SND_AD1816A is not set +# CONFIG_SND_AD1848 is not set +# CONFIG_SND_ALS100 is not set +# CONFIG_SND_AZT2320 is not set +# CONFIG_SND_CMI8330 is not set +# CONFIG_SND_CS4231 is not set +# CONFIG_SND_CS4232 is not set +# CONFIG_SND_CS4236 is not set +# CONFIG_SND_DT019X is not set +# CONFIG_SND_ES968 is not set +# CONFIG_SND_ES1688 is not set +# CONFIG_SND_ES18XX is not set +# CONFIG_SND_GUSCLASSIC is not set +# CONFIG_SND_GUSEXTREME is not set +# CONFIG_SND_GUSMAX is not set +# CONFIG_SND_INTERWAVE is not set +# CONFIG_SND_INTERWAVE_STB is not set +# CONFIG_SND_OPL3SA2 is not set +# CONFIG_SND_OPTI92X_AD1848 is not set +# CONFIG_SND_OPTI92X_CS4231 is not set +# CONFIG_SND_OPTI93X is not set +# CONFIG_SND_SB8 is not set +# CONFIG_SND_SB16 is not set +# CONFIG_SND_SBAWE is not set +# CONFIG_SND_SGALAXY is not set +# CONFIG_SND_SSCAPE is not set +# CONFIG_SND_WAVEFRONT is not set # # PCI devices # CONFIG_SND_AD1889=m -CONFIG_SND_ALS300=m CONFIG_SND_ALS4000=m CONFIG_SND_ALI5451=m CONFIG_SND_ATIIXP=m @@ -1825,13 +1811,10 @@ CONFIG_SND_ICE1724=m CONFIG_SND_INTEL8X0=m CONFIG_SND_INTEL8X0M=m CONFIG_SND_KORG1212=m -CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL=y CONFIG_SND_MAESTRO3=m -CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL=y CONFIG_SND_MIXART=m CONFIG_SND_NM256=m CONFIG_SND_PCXHR=m -CONFIG_SND_RIPTIDE=m CONFIG_SND_RME32=m CONFIG_SND_RME96=m CONFIG_SND_RME9652=m @@ -1841,54 +1824,23 @@ CONFIG_SND_VIA82XX=m CONFIG_SND_VIA82XX_MODEM=m CONFIG_SND_VX222=m CONFIG_SND_YMFPCI=m -CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y -CONFIG_SND_AC97_POWER_SAVE=y # # USB devices # CONFIG_SND_USB_AUDIO=m CONFIG_SND_USB_USX2Y=m -CONFIG_SND_USB_CAIAQ=m -# CONFIG_SND_USB_CAIAQ_INPUT is not set - -# -# System on Chip audio support -# -CONFIG_SND_SOC=m # # Open Sound System # # CONFIG_SOUND_PRIME is not set -CONFIG_AC97_BUS=m - -# -# HID Devices -# -CONFIG_HID=m -# CONFIG_HID_DEBUG is not set - -# -# USB Input Devices -# -CONFIG_USB_HID=m -# CONFIG_USB_HIDINPUT_POWERBOOK is not set -# CONFIG_HID_FF is not set -CONFIG_USB_HIDDEV=y - -# -# USB HID Boot Protocol drivers -# -# CONFIG_USB_KBD is not set -# CONFIG_USB_MOUSE is not set # # USB support # CONFIG_USB_ARCH_HAS_HCD=y CONFIG_USB_ARCH_HAS_OHCI=y -CONFIG_USB_ARCH_HAS_EHCI=y CONFIG_USB=m # CONFIG_USB_DEBUG is not set @@ -1896,7 +1848,7 @@ CONFIG_USB=m # Miscellaneous USB options # CONFIG_USB_DEVICEFS=y -CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_BANDWIDTH is not set CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_SUSPEND=y # CONFIG_USB_OTG is not set @@ -1907,12 +1859,9 @@ CONFIG_USB_SUSPEND=y CONFIG_USB_EHCI_HCD=m # CONFIG_USB_EHCI_SPLIT_ISO is not set # CONFIG_USB_EHCI_ROOT_HUB_TT is not set -# CONFIG_USB_EHCI_TT_NEWSCHED is not set -# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set CONFIG_USB_ISP116X_HCD=m CONFIG_USB_OHCI_HCD=m -# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set -# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set +# CONFIG_USB_OHCI_BIG_ENDIAN is not set CONFIG_USB_OHCI_LITTLE_ENDIAN=y CONFIG_USB_UHCI_HCD=m CONFIG_USB_SL811_HCD=m @@ -1920,6 +1869,7 @@ CONFIG_USB_SL811_HCD=m # # USB Device Class drivers # +# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set CONFIG_USB_ACM=m CONFIG_USB_PRINTER=m @@ -1941,14 +1891,74 @@ CONFIG_USB_STORAGE_SDDR09=y CONFIG_USB_STORAGE_SDDR55=y CONFIG_USB_STORAGE_JUMPSHOT=y CONFIG_USB_STORAGE_ALAUDA=y -CONFIG_USB_STORAGE_KARMA=y # CONFIG_USB_LIBUSUAL is not set +# +# USB Input Devices +# +CONFIG_USB_HID=m +CONFIG_USB_HIDINPUT=y +# CONFIG_USB_HIDINPUT_POWERBOOK is not set +# CONFIG_HID_FF is not set +CONFIG_USB_HIDDEV=y + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set +# CONFIG_USB_AIPTEK is not set +# CONFIG_USB_WACOM is not set +# CONFIG_USB_ACECAD is not set +# CONFIG_USB_KBTAB is not set +# CONFIG_USB_POWERMATE is not set +# CONFIG_USB_MTOUCH is not set +# CONFIG_USB_ITMTOUCH is not set +# CONFIG_USB_EGALAX is not set +# CONFIG_USB_YEALINK is not set +# CONFIG_USB_XPAD is not set +# CONFIG_USB_ATI_REMOTE is not set +# CONFIG_USB_ATI_REMOTE2 is not set +# CONFIG_USB_KEYSPAN_REMOTE is not set +# CONFIG_USB_APPLETOUCH is not set + # # USB Imaging devices # # CONFIG_USB_MDC800 is not set # CONFIG_USB_MICROTEK is not set + +# +# USB Multimedia devices +# +# CONFIG_USB_DABUSB is not set + +# +# Video4Linux support is needed for USB Multimedia device support +# + +# +# USB Network Adapters +# +CONFIG_USB_CATC=m +CONFIG_USB_KAWETH=m +CONFIG_USB_PEGASUS=m +CONFIG_USB_RTL8150=m +CONFIG_USB_USBNET=m +CONFIG_USB_NET_AX8817X=m +CONFIG_USB_NET_CDCETHER=m +CONFIG_USB_NET_GL620A=m +CONFIG_USB_NET_NET1080=m +CONFIG_USB_NET_PLUSB=m +CONFIG_USB_NET_RNDIS_HOST=m +CONFIG_USB_NET_CDC_SUBSET=m +CONFIG_USB_ALI_M5632=y +CONFIG_USB_AN2720=y +CONFIG_USB_BELKIN=y +CONFIG_USB_ARMLINUX=y +CONFIG_USB_EPSON2888=y +CONFIG_USB_NET_ZAURUS=m +CONFIG_USB_ZD1201=m # CONFIG_USB_MON is not set # @@ -1966,26 +1976,17 @@ CONFIG_USB_STORAGE_KARMA=y # CONFIG_USB_EMI62=m CONFIG_USB_EMI26=m -CONFIG_USB_ADUTUX=m # CONFIG_USB_AUERSWALD is not set # CONFIG_USB_RIO500 is not set # CONFIG_USB_LEGOTOWER is not set CONFIG_USB_LCD=m -CONFIG_USB_BERRY_CHARGE=m CONFIG_USB_LED=m -CONFIG_USB_CYPRESS_CY7C63=m # CONFIG_USB_CYTHERM is not set -CONFIG_USB_PHIDGET=m -CONFIG_USB_PHIDGETKIT=m -CONFIG_USB_PHIDGETMOTORCONTROL=m -CONFIG_USB_PHIDGETSERVO=m +# CONFIG_USB_PHIDGETKIT is not set +# CONFIG_USB_PHIDGETSERVO is not set # CONFIG_USB_IDMOUSE is not set -# CONFIG_USB_FTDI_ELAN is not set -# CONFIG_USB_APPLEDISPLAY is not set # CONFIG_USB_SISUSBVGA is not set # CONFIG_USB_LD is not set -# CONFIG_USB_TRANCEVIBRATOR is not set -# CONFIG_USB_IOWARRIOR is not set # CONFIG_USB_TEST is not set # @@ -2001,39 +2002,14 @@ CONFIG_USB_XUSBATM=m # USB Gadget Support # # CONFIG_USB_GADGET is not set -CONFIG_MMC=m -# CONFIG_MMC_DEBUG is not set -# CONFIG_MMC_UNSAFE_RESUME is not set # -# MMC/SD Card Drivers +# MMC/SD Card support # +CONFIG_MMC=m +# CONFIG_MMC_DEBUG is not set CONFIG_MMC_BLOCK=m - -# -# MMC/SD Host Controller Drivers -# -# CONFIG_MMC_SDHCI is not set CONFIG_MMC_WBSD=m -CONFIG_MMC_TIFM_SD=m - -# -# LED devices -# -CONFIG_NEW_LEDS=y -CONFIG_LEDS_CLASS=m - -# -# LED drivers -# - -# -# LED Triggers -# -CONFIG_LEDS_TRIGGERS=y -CONFIG_LEDS_TRIGGER_TIMER=m -CONFIG_LEDS_TRIGGER_IDE_DISK=y -CONFIG_LEDS_TRIGGER_HEARTBEAT=m # # InfiniBand support @@ -2045,71 +2021,6 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=m # # CONFIG_EDAC is not set -# -# Real Time Clock -# -CONFIG_RTC_LIB=m -CONFIG_RTC_CLASS=m - -# -# RTC interfaces -# -CONFIG_RTC_INTF_SYSFS=y -CONFIG_RTC_INTF_PROC=y -CONFIG_RTC_INTF_DEV=y -# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set -# CONFIG_RTC_DRV_TEST is not set - -# -# I2C RTC drivers -# - -# -# SPI RTC drivers -# - -# -# Platform RTC drivers -# -CONFIG_RTC_DRV_CMOS=m -CONFIG_RTC_DRV_DS1553=m -CONFIG_RTC_DRV_DS1742=m -CONFIG_RTC_DRV_M48T86=m -CONFIG_RTC_DRV_V3020=m - -# -# on-CPU RTC drivers -# - -# -# DMA Engine support -# -CONFIG_DMA_ENGINE=y - -# -# DMA Clients -# -CONFIG_NET_DMA=y - -# -# DMA Devices -# -CONFIG_INTEL_IOATDMA=m - -# -# Auxiliary Display support -# -CONFIG_KS0108=m -CONFIG_KS0108_PORT=0x378 -CONFIG_KS0108_DELAY=2 -CONFIG_CFAG12864B=m -CONFIG_CFAG12864B_RATE=20 - -# -# Virtualization -# -# CONFIG_KVM is not set - # # File systems # @@ -2122,14 +2033,8 @@ CONFIG_EXT3_FS=m CONFIG_EXT3_FS_XATTR=y CONFIG_EXT3_FS_POSIX_ACL=y CONFIG_EXT3_FS_SECURITY=y -CONFIG_EXT4DEV_FS=m -CONFIG_EXT4DEV_FS_XATTR=y -CONFIG_EXT4DEV_FS_POSIX_ACL=y -CONFIG_EXT4DEV_FS_SECURITY=y CONFIG_JBD=m # CONFIG_JBD_DEBUG is not set -CONFIG_JBD2=m -# CONFIG_JBD2_DEBUG is not set CONFIG_FS_MBCACHE=m CONFIG_REISER4_FS=m # CONFIG_REISER4_DEBUG is not set @@ -2146,22 +2051,21 @@ CONFIG_JFS_SECURITY=y CONFIG_JFS_STATISTICS=y CONFIG_FS_POSIX_ACL=y CONFIG_XFS_FS=m +CONFIG_XFS_EXPORT=y CONFIG_XFS_QUOTA=y CONFIG_XFS_SECURITY=y CONFIG_XFS_POSIX_ACL=y # CONFIG_XFS_RT is not set -# CONFIG_GFS2_FS is not set # CONFIG_OCFS2_FS is not set # CONFIG_MINIX_FS is not set # CONFIG_ROMFS_FS is not set CONFIG_INOTIFY=y -CONFIG_INOTIFY_USER=y # CONFIG_QUOTA is not set CONFIG_QUOTACTL=y CONFIG_DNOTIFY=y # CONFIG_AUTOFS_FS is not set # CONFIG_AUTOFS4_FS is not set -CONFIG_FUSE_FS=m +# CONFIG_FUSE_FS is not set # # CD-ROM/DVD Filesystems @@ -2186,34 +2090,30 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" # Pseudo filesystems # CONFIG_PROC_FS=y -CONFIG_PROC_KCORE=y -CONFIG_PROC_SYSCTL=y +# CONFIG_PROC_KCORE is not set CONFIG_SYSFS=y CONFIG_TMPFS=y -# CONFIG_TMPFS_POSIX_ACL is not set # CONFIG_HUGETLBFS is not set # CONFIG_HUGETLB_PAGE is not set CONFIG_RAMFS=y -CONFIG_CONFIGFS_FS=m +# CONFIG_RELAYFS_FS is not set +# CONFIG_CONFIGFS_FS is not set # # Miscellaneous filesystems # # CONFIG_ADFS_FS is not set # CONFIG_AFFS_FS is not set -# CONFIG_ECRYPT_FS is not set # CONFIG_HFS_FS is not set # CONFIG_HFSPLUS_FS is not set # CONFIG_BEFS_FS is not set # CONFIG_BFS_FS is not set # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set CONFIG_JFFS2_FS=m CONFIG_JFFS2_FS_DEBUG=0 CONFIG_JFFS2_FS_WRITEBUFFER=y # CONFIG_JFFS2_SUMMARY is not set -CONFIG_JFFS2_FS_XATTR=y -CONFIG_JFFS2_FS_POSIX_ACL=y -CONFIG_JFFS2_FS_SECURITY=y CONFIG_JFFS2_COMPRESSION_OPTIONS=y CONFIG_JFFS2_ZLIB=y CONFIG_JFFS2_RTIME=y @@ -2222,6 +2122,10 @@ CONFIG_JFFS2_RUBIN=y CONFIG_JFFS2_CMODE_PRIORITY=y # CONFIG_JFFS2_CMODE_SIZE is not set # CONFIG_CRAMFS is not set +CONFIG_SQUASHFS=y +# CONFIG_SQUASHFS_EMBEDDED is not set +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_SQUASHFS_VMALLOC is not set # CONFIG_VXFS_FS is not set # CONFIG_HPFS_FS is not set # CONFIG_QNX4FS_FS is not set @@ -2245,7 +2149,6 @@ CONFIG_EXPORTFS=m CONFIG_NFS_COMMON=y CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m -# CONFIG_SUNRPC_BIND34 is not set CONFIG_RPCSEC_GSS_KRB5=m # CONFIG_RPCSEC_GSS_SPKM3 is not set CONFIG_SMB_FS=m @@ -2253,10 +2156,8 @@ CONFIG_SMB_FS=m CONFIG_CIFS=m CONFIG_CIFS_STATS=y CONFIG_CIFS_STATS2=y -# CONFIG_CIFS_WEAK_PW_HASH is not set CONFIG_CIFS_XATTR=y # CONFIG_CIFS_POSIX is not set -# CONFIG_CIFS_DEBUG2 is not set # CONFIG_CIFS_EXPERIMENTAL is not set # CONFIG_NCP_FS is not set # CONFIG_CODA_FS is not set @@ -2313,12 +2214,6 @@ CONFIG_NLS_ISO8859_1=y # CONFIG_NLS_KOI8_U is not set CONFIG_NLS_UTF8=y -# -# Distributed Lock Manager -# -CONFIG_DLM=m -# CONFIG_DLM_DEBUG is not set - # # Instrumentation Support # @@ -2328,36 +2223,24 @@ CONFIG_DLM=m # # Kernel hacking # -CONFIG_TRACE_IRQFLAGS_SUPPORT=y # CONFIG_PRINTK_TIME is not set -CONFIG_ENABLE_MUST_CHECK=y # CONFIG_MAGIC_SYSRQ is not set -CONFIG_UNUSED_SYMBOLS=y -CONFIG_DEBUG_FS=y -# CONFIG_HEADERS_CHECK is not set # CONFIG_DEBUG_KERNEL is not set +CONFIG_LOG_BUF_SHIFT=14 CONFIG_DEBUG_BUGVERBOSE=y CONFIG_EARLY_PRINTK=y -CONFIG_DOUBLEFAULT=y # # Security options # -CONFIG_KEYS=y -# CONFIG_KEYS_DEBUG_PROC_KEYS is not set +# CONFIG_KEYS is not set # CONFIG_SECURITY is not set # # Cryptographic options # CONFIG_CRYPTO=y -CONFIG_CRYPTO_ALGAPI=y -CONFIG_CRYPTO_ABLKCIPHER=m -CONFIG_CRYPTO_BLKCIPHER=m -CONFIG_CRYPTO_HASH=m -CONFIG_CRYPTO_MANAGER=y -CONFIG_CRYPTO_HMAC=m -CONFIG_CRYPTO_XCBC=m +CONFIG_CRYPTO_HMAC=y # CONFIG_CRYPTO_NULL is not set # CONFIG_CRYPTO_MD4 is not set CONFIG_CRYPTO_MD5=m @@ -2366,18 +2249,9 @@ CONFIG_CRYPTO_SHA256=m CONFIG_CRYPTO_SHA512=m # CONFIG_CRYPTO_WP512 is not set # CONFIG_CRYPTO_TGR192 is not set -CONFIG_CRYPTO_GF128MUL=m -CONFIG_CRYPTO_ECB=m -CONFIG_CRYPTO_CBC=m -CONFIG_CRYPTO_PCBC=m -CONFIG_CRYPTO_LRW=m -CONFIG_CRYPTO_CRYPTD=m CONFIG_CRYPTO_DES=m -CONFIG_CRYPTO_FCRYPT=m CONFIG_CRYPTO_BLOWFISH=m CONFIG_CRYPTO_TWOFISH=m -CONFIG_CRYPTO_TWOFISH_COMMON=m -CONFIG_CRYPTO_TWOFISH_586=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_AES=m CONFIG_CRYPTO_AES_586=m @@ -2388,39 +2262,29 @@ CONFIG_CRYPTO_ARC4=m # CONFIG_CRYPTO_KHAZAD is not set # CONFIG_CRYPTO_ANUBIS is not set CONFIG_CRYPTO_DEFLATE=y -CONFIG_CRYPTO_MICHAEL_MIC=m +# CONFIG_CRYPTO_MICHAEL_MIC is not set CONFIG_CRYPTO_CRC32C=m -CONFIG_CRYPTO_CAMELLIA=m # CONFIG_CRYPTO_TEST is not set # # Hardware crypto devices # CONFIG_CRYPTO_DEV_PADLOCK=m -CONFIG_CRYPTO_DEV_PADLOCK_AES=m -CONFIG_CRYPTO_DEV_PADLOCK_SHA=m -CONFIG_CRYPTO_DEV_GEODE=m +CONFIG_CRYPTO_DEV_PADLOCK_AES=y # # Library routines # -CONFIG_BITREVERSE=y CONFIG_CRC_CCITT=m CONFIG_CRC16=m -CONFIG_CRC_ITU_T=m CONFIG_CRC32=y CONFIG_LIBCRC32C=m -CONFIG_AUDIT_GENERIC=y CONFIG_ZLIB_INFLATE=y CONFIG_ZLIB_DEFLATE=y CONFIG_TEXTSEARCH=y CONFIG_TEXTSEARCH_KMP=m CONFIG_TEXTSEARCH_BM=m CONFIG_TEXTSEARCH_FSM=m -CONFIG_PLIST=y -CONFIG_HAS_IOMEM=y -CONFIG_HAS_IOPORT=y -CONFIG_HAS_DMA=y CONFIG_GENERIC_HARDIRQS=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_X86_BIOS_REBOOT=y diff --git a/config/kernel/kernel.config.i586.smp b/config/kernel/kernel.config.i586.smp index 945c2e24d..e10dec109 100644 --- a/config/kernel/kernel.config.i586.smp +++ b/config/kernel/kernel.config.i586.smp @@ -1,27 +1,16 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.22.1-ipfire -# Thu Aug 2 21:47:47 2007 +# Linux kernel version: 2.6.16.50-ipfire +# Wed Aug 1 13:18:55 2007 # CONFIG_X86_32=y -CONFIG_GENERIC_TIME=y -CONFIG_CLOCKSOURCE_WATCHDOG=y -CONFIG_GENERIC_CLOCKEVENTS=y -CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y -CONFIG_LOCKDEP_SUPPORT=y -CONFIG_STACKTRACE_SUPPORT=y CONFIG_SEMAPHORE_SLEEPERS=y CONFIG_X86=y CONFIG_MMU=y -CONFIG_ZONE_DMA=y -CONFIG_QUICKLIST=y CONFIG_GENERIC_ISA_DMA=y CONFIG_GENERIC_IOMAP=y -CONFIG_GENERIC_BUG=y -CONFIG_GENERIC_HWEIGHT=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_DMI=y -CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" # # Code maturity level options @@ -37,26 +26,18 @@ CONFIG_LOCALVERSION="" # CONFIG_LOCALVERSION_AUTO is not set CONFIG_SWAP=y CONFIG_SYSVIPC=y -# CONFIG_IPC_NS is not set -CONFIG_SYSVIPC_SYSCTL=y CONFIG_POSIX_MQUEUE=y # CONFIG_BSD_PROCESS_ACCT is not set -# CONFIG_TASKSTATS is not set -# CONFIG_UTS_NS is not set +CONFIG_SYSCTL=y CONFIG_AUDIT=y CONFIG_AUDITSYSCALL=y # CONFIG_IKCONFIG is not set -CONFIG_LOG_BUF_SHIFT=14 # CONFIG_CPUSETS is not set -CONFIG_SYSFS_DEPRECATED=y -CONFIG_RELAY=y -CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" +CONFIG_UID16=y +CONFIG_VM86=y CONFIG_CC_OPTIMIZE_FOR_SIZE=y -CONFIG_SYSCTL=y # CONFIG_EMBEDDED is not set -CONFIG_UID16=y -CONFIG_SYSCTL_SYSCALL=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_EXTRA_PASS is not set CONFIG_HOTPLUG=y @@ -65,20 +46,16 @@ CONFIG_BUG=y CONFIG_ELF_CORE=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y -CONFIG_ANON_INODES=y CONFIG_EPOLL=y -CONFIG_SIGNALFD=y -CONFIG_TIMERFD=y -CONFIG_EVENTFD=y CONFIG_SHMEM=y -CONFIG_VM_EVENT_COUNTERS=y -CONFIG_SLUB_DEBUG=y -# CONFIG_SLAB is not set -CONFIG_SLUB=y -# CONFIG_SLOB is not set -CONFIG_RT_MUTEXES=y +CONFIG_CC_ALIGN_FUNCTIONS=0 +CONFIG_CC_ALIGN_LABELS=0 +CONFIG_CC_ALIGN_LOOPS=0 +CONFIG_CC_ALIGN_JUMPS=0 +CONFIG_SLAB=y # CONFIG_TINY_SHMEM is not set CONFIG_BASE_SMALL=0 +# CONFIG_SLOB is not set # # Loadable module support @@ -86,7 +63,8 @@ CONFIG_BASE_SMALL=0 CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y CONFIG_MODULE_FORCE_UNLOAD=y -CONFIG_MODVERSIONS=y +CONFIG_OBSOLETE_MODPARM=y +# CONFIG_MODVERSIONS is not set # CONFIG_MODULE_SRCVERSION_ALL is not set CONFIG_KMOD=y CONFIG_STOP_MACHINE=y @@ -94,10 +72,7 @@ CONFIG_STOP_MACHINE=y # # Block layer # -CONFIG_BLOCK=y -CONFIG_LBD=y -CONFIG_BLK_DEV_IO_TRACE=y -CONFIG_LSF=y +# CONFIG_LBD is not set # # IO Schedulers @@ -115,10 +90,6 @@ CONFIG_DEFAULT_IOSCHED="anticipatory" # # Processor type and features # -CONFIG_TICK_ONESHOT=y -CONFIG_NO_HZ=y -CONFIG_HIGH_RES_TIMERS=y -CONFIG_SMP=y CONFIG_X86_PC=y # CONFIG_X86_ELAN is not set # CONFIG_X86_VOYAGER is not set @@ -128,7 +99,6 @@ CONFIG_X86_PC=y # CONFIG_X86_VISWS is not set # CONFIG_X86_GENERICARCH is not set # CONFIG_X86_ES7000 is not set -# CONFIG_PARAVIRT is not set # CONFIG_M386 is not set # CONFIG_M486 is not set CONFIG_M586=y @@ -138,7 +108,6 @@ CONFIG_M586=y # CONFIG_MPENTIUMII is not set # CONFIG_MPENTIUMIII is not set # CONFIG_MPENTIUMM is not set -# CONFIG_MCORE2 is not set # CONFIG_MPENTIUM4 is not set # CONFIG_MK6 is not set # CONFIG_MK7 is not set @@ -152,14 +121,11 @@ CONFIG_M586=y # CONFIG_MGEODE_LX is not set # CONFIG_MCYRIXIII is not set # CONFIG_MVIAC3_2 is not set -# CONFIG_MVIAC7 is not set CONFIG_X86_GENERIC=y CONFIG_X86_CMPXCHG=y -CONFIG_X86_L1_CACHE_SHIFT=7 CONFIG_X86_XADD=y +CONFIG_X86_L1_CACHE_SHIFT=7 CONFIG_RWSEM_XCHGADD_ALGORITHM=y -# CONFIG_ARCH_HAS_ILOG2_U32 is not set -# CONFIG_ARCH_HAS_ILOG2_U64 is not set CONFIG_GENERIC_CALIBRATE_DELAY=y CONFIG_X86_PPRO_FENCE=y CONFIG_X86_F00F_BUG=y @@ -167,14 +133,14 @@ CONFIG_X86_WP_WORKS_OK=y CONFIG_X86_INVLPG=y CONFIG_X86_BSWAP=y CONFIG_X86_POPAD_OK=y +CONFIG_X86_CMPXCHG64=y CONFIG_X86_ALIGNMENT_16=y CONFIG_X86_INTEL_USERCOPY=y -CONFIG_X86_MINIMUM_CPU_MODEL=4 CONFIG_HPET_TIMER=y CONFIG_HPET_EMULATE_RTC=y +CONFIG_SMP=y CONFIG_NR_CPUS=8 CONFIG_SCHED_SMT=y -CONFIG_SCHED_MC=y CONFIG_PREEMPT_NONE=y # CONFIG_PREEMPT_VOLUNTARY is not set # CONFIG_PREEMPT is not set @@ -184,7 +150,6 @@ CONFIG_X86_IO_APIC=y CONFIG_X86_MCE=y CONFIG_X86_MCE_NONFATAL=m # CONFIG_X86_MCE_P4THERMAL is not set -CONFIG_VM86=y # CONFIG_TOSHIBA is not set # CONFIG_I8K is not set CONFIG_X86_REBOOTFIXUPS=y @@ -201,12 +166,15 @@ CONFIG_X86_CPUID=y # CONFIG_NOHIGHMEM is not set CONFIG_HIGHMEM4G=y # CONFIG_HIGHMEM64G is not set +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_3G_OPT is not set +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set CONFIG_PAGE_OFFSET=0xC0000000 CONFIG_HIGHMEM=y CONFIG_ARCH_FLATMEM_ENABLE=y CONFIG_ARCH_SPARSEMEM_ENABLE=y CONFIG_ARCH_SELECT_MEMORY_MODEL=y -CONFIG_ARCH_POPULATES_NODE_MAP=y CONFIG_SELECT_MEMORY_MODEL=y CONFIG_FLATMEM_MANUAL=y # CONFIG_DISCONTIGMEM_MANUAL is not set @@ -215,27 +183,22 @@ CONFIG_FLATMEM=y CONFIG_FLAT_NODE_MEM_MAP=y CONFIG_SPARSEMEM_STATIC=y CONFIG_SPLIT_PTLOCK_CPUS=4 -# CONFIG_RESOURCES_64BIT is not set -CONFIG_ZONE_DMA_FLAG=1 -CONFIG_NR_QUICK=1 # CONFIG_HIGHPTE is not set CONFIG_MATH_EMULATION=y # CONFIG_MTRR is not set # CONFIG_EFI is not set CONFIG_IRQBALANCE=y +# CONFIG_REGPARM is not set CONFIG_SECCOMP=y CONFIG_HZ_100=y # CONFIG_HZ_250 is not set -# CONFIG_HZ_300 is not set # CONFIG_HZ_1000 is not set CONFIG_HZ=100 # CONFIG_KEXEC is not set # CONFIG_CRASH_DUMP is not set CONFIG_PHYSICAL_START=0x100000 -# CONFIG_RELOCATABLE is not set -CONFIG_PHYSICAL_ALIGN=0x100000 # CONFIG_HOTPLUG_CPU is not set -# CONFIG_COMPAT_VDSO is not set +CONFIG_DOUBLEFAULT=y CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y # @@ -244,24 +207,22 @@ CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y CONFIG_PM=y CONFIG_PM_LEGACY=y # CONFIG_PM_DEBUG is not set -# CONFIG_PM_SYSFS_DEPRECATED is not set # # ACPI (Advanced Configuration and Power Interface) Support # CONFIG_ACPI=y -# CONFIG_ACPI_PROCFS is not set CONFIG_ACPI_AC=m CONFIG_ACPI_BATTERY=m CONFIG_ACPI_BUTTON=m CONFIG_ACPI_VIDEO=m +# CONFIG_ACPI_HOTKEY is not set CONFIG_ACPI_FAN=m -CONFIG_ACPI_DOCK=m -# CONFIG_ACPI_BAY is not set CONFIG_ACPI_PROCESSOR=m CONFIG_ACPI_THERMAL=m -CONFIG_ACPI_ASUS=m -CONFIG_ACPI_TOSHIBA=m +# CONFIG_ACPI_ASUS is not set +# CONFIG_ACPI_IBM is not set +# CONFIG_ACPI_TOSHIBA is not set # CONFIG_ACPI_CUSTOM_DSDT is not set CONFIG_ACPI_BLACKLIST_YEAR=0 # CONFIG_ACPI_DEBUG is not set @@ -270,12 +231,16 @@ CONFIG_ACPI_POWER=y CONFIG_ACPI_SYSTEM=y CONFIG_X86_PM_TIMER=y # CONFIG_ACPI_CONTAINER is not set -# CONFIG_ACPI_SBS is not set + +# +# APM (Advanced Power Management) BIOS Support +# CONFIG_APM=m CONFIG_APM_IGNORE_USER_SUSPEND=y # CONFIG_APM_DO_ENABLE is not set # CONFIG_APM_CPU_IDLE is not set # CONFIG_APM_DISPLAY_BLANK is not set +CONFIG_APM_RTC_IS_GMT=y # CONFIG_APM_ALLOW_INTS is not set # CONFIG_APM_REAL_MODE_POWER_OFF is not set @@ -313,8 +278,6 @@ CONFIG_X86_SPEEDSTEP_SMI=m CONFIG_X86_P4_CLOCKMOD=m CONFIG_X86_CPUFREQ_NFORCE2=m CONFIG_X86_LONGRUN=m -CONFIG_X86_LONGHAUL=m -CONFIG_X86_E_POWERSAVER=m # # shared options @@ -335,19 +298,28 @@ CONFIG_PCI_BIOS=y CONFIG_PCI_DIRECT=y CONFIG_PCI_MMCONFIG=y CONFIG_PCIEPORTBUS=y -CONFIG_PCIEAER=y -CONFIG_ARCH_SUPPORTS_MSI=y # CONFIG_PCI_MSI is not set -CONFIG_HT_IRQ=y +CONFIG_PCI_LEGACY_PROC=y CONFIG_ISA_DMA_API=y -# CONFIG_ISA is not set -# CONFIG_MCA is not set +CONFIG_ISA=y +CONFIG_EISA=y +CONFIG_EISA_VLB_PRIMING=y +CONFIG_EISA_PCI_EISA=y +CONFIG_EISA_VIRTUAL_ROOT=y +CONFIG_EISA_NAMES=y +CONFIG_MCA=y +CONFIG_MCA_LEGACY=y +# CONFIG_MCA_PROC_FS is not set # CONFIG_SCx200 is not set # # PCCARD (PCMCIA/CardBus) support # # CONFIG_PCCARD is not set + +# +# PCI Hotplug Support +# # CONFIG_HOTPLUG_PCI is not set # @@ -365,15 +337,13 @@ CONFIG_NET=y # # Networking options # +# CONFIG_NETDEBUG is not set CONFIG_PACKET=y CONFIG_PACKET_MMAP=y CONFIG_UNIX=y CONFIG_XFRM=y CONFIG_XFRM_USER=m -# CONFIG_XFRM_SUB_POLICY is not set -# CONFIG_XFRM_MIGRATE is not set CONFIG_NET_KEY=m -# CONFIG_NET_KEY_MIGRATE is not set CONFIG_INET=y CONFIG_IP_MULTICAST=y CONFIG_IP_ADVANCED_ROUTER=y @@ -381,6 +351,7 @@ CONFIG_ASK_IP_FIB_HASH=y # CONFIG_IP_FIB_TRIE is not set CONFIG_IP_FIB_HASH=y CONFIG_IP_MULTIPLE_TABLES=y +# CONFIG_IP_ROUTE_FWMARK is not set CONFIG_IP_ROUTE_MULTIPATH=y # CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set CONFIG_IP_ROUTE_VERBOSE=y @@ -393,17 +364,18 @@ CONFIG_IP_PIMSM_V1=y CONFIG_IP_PIMSM_V2=y CONFIG_ARPD=y CONFIG_SYN_COOKIES=y +CONFIG_IPSEC_NAT_TRAVERSAL=y CONFIG_INET_AH=m CONFIG_INET_ESP=m CONFIG_INET_IPCOMP=m -CONFIG_INET_XFRM_TUNNEL=m CONFIG_INET_TUNNEL=m -CONFIG_INET_XFRM_MODE_TRANSPORT=m -CONFIG_INET_XFRM_MODE_TUNNEL=m -CONFIG_INET_XFRM_MODE_BEET=m CONFIG_INET_DIAG=m CONFIG_INET_TCP_DIAG=m CONFIG_TCP_CONG_ADVANCED=y + +# +# TCP congestion control +# CONFIG_TCP_CONG_BIC=m CONFIG_TCP_CONG_CUBIC=m CONFIG_TCP_CONG_WESTWOOD=m @@ -412,23 +384,12 @@ CONFIG_TCP_CONG_HSTCP=m CONFIG_TCP_CONG_HYBLA=m CONFIG_TCP_CONG_VEGAS=m CONFIG_TCP_CONG_SCALABLE=m -CONFIG_TCP_CONG_LP=m -CONFIG_TCP_CONG_VENO=m -CONFIG_TCP_CONG_YEAH=m -CONFIG_TCP_CONG_ILLINOIS=m -# CONFIG_DEFAULT_BIC is not set -# CONFIG_DEFAULT_CUBIC is not set -# CONFIG_DEFAULT_HTCP is not set -# CONFIG_DEFAULT_VEGAS is not set -# CONFIG_DEFAULT_WESTWOOD is not set -CONFIG_DEFAULT_RENO=y -CONFIG_DEFAULT_TCP_CONG="reno" -# CONFIG_TCP_MD5SIG is not set + +# +# IP: Virtual Server Configuration +# # CONFIG_IP_VS is not set # CONFIG_IPV6 is not set -# CONFIG_INET6_XFRM_TUNNEL is not set -# CONFIG_INET6_TUNNEL is not set -CONFIG_NETWORK_SECMARK=y CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set CONFIG_BRIDGE_NETFILTER=y @@ -439,106 +400,95 @@ CONFIG_BRIDGE_NETFILTER=y CONFIG_NETFILTER_NETLINK=m CONFIG_NETFILTER_NETLINK_QUEUE=m CONFIG_NETFILTER_NETLINK_LOG=m -CONFIG_NF_CONNTRACK_ENABLED=m -CONFIG_NF_CONNTRACK=m -CONFIG_NF_CT_ACCT=y -CONFIG_NF_CONNTRACK_MARK=y -CONFIG_NF_CONNTRACK_SECMARK=y -# CONFIG_NF_CONNTRACK_EVENTS is not set -CONFIG_NF_CT_PROTO_GRE=m -# CONFIG_NF_CT_PROTO_SCTP is not set -CONFIG_NF_CONNTRACK_AMANDA=m -CONFIG_NF_CONNTRACK_FTP=m -CONFIG_NF_CONNTRACK_H323=m -CONFIG_NF_CONNTRACK_IRC=m -CONFIG_NF_CONNTRACK_NETBIOS_NS=m -CONFIG_NF_CONNTRACK_PPTP=m -# CONFIG_NF_CONNTRACK_SANE is not set -CONFIG_NF_CONNTRACK_SIP=m -CONFIG_NF_CONNTRACK_TFTP=m -CONFIG_NF_CT_NETLINK=m CONFIG_NETFILTER_XTABLES=m CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m CONFIG_NETFILTER_XT_TARGET_CONNMARK=m -# CONFIG_NETFILTER_XT_TARGET_DSCP is not set CONFIG_NETFILTER_XT_TARGET_MARK=m CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m -CONFIG_NETFILTER_XT_TARGET_NFLOG=m CONFIG_NETFILTER_XT_TARGET_NOTRACK=m -CONFIG_NETFILTER_XT_TARGET_SECMARK=m -CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m -CONFIG_NETFILTER_XT_TARGET_TCPMSS=m CONFIG_NETFILTER_XT_MATCH_COMMENT=m CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m CONFIG_NETFILTER_XT_MATCH_CONNMARK=m CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m CONFIG_NETFILTER_XT_MATCH_DCCP=m -# CONFIG_NETFILTER_XT_MATCH_DSCP is not set -CONFIG_NETFILTER_XT_MATCH_ESP=m CONFIG_NETFILTER_XT_MATCH_HELPER=m CONFIG_NETFILTER_XT_MATCH_LENGTH=m CONFIG_NETFILTER_XT_MATCH_LIMIT=m CONFIG_NETFILTER_XT_MATCH_MAC=m CONFIG_NETFILTER_XT_MATCH_MARK=m -CONFIG_NETFILTER_XT_MATCH_POLICY=m -CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m -CONFIG_NETFILTER_XT_MATCH_QUOTA=m CONFIG_NETFILTER_XT_MATCH_REALM=m CONFIG_NETFILTER_XT_MATCH_SCTP=m CONFIG_NETFILTER_XT_MATCH_STATE=m -CONFIG_NETFILTER_XT_MATCH_LAYER7=m -# CONFIG_NETFILTER_XT_MATCH_LAYER7_DEBUG is not set -CONFIG_NETFILTER_XT_MATCH_STATISTIC=m CONFIG_NETFILTER_XT_MATCH_STRING=m CONFIG_NETFILTER_XT_MATCH_TCPMSS=m -CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m # # IP: Netfilter Configuration # -CONFIG_NF_CONNTRACK_IPV4=m -CONFIG_NF_CONNTRACK_PROC_COMPAT=y +CONFIG_IP_NF_CONNTRACK=m +CONFIG_IP_NF_CT_ACCT=y +CONFIG_IP_NF_CONNTRACK_MARK=y +CONFIG_IP_NF_CONNTRACK_EVENTS=y +CONFIG_IP_NF_CONNTRACK_NETLINK=m +CONFIG_IP_NF_CT_PROTO_SCTP=m +CONFIG_IP_NF_FTP=m +CONFIG_IP_NF_IRC=m +CONFIG_IP_NF_NETBIOS_NS=m +CONFIG_IP_NF_TFTP=m +CONFIG_IP_NF_AMANDA=m +CONFIG_IP_NF_PPTP=m +CONFIG_IP_NF_H323=m CONFIG_IP_NF_QUEUE=m CONFIG_IP_NF_IPTABLES=m CONFIG_IP_NF_MATCH_IPRANGE=m +CONFIG_IP_NF_MATCH_LAYER7=m +# CONFIG_IP_NF_MATCH_LAYER7_DEBUG is not set +CONFIG_IP_NF_MATCH_MULTIPORT=m CONFIG_IP_NF_MATCH_TOS=m CONFIG_IP_NF_MATCH_RECENT=m CONFIG_IP_NF_MATCH_ECN=m -CONFIG_IP_NF_MATCH_AH=m +CONFIG_IP_NF_MATCH_DSCP=m +CONFIG_IP_NF_MATCH_AH_ESP=m CONFIG_IP_NF_MATCH_TTL=m CONFIG_IP_NF_MATCH_OWNER=m CONFIG_IP_NF_MATCH_ADDRTYPE=m +CONFIG_IP_NF_MATCH_HASHLIMIT=m +CONFIG_IP_NF_MATCH_POLICY=m CONFIG_IP_NF_FILTER=m CONFIG_IP_NF_TARGET_REJECT=m CONFIG_IP_NF_TARGET_LOG=m CONFIG_IP_NF_TARGET_ULOG=m -CONFIG_NF_NAT=m -CONFIG_NF_NAT_NEEDED=y +CONFIG_IP_NF_TARGET_TCPMSS=m +CONFIG_IP_NF_NAT=m +CONFIG_IP_NF_NAT_NEEDED=y CONFIG_IP_NF_TARGET_MASQUERADE=m CONFIG_IP_NF_TARGET_REDIRECT=m CONFIG_IP_NF_TARGET_NETMAP=m CONFIG_IP_NF_TARGET_SAME=m -CONFIG_NF_NAT_SNMP_BASIC=m -CONFIG_NF_NAT_PROTO_GRE=m -CONFIG_NF_NAT_FTP=m -CONFIG_NF_NAT_IRC=m -CONFIG_NF_NAT_TFTP=m -CONFIG_NF_NAT_AMANDA=m -CONFIG_NF_NAT_PPTP=m -CONFIG_NF_NAT_H323=m -CONFIG_NF_NAT_SIP=m +CONFIG_IP_NF_NAT_SNMP_BASIC=m +CONFIG_IP_NF_NAT_IRC=m +CONFIG_IP_NF_NAT_FTP=m +CONFIG_IP_NF_NAT_TFTP=m +CONFIG_IP_NF_NAT_AMANDA=m +CONFIG_IP_NF_NAT_PPTP=m +CONFIG_IP_NF_NAT_H323=m CONFIG_IP_NF_MANGLE=m CONFIG_IP_NF_TARGET_IMQ=m CONFIG_IP_NF_TARGET_TOS=m CONFIG_IP_NF_TARGET_ECN=m +CONFIG_IP_NF_TARGET_DSCP=m CONFIG_IP_NF_TARGET_TTL=m CONFIG_IP_NF_TARGET_CLUSTERIP=m CONFIG_IP_NF_RAW=m CONFIG_IP_NF_ARPTABLES=m CONFIG_IP_NF_ARPFILTER=m CONFIG_IP_NF_ARP_MANGLE=m +CONFIG_IP_NF_NAT_MMS=m +CONFIG_IP_NF_MMS=m +CONFIG_IP_NF_NAT_SIP=m +CONFIG_IP_NF_SIP=m # # Bridge: Netfilter Configuration @@ -563,13 +513,20 @@ CONFIG_BRIDGE_EBT_REDIRECT=m CONFIG_BRIDGE_EBT_SNAT=m CONFIG_BRIDGE_EBT_LOG=m # CONFIG_BRIDGE_EBT_ULOG is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# # CONFIG_IP_DCCP is not set -CONFIG_IP_SCTP=m -# CONFIG_SCTP_DBG_MSG is not set -# CONFIG_SCTP_DBG_OBJCNT is not set -# CONFIG_SCTP_HMAC_NONE is not set -# CONFIG_SCTP_HMAC_SHA1 is not set -CONFIG_SCTP_HMAC_MD5=y + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set + +# +# TIPC Configuration (EXPERIMENTAL) +# # CONFIG_TIPC is not set CONFIG_ATM=m CONFIG_ATM_CLIP=m @@ -580,12 +537,12 @@ CONFIG_ATM_BR2684=m CONFIG_BRIDGE=m CONFIG_VLAN_8021Q=m # CONFIG_DECNET is not set -CONFIG_LLC=m # CONFIG_LLC2 is not set # CONFIG_IPX is not set # CONFIG_ATALK is not set # CONFIG_X25 is not set # CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set @@ -593,7 +550,9 @@ CONFIG_LLC=m # QoS and/or fair queueing # CONFIG_NET_SCHED=y -CONFIG_NET_SCH_FIFO=y +CONFIG_NET_SCH_CLK_JIFFIES=y +# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set +# CONFIG_NET_SCH_CLK_CPU is not set # # Queueing/Scheduling @@ -622,7 +581,7 @@ CONFIG_NET_CLS_ROUTE4=m CONFIG_NET_CLS_ROUTE=y CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m -CONFIG_CLS_U32_PERF=y +# CONFIG_CLS_U32_PERF is not set CONFIG_CLS_U32_MARK=y CONFIG_NET_CLS_RSVP=m CONFIG_NET_CLS_RSVP6=y @@ -634,12 +593,11 @@ CONFIG_NET_EMATCH_U32=m CONFIG_NET_EMATCH_META=m CONFIG_NET_EMATCH_TEXT=m CONFIG_NET_CLS_ACT=y -CONFIG_NET_ACT_POLICE=m -CONFIG_NET_ACT_GACT=m -CONFIG_GACT_PROB=y -CONFIG_NET_ACT_MIRRED=m -CONFIG_NET_ACT_IPT=m -CONFIG_NET_ACT_PEDIT=m +# CONFIG_NET_ACT_POLICE is not set +# CONFIG_NET_ACT_GACT is not set +# CONFIG_NET_ACT_MIRRED is not set +# CONFIG_NET_ACT_IPT is not set +# CONFIG_NET_ACT_PEDIT is not set # CONFIG_NET_ACT_SIMP is not set CONFIG_NET_CLS_IND=y CONFIG_NET_ESTIMATOR=y @@ -651,28 +609,11 @@ CONFIG_NET_ESTIMATOR=y # CONFIG_HAMRADIO is not set # CONFIG_IRDA is not set # CONFIG_BT is not set -CONFIG_AF_RXRPC=m -# CONFIG_AF_RXRPC_DEBUG is not set -# CONFIG_RXKAD is not set -CONFIG_FIB_RULES=y - -# -# Wireless -# -CONFIG_CFG80211=m -CONFIG_WIRELESS_EXT=y -CONFIG_MAC80211=m -CONFIG_MAC80211_LEDS=y -# CONFIG_MAC80211_DEBUGFS is not set -# CONFIG_MAC80211_DEBUG is not set CONFIG_IEEE80211=m # CONFIG_IEEE80211_DEBUG is not set CONFIG_IEEE80211_CRYPT_WEP=m -CONFIG_IEEE80211_CRYPT_CCMP=m -CONFIG_IEEE80211_CRYPT_TKIP=m -CONFIG_IEEE80211_SOFTMAC=m -# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set -# CONFIG_RFKILL is not set +# CONFIG_IEEE80211_CRYPT_CCMP is not set +# CONFIG_IEEE80211_CRYPT_TKIP is not set CONFIG_KLIPS=m # @@ -688,7 +629,7 @@ CONFIG_KLIPS_ENC_3DES=y CONFIG_KLIPS_ENC_AES=y # CONFIG_KLIPS_ENC_NULL is not set CONFIG_KLIPS_IPCOMP=y -# CONFIG_KLIPS_DEBUG is not set +CONFIG_KLIPS_DEBUG=y # # Device Drivers @@ -700,30 +641,32 @@ CONFIG_KLIPS_IPCOMP=y # CONFIG_STANDALONE is not set # CONFIG_PREVENT_FIRMWARE_BUILD is not set CONFIG_FW_LOADER=m -# CONFIG_SYS_HYPERVISOR is not set # # Connector - unified userspace <-> kernelspace linker # CONFIG_CONNECTOR=m + +# +# Memory Technology Devices (MTD) +# CONFIG_MTD=m # CONFIG_MTD_DEBUG is not set CONFIG_MTD_CONCAT=m CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y # # User Modules And Translation Layers # CONFIG_MTD_CHAR=m -CONFIG_MTD_BLKDEVS=m CONFIG_MTD_BLOCK=m # CONFIG_MTD_BLOCK_RO is not set # CONFIG_FTL is not set # CONFIG_NFTL is not set # CONFIG_INFTL is not set # CONFIG_RFD_FTL is not set -CONFIG_SSFDC=m # # RAM/ROM/Flash chip drivers @@ -743,6 +686,7 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_RAM is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_ABSENT is not set +# CONFIG_MTD_OBSOLETE_CHIPS is not set # # Mapping drivers for chip access @@ -758,6 +702,7 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_SLRAM is not set # CONFIG_MTD_PHRAM is not set # CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLKMTD is not set # CONFIG_MTD_BLOCK2MTD is not set # @@ -766,21 +711,16 @@ CONFIG_MTD_CFI_I2=y # CONFIG_MTD_DOC2000 is not set # CONFIG_MTD_DOC2001 is not set # CONFIG_MTD_DOC2001PLUS is not set -# CONFIG_MTD_NAND is not set -# CONFIG_MTD_ONENAND is not set # -# UBI - Unsorted block images +# NAND Flash Device Drivers # -CONFIG_MTD_UBI=m -CONFIG_MTD_UBI_WL_THRESHOLD=4096 -CONFIG_MTD_UBI_BEB_RESERVE=1 -CONFIG_MTD_UBI_GLUEBI=y +# CONFIG_MTD_NAND is not set # -# UBI debugging options +# OneNAND Flash Device Drivers # -# CONFIG_MTD_UBI_DEBUG is not set +# CONFIG_MTD_ONENAND is not set # # Parallel port support @@ -791,9 +731,7 @@ CONFIG_PARPORT_PC=m # CONFIG_PARPORT_PC_FIFO is not set # CONFIG_PARPORT_PC_SUPERIO is not set # CONFIG_PARPORT_GSC is not set -CONFIG_PARPORT_AX88796=m # CONFIG_PARPORT_1284 is not set -CONFIG_PARPORT_NOT_PC=y # # Plug and Play support @@ -804,12 +742,16 @@ CONFIG_PNP=y # # Protocols # +# CONFIG_ISAPNP is not set +CONFIG_PNPBIOS=y +CONFIG_PNPBIOS_PROC_FS=y CONFIG_PNPACPI=y # # Block devices # CONFIG_BLK_DEV_FD=m +# CONFIG_BLK_DEV_XD is not set # CONFIG_PARIDE is not set CONFIG_BLK_CPQ_DA=m CONFIG_BLK_CPQ_CISS_DA=m @@ -825,22 +767,13 @@ CONFIG_BLK_DEV_UB=m CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=8192 -CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 +CONFIG_BLK_DEV_INITRD=y # CONFIG_CDROM_PKTCDVD is not set # CONFIG_ATA_OVER_ETH is not set # -# Misc devices +# ATA/ATAPI/MFM/RLL support # -# CONFIG_IBM_ASM is not set -CONFIG_PHANTOM=m -# CONFIG_SGI_IOC4 is not set -CONFIG_TIFM_CORE=m -CONFIG_TIFM_7XX1=m -# CONFIG_ASUS_LAPTOP is not set -# CONFIG_MSI_LAPTOP is not set -# CONFIG_SONY_LAPTOP is not set -# CONFIG_THINKPAD_ACPI is not set CONFIG_IDE=y CONFIG_BLK_DEV_IDE=m @@ -855,9 +788,7 @@ CONFIG_BLK_DEV_IDECD=m # CONFIG_BLK_DEV_IDETAPE is not set CONFIG_BLK_DEV_IDEFLOPPY=m # CONFIG_BLK_DEV_IDESCSI is not set -CONFIG_BLK_DEV_IDEACPI=y # CONFIG_IDE_TASK_IOCTL is not set -CONFIG_IDE_PROC_FS=y # # IDE chipset support/bugfixes @@ -868,13 +799,13 @@ CONFIG_BLK_DEV_CMD640=y CONFIG_BLK_DEV_IDEPNP=y CONFIG_BLK_DEV_IDEPCI=y CONFIG_IDEPCI_SHARE_IRQ=y -# CONFIG_IDEPCI_PCIBUS_ORDER is not set # CONFIG_BLK_DEV_OFFBOARD is not set CONFIG_BLK_DEV_GENERIC=m CONFIG_BLK_DEV_OPTI621=m CONFIG_BLK_DEV_RZ1000=m CONFIG_BLK_DEV_IDEDMA_PCI=y # CONFIG_BLK_DEV_IDEDMA_FORCED is not set +CONFIG_IDEDMA_PCI_AUTO=y # CONFIG_IDEDMA_ONLYDISK is not set CONFIG_BLK_DEV_AEC62XX=m CONFIG_BLK_DEV_ALI15X3=m @@ -890,10 +821,8 @@ CONFIG_BLK_DEV_CS5530=m CONFIG_BLK_DEV_HPT34X=m # CONFIG_HPT34X_AUTODMA is not set CONFIG_BLK_DEV_HPT366=m -CONFIG_BLK_DEV_JMICRON=m CONFIG_BLK_DEV_SC1200=m CONFIG_BLK_DEV_PIIX=m -CONFIG_BLK_DEV_IT8213=m CONFIG_BLK_DEV_IT821X=m CONFIG_BLK_DEV_NS87415=m CONFIG_BLK_DEV_PDC202XX_OLD=m @@ -905,10 +834,21 @@ CONFIG_BLK_DEV_SIS5513=m CONFIG_BLK_DEV_SLC90E66=m CONFIG_BLK_DEV_TRM290=m CONFIG_BLK_DEV_VIA82CXXX=m -CONFIG_BLK_DEV_TC86C001=m # CONFIG_IDE_ARM is not set +CONFIG_IDE_CHIPSETS=y + +# +# Note: most of these also require special kernel boot parameters +# +CONFIG_BLK_DEV_4DRIVES=y +CONFIG_BLK_DEV_ALI14XX=m +CONFIG_BLK_DEV_DTC2278=m +CONFIG_BLK_DEV_HT6560B=m +CONFIG_BLK_DEV_QD65XX=m +CONFIG_BLK_DEV_UMC8672=m CONFIG_BLK_DEV_IDEDMA=y # CONFIG_IDEDMA_IVB is not set +CONFIG_IDEDMA_AUTO=y # CONFIG_BLK_DEV_HD is not set # @@ -916,8 +856,6 @@ CONFIG_BLK_DEV_IDEDMA=y # CONFIG_RAID_ATTRS=y CONFIG_SCSI=m -CONFIG_SCSI_TGT=m -CONFIG_SCSI_NETLINK=y CONFIG_SCSI_PROC_FS=y # @@ -937,18 +875,14 @@ CONFIG_CHR_DEV_SCH=m CONFIG_SCSI_MULTI_LUN=y # CONFIG_SCSI_CONSTANTS is not set # CONFIG_SCSI_LOGGING is not set -CONFIG_SCSI_SCAN_ASYNC=y -CONFIG_SCSI_WAIT_SCAN=m # -# SCSI Transports +# SCSI Transport Attributes # CONFIG_SCSI_SPI_ATTRS=m CONFIG_SCSI_FC_ATTRS=m -CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_ISCSI_ATTRS is not set CONFIG_SCSI_SAS_ATTRS=m -CONFIG_SCSI_SAS_LIBSAS=m -# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set # # SCSI low-level drivers @@ -956,11 +890,16 @@ CONFIG_SCSI_SAS_LIBSAS=m # CONFIG_ISCSI_TCP is not set CONFIG_BLK_DEV_3W_XXXX_RAID=m CONFIG_SCSI_3W_9XXX=m +CONFIG_SCSI_7000FASST=m CONFIG_SCSI_ACARD=m +CONFIG_SCSI_AHA152X=m +CONFIG_SCSI_AHA1542=m +CONFIG_SCSI_AHA1740=m CONFIG_SCSI_AACRAID=m CONFIG_SCSI_AIC7XXX=m CONFIG_AIC7XXX_CMDS_PER_DEVICE=253 CONFIG_AIC7XXX_RESET_DELAY_MS=15000 +# CONFIG_AIC7XXX_PROBE_EISA_VL is not set # CONFIG_AIC7XXX_BUILD_FIRMWARE is not set # CONFIG_AIC7XXX_DEBUG_ENABLE is not set CONFIG_AIC7XXX_DEBUG_MASK=0 @@ -970,108 +909,97 @@ CONFIG_SCSI_AIC79XX=m CONFIG_AIC79XX_CMDS_PER_DEVICE=32 CONFIG_AIC79XX_RESET_DELAY_MS=15000 # CONFIG_AIC79XX_BUILD_FIRMWARE is not set +# CONFIG_AIC79XX_ENABLE_RD_STRM is not set # CONFIG_AIC79XX_DEBUG_ENABLE is not set CONFIG_AIC79XX_DEBUG_MASK=0 # CONFIG_AIC79XX_REG_PRETTY_PRINT is not set -CONFIG_SCSI_AIC94XX=m -# CONFIG_AIC94XX_DEBUG is not set CONFIG_SCSI_DPT_I2O=m CONFIG_SCSI_ADVANSYS=m +CONFIG_SCSI_IN2000=m CONFIG_SCSI_ARCMSR=m CONFIG_MEGARAID_NEWGEN=y CONFIG_MEGARAID_MM=m CONFIG_MEGARAID_MAILBOX=m CONFIG_MEGARAID_LEGACY=m CONFIG_MEGARAID_SAS=m +CONFIG_SCSI_SATA=m +CONFIG_SCSI_SATA_AHCI=m +CONFIG_SCSI_SATA_SVW=m +CONFIG_SCSI_ATA_PIIX=m +# CONFIG_SCSI_SATA_MV is not set +CONFIG_SCSI_SATA_NV=m +CONFIG_SCSI_PDC_ADMA=m CONFIG_SCSI_HPTIOP=m +CONFIG_SCSI_SATA_QSTOR=m +CONFIG_SCSI_SATA_PROMISE=m +CONFIG_SCSI_SATA_SX4=m +CONFIG_SCSI_SATA_SIL=m +CONFIG_SCSI_SATA_SIL24=m +CONFIG_SCSI_SATA_SIS=m +CONFIG_SCSI_SATA_ULI=m +CONFIG_SCSI_SATA_VIA=m +CONFIG_SCSI_SATA_VITESSE=m +CONFIG_SCSI_SATA_INTEL_COMBINED=y CONFIG_SCSI_BUSLOGIC=m # CONFIG_SCSI_OMIT_FLASHPOINT is not set CONFIG_SCSI_DMX3191D=m +CONFIG_SCSI_DTC3280=m CONFIG_SCSI_EATA=m CONFIG_SCSI_EATA_TAGGED_QUEUE=y CONFIG_SCSI_EATA_LINKED_COMMANDS=y CONFIG_SCSI_EATA_MAX_TAGS=16 CONFIG_SCSI_FUTURE_DOMAIN=m +CONFIG_SCSI_FD_MCS=m CONFIG_SCSI_GDTH=m +CONFIG_SCSI_GENERIC_NCR5380=m +CONFIG_SCSI_GENERIC_NCR5380_MMIO=m +CONFIG_SCSI_GENERIC_NCR53C400=y +CONFIG_SCSI_IBMMCA=m +# CONFIG_IBMMCA_SCSI_ORDER_STANDARD is not set +# CONFIG_IBMMCA_SCSI_DEV_RESET is not set CONFIG_SCSI_IPS=m CONFIG_SCSI_INITIO=m CONFIG_SCSI_INIA100=m # CONFIG_SCSI_PPA is not set # CONFIG_SCSI_IMM is not set -CONFIG_SCSI_STEX=m +CONFIG_SCSI_NCR53C406A=m +CONFIG_SCSI_NCR_D700=m CONFIG_SCSI_SYM53C8XX_2=m CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1 CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16 CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64 -CONFIG_SCSI_SYM53C8XX_MMIO=y -CONFIG_SCSI_IPR=m -CONFIG_SCSI_IPR_TRACE=y -CONFIG_SCSI_IPR_DUMP=y +# CONFIG_SCSI_SYM53C8XX_IOMAPPED is not set +# CONFIG_SCSI_IPR is not set +CONFIG_SCSI_NCR_Q720=m +CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS=8 +CONFIG_SCSI_NCR53C8XX_MAX_TAGS=32 +CONFIG_SCSI_NCR53C8XX_SYNC=20 +# CONFIG_SCSI_NCR53C8XX_PROFILE is not set +CONFIG_SCSI_PAS16=m +CONFIG_SCSI_PSI240I=m +# CONFIG_SCSI_QLOGIC_FAS is not set +# CONFIG_SCSI_QLOGIC_FC is not set CONFIG_SCSI_QLOGIC_1280=m # CONFIG_SCSI_QLA_FC is not set -CONFIG_SCSI_QLA_ISCSI=m # CONFIG_SCSI_LPFC is not set +CONFIG_SCSI_SIM710=m +CONFIG_53C700_IO_MAPPED=y +CONFIG_SCSI_SYM53C416=m CONFIG_SCSI_DC395x=m CONFIG_SCSI_DC390T=m +CONFIG_SCSI_T128=m +CONFIG_SCSI_U14_34F=m +CONFIG_SCSI_U14_34F_TAGGED_QUEUE=y +CONFIG_SCSI_U14_34F_LINKED_COMMANDS=y +CONFIG_SCSI_U14_34F_MAX_TAGS=8 +CONFIG_SCSI_ULTRASTOR=m CONFIG_SCSI_NSP32=m # CONFIG_SCSI_DEBUG is not set -CONFIG_SCSI_SRP=m -CONFIG_ATA=m -# CONFIG_ATA_NONSTANDARD is not set -CONFIG_ATA_ACPI=y -CONFIG_SATA_AHCI=m -CONFIG_SATA_SVW=m -CONFIG_ATA_PIIX=m -CONFIG_SATA_MV=m -CONFIG_SATA_NV=m -CONFIG_PDC_ADMA=m -CONFIG_SATA_QSTOR=m -CONFIG_SATA_PROMISE=m -CONFIG_SATA_SX4=m -CONFIG_SATA_SIL=m -CONFIG_SATA_SIL24=m -CONFIG_SATA_SIS=m -CONFIG_SATA_ULI=m -CONFIG_SATA_VIA=m -CONFIG_SATA_VITESSE=m -CONFIG_SATA_INIC162X=m -CONFIG_PATA_ALI=m -CONFIG_PATA_AMD=m -CONFIG_PATA_ARTOP=m -CONFIG_PATA_ATIIXP=m -CONFIG_PATA_CMD640_PCI=m -CONFIG_PATA_CMD64X=m -CONFIG_PATA_CS5520=m -CONFIG_PATA_CS5530=m -CONFIG_PATA_CS5535=m -CONFIG_PATA_CYPRESS=m -CONFIG_PATA_EFAR=m -CONFIG_ATA_GENERIC=m -CONFIG_PATA_HPT366=m -CONFIG_PATA_HPT37X=m -CONFIG_PATA_HPT3X2N=m -CONFIG_PATA_HPT3X3=m -CONFIG_PATA_IT821X=m -CONFIG_PATA_IT8213=m -CONFIG_PATA_JMICRON=m -CONFIG_PATA_TRIFLEX=m -CONFIG_PATA_MARVELL=m -CONFIG_PATA_MPIIX=m -CONFIG_PATA_OLDPIIX=m -CONFIG_PATA_NETCELL=m -CONFIG_PATA_NS87410=m -CONFIG_PATA_OPTI=m -CONFIG_PATA_OPTIDMA=m -CONFIG_PATA_PDC_OLD=m -CONFIG_PATA_RADISYS=m -CONFIG_PATA_RZ1000=m -CONFIG_PATA_SC1200=m -CONFIG_PATA_SERVERWORKS=m -CONFIG_PATA_PDC2027X=m -CONFIG_PATA_SIL680=m -CONFIG_PATA_SIS=m -CONFIG_PATA_VIA=m -CONFIG_PATA_WINBOND=m + +# +# Old CD-ROM drivers (not SCSI, not IDE) +# +# CONFIG_CD_NO_IDESCSI is not set # # Multi-device support (RAID and LVM) @@ -1082,8 +1010,8 @@ CONFIG_MD_LINEAR=m CONFIG_MD_RAID0=m CONFIG_MD_RAID1=m # CONFIG_MD_RAID10 is not set -CONFIG_MD_RAID456=m -CONFIG_MD_RAID5_RESHAPE=y +CONFIG_MD_RAID5=m +# CONFIG_MD_RAID6 is not set CONFIG_MD_MULTIPATH=m # CONFIG_MD_FAULTY is not set # CONFIG_BLK_DEV_DM is not set @@ -1101,18 +1029,19 @@ CONFIG_FUSION_CTL=m # # IEEE 1394 (FireWire) support # -CONFIG_FIREWIRE=m -CONFIG_FIREWIRE_OHCI=m -CONFIG_FIREWIRE_SBP2=m CONFIG_IEEE1394=m # # Subsystem Options # # CONFIG_IEEE1394_VERBOSEDEBUG is not set +# CONFIG_IEEE1394_OUI_DB is not set +CONFIG_IEEE1394_EXTRA_CONFIG_ROMS=y +CONFIG_IEEE1394_CONFIG_ROM_IP1394=y +# CONFIG_IEEE1394_EXPORT_FULL_API is not set # -# Controllers +# Device Drivers # # @@ -1121,11 +1050,10 @@ CONFIG_IEEE1394=m CONFIG_IEEE1394_OHCI1394=m # -# Protocols +# Protocol Drivers # # CONFIG_IEEE1394_VIDEO1394 is not set # CONFIG_IEEE1394_SBP2 is not set -CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y CONFIG_IEEE1394_ETH1394=m # CONFIG_IEEE1394_DV1394 is not set # CONFIG_IEEE1394_RAWIO is not set @@ -1134,7 +1062,6 @@ CONFIG_IEEE1394_ETH1394=m # I2O device support # # CONFIG_I2O is not set -# CONFIG_MACINTOSH_DRIVERS is not set # # Network device support @@ -1152,7 +1079,15 @@ CONFIG_IMQ_BEHAVIOR_BA=y CONFIG_IMQ_NUM_DEVS=2 CONFIG_TUN=m CONFIG_NET_SB1000=m + +# +# ARCnet devices +# # CONFIG_ARCNET is not set + +# +# PHY device support +# CONFIG_PHYLIB=m # @@ -1163,12 +1098,6 @@ CONFIG_DAVICOM_PHY=m CONFIG_QSEMI_PHY=m CONFIG_LXT_PHY=m CONFIG_CICADA_PHY=m -CONFIG_VITESSE_PHY=m -CONFIG_SMSC_PHY=m -CONFIG_BROADCOM_PHY=m -CONFIG_FIXED_PHY=m -# CONFIG_FIXED_MII_10_FDX is not set -# CONFIG_FIXED_MII_100_FDX is not set # # Ethernet (10 or 100Mbit) @@ -1179,8 +1108,26 @@ CONFIG_HAPPYMEAL=m CONFIG_SUNGEM=m CONFIG_CASSINI=m CONFIG_NET_VENDOR_3COM=y +CONFIG_EL1=m +CONFIG_EL2=m +CONFIG_ELPLUS=m +CONFIG_EL16=m +CONFIG_EL3=m +CONFIG_3C515=m +CONFIG_ELMC=m +CONFIG_ELMC_II=m CONFIG_VORTEX=m CONFIG_TYPHOON=m +CONFIG_LANCE=m +CONFIG_NET_VENDOR_SMC=y +CONFIG_WD80x3=m +CONFIG_ULTRAMCA=m +CONFIG_ULTRA=m +CONFIG_ULTRA32=m +CONFIG_SMC9194=m +CONFIG_NET_VENDOR_RACAL=y +CONFIG_NI52=m +CONFIG_NI65=m # # Tulip family network device support @@ -1195,23 +1142,43 @@ CONFIG_DE4X5=m CONFIG_WINBOND_840=m CONFIG_DM9102=m CONFIG_ULI526X=m +CONFIG_AT1700=m +CONFIG_DEPCA=m CONFIG_HP100=m +CONFIG_NET_ISA=y +CONFIG_E2100=m +CONFIG_EWRK3=m +CONFIG_EEXPRESS=m +CONFIG_EEXPRESS_PRO=m +CONFIG_HPLAN_PLUS=m +CONFIG_HPLAN=m +CONFIG_LP486E=m +CONFIG_ETH16I=m +CONFIG_NE2000=m +CONFIG_ZNET=m +CONFIG_SEEQ8005=m +CONFIG_NE2_MCA=m +CONFIG_IBMLANA=m CONFIG_NET_PCI=y CONFIG_PCNET32=m -CONFIG_PCNET32_NAPI=y CONFIG_AMD8111_ETH=m CONFIG_AMD8111E_NAPI=y CONFIG_ADAPTEC_STARFIRE=m CONFIG_ADAPTEC_STARFIRE_NAPI=y +CONFIG_AC3200=m +CONFIG_APRICOT=m CONFIG_B44=m CONFIG_FORCEDETH=m -CONFIG_FORCEDETH_NAPI=y +CONFIG_CS89x0=m CONFIG_DGRS=m CONFIG_EEPRO100=m CONFIG_E100=m +CONFIG_LNE390=m CONFIG_FEALNX=m CONFIG_NATSEMI=m CONFIG_NE2K_PCI=m +CONFIG_NE3210=m +CONFIG_ES3210=m CONFIG_8139CP=m CONFIG_8139TOO=m # CONFIG_8139TOO_PIO is not set @@ -1225,13 +1192,14 @@ CONFIG_SUNDANCE_MMIO=y CONFIG_TLAN=m CONFIG_VIA_RHINE=m CONFIG_VIA_RHINE_MMIO=y -CONFIG_VIA_RHINE_NAPI=y -CONFIG_SC92031=y CONFIG_NET_POCKET=y CONFIG_ATP=m CONFIG_DE600=m CONFIG_DE620=m -CONFIG_NETDEV_1000=y + +# +# Ethernet (1000 Mbit) +# CONFIG_ACENIC=m # CONFIG_ACENIC_OMIT_TIGON_I is not set CONFIG_DL2K=m @@ -1251,40 +1219,41 @@ CONFIG_SK98LIN=m CONFIG_VIA_VELOCITY=m CONFIG_TIGON3=m CONFIG_BNX2=m -CONFIG_QLA3XXX=m -CONFIG_ATL1=m -CONFIG_NETDEV_10000=y + +# +# Ethernet (10000 Mbit) +# CONFIG_CHELSIO_T1=m -CONFIG_CHELSIO_T1_1G=y -CONFIG_CHELSIO_T1_NAPI=y -CONFIG_CHELSIO_T3=m CONFIG_IXGB=m # CONFIG_IXGB_NAPI is not set CONFIG_S2IO=m # CONFIG_S2IO_NAPI is not set -CONFIG_MYRI10GE=m -CONFIG_NETXEN_NIC=m -# CONFIG_MLX4_CORE is not set + +# +# Token Ring devices +# # CONFIG_TR is not set # -# Wireless LAN +# Wireless LAN (non-hamradio) +# +CONFIG_NET_RADIO=y + +# +# Obsolete Wireless cards support (pre-802.11) +# +# CONFIG_STRIP is not set +CONFIG_ARLAN=m +CONFIG_WAVELAN=m + +# +# Wireless 802.11b ISA/PCI cards support # -CONFIG_WLAN_PRE80211=y -CONFIG_STRIP=m -CONFIG_WLAN_80211=y CONFIG_IPW2100=m CONFIG_IPW2100_MONITOR=y # CONFIG_IPW2100_DEBUG is not set CONFIG_IPW2200=m -CONFIG_IPW2200_MONITOR=y -CONFIG_IPW2200_RADIOTAP=y -CONFIG_IPW2200_PROMISCUOUS=y -CONFIG_IPW2200_QOS=y # CONFIG_IPW2200_DEBUG is not set -CONFIG_LIBERTAS=m -CONFIG_LIBERTAS_USB=m -# CONFIG_LIBERTAS_DEBUG is not set CONFIG_AIRO=m CONFIG_HERMES=m CONFIG_PLX_HERMES=m @@ -1293,50 +1262,65 @@ CONFIG_NORTEL_HERMES=m CONFIG_PCI_HERMES=m CONFIG_ATMEL=m CONFIG_PCI_ATMEL=m + +# +# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support +# CONFIG_PRISM54=m -CONFIG_USB_ZD1201=m CONFIG_HOSTAP=m CONFIG_HOSTAP_FIRMWARE=y -CONFIG_HOSTAP_FIRMWARE_NVRAM=y +# CONFIG_HOSTAP_FIRMWARE_NVRAM is not set CONFIG_HOSTAP_PLX=m CONFIG_HOSTAP_PCI=m -CONFIG_BCM43XX=m -# CONFIG_BCM43XX_DEBUG is not set -CONFIG_BCM43XX_DMA=y -CONFIG_BCM43XX_PIO=y -CONFIG_BCM43XX_DMA_AND_PIO_MODE=y -# CONFIG_BCM43XX_DMA_MODE is not set -# CONFIG_BCM43XX_PIO_MODE is not set -CONFIG_ZD1211RW=m -# CONFIG_ZD1211RW_DEBUG is not set +CONFIG_NET_WIRELESS=y # -# USB Network Adapters +# Wan interfaces # -CONFIG_USB_CATC=m -CONFIG_USB_KAWETH=m -CONFIG_USB_PEGASUS=m -CONFIG_USB_RTL8150=m -CONFIG_USB_USBNET_MII=m -CONFIG_USB_USBNET=m -CONFIG_USB_NET_AX8817X=m -CONFIG_USB_NET_CDCETHER=m -CONFIG_USB_NET_DM9601=m -CONFIG_USB_NET_GL620A=m -CONFIG_USB_NET_NET1080=m -CONFIG_USB_NET_PLUSB=m -CONFIG_USB_NET_MCS7830=m -CONFIG_USB_NET_RNDIS_HOST=m -CONFIG_USB_NET_CDC_SUBSET=m -CONFIG_USB_ALI_M5632=y -CONFIG_USB_AN2720=y -CONFIG_USB_BELKIN=y -CONFIG_USB_ARMLINUX=y -CONFIG_USB_EPSON2888=y -CONFIG_USB_KC2190=y -CONFIG_USB_NET_ZAURUS=m # CONFIG_WAN is not set -# CONFIG_ATM_DRIVERS is not set + +# +# ATM drivers +# +# CONFIG_ATM_DUMMY is not set +CONFIG_ATM_TCP=m +CONFIG_ATM_LANAI=m +CONFIG_ATM_ENI=m +CONFIG_ATM_ENI_DEBUG=y +CONFIG_ATM_ENI_TUNE_BURST=y +CONFIG_ATM_ENI_BURST_TX_16W=y +CONFIG_ATM_ENI_BURST_TX_8W=y +CONFIG_ATM_ENI_BURST_TX_4W=y +CONFIG_ATM_ENI_BURST_TX_2W=y +CONFIG_ATM_ENI_BURST_RX_16W=y +CONFIG_ATM_ENI_BURST_RX_8W=y +CONFIG_ATM_ENI_BURST_RX_4W=y +CONFIG_ATM_ENI_BURST_RX_2W=y +CONFIG_ATM_FIRESTREAM=m +CONFIG_ATM_ZATM=m +# CONFIG_ATM_ZATM_DEBUG is not set +CONFIG_ATM_NICSTAR=m +CONFIG_ATM_NICSTAR_USE_SUNI=y +CONFIG_ATM_NICSTAR_USE_IDT77105=y +CONFIG_ATM_IDT77252=m +# CONFIG_ATM_IDT77252_DEBUG is not set +# CONFIG_ATM_IDT77252_RCV_ALL is not set +CONFIG_ATM_IDT77252_USE_SUNI=y +CONFIG_ATM_AMBASSADOR=m +# CONFIG_ATM_AMBASSADOR_DEBUG is not set +CONFIG_ATM_HORIZON=m +# CONFIG_ATM_HORIZON_DEBUG is not set +CONFIG_ATM_IA=m +# CONFIG_ATM_IA_DEBUG is not set +CONFIG_ATM_FORE200E_MAYBE=m +CONFIG_ATM_FORE200E_PCA=y +CONFIG_ATM_FORE200E_PCA_DEFAULT_FW=y +CONFIG_ATM_FORE200E_USE_TASKLET=y +CONFIG_ATM_FORE200E_TX_RETRY=16 +CONFIG_ATM_FORE200E_DEBUG=0 +CONFIG_ATM_FORE200E=m +CONFIG_ATM_HE=m +CONFIG_ATM_HE_USE_SUNI=y # CONFIG_FDDI is not set # CONFIG_HIPPI is not set # CONFIG_PLIP is not set @@ -1352,7 +1336,6 @@ CONFIG_PPPOE=m CONFIG_PPPOATM=m CONFIG_SLIP=m CONFIG_SLIP_COMPRESSED=y -CONFIG_SLHC=m CONFIG_SLIP_SMART=y CONFIG_SLIP_MODE_SLIP6=y # CONFIG_NET_FC is not set @@ -1376,7 +1359,6 @@ CONFIG_ISDN=m # CONFIG_ISDN_CAPI=m CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y -CONFIG_CAPI_TRACE=y CONFIG_ISDN_CAPI_MIDDLEWARE=y CONFIG_ISDN_CAPI_CAPI20=m CONFIG_ISDN_CAPI_CAPIFS_BOOL=y @@ -1390,8 +1372,10 @@ CONFIG_ISDN_CAPI_CAPIFS=m # Active AVM cards # CONFIG_CAPI_AVM=y +CONFIG_ISDN_DRV_AVMB1_B1ISA=m CONFIG_ISDN_DRV_AVMB1_B1PCI=m CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y +CONFIG_ISDN_DRV_AVMB1_T1ISA=m CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m CONFIG_ISDN_DRV_AVMB1_T1PCI=m CONFIG_ISDN_DRV_AVMB1_C4=m @@ -1409,12 +1393,11 @@ CONFIG_MISDN_DRV=m CONFIG_MISDN_AVM_FRITZ=y CONFIG_MISDN_NETJET=y CONFIG_MISDN_HFCPCI=y -CONFIG_MISDN_HFCMULTI=y -# CONFIG_HFCMULTI_PCIMEM is not set +# CONFIG_MISDN_HFCMULTI is not set CONFIG_MISDN_HFCUSB=y -# CONFIG_MISDN_HFCMINI is not set -# CONFIG_MISDN_XHFC is not set -# CONFIG_MISDN_SPEEDFAX is not set +CONFIG_MISDN_HFCMINI=y +CONFIG_MISDN_XHFC=y +CONFIG_MISDN_SPEEDFAX=y CONFIG_MISDN_W6692=y CONFIG_MISDN_DSP=y CONFIG_MISDN_LOOP=y @@ -1429,8 +1412,6 @@ CONFIG_MISDN_L1OIP=y # Input device support # CONFIG_INPUT=y -# CONFIG_INPUT_FF_MEMLESS is not set -# CONFIG_INPUT_POLLDEV is not set # # Userland interfaces @@ -1453,20 +1434,12 @@ CONFIG_KEYBOARD_SUNKBD=m CONFIG_KEYBOARD_LKKBD=m CONFIG_KEYBOARD_XTKBD=m CONFIG_KEYBOARD_NEWTON=m -CONFIG_KEYBOARD_STOWAWAY=m # CONFIG_INPUT_MOUSE is not set # CONFIG_INPUT_JOYSTICK is not set -# CONFIG_INPUT_TABLET is not set # CONFIG_INPUT_TOUCHSCREEN is not set CONFIG_INPUT_MISC=y CONFIG_INPUT_PCSPKR=y # CONFIG_INPUT_WISTRON_BTNS is not set -CONFIG_INPUT_ATLAS_BTNS=m -CONFIG_INPUT_ATI_REMOTE=m -CONFIG_INPUT_ATI_REMOTE2=m -# CONFIG_INPUT_KEYSPAN_REMOTE is not set -# CONFIG_INPUT_POWERMATE is not set -# CONFIG_INPUT_YEALINK is not set # CONFIG_INPUT_UINPUT is not set # @@ -1488,15 +1461,13 @@ CONFIG_SERIO_LIBPS2=y CONFIG_VT=y CONFIG_VT_CONSOLE=y CONFIG_HW_CONSOLE=y -# CONFIG_VT_HW_CONSOLE_BINDING is not set # CONFIG_SERIAL_NONSTANDARD is not set # # Serial drivers # CONFIG_SERIAL_8250=m -CONFIG_SERIAL_8250_PCI=m -CONFIG_SERIAL_8250_PNP=m +# CONFIG_SERIAL_8250_ACPI is not set CONFIG_SERIAL_8250_NR_UARTS=4 CONFIG_SERIAL_8250_RUNTIME_UARTS=4 CONFIG_SERIAL_8250_EXTENDED=y @@ -1504,6 +1475,11 @@ CONFIG_SERIAL_8250_MANY_PORTS=y CONFIG_SERIAL_8250_SHARE_IRQ=y CONFIG_SERIAL_8250_DETECT_IRQ=y CONFIG_SERIAL_8250_RSA=y +# CONFIG_SERIAL_8250_FOURPORT is not set +# CONFIG_SERIAL_8250_ACCENT is not set +# CONFIG_SERIAL_8250_BOCA is not set +# CONFIG_SERIAL_8250_HUB6 is not set +# CONFIG_SERIAL_8250_MCA is not set # # Non-8250 serial port support @@ -1527,6 +1503,10 @@ CONFIG_IPMI_DEVICE_INTERFACE=m CONFIG_IPMI_SI=m CONFIG_IPMI_WATCHDOG=m CONFIG_IPMI_POWEROFF=m + +# +# Watchdog Cards +# CONFIG_WATCHDOG=y # CONFIG_WATCHDOG_NOWAYOUT is not set @@ -1544,21 +1524,24 @@ CONFIG_IB700_WDT=m CONFIG_IBMASR=m CONFIG_WAFER_WDT=m CONFIG_I6300ESB_WDT=m -CONFIG_ITCO_WDT=m -# CONFIG_ITCO_VENDOR_SUPPORT is not set +CONFIG_I8XX_TCO=m CONFIG_SC1200_WDT=m -CONFIG_PC87413_WDT=m CONFIG_60XX_WDT=m CONFIG_SBC8360_WDT=m CONFIG_CPU5_WDT=m -CONFIG_SMSC37B787_WDT=m CONFIG_W83627HF_WDT=m -CONFIG_W83697HF_WDT=m CONFIG_W83877F_WDT=m CONFIG_W83977F_WDT=m CONFIG_MACHZ_WDT=m CONFIG_SBC_EPX_C3_WATCHDOG=m +# +# ISA-based Watchdog Cards +# +# CONFIG_PCWATCHDOG is not set +# CONFIG_MIXCOMWD is not set +# CONFIG_WDT is not set + # # PCI-based Watchdog Cards # @@ -1571,20 +1554,19 @@ CONFIG_WDT_501_PCI=y # CONFIG_USBPCWATCHDOG=m CONFIG_HW_RANDOM=m -CONFIG_HW_RANDOM_INTEL=m -CONFIG_HW_RANDOM_AMD=m -CONFIG_HW_RANDOM_GEODE=m -CONFIG_HW_RANDOM_VIA=m # CONFIG_NVRAM is not set CONFIG_RTC=y +# CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set # CONFIG_SONYPI is not set + +# +# Ftape, the floppy tape device driver +# # CONFIG_AGP is not set # CONFIG_DRM is not set CONFIG_MWAVE=m -CONFIG_PC8736x_GPIO=m -CONFIG_NSC_GPIO=m CONFIG_CS5535_GPIO=m # CONFIG_RAW_DRIVER is not set CONFIG_HPET=y @@ -1597,7 +1579,10 @@ CONFIG_HANGCHECK_TIMER=m # # CONFIG_TCG_TPM is not set # CONFIG_TELCLOCK is not set -CONFIG_DEVPORT=y + +# +# I2C support +# # CONFIG_I2C is not set # @@ -1610,84 +1595,54 @@ CONFIG_DEVPORT=y # Dallas's 1-wire bus # CONFIG_W1=m -CONFIG_W1_CON=y - -# -# 1-wire Bus Masters -# -CONFIG_W1_MASTER_MATROX=m -CONFIG_W1_MASTER_DS2490=m +CONFIG_W1_MATROX=m +CONFIG_W1_DS9490=m +CONFIG_W1_DS9490_BRIDGE=m +CONFIG_W1_THERM=m +CONFIG_W1_SMEM=m +CONFIG_W1_DS2433=m +CONFIG_W1_DS2433_CRC=y # -# 1-wire Slaves +# Hardware Monitoring support # -CONFIG_W1_SLAVE_THERM=m -CONFIG_W1_SLAVE_SMEM=m -CONFIG_W1_SLAVE_DS2433=m -CONFIG_W1_SLAVE_DS2433_CRC=y CONFIG_HWMON=m -CONFIG_HWMON_VID=m -CONFIG_SENSORS_ABITUGURU=m +# CONFIG_HWMON_VID is not set CONFIG_SENSORS_K8TEMP=m CONFIG_SENSORS_F71805F=m -CONFIG_SENSORS_CORETEMP=m CONFIG_SENSORS_PC87427=m -CONFIG_SENSORS_SMSC47M1=m -CONFIG_SENSORS_SMSC47B397=m -CONFIG_SENSORS_VT1211=m -CONFIG_SENSORS_W83627HF=m CONFIG_SENSORS_HDAPS=m -CONFIG_SENSORS_APPLESMC=m # CONFIG_HWMON_DEBUG_CHIP is not set # -# Multifunction device drivers +# Misc devices # -CONFIG_MFD_SM501=m +# CONFIG_IBM_ASM is not set # -# Multimedia devices +# Multimedia Capabilities Port drivers # -# CONFIG_VIDEO_DEV is not set -# CONFIG_DVB_CORE is not set -# CONFIG_DAB is not set # -# Graphics support +# Multimedia devices # -# CONFIG_BACKLIGHT_LCD_SUPPORT is not set -CONFIG_BACKLIGHT_CLASS_DEVICE=m -# CONFIG_BACKLIGHT_PROGEAR is not set +# CONFIG_VIDEO_DEV is not set # -# Display device support +# Digital Video Broadcasting Devices # -CONFIG_DISPLAY_SUPPORT=m +# CONFIG_DVB is not set # -# Display hardware drivers +# Graphics support # -# CONFIG_VGASTATE is not set CONFIG_FB=y -# CONFIG_FIRMWARE_EDID is not set -# CONFIG_FB_DDC is not set CONFIG_FB_CFB_FILLRECT=y CONFIG_FB_CFB_COPYAREA=y CONFIG_FB_CFB_IMAGEBLIT=y -CONFIG_FB_SYS_FILLRECT=m -CONFIG_FB_SYS_COPYAREA=m -CONFIG_FB_SYS_IMAGEBLIT=m -CONFIG_FB_SYS_FOPS=m -CONFIG_FB_DEFERRED_IO=y -# CONFIG_FB_SVGALIB is not set # CONFIG_FB_MACMODES is not set -# CONFIG_FB_BACKLIGHT is not set # CONFIG_FB_MODE_HELPERS is not set # CONFIG_FB_TILEBLITTING is not set - -# -# Frame buffer hardware drivers -# # CONFIG_FB_CIRRUS is not set # CONFIG_FB_PM2 is not set # CONFIG_FB_CYBER2000 is not set @@ -1696,51 +1651,49 @@ CONFIG_FB_DEFERRED_IO=y # CONFIG_FB_IMSTT is not set # CONFIG_FB_VGA16 is not set CONFIG_FB_VESA=y -# CONFIG_FB_HECUBA is not set +CONFIG_VIDEO_SELECT=y # CONFIG_FB_HGA is not set # CONFIG_FB_S1D13XXX is not set # CONFIG_FB_NVIDIA is not set # CONFIG_FB_RIVA is not set # CONFIG_FB_I810 is not set -# CONFIG_FB_LE80578 is not set # CONFIG_FB_INTEL is not set # CONFIG_FB_MATROX is not set +# CONFIG_FB_RADEON_OLD is not set # CONFIG_FB_RADEON is not set # CONFIG_FB_ATY128 is not set # CONFIG_FB_ATY is not set -# CONFIG_FB_S3 is not set # CONFIG_FB_SAVAGE is not set # CONFIG_FB_SIS is not set # CONFIG_FB_NEOMAGIC is not set # CONFIG_FB_KYRO is not set # CONFIG_FB_3DFX is not set # CONFIG_FB_VOODOO1 is not set -# CONFIG_FB_VT8623 is not set # CONFIG_FB_CYBLA is not set # CONFIG_FB_TRIDENT is not set -# CONFIG_FB_ARK is not set -# CONFIG_FB_PM3 is not set # CONFIG_FB_GEODE is not set -# CONFIG_FB_SM501 is not set # CONFIG_FB_VIRTUAL is not set # # Console display driver support # CONFIG_VGA_CONSOLE=y -CONFIG_VGACON_SOFT_SCROLLBACK=y -CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64 -CONFIG_VIDEO_SELECT=y +# CONFIG_MDA_CONSOLE is not set CONFIG_DUMMY_CONSOLE=y CONFIG_FRAMEBUFFER_CONSOLE=y # CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set # CONFIG_FONTS is not set CONFIG_FONT_8x8=y CONFIG_FONT_8x16=y + +# +# Logo configuration +# CONFIG_LOGO=y CONFIG_LOGO_LINUX_MONO=y CONFIG_LOGO_LINUX_VGA16=y CONFIG_LOGO_LINUX_CLUT224=y +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set # # Sound @@ -1760,13 +1713,11 @@ CONFIG_SND_SEQUENCER=m CONFIG_SND_OSSEMUL=y CONFIG_SND_MIXER_OSS=m CONFIG_SND_PCM_OSS=m -CONFIG_SND_PCM_OSS_PLUGINS=y # CONFIG_SND_SEQUENCER_OSS is not set CONFIG_SND_RTCTIMER=m CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y # CONFIG_SND_DYNAMIC_MINORS is not set # CONFIG_SND_SUPPORT_OLD_API is not set -CONFIG_SND_VERBOSE_PROCFS=y # CONFIG_SND_VERBOSE_PRINTK is not set # CONFIG_SND_DEBUG is not set @@ -1777,19 +1728,48 @@ CONFIG_SND_MPU401_UART=m CONFIG_SND_OPL3_LIB=m CONFIG_SND_VX_LIB=m CONFIG_SND_AC97_CODEC=m +CONFIG_SND_AC97_BUS=m CONFIG_SND_DUMMY=m # CONFIG_SND_VIRMIDI is not set CONFIG_SND_MTPAV=m -CONFIG_SND_MTS64=m CONFIG_SND_SERIAL_U16550=m CONFIG_SND_MPU401=m -CONFIG_SND_PORTMAN2X4=m + +# +# ISA devices +# +# CONFIG_SND_AD1816A is not set +# CONFIG_SND_AD1848 is not set +# CONFIG_SND_ALS100 is not set +# CONFIG_SND_AZT2320 is not set +# CONFIG_SND_CMI8330 is not set +# CONFIG_SND_CS4231 is not set +# CONFIG_SND_CS4232 is not set +# CONFIG_SND_CS4236 is not set +# CONFIG_SND_DT019X is not set +# CONFIG_SND_ES968 is not set +# CONFIG_SND_ES1688 is not set +# CONFIG_SND_ES18XX is not set +# CONFIG_SND_GUSCLASSIC is not set +# CONFIG_SND_GUSEXTREME is not set +# CONFIG_SND_GUSMAX is not set +# CONFIG_SND_INTERWAVE is not set +# CONFIG_SND_INTERWAVE_STB is not set +# CONFIG_SND_OPL3SA2 is not set +# CONFIG_SND_OPTI92X_AD1848 is not set +# CONFIG_SND_OPTI92X_CS4231 is not set +# CONFIG_SND_OPTI93X is not set +# CONFIG_SND_SB8 is not set +# CONFIG_SND_SB16 is not set +# CONFIG_SND_SBAWE is not set +# CONFIG_SND_SGALAXY is not set +# CONFIG_SND_SSCAPE is not set +# CONFIG_SND_WAVEFRONT is not set # # PCI devices # CONFIG_SND_AD1889=m -CONFIG_SND_ALS300=m CONFIG_SND_ALS4000=m CONFIG_SND_ALI5451=m CONFIG_SND_ATIIXP=m @@ -1834,13 +1814,10 @@ CONFIG_SND_ICE1724=m CONFIG_SND_INTEL8X0=m CONFIG_SND_INTEL8X0M=m CONFIG_SND_KORG1212=m -CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL=y CONFIG_SND_MAESTRO3=m -CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL=y CONFIG_SND_MIXART=m CONFIG_SND_NM256=m CONFIG_SND_PCXHR=m -CONFIG_SND_RIPTIDE=m CONFIG_SND_RME32=m CONFIG_SND_RME96=m CONFIG_SND_RME9652=m @@ -1850,54 +1827,23 @@ CONFIG_SND_VIA82XX=m CONFIG_SND_VIA82XX_MODEM=m CONFIG_SND_VX222=m CONFIG_SND_YMFPCI=m -CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y -CONFIG_SND_AC97_POWER_SAVE=y # # USB devices # CONFIG_SND_USB_AUDIO=m CONFIG_SND_USB_USX2Y=m -CONFIG_SND_USB_CAIAQ=m -# CONFIG_SND_USB_CAIAQ_INPUT is not set - -# -# System on Chip audio support -# -CONFIG_SND_SOC=m # # Open Sound System # # CONFIG_SOUND_PRIME is not set -CONFIG_AC97_BUS=m - -# -# HID Devices -# -CONFIG_HID=m -# CONFIG_HID_DEBUG is not set - -# -# USB Input Devices -# -CONFIG_USB_HID=m -# CONFIG_USB_HIDINPUT_POWERBOOK is not set -# CONFIG_HID_FF is not set -CONFIG_USB_HIDDEV=y - -# -# USB HID Boot Protocol drivers -# -# CONFIG_USB_KBD is not set -# CONFIG_USB_MOUSE is not set # # USB support # CONFIG_USB_ARCH_HAS_HCD=y CONFIG_USB_ARCH_HAS_OHCI=y -CONFIG_USB_ARCH_HAS_EHCI=y CONFIG_USB=m # CONFIG_USB_DEBUG is not set @@ -1905,7 +1851,7 @@ CONFIG_USB=m # Miscellaneous USB options # CONFIG_USB_DEVICEFS=y -CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_BANDWIDTH is not set CONFIG_USB_DYNAMIC_MINORS=y CONFIG_USB_SUSPEND=y # CONFIG_USB_OTG is not set @@ -1916,12 +1862,9 @@ CONFIG_USB_SUSPEND=y CONFIG_USB_EHCI_HCD=m # CONFIG_USB_EHCI_SPLIT_ISO is not set # CONFIG_USB_EHCI_ROOT_HUB_TT is not set -# CONFIG_USB_EHCI_TT_NEWSCHED is not set -# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set CONFIG_USB_ISP116X_HCD=m CONFIG_USB_OHCI_HCD=m -# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set -# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set +# CONFIG_USB_OHCI_BIG_ENDIAN is not set CONFIG_USB_OHCI_LITTLE_ENDIAN=y CONFIG_USB_UHCI_HCD=m CONFIG_USB_SL811_HCD=m @@ -1929,6 +1872,7 @@ CONFIG_USB_SL811_HCD=m # # USB Device Class drivers # +# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set CONFIG_USB_ACM=m CONFIG_USB_PRINTER=m @@ -1950,14 +1894,74 @@ CONFIG_USB_STORAGE_SDDR09=y CONFIG_USB_STORAGE_SDDR55=y CONFIG_USB_STORAGE_JUMPSHOT=y CONFIG_USB_STORAGE_ALAUDA=y -CONFIG_USB_STORAGE_KARMA=y # CONFIG_USB_LIBUSUAL is not set +# +# USB Input Devices +# +CONFIG_USB_HID=m +CONFIG_USB_HIDINPUT=y +# CONFIG_USB_HIDINPUT_POWERBOOK is not set +# CONFIG_HID_FF is not set +CONFIG_USB_HIDDEV=y + +# +# USB HID Boot Protocol drivers +# +# CONFIG_USB_KBD is not set +# CONFIG_USB_MOUSE is not set +# CONFIG_USB_AIPTEK is not set +# CONFIG_USB_WACOM is not set +# CONFIG_USB_ACECAD is not set +# CONFIG_USB_KBTAB is not set +# CONFIG_USB_POWERMATE is not set +# CONFIG_USB_MTOUCH is not set +# CONFIG_USB_ITMTOUCH is not set +# CONFIG_USB_EGALAX is not set +# CONFIG_USB_YEALINK is not set +# CONFIG_USB_XPAD is not set +# CONFIG_USB_ATI_REMOTE is not set +# CONFIG_USB_ATI_REMOTE2 is not set +# CONFIG_USB_KEYSPAN_REMOTE is not set +# CONFIG_USB_APPLETOUCH is not set + # # USB Imaging devices # # CONFIG_USB_MDC800 is not set # CONFIG_USB_MICROTEK is not set + +# +# USB Multimedia devices +# +# CONFIG_USB_DABUSB is not set + +# +# Video4Linux support is needed for USB Multimedia device support +# + +# +# USB Network Adapters +# +CONFIG_USB_CATC=m +CONFIG_USB_KAWETH=m +CONFIG_USB_PEGASUS=m +CONFIG_USB_RTL8150=m +CONFIG_USB_USBNET=m +CONFIG_USB_NET_AX8817X=m +CONFIG_USB_NET_CDCETHER=m +CONFIG_USB_NET_GL620A=m +CONFIG_USB_NET_NET1080=m +CONFIG_USB_NET_PLUSB=m +CONFIG_USB_NET_RNDIS_HOST=m +CONFIG_USB_NET_CDC_SUBSET=m +CONFIG_USB_ALI_M5632=y +CONFIG_USB_AN2720=y +CONFIG_USB_BELKIN=y +CONFIG_USB_ARMLINUX=y +CONFIG_USB_EPSON2888=y +CONFIG_USB_NET_ZAURUS=m +CONFIG_USB_ZD1201=m # CONFIG_USB_MON is not set # @@ -1975,26 +1979,17 @@ CONFIG_USB_STORAGE_KARMA=y # CONFIG_USB_EMI62=m CONFIG_USB_EMI26=m -CONFIG_USB_ADUTUX=m # CONFIG_USB_AUERSWALD is not set # CONFIG_USB_RIO500 is not set # CONFIG_USB_LEGOTOWER is not set CONFIG_USB_LCD=m -CONFIG_USB_BERRY_CHARGE=m CONFIG_USB_LED=m -CONFIG_USB_CYPRESS_CY7C63=m # CONFIG_USB_CYTHERM is not set -CONFIG_USB_PHIDGET=m -CONFIG_USB_PHIDGETKIT=m -CONFIG_USB_PHIDGETMOTORCONTROL=m -CONFIG_USB_PHIDGETSERVO=m +# CONFIG_USB_PHIDGETKIT is not set +# CONFIG_USB_PHIDGETSERVO is not set # CONFIG_USB_IDMOUSE is not set -# CONFIG_USB_FTDI_ELAN is not set -# CONFIG_USB_APPLEDISPLAY is not set # CONFIG_USB_SISUSBVGA is not set # CONFIG_USB_LD is not set -# CONFIG_USB_TRANCEVIBRATOR is not set -# CONFIG_USB_IOWARRIOR is not set # CONFIG_USB_TEST is not set # @@ -2010,39 +2005,14 @@ CONFIG_USB_XUSBATM=m # USB Gadget Support # # CONFIG_USB_GADGET is not set -CONFIG_MMC=m -# CONFIG_MMC_DEBUG is not set -# CONFIG_MMC_UNSAFE_RESUME is not set # -# MMC/SD Card Drivers +# MMC/SD Card support # +CONFIG_MMC=m +# CONFIG_MMC_DEBUG is not set CONFIG_MMC_BLOCK=m - -# -# MMC/SD Host Controller Drivers -# -# CONFIG_MMC_SDHCI is not set CONFIG_MMC_WBSD=m -CONFIG_MMC_TIFM_SD=m - -# -# LED devices -# -CONFIG_NEW_LEDS=y -CONFIG_LEDS_CLASS=m - -# -# LED drivers -# - -# -# LED Triggers -# -CONFIG_LEDS_TRIGGERS=y -CONFIG_LEDS_TRIGGER_TIMER=m -CONFIG_LEDS_TRIGGER_IDE_DISK=y -CONFIG_LEDS_TRIGGER_HEARTBEAT=m # # InfiniBand support @@ -2054,71 +2024,6 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=m # # CONFIG_EDAC is not set -# -# Real Time Clock -# -CONFIG_RTC_LIB=m -CONFIG_RTC_CLASS=m - -# -# RTC interfaces -# -CONFIG_RTC_INTF_SYSFS=y -CONFIG_RTC_INTF_PROC=y -CONFIG_RTC_INTF_DEV=y -# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set -# CONFIG_RTC_DRV_TEST is not set - -# -# I2C RTC drivers -# - -# -# SPI RTC drivers -# - -# -# Platform RTC drivers -# -CONFIG_RTC_DRV_CMOS=m -CONFIG_RTC_DRV_DS1553=m -CONFIG_RTC_DRV_DS1742=m -CONFIG_RTC_DRV_M48T86=m -CONFIG_RTC_DRV_V3020=m - -# -# on-CPU RTC drivers -# - -# -# DMA Engine support -# -CONFIG_DMA_ENGINE=y - -# -# DMA Clients -# -CONFIG_NET_DMA=y - -# -# DMA Devices -# -CONFIG_INTEL_IOATDMA=m - -# -# Auxiliary Display support -# -CONFIG_KS0108=m -CONFIG_KS0108_PORT=0x378 -CONFIG_KS0108_DELAY=2 -CONFIG_CFAG12864B=m -CONFIG_CFAG12864B_RATE=20 - -# -# Virtualization -# -# CONFIG_KVM is not set - # # File systems # @@ -2131,14 +2036,8 @@ CONFIG_EXT3_FS=m CONFIG_EXT3_FS_XATTR=y CONFIG_EXT3_FS_POSIX_ACL=y CONFIG_EXT3_FS_SECURITY=y -CONFIG_EXT4DEV_FS=m -CONFIG_EXT4DEV_FS_XATTR=y -CONFIG_EXT4DEV_FS_POSIX_ACL=y -CONFIG_EXT4DEV_FS_SECURITY=y CONFIG_JBD=m # CONFIG_JBD_DEBUG is not set -CONFIG_JBD2=m -# CONFIG_JBD2_DEBUG is not set CONFIG_FS_MBCACHE=m CONFIG_REISER4_FS=m # CONFIG_REISER4_DEBUG is not set @@ -2155,22 +2054,21 @@ CONFIG_JFS_SECURITY=y CONFIG_JFS_STATISTICS=y CONFIG_FS_POSIX_ACL=y CONFIG_XFS_FS=m +CONFIG_XFS_EXPORT=y CONFIG_XFS_QUOTA=y CONFIG_XFS_SECURITY=y CONFIG_XFS_POSIX_ACL=y # CONFIG_XFS_RT is not set -# CONFIG_GFS2_FS is not set # CONFIG_OCFS2_FS is not set # CONFIG_MINIX_FS is not set # CONFIG_ROMFS_FS is not set CONFIG_INOTIFY=y -CONFIG_INOTIFY_USER=y # CONFIG_QUOTA is not set CONFIG_QUOTACTL=y CONFIG_DNOTIFY=y # CONFIG_AUTOFS_FS is not set # CONFIG_AUTOFS4_FS is not set -CONFIG_FUSE_FS=m +# CONFIG_FUSE_FS is not set # # CD-ROM/DVD Filesystems @@ -2195,34 +2093,30 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" # Pseudo filesystems # CONFIG_PROC_FS=y -CONFIG_PROC_KCORE=y -CONFIG_PROC_SYSCTL=y +# CONFIG_PROC_KCORE is not set CONFIG_SYSFS=y CONFIG_TMPFS=y -# CONFIG_TMPFS_POSIX_ACL is not set # CONFIG_HUGETLBFS is not set # CONFIG_HUGETLB_PAGE is not set CONFIG_RAMFS=y -CONFIG_CONFIGFS_FS=m +# CONFIG_RELAYFS_FS is not set +# CONFIG_CONFIGFS_FS is not set # # Miscellaneous filesystems # # CONFIG_ADFS_FS is not set # CONFIG_AFFS_FS is not set -# CONFIG_ECRYPT_FS is not set # CONFIG_HFS_FS is not set # CONFIG_HFSPLUS_FS is not set # CONFIG_BEFS_FS is not set # CONFIG_BFS_FS is not set # CONFIG_EFS_FS is not set +# CONFIG_JFFS_FS is not set CONFIG_JFFS2_FS=m CONFIG_JFFS2_FS_DEBUG=0 CONFIG_JFFS2_FS_WRITEBUFFER=y # CONFIG_JFFS2_SUMMARY is not set -CONFIG_JFFS2_FS_XATTR=y -CONFIG_JFFS2_FS_POSIX_ACL=y -CONFIG_JFFS2_FS_SECURITY=y CONFIG_JFFS2_COMPRESSION_OPTIONS=y CONFIG_JFFS2_ZLIB=y CONFIG_JFFS2_RTIME=y @@ -2231,6 +2125,10 @@ CONFIG_JFFS2_RUBIN=y CONFIG_JFFS2_CMODE_PRIORITY=y # CONFIG_JFFS2_CMODE_SIZE is not set # CONFIG_CRAMFS is not set +CONFIG_SQUASHFS=y +# CONFIG_SQUASHFS_EMBEDDED is not set +CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 +# CONFIG_SQUASHFS_VMALLOC is not set # CONFIG_VXFS_FS is not set # CONFIG_HPFS_FS is not set # CONFIG_QNX4FS_FS is not set @@ -2254,7 +2152,6 @@ CONFIG_EXPORTFS=m CONFIG_NFS_COMMON=y CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m -# CONFIG_SUNRPC_BIND34 is not set CONFIG_RPCSEC_GSS_KRB5=m # CONFIG_RPCSEC_GSS_SPKM3 is not set CONFIG_SMB_FS=m @@ -2262,10 +2159,8 @@ CONFIG_SMB_FS=m CONFIG_CIFS=m CONFIG_CIFS_STATS=y CONFIG_CIFS_STATS2=y -# CONFIG_CIFS_WEAK_PW_HASH is not set CONFIG_CIFS_XATTR=y # CONFIG_CIFS_POSIX is not set -# CONFIG_CIFS_DEBUG2 is not set # CONFIG_CIFS_EXPERIMENTAL is not set # CONFIG_NCP_FS is not set # CONFIG_CODA_FS is not set @@ -2322,12 +2217,6 @@ CONFIG_NLS_ISO8859_1=y # CONFIG_NLS_KOI8_U is not set CONFIG_NLS_UTF8=y -# -# Distributed Lock Manager -# -CONFIG_DLM=m -# CONFIG_DLM_DEBUG is not set - # # Instrumentation Support # @@ -2337,38 +2226,26 @@ CONFIG_DLM=m # # Kernel hacking # -CONFIG_TRACE_IRQFLAGS_SUPPORT=y # CONFIG_PRINTK_TIME is not set -CONFIG_ENABLE_MUST_CHECK=y # CONFIG_MAGIC_SYSRQ is not set -CONFIG_UNUSED_SYMBOLS=y -CONFIG_DEBUG_FS=y -# CONFIG_HEADERS_CHECK is not set # CONFIG_DEBUG_KERNEL is not set +CONFIG_LOG_BUF_SHIFT=15 CONFIG_DEBUG_BUGVERBOSE=y CONFIG_EARLY_PRINTK=y CONFIG_X86_FIND_SMP_CONFIG=y CONFIG_X86_MPPARSE=y -CONFIG_DOUBLEFAULT=y # # Security options # -CONFIG_KEYS=y -# CONFIG_KEYS_DEBUG_PROC_KEYS is not set +# CONFIG_KEYS is not set # CONFIG_SECURITY is not set # # Cryptographic options # CONFIG_CRYPTO=y -CONFIG_CRYPTO_ALGAPI=y -CONFIG_CRYPTO_ABLKCIPHER=m -CONFIG_CRYPTO_BLKCIPHER=m -CONFIG_CRYPTO_HASH=m -CONFIG_CRYPTO_MANAGER=y -CONFIG_CRYPTO_HMAC=m -CONFIG_CRYPTO_XCBC=m +CONFIG_CRYPTO_HMAC=y # CONFIG_CRYPTO_NULL is not set # CONFIG_CRYPTO_MD4 is not set CONFIG_CRYPTO_MD5=m @@ -2377,18 +2254,9 @@ CONFIG_CRYPTO_SHA256=m CONFIG_CRYPTO_SHA512=m # CONFIG_CRYPTO_WP512 is not set # CONFIG_CRYPTO_TGR192 is not set -CONFIG_CRYPTO_GF128MUL=m -CONFIG_CRYPTO_ECB=m -CONFIG_CRYPTO_CBC=m -CONFIG_CRYPTO_PCBC=m -CONFIG_CRYPTO_LRW=m -CONFIG_CRYPTO_CRYPTD=m CONFIG_CRYPTO_DES=m -CONFIG_CRYPTO_FCRYPT=m CONFIG_CRYPTO_BLOWFISH=m CONFIG_CRYPTO_TWOFISH=m -CONFIG_CRYPTO_TWOFISH_COMMON=m -CONFIG_CRYPTO_TWOFISH_586=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_AES=m CONFIG_CRYPTO_AES_586=m @@ -2399,39 +2267,29 @@ CONFIG_CRYPTO_ARC4=m # CONFIG_CRYPTO_KHAZAD is not set # CONFIG_CRYPTO_ANUBIS is not set CONFIG_CRYPTO_DEFLATE=y -CONFIG_CRYPTO_MICHAEL_MIC=m +# CONFIG_CRYPTO_MICHAEL_MIC is not set CONFIG_CRYPTO_CRC32C=m -CONFIG_CRYPTO_CAMELLIA=m # CONFIG_CRYPTO_TEST is not set # # Hardware crypto devices # CONFIG_CRYPTO_DEV_PADLOCK=m -CONFIG_CRYPTO_DEV_PADLOCK_AES=m -CONFIG_CRYPTO_DEV_PADLOCK_SHA=m -CONFIG_CRYPTO_DEV_GEODE=m +CONFIG_CRYPTO_DEV_PADLOCK_AES=y # # Library routines # -CONFIG_BITREVERSE=y CONFIG_CRC_CCITT=m CONFIG_CRC16=m -CONFIG_CRC_ITU_T=m CONFIG_CRC32=y CONFIG_LIBCRC32C=m -CONFIG_AUDIT_GENERIC=y CONFIG_ZLIB_INFLATE=y CONFIG_ZLIB_DEFLATE=y CONFIG_TEXTSEARCH=y CONFIG_TEXTSEARCH_KMP=m CONFIG_TEXTSEARCH_BM=m CONFIG_TEXTSEARCH_FSM=m -CONFIG_PLIST=y -CONFIG_HAS_IOMEM=y -CONFIG_HAS_IOPORT=y -CONFIG_HAS_DMA=y CONFIG_GENERIC_HARDIRQS=y CONFIG_GENERIC_IRQ_PROBE=y CONFIG_GENERIC_PENDING_IRQ=y diff --git a/lfs/iptables b/lfs/iptables index b32781c58..984f6338e 100644 --- a/lfs/iptables +++ b/lfs/iptables @@ -26,7 +26,7 @@ include Config -VER = 1.3.8 +VER = 1.3.5 THISAPP = iptables-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -34,24 +34,22 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) -LAYER7 = netfilter-layer7-v2.13 - ############################################################################### # Top-level Rules ############################################################################### objects = $(DL_FILE) \ - $(LAYER7).tar.gz \ - libnfnetlink-0.0.30.tar.bz2 \ + netfilter-layer7-v2.9.tar.gz \ + libnfnetlink-0.0.25.tar.bz2 \ libnetfilter_queue-0.0.13.tar.bz2 $(DL_FILE) = $(DL_FROM)/$(DL_FILE) -$(LAYER7).tar.gz = $(URL_IPFIRE)/$(LAYER7).tar.gz -libnfnetlink-0.0.30.tar.bz2 = $(URL_IPFIRE)/libnfnetlink-0.0.30.tar.bz2 +netfilter-layer7-v2.9.tar.gz = $(URL_IPFIRE)/netfilter-layer7-v2.9.tar.gz +libnfnetlink-0.0.25.tar.bz2 = $(URL_IPFIRE)/libnfnetlink-0.0.25.tar.bz2 libnetfilter_queue-0.0.13.tar.bz2 = $(URL_IPFIRE)/libnetfilter_queue-0.0.13.tar.bz2 -$(DL_FILE)_MD5 = 0a9209f928002e5eee9cdff8fef4d4b3 -$(LAYER7).tar.gz_MD5 = c8097875074405be31e4372682b68d7a -libnfnetlink-0.0.30.tar.bz2_MD5 = 7fd3c8ddc03d42fa9f0177a17a38f163 +$(DL_FILE)_MD5 = 00fb916fa8040ca992a5ace56d905ea5 +netfilter-layer7-v2.9.tar.gz_MD5 = ebf9043a5352ebe6dbd721989ef83dee +libnfnetlink-0.0.25.tar.bz2_MD5 = fc915a2e66d282e524af6ef939042d7d libnetfilter_queue-0.0.13.tar.bz2_MD5 = 660cbfd3dc8c10bf9b1803cd2b688256 install : $(TARGET) @@ -81,12 +79,14 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) $(DIR_SRC)/libnfnetlink-* $(DIR_SRC)/netfilter-layer7* $(DIR_SRC)/libnetfilter_queue-* - @cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(LAYER7).tar.gz - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/$(LAYER7)/iptables-for-kernel-2.6.20forward-layer7-2.13.patch + # iptables-fixed.tar.gz is made in the linux kernel build process + @rm -rf $(DIR_APP) $(DIR_SRC)/libnfnetlink-0.0.25 $(DIR_SRC)/netfilter-layer7* $(DIR_SRC)/libnetfilter_queue-0.0.13 + + @cd $(DIR_SRC) && tar zxf $(DIR_DL)/iptables-fixed.tar.gz + cd $(DIR_SRC) && tar zxf $(DIR_DL)/netfilter-layer7-v2.9.tar.gz + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/netfilter-layer7-v2.9/iptables-layer7-2.9.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/iptables-1.3.6-imq.diff + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/iptables-1.3.0-imq1.diff chmod +x $(DIR_APP)/extensions/.IMQ-test* $(DIR_APP)/extensions/.layer7-test* # hack to disable IPv6 compilation as the configuration variable does not work when ip6.h is present @@ -95,15 +95,15 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) cd $(DIR_APP) && make BINDIR=/sbin MANDIR=/usr/share/man LIBDIR=/lib install cd $(DIR_APP) && cp -fva include/* /usr/include - cd $(DIR_SRC) && tar xfj $(DIR_DL)/libnfnetlink-0.0.30.tar.bz2 - cd $(DIR_SRC)/libnfnetlink-0.0.30 && ./configure --prefix=/usr - cd $(DIR_SRC)/libnfnetlink-0.0.30 && make - cd $(DIR_SRC)/libnfnetlink-0.0.30 && make install + cd $(DIR_SRC) && tar xfj $(DIR_DL)/libnfnetlink-0.0.25.tar.bz2 + cd $(DIR_SRC)/libnfnetlink-0.0.25 && ./configure --prefix=/usr + cd $(DIR_SRC)/libnfnetlink-0.0.25 && make + cd $(DIR_SRC)/libnfnetlink-0.0.25 && make install cd $(DIR_SRC) && tar xfj $(DIR_DL)/libnetfilter_queue-0.0.13.tar.bz2 cd $(DIR_SRC)/libnetfilter_queue-0.0.13 && ./configure --prefix=/usr cd $(DIR_SRC)/libnetfilter_queue-0.0.13 && make cd $(DIR_SRC)/libnetfilter_queue-0.0.13 && make install - @rm -rf $(DIR_APP) $(DIR_SRC)/libnfnetlink-* $(DIR_SRC)/netfilter-layer7* $(DIR_SRC)/libnetfilter_queue-* + @rm -rf $(DIR_APP) $(DIR_SRC)/libnfnetlink-0.0.25 $(DIR_SRC)/netfilter-layer7* $(DIR_SRC)/libnetfilter_queue-0.0.13 @$(POSTBUILD) diff --git a/lfs/linux b/lfs/linux index 7fcd37cde..9e67a7b00 100644 --- a/lfs/linux +++ b/lfs/linux @@ -26,8 +26,8 @@ include Config -PATCHLEVEL = .1 -VER = 2.6.22.1 +PATCHLEVEL = .50 +VER = 2.6.16.50 THISAPP = linux-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -36,10 +36,6 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) CFLAGS = CXXFLAGS = -OPENSWAN = openswan-2.4.9 -MISDN = mISDN-1_1_5 -LAYER7 = netfilter-layer7-v2.13 - # Normal build or SMP build. # ifeq "$(SMP)" "1" @@ -53,19 +49,32 @@ endif # Top-level Rules ############################################################################### objects =$(DL_FILE) \ - $(OPENSWAN).tar.gz \ - $(MISDN).tar.gz \ - $(LAYER7).tar.gz + mISDN-1_1_3.tar.gz \ + squashfs3.2-r2.tar.gz \ + iptables-1.3.5.tar.bz2 \ + patch-o-matic-ng-20061210.tar.bz2 \ + netfilter-layer7-v2.9.tar.gz \ + patch-2.6.16-nath323-1.3.bz2 \ + openswan-2.4.9.tar.gz $(DL_FILE) = $(URL_IPFIRE)/$(DL_FILE) -$(LAYER7).tar.gz = $(URL_IPFIRE)/$(LAYER7).tar.gz -$(MISDN).tar.gz = $(URL_IPFIRE)/$(MISDN).tar.gz -$(OPENSWAN).tar.gz = $(URL_IPFIRE)/$(OPENSWAN).tar.gz - -$(DL_FILE)_MD5 = 50249e822a2a112d9221129a4a3af374 -$(LAYER7).tar.gz_MD5 = c8097875074405be31e4372682b68d7a -$(MISDN).tar.gz_MD5 = 93b1cff7817b82638a0475c2b7b7f1b6 -$(OPENSWAN).tar.gz_MD5 = 845f12d80d443cfa1a52f2b53b987bee +patch-o-matic-ng-20061210.tar.bz2 = $(URL_IPFIRE)/patch-o-matic-ng-20061210.tar.bz2 +iptables-1.3.5.tar.bz2 = $(URL_IPFIRE)/iptables-1.3.5.tar.bz2 +netfilter-layer7-v2.9.tar.gz = $(URL_IPFIRE)/netfilter-layer7-v2.9.tar.gz +patch-2.6.16-nath323-1.3.bz2 = $(URL_IPFIRE)/patch-2.6.16-nath323-1.3.bz2 +squashfs3.2-r2.tar.gz = $(URL_IPFIRE)/squashfs3.2-r2.tar.gz +mISDN-1_1_3.tar.gz = $(URL_IPFIRE)/mISDN-1_1_3.tar.gz +openswan-2.4.9.tar.gz = $(URL_IPFIRE)/openswan-2.4.9.tar.gz + +$(DL_FILE)_MD5 = cc2106c6188675187d636aa518b04958 +linux-2.6.16.33.tar.bz2_MD5 = 22f56e3a5e7524b2bbde2696152b5ad7 +patch-o-matic-ng-20061210.tar.bz2_MD5 = 76edac76301b45f89e467b41c8cf4393 +iptables-1.3.5.tar.bz2_MD5 = 00fb916fa8040ca992a5ace56d905ea5 +netfilter-layer7-v2.9.tar.gz_MD5 = ebf9043a5352ebe6dbd721989ef83dee +patch-2.6.16-nath323-1.3.bz2_MD5 = f926409ff703a307baf54b57ab75d138 +squashfs3.2-r2.tar.gz_MD5 = bf360b92eba9e6d5610196ce2e02fcd1 +mISDN-1_1_3.tar.gz_MD5 = d29bcf48f16fc8a9b9f3552d111b308d +openswan-2.4.9.tar.gz_MD5 = 845f12d80d443cfa1a52f2b53b987bee install : $(TARGET) @@ -94,35 +103,68 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) $(DIR_SRC)/linux && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + @rm -rf $(DIR_APP) $(DIR_SRC)/linux $(DIR_SRC)/xen-* && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) ln -s linux-$(VER) /usr/src/linux + # An UTF8 patch from LFS + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.16.27-utf8_input-1.patch + # Openswan 2 cd $(DIR_SRC) && rm -rf openswan-* - cd $(DIR_SRC) && tar xfz $(DIR_DL)/$(OPENSWAN).tar.gz - #cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(OPENSWAN).kernel-2.6-natt.patch - #cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(OPENSWAN).kernel-2.6-klips.patch + cd $(DIR_SRC) && tar xfz $(DIR_DL)/openswan-2.4.9.tar.gz + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openswan-2.4.9.kernel-2.6-klips.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/openswan-2.4.9.kernel-2.6-natt.patch cd $(DIR_SRC)/openswan-* && sed -i -e 's/INC_USRLOCAL=\/usr\/local/INC_USRLOCAL=\/usr/' Makefile.inc + # H323 conntrack + cd $(DIR_APP) && bunzip2 -cd $(DIR_DL)/patch-2.6.16-nath323-1.3.bz2 | patch -Np1 + # Reiser4 - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/reiser4-for-2.6.22-2.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/reiser4-for-2.6.16-5.patch + + # SquashFS + cd $(DIR_SRC) && rm -rf squashfs* + cd $(DIR_SRC) && tar xfz $(DIR_DL)/squashfs3.2-r2.tar.gz + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/squashfs3.2-r2/kernel-patches/linux-2.6.16/squashfs3.2-patch # ip_conntrack permissions from 440 to 444 - #cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/ip_conntrack_standalone-patch-for-ipfire.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/ip_conntrack_standalone-patch-for-ipfire.patch + + # Some VIA patches + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/padlock-prereq-2.6.16.diff + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/epia_dma.patch + + # Patch-o-matic + cd $(DIR_SRC) && rm -rf iptables-* patch-o-matic* + cd $(DIR_SRC) && tar xfj $(DIR_DL)/iptables-1.3.5.tar.bz2 + cd $(DIR_SRC) && ln -sf iptables-1.3.5 iptables + cd $(DIR_SRC) && tar xfj $(DIR_DL)/patch-o-matic-ng-20061210.tar.bz2 + cd $(DIR_SRC)/patch-o-matic-ng* && \ + ./runme --batch --kernel-path=$(ROOT)/usr/src/$(THISAPP)/ \ + --iptables-path=$(ROOT)/usr/src/iptables/ \ + sip-conntrack-nat rtsp-conntrack-nat \ + mms-conntrack-nat # Layer7-patch - cd $(DIR_SRC) && rm -rf $(DIR_SRC)/$(LAYER7) - cd $(DIR_SRC) && tar xzf $(DIR_DL)/$(LAYER7).tar.gz - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/$(LAYER7)/kernel-2.6.22-layer7-2.13.patch + cd $(DIR_SRC) && rm -rf $(DIR_SRC)/netfilter-layer7-v2.9 + cd $(DIR_SRC) && tar xzf $(DIR_DL)/netfilter-layer7-v2.9.tar.gz + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/netfilter-layer7-v2.9/for_older_kernels/kernel-2.6.13-2.6.16-layer7-2.2.patch # Linux Intermediate Queueing Device - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.21-img2.diff +ifeq "$(XEN)" "" + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-2.6.16-imq2.diff +endif # mISDN cd $(DIR_SRC) && rm -rf mISDN-* - cd $(DIR_SRC) && tar xfz $(DIR_DL)/$(MISDN).tar.gz - cd $(DIR_SRC)/$(MISDN) && yes 'yes' | ./std2kern -k /usr/src/linux + cd $(DIR_SRC) && tar xfz $(DIR_DL)/mISDN-1_1_3.tar.gz + cd $(DIR_SRC)/mISDN-1_1_3 && yes 'yes' | ./std2kern -k /usr/src/linux + +ifeq "$(SMP)" "" + # Only do this once on the non-SMP pass + cd $(DIR_SRC) && tar czf $(DIR_DL)/iptables-fixed.tar.gz iptables-1.3.5 +endif # Cleanup kernel source cd $(DIR_APP) && make mrproper @@ -156,10 +198,13 @@ else cd $(DIR_APP) && make CC="$(KGCC)" $(MAKETUNING) modules_install endif + # remove symlinked pcmcia directory + -rm -rf /lib/modules/$(VER)-ipfire{,-smp}/pcmcia + ifeq "$(SMP)" "" # Only do this once on the non-SMP pass cd $(DIR_APP) && install -m 755 usr/gen_init_cpio /sbin/ endif - @rm -rf $(DIR_SRC)/mISDN-* $(DIR_SRC)/netfilter-layer7-* + @rm -rf $(DIR_SRC)/patch-o-matic* $(DIR_SRC)/iptables* $(DIR_SRC)/squashfs* $(DIR_SRC)/mISDN-* $(DIR_SRC)/netfilter-layer7-* @$(POSTBUILD) diff --git a/src/ipp2p/ipt_ipp2p.c b/src/ipp2p/ipt_ipp2p.c index 38869cdfb..29f6e7a42 100644 --- a/src/ipp2p/ipt_ipp2p.c +++ b/src/ipp2p/ipt_ipp2p.c @@ -831,9 +831,7 @@ checkentry(const char *tablename, const struct ipt_ip *ip, #endif void *matchinfo, -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) unsigned int matchsize, -#endif unsigned int hook_mask) { /* Must specify -p tcp */ @@ -882,20 +880,12 @@ static struct ipt_match ipp2p_match = { static int __init init(void) { printk(KERN_INFO "IPP2P v%s loading\n", IPP2P_VERSION); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) - return xt_register_match(&ipp2p_match); -#else return ipt_register_match(&ipp2p_match); -#endif } static void __exit fini(void) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21) - xt_unregister_match(&ipp2p_match); -#else ipt_unregister_match(&ipp2p_match); -#endif printk(KERN_INFO "IPP2P v%s unloaded\n", IPP2P_VERSION); } diff --git a/src/patches/iptables-1.3.6-imq.diff b/src/patches/iptables-1.3.0-imq1.diff similarity index 84% rename from src/patches/iptables-1.3.6-imq.diff rename to src/patches/iptables-1.3.0-imq1.diff index 262fef1a1..c3bf8d015 100644 --- a/src/patches/iptables-1.3.6-imq.diff +++ b/src/patches/iptables-1.3.0-imq1.diff @@ -1,221 +1,220 @@ ---- iptables-1.3.6.orig/extensions.orig/.IMQ-test6 Thu Jan 1 01:00:00 1970 -+++ iptables-1.3.6/extensions/.IMQ-test6 Mon Jun 16 10:12:47 2003 -@@ -0,0 +1,3 @@ -+#!/bin/sh -+# True if IMQ target patch is applied. -+[ -f $KERNEL_DIR/net/ipv6/netfilter/ip6t_IMQ.c ] && echo IMQ ---- iptables-1.3.6.orig/extensions.orig/libip6t_IMQ.c Thu Jan 1 01:00:00 1970 -+++ iptables-1.3.6/extensions/libip6t_IMQ.c Mon Jun 16 10:12:47 2003 -@@ -0,0 +1,101 @@ -+/* Shared library add-on to iptables to add IMQ target support. */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+/* Function which prints out usage message. */ -+static void -+help(void) -+{ -+ printf( -+"IMQ target v%s options:\n" -+" --todev enqueue to imq, defaults to 0\n", -+IPTABLES_VERSION); -+} -+ -+static struct option opts[] = { -+ { "todev", 1, 0, '1' }, -+ { 0 } -+}; -+ -+/* Initialize the target. */ -+static void -+init(struct ip6t_entry_target *t, unsigned int *nfcache) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data; -+ -+ mr->todev = 0; -+ *nfcache |= NFC_UNKNOWN; -+} -+ -+/* Function which parses command options; returns true if it -+ ate an option */ -+static int -+parse(int c, char **argv, int invert, unsigned int *flags, -+ const struct ip6t_entry *entry, -+ struct ip6t_entry_target **target) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data; -+ -+ switch(c) { -+ case '1': -+ if (check_inverse(optarg, &invert, NULL, 0)) -+ exit_error(PARAMETER_PROBLEM, -+ "Unexpected `!' after --todev"); -+ mr->todev=atoi(optarg); -+ break; -+ default: -+ return 0; -+ } -+ return 1; -+} -+ -+static void -+final_check(unsigned int flags) -+{ -+} -+ -+/* Prints out the targinfo. */ -+static void -+print(const struct ip6t_ip6 *ip, -+ const struct ip6t_entry_target *target, -+ int numeric) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data; -+ -+ printf("IMQ: todev %u ", mr->todev); -+} -+ -+/* Saves the union ipt_targinfo in parsable form to stdout. */ -+static void -+save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data; -+ -+ printf("--todev %u", mr->todev); -+} -+ -+static struct ip6tables_target imq = { -+ .next = NULL, -+ .name = "IMQ", -+ .version = IPTABLES_VERSION, -+ .size = IP6T_ALIGN(sizeof(struct ip6t_imq_info)), -+ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_imq_info)), -+ .help = &help, -+ .init = &init, -+ .parse = &parse, -+ .final_check = &final_check, -+ .print = &print, -+ .save = &save, -+ .extra_opts = opts -+}; -+ -+static __attribute__((constructor)) void _init(void) -+{ -+ register_target6(&imq); -+} ---- iptables-1.3.6.orig/extensions.orig/.IMQ-test Thu Jan 1 01:00:00 1970 -+++ iptables-1.3.6/extensions/.IMQ-test Mon Jun 16 10:12:47 2003 -@@ -0,0 +1,3 @@ -+#!/bin/sh -+# True if IMQ target patch is applied. -+[ -f $KERNEL_DIR/net/ipv4/netfilter/ipt_IMQ.c ] && echo IMQ ---- iptables-1.3.6.orig/extensions.orig/libipt_IMQ.c Thu Jan 1 01:00:00 1970 -+++ iptables-1.3.6/extensions/libipt_IMQ.c Mon Jun 16 10:12:47 2003 -@@ -0,0 +1,101 @@ -+/* Shared library add-on to iptables to add IMQ target support. */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+/* Function which prints out usage message. */ -+static void -+help(void) -+{ -+ printf( -+"IMQ target v%s options:\n" -+" --todev enqueue to imq, defaults to 0\n", -+IPTABLES_VERSION); -+} -+ -+static struct option opts[] = { -+ { "todev", 1, 0, '1' }, -+ { 0 } -+}; -+ -+/* Initialize the target. */ -+static void -+init(struct ipt_entry_target *t, unsigned int *nfcache) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data; -+ -+ mr->todev = 0; -+ *nfcache |= NFC_UNKNOWN; -+} -+ -+/* Function which parses command options; returns true if it -+ ate an option */ -+static int -+parse(int c, char **argv, int invert, unsigned int *flags, -+ const struct ipt_entry *entry, -+ struct ipt_entry_target **target) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data; -+ -+ switch(c) { -+ case '1': -+ if (check_inverse(optarg, &invert, NULL, 0)) -+ exit_error(PARAMETER_PROBLEM, -+ "Unexpected `!' after --todev"); -+ mr->todev=atoi(optarg); -+ break; -+ default: -+ return 0; -+ } -+ return 1; -+} -+ -+static void -+final_check(unsigned int flags) -+{ -+} -+ -+/* Prints out the targinfo. */ -+static void -+print(const struct ipt_ip *ip, -+ const struct ipt_entry_target *target, -+ int numeric) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data; -+ -+ printf("IMQ: todev %u ", mr->todev); -+} -+ -+/* Saves the union ipt_targinfo in parsable form to stdout. */ -+static void -+save(const struct ipt_ip *ip, const struct ipt_entry_target *target) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data; -+ -+ printf("--todev %u", mr->todev); -+} -+ -+static struct iptables_target imq = { -+ .next = NULL, -+ .name = "IMQ", -+ .version = IPTABLES_VERSION, -+ .size = IPT_ALIGN(sizeof(struct ipt_imq_info)), -+ .userspacesize = IPT_ALIGN(sizeof(struct ipt_imq_info)), -+ .help = &help, -+ .init = &init, -+ .parse = &parse, -+ .final_check = &final_check, -+ .print = &print, -+ .save = &save, -+ .extra_opts = opts -+}; -+ -+static __attribute__((constructor)) void _init(void) -+{ -+ register_target(&imq); -+} - +--- userspace/extensions.orig/.IMQ-test6 Thu Jan 1 01:00:00 1970 ++++ userspace/extensions/.IMQ-test6 Mon Jun 16 10:12:47 2003 +@@ -0,0 +1,3 @@ ++#!/bin/sh ++# True if IMQ target patch is applied. ++[ -f $KERNEL_DIR/net/ipv6/netfilter/ip6t_IMQ.c ] && echo IMQ +--- userspace/extensions.orig/libip6t_IMQ.c Thu Jan 1 01:00:00 1970 ++++ userspace/extensions/libip6t_IMQ.c Mon Jun 16 10:12:47 2003 +@@ -0,0 +1,101 @@ ++/* Shared library add-on to iptables to add IMQ target support. */ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++/* Function which prints out usage message. */ ++static void ++help(void) ++{ ++ printf( ++"IMQ target v%s options:\n" ++" --todev enqueue to imq, defaults to 0\n", ++IPTABLES_VERSION); ++} ++ ++static struct option opts[] = { ++ { "todev", 1, 0, '1' }, ++ { 0 } ++}; ++ ++/* Initialize the target. */ ++static void ++init(struct ip6t_entry_target *t, unsigned int *nfcache) ++{ ++ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)t->data; ++ ++ mr->todev = 0; ++ *nfcache |= NFC_UNKNOWN; ++} ++ ++/* Function which parses command options; returns true if it ++ ate an option */ ++static int ++parse(int c, char **argv, int invert, unsigned int *flags, ++ const struct ip6t_entry *entry, ++ struct ip6t_entry_target **target) ++{ ++ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)(*target)->data; ++ ++ switch(c) { ++ case '1': ++ if (check_inverse(optarg, &invert, NULL, 0)) ++ exit_error(PARAMETER_PROBLEM, ++ "Unexpected `!' after --todev"); ++ mr->todev=atoi(optarg); ++ break; ++ default: ++ return 0; ++ } ++ return 1; ++} ++ ++static void ++final_check(unsigned int flags) ++{ ++} ++ ++/* Prints out the targinfo. */ ++static void ++print(const struct ip6t_ip6 *ip, ++ const struct ip6t_entry_target *target, ++ int numeric) ++{ ++ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data; ++ ++ printf("IMQ: todev %u ", mr->todev); ++} ++ ++/* Saves the union ipt_targinfo in parsable form to stdout. */ ++static void ++save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target) ++{ ++ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)target->data; ++ ++ printf("--todev %u", mr->todev); ++} ++ ++static struct ip6tables_target imq = { ++ .next = NULL, ++ .name = "IMQ", ++ .version = IPTABLES_VERSION, ++ .size = IP6T_ALIGN(sizeof(struct ip6t_imq_info)), ++ .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_imq_info)), ++ .help = &help, ++ .init = &init, ++ .parse = &parse, ++ .final_check = &final_check, ++ .print = &print, ++ .save = &save, ++ .extra_opts = opts ++}; ++ ++void _init(void) ++{ ++ register_target6(&imq); ++} +--- userspace/extensions.orig/.IMQ-test Thu Jan 1 01:00:00 1970 ++++ userspace/extensions/.IMQ-test Mon Jun 16 10:12:47 2003 +@@ -0,0 +1,3 @@ ++#!/bin/sh ++# True if IMQ target patch is applied. ++[ -f $KERNEL_DIR/net/ipv4/netfilter/ipt_IMQ.c ] && echo IMQ +--- userspace/extensions.orig/libipt_IMQ.c Thu Jan 1 01:00:00 1970 ++++ userspace/extensions/libipt_IMQ.c Mon Jun 16 10:12:47 2003 +@@ -0,0 +1,101 @@ ++/* Shared library add-on to iptables to add IMQ target support. */ ++#include ++#include ++#include ++#include ++ ++#include ++#include ++#include ++ ++/* Function which prints out usage message. */ ++static void ++help(void) ++{ ++ printf( ++"IMQ target v%s options:\n" ++" --todev enqueue to imq, defaults to 0\n", ++IPTABLES_VERSION); ++} ++ ++static struct option opts[] = { ++ { "todev", 1, 0, '1' }, ++ { 0 } ++}; ++ ++/* Initialize the target. */ ++static void ++init(struct ipt_entry_target *t, unsigned int *nfcache) ++{ ++ struct ipt_imq_info *mr = (struct ipt_imq_info*)t->data; ++ ++ mr->todev = 0; ++ *nfcache |= NFC_UNKNOWN; ++} ++ ++/* Function which parses command options; returns true if it ++ ate an option */ ++static int ++parse(int c, char **argv, int invert, unsigned int *flags, ++ const struct ipt_entry *entry, ++ struct ipt_entry_target **target) ++{ ++ struct ipt_imq_info *mr = (struct ipt_imq_info*)(*target)->data; ++ ++ switch(c) { ++ case '1': ++ if (check_inverse(optarg, &invert, NULL, 0)) ++ exit_error(PARAMETER_PROBLEM, ++ "Unexpected `!' after --todev"); ++ mr->todev=atoi(optarg); ++ break; ++ default: ++ return 0; ++ } ++ return 1; ++} ++ ++static void ++final_check(unsigned int flags) ++{ ++} ++ ++/* Prints out the targinfo. */ ++static void ++print(const struct ipt_ip *ip, ++ const struct ipt_entry_target *target, ++ int numeric) ++{ ++ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data; ++ ++ printf("IMQ: todev %u ", mr->todev); ++} ++ ++/* Saves the union ipt_targinfo in parsable form to stdout. */ ++static void ++save(const struct ipt_ip *ip, const struct ipt_entry_target *target) ++{ ++ struct ipt_imq_info *mr = (struct ipt_imq_info*)target->data; ++ ++ printf("--todev %u", mr->todev); ++} ++ ++static struct iptables_target imq = { ++ .next = NULL, ++ .name = "IMQ", ++ .version = IPTABLES_VERSION, ++ .size = IPT_ALIGN(sizeof(struct ipt_imq_info)), ++ .userspacesize = IPT_ALIGN(sizeof(struct ipt_imq_info)), ++ .help = &help, ++ .init = &init, ++ .parse = &parse, ++ .final_check = &final_check, ++ .print = &print, ++ .save = &save, ++ .extra_opts = opts ++}; ++ ++void _init(void) ++{ ++ register_target(&imq); ++} diff --git a/src/patches/linux-2.6.16-imq2.diff b/src/patches/linux-2.6.16-imq2.diff new file mode 100644 index 000000000..bb224d0ad --- /dev/null +++ b/src/patches/linux-2.6.16-imq2.diff @@ -0,0 +1,885 @@ +diff -Nru linux-2.6.16/drivers/net/Kconfig linux-2.6.16-imq/drivers/net/Kconfig +--- linux-2.6.16/drivers/net/Kconfig 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/drivers/net/Kconfig 2006-03-25 20:57:14.000000000 +0000 +@@ -93,6 +93,129 @@ + To compile this driver as a module, choose M here: the module + will be called eql. If unsure, say N. + ++config IMQ ++ tristate "IMQ (intermediate queueing device) support" ++ depends on NETDEVICES && NETFILTER ++ ---help--- ++ The IMQ device(s) is used as placeholder for QoS queueing disciplines. ++ Every packet entering/leaving the IP stack can be directed through ++ the IMQ device where it's enqueued/dequeued to the attached qdisc. ++ This allows you to treat network devices as classes and distribute ++ bandwidth among them. Iptables is used to specify through which IMQ ++ device, if any, packets travel. ++ ++ More information at: http://www.linuximq.net/ ++ ++ To compile this driver as a module, choose M here: the module ++ will be called imq. If unsure, say N. ++ ++choice ++ prompt "IMQ behavior (PRE/POSTROUTING)" ++ depends on IMQ ++ default IMQ_BEHAVIOR_BA ++ help ++ ++ This settings defines how IMQ behaves in respect to its ++ hooking in PREROUTING and POSTROUTING. ++ ++ IMQ can work in any of the following ways: ++ ++ PREROUTING | POSTROUTING ++ -----------------|------------------- ++ #1 After NAT | After NAT ++ #2 After NAT | Before NAT ++ #3 Before NAT | After NAT ++ #4 Before NAT | Before NAT ++ ++ The default behavior is to hook before NAT on PREROUTING ++ and after NAT on POSTROUTING (#3). ++ ++ This settings are specially usefull when trying to use IMQ ++ to shape NATed clients. ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ ++config IMQ_BEHAVIOR_AA ++ bool "IMQ AA" ++ help ++ This settings defines how IMQ behaves in respect to its ++ hooking in PREROUTING and POSTROUTING. ++ ++ Choosing this option will make IMQ hook like this: ++ ++ PREROUTING: After NAT ++ POSTROUTING: After NAT ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ ++config IMQ_BEHAVIOR_AB ++ bool "IMQ AB" ++ help ++ This settings defines how IMQ behaves in respect to its ++ hooking in PREROUTING and POSTROUTING. ++ ++ Choosing this option will make IMQ hook like this: ++ ++ PREROUTING: After NAT ++ POSTROUTING: Before NAT ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ ++config IMQ_BEHAVIOR_BA ++ bool "IMQ BA" ++ help ++ This settings defines how IMQ behaves in respect to its ++ hooking in PREROUTING and POSTROUTING. ++ ++ Choosing this option will make IMQ hook like this: ++ ++ PREROUTING: Before NAT ++ POSTROUTING: After NAT ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ ++config IMQ_BEHAVIOR_BB ++ bool "IMQ BB" ++ help ++ This settings defines how IMQ behaves in respect to its ++ hooking in PREROUTING and POSTROUTING. ++ ++ Choosing this option will make IMQ hook like this: ++ ++ PREROUTING: Before NAT ++ POSTROUTING: Before NAT ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ ++endchoice ++ ++config IMQ_NUM_DEVS ++ ++ int "Number of IMQ devices" ++ range 2 8 ++ depends on IMQ ++ default "2" ++ help ++ ++ This settings defines how many IMQ devices will be ++ created. ++ ++ The default value is 2. ++ ++ More information can be found at: www.linuximq.net ++ ++ If not sure leave the default settings alone. ++ + config TUN + tristate "Universal TUN/TAP device driver support" + select CRC32 +diff -Nru linux-2.6.16/drivers/net/Makefile linux-2.6.16-imq/drivers/net/Makefile +--- linux-2.6.16/drivers/net/Makefile 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/drivers/net/Makefile 2006-03-25 21:04:53.000000000 +0000 +@@ -125,6 +125,7 @@ + endif + + obj-$(CONFIG_DUMMY) += dummy.o ++obj-$(CONFIG_IMQ) += imq.o + obj-$(CONFIG_IFB) += ifb.o + obj-$(CONFIG_DE600) += de600.o + obj-$(CONFIG_DE620) += de620.o +diff -Nru linux-2.6.16/drivers/net/imq.c linux-2.6.16-imq/drivers/net/imq.c +--- linux-2.6.16/drivers/net/imq.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/drivers/net/imq.c 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,403 @@ ++/* ++ * Pseudo-driver for the intermediate queue device. ++ * ++ * 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. ++ * ++ * Authors: Patrick McHardy, ++ * ++ * The first version was written by Martin Devera, ++ * ++ * Credits: Jan Rafaj ++ * - Update patch to 2.4.21 ++ * Sebastian Strollo ++ * - Fix "Dead-loop on netdevice imq"-issue ++ * Marcel Sebek ++ * - Update to 2.6.2-rc1 ++ * ++ * After some time of inactivity there is a group taking care ++ * of IMQ again: http://www.linuximq.net ++ * ++ * ++ * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including ++ * the following changes: ++ * ++ * - Correction of ipv6 support "+"s issue (Hasso Tepper) ++ * - Correction of imq_init_devs() issue that resulted in ++ * kernel OOPS unloading IMQ as module (Norbert Buchmuller) ++ * - Addition of functionality to choose number of IMQ devices ++ * during kernel config (Andre Correa) ++ * - Addition of functionality to choose how IMQ hooks on ++ * PRE and POSTROUTING (after or before NAT) (Andre Correa) ++ * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa) ++ * ++ * ++ * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were ++ * released with almost no problems. 2.6.14-x was released ++ * with some important changes: nfcache was removed; After ++ * some weeks of trouble we figured out that some IMQ fields ++ * in skb were missing in skbuff.c - skb_clone and copy_skb_header. ++ * These functions are correctly patched by this new patch version. ++ * ++ * Thanks for all who helped to figure out all the problems with ++ * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX, ++ * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully ++ * I didn't forget anybody). I apologize again for my lack of time. ++ * ++ * More info at: http://www.linuximq.net/ (Andre Correa) ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) ++ #include ++#endif ++#include ++#include ++ ++static nf_hookfn imq_nf_hook; ++ ++static struct nf_hook_ops imq_ingress_ipv4 = { ++ .hook = imq_nf_hook, ++ .owner = THIS_MODULE, ++ .pf = PF_INET, ++ .hooknum = NF_IP_PRE_ROUTING, ++#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) ++ .priority = NF_IP_PRI_MANGLE + 1 ++#else ++ .priority = NF_IP_PRI_NAT_DST + 1 ++#endif ++}; ++ ++static struct nf_hook_ops imq_egress_ipv4 = { ++ .hook = imq_nf_hook, ++ .owner = THIS_MODULE, ++ .pf = PF_INET, ++ .hooknum = NF_IP_POST_ROUTING, ++#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA) ++ .priority = NF_IP_PRI_LAST ++#else ++ .priority = NF_IP_PRI_NAT_SRC - 1 ++#endif ++}; ++ ++#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) ++static struct nf_hook_ops imq_ingress_ipv6 = { ++ .hook = imq_nf_hook, ++ .owner = THIS_MODULE, ++ .pf = PF_INET6, ++ .hooknum = NF_IP6_PRE_ROUTING, ++#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) ++ .priority = NF_IP6_PRI_MANGLE + 1 ++#else ++ .priority = NF_IP6_PRI_NAT_DST + 1 ++#endif ++}; ++ ++static struct nf_hook_ops imq_egress_ipv6 = { ++ .hook = imq_nf_hook, ++ .owner = THIS_MODULE, ++ .pf = PF_INET6, ++ .hooknum = NF_IP6_POST_ROUTING, ++#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA) ++ .priority = NF_IP6_PRI_LAST ++#else ++ .priority = NF_IP6_PRI_NAT_SRC - 1 ++#endif ++}; ++#endif ++ ++#if defined(CONFIG_IMQ_NUM_DEVS) ++static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS; ++#else ++static unsigned int numdevs = 2; ++#endif ++ ++static struct net_device *imq_devs; ++ ++static struct net_device_stats *imq_get_stats(struct net_device *dev) ++{ ++ return (struct net_device_stats *)dev->priv; ++} ++ ++/* called for packets kfree'd in qdiscs at places other than enqueue */ ++static void imq_skb_destructor(struct sk_buff *skb) ++{ ++ struct nf_info *info = skb->nf_info; ++ ++ if (info) { ++ if (info->indev) ++ dev_put(info->indev); ++ if (info->outdev) ++ dev_put(info->outdev); ++ kfree(info); ++ } ++} ++ ++static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev) ++{ ++ struct net_device_stats *stats = (struct net_device_stats*) dev->priv; ++ ++ stats->tx_bytes += skb->len; ++ stats->tx_packets++; ++ ++ skb->imq_flags = 0; ++ skb->destructor = NULL; ++ ++ dev->trans_start = jiffies; ++ nf_reinject(skb, skb->nf_info, NF_ACCEPT); ++ return 0; ++} ++ ++static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data) ++{ ++ struct net_device *dev; ++ struct net_device_stats *stats; ++ struct sk_buff *skb2 = NULL; ++ struct Qdisc *q; ++ unsigned int index = skb->imq_flags&IMQ_F_IFMASK; ++ int ret = -1; ++ ++ if (index > numdevs) ++ return -1; ++ ++ dev = imq_devs + index; ++ if (!(dev->flags & IFF_UP)) { ++ skb->imq_flags = 0; ++ nf_reinject(skb, info, NF_ACCEPT); ++ return 0; ++ } ++ dev->last_rx = jiffies; ++ ++ if (skb->destructor) { ++ skb2 = skb; ++ skb = skb_clone(skb, GFP_ATOMIC); ++ if (!skb) ++ return -1; ++ } ++ skb->nf_info = info; ++ ++ stats = (struct net_device_stats *)dev->priv; ++ stats->rx_bytes+= skb->len; ++ stats->rx_packets++; ++ ++ spin_lock_bh(&dev->queue_lock); ++ q = dev->qdisc; ++ if (q->enqueue) { ++ q->enqueue(skb_get(skb), q); ++ if (skb_shared(skb)) { ++ skb->destructor = imq_skb_destructor; ++ kfree_skb(skb); ++ ret = 0; ++ } ++ } ++ if (spin_is_locked(&dev->xmit_lock)) ++ netif_schedule(dev); ++ else ++ ++ while (!netif_queue_stopped(dev) && ++ qdisc_restart(dev)<0) ++ /* NOTHING */; ++ ++ spin_unlock_bh(&dev->queue_lock); ++ ++ if (skb2) ++ kfree_skb(ret ? skb : skb2); ++ ++ return ret; ++} ++ ++static struct nf_queue_handler nfqh = { ++ .name = "imq", ++ .outfn = imq_nf_queue, ++}; ++ ++static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb, ++ const struct net_device *indev, ++ const struct net_device *outdev, ++ int (*okfn)(struct sk_buff *)) ++{ ++ if ((*pskb)->imq_flags & IMQ_F_ENQUEUE) ++ return NF_QUEUE; ++ ++ return NF_ACCEPT; ++} ++ ++ ++static int __init imq_init_hooks(void) ++{ ++ int err; ++ ++ err = nf_register_queue_handler(PF_INET, &nfqh); ++ if (err > 0) ++ goto err1; ++ if ((err = nf_register_hook(&imq_ingress_ipv4))) ++ goto err2; ++ if ((err = nf_register_hook(&imq_egress_ipv4))) ++ goto err3; ++#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) ++ if ((err = nf_register_queue_handler(PF_INET6, &nfqh))) ++ goto err4; ++ if ((err = nf_register_hook(&imq_ingress_ipv6))) ++ goto err5; ++ if ((err = nf_register_hook(&imq_egress_ipv6))) ++ goto err6; ++#endif ++ ++ return 0; ++ ++#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) ++err6: ++ nf_unregister_hook(&imq_ingress_ipv6); ++err5: ++ nf_unregister_queue_handler(PF_INET6); ++err4: ++ nf_unregister_hook(&imq_egress_ipv6); ++#endif ++err3: ++ nf_unregister_hook(&imq_ingress_ipv4); ++err2: ++ nf_unregister_queue_handler(PF_INET); ++err1: ++ return err; ++} ++ ++static void __exit imq_unhook(void) ++{ ++ nf_unregister_hook(&imq_ingress_ipv4); ++ nf_unregister_hook(&imq_egress_ipv4); ++ nf_unregister_queue_handler(PF_INET); ++#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) ++ nf_unregister_hook(&imq_ingress_ipv6); ++ nf_unregister_hook(&imq_egress_ipv6); ++ nf_unregister_queue_handler(PF_INET6); ++#endif ++} ++ ++static int __init imq_dev_init(struct net_device *dev) ++{ ++ dev->hard_start_xmit = imq_dev_xmit; ++ dev->type = ARPHRD_VOID; ++ dev->mtu = 1500; ++ dev->tx_queue_len = 30; ++ dev->flags = IFF_NOARP; ++ dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL); ++ if (dev->priv == NULL) ++ return -ENOMEM; ++ memset(dev->priv, 0, sizeof(struct net_device_stats)); ++ dev->get_stats = imq_get_stats; ++ ++ return 0; ++} ++ ++static void imq_dev_uninit(struct net_device *dev) ++{ ++ kfree(dev->priv); ++} ++ ++static int __init imq_init_devs(void) ++{ ++ struct net_device *dev; ++ int i,j; ++ j = numdevs; ++ ++ if (!numdevs || numdevs > IMQ_MAX_DEVS) { ++ printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n", ++ IMQ_MAX_DEVS); ++ return -EINVAL; ++ } ++ ++ imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL); ++ if (!imq_devs) ++ return -ENOMEM; ++ memset(imq_devs, 0, sizeof(struct net_device) * numdevs); ++ ++ /* we start counting at zero */ ++ numdevs--; ++ ++ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) { ++ SET_MODULE_OWNER(dev); ++ strcpy(dev->name, "imq%d"); ++ dev->init = imq_dev_init; ++ dev->uninit = imq_dev_uninit; ++ ++ if (register_netdev(dev) < 0) ++ goto err_register; ++ } ++ printk(KERN_INFO "IMQ starting with %u devices...\n", j); ++ return 0; ++ ++err_register: ++ for (; i; i--) ++ unregister_netdev(--dev); ++ kfree(imq_devs); ++ return -EIO; ++} ++ ++static void imq_cleanup_devs(void) ++{ ++ int i; ++ struct net_device *dev = imq_devs; ++ ++ for (i = 0; i <= numdevs; i++) ++ unregister_netdev(dev++); ++ ++ kfree(imq_devs); ++} ++ ++static int __init imq_init_module(void) ++{ ++ int err; ++ ++ if ((err = imq_init_devs())) { ++ printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n"); ++ return err; ++ } ++ if ((err = imq_init_hooks())) { ++ printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n"); ++ imq_cleanup_devs(); ++ return err; ++ } ++ ++ printk(KERN_INFO "IMQ driver loaded successfully.\n"); ++ ++#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) ++ printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n"); ++#else ++ printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n"); ++#endif ++#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB) ++ printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n"); ++#else ++ printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n"); ++#endif ++ ++ return 0; ++} ++ ++static void __exit imq_cleanup_module(void) ++{ ++ imq_unhook(); ++ imq_cleanup_devs(); ++ printk(KERN_INFO "IMQ driver unloaded successfully.\n"); ++} ++ ++ ++module_init(imq_init_module); ++module_exit(imq_cleanup_module); ++ ++module_param(numdevs, int, 0); ++MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)"); ++MODULE_AUTHOR("http://www.linuximq.net"); ++MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); ++MODULE_LICENSE("GPL"); +diff -Nru linux-2.6.16/include/linux/imq.h linux-2.6.16-imq/include/linux/imq.h +--- linux-2.6.16/include/linux/imq.h 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/include/linux/imq.h 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,9 @@ ++#ifndef _IMQ_H ++#define _IMQ_H ++ ++#define IMQ_MAX_DEVS 16 ++ ++#define IMQ_F_IFMASK 0x7f ++#define IMQ_F_ENQUEUE 0x80 ++ ++#endif /* _IMQ_H */ +diff -Nru linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.16-imq/include/linux/netfilter_ipv4/ipt_IMQ.h +--- linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/include/linux/netfilter_ipv4/ipt_IMQ.h 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,8 @@ ++#ifndef _IPT_IMQ_H ++#define _IPT_IMQ_H ++ ++struct ipt_imq_info { ++ unsigned int todev; /* target imq device */ ++}; ++ ++#endif /* _IPT_IMQ_H */ +diff -Nru linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.16-imq/include/linux/netfilter_ipv6/ip6t_IMQ.h +--- linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/include/linux/netfilter_ipv6/ip6t_IMQ.h 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,8 @@ ++#ifndef _IP6T_IMQ_H ++#define _IP6T_IMQ_H ++ ++struct ip6t_imq_info { ++ unsigned int todev; /* target imq device */ ++}; ++ ++#endif /* _IP6T_IMQ_H */ +diff -Nru linux-2.6.16/include/linux/skbuff.h linux-2.6.16-imq/include/linux/skbuff.h +--- linux-2.6.16/include/linux/skbuff.h 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/include/linux/skbuff.h 2006-03-25 20:57:14.000000000 +0000 +@@ -275,6 +275,10 @@ + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) + struct sk_buff *nfct_reasm; + #endif ++#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) ++ unsigned char imq_flags; ++ struct nf_info *nf_info; ++#endif + #ifdef CONFIG_BRIDGE_NETFILTER + struct nf_bridge_info *nf_bridge; + #endif +diff -Nru linux-2.6.16/net/core/skbuff.c linux-2.6.16-imq/net/core/skbuff.c +--- linux-2.6.16/net/core/skbuff.c 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/core/skbuff.c 2006-03-25 20:57:14.000000000 +0000 +@@ -425,6 +425,10 @@ + C(nfct_reasm); + nf_conntrack_get_reasm(skb->nfct_reasm); + #endif ++#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) ++ C(imq_flags); ++ C(nf_info); ++#endif /*CONFIG_IMQ*/ + #ifdef CONFIG_BRIDGE_NETFILTER + C(nf_bridge); + nf_bridge_get(skb->nf_bridge); +@@ -489,6 +493,10 @@ + #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) + new->ipvs_property = old->ipvs_property; + #endif ++#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) ++ new->imq_flags = old->imq_flags; ++ new->nf_info = old->nf_info; ++#endif /*CONFIG_IMQ*/ + #ifdef CONFIG_BRIDGE_NETFILTER + new->nf_bridge = old->nf_bridge; + nf_bridge_get(old->nf_bridge); +diff -Nru linux-2.6.16/net/ipv4/netfilter/Kconfig linux-2.6.16-imq/net/ipv4/netfilter/Kconfig +--- linux-2.6.16/net/ipv4/netfilter/Kconfig 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv4/netfilter/Kconfig 2006-03-25 21:54:10.000000000 +0000 +@@ -505,6 +505,17 @@ + + To compile it as a module, choose M here. If unsure, say N. + ++config IP_NF_TARGET_IMQ ++ tristate "IMQ target support" ++ depends on IP_NF_MANGLE ++ help ++ This option adds a `IMQ' target which is used to specify if and ++ to which IMQ device packets should get enqueued/dequeued. ++ ++ For more information visit: http://www.linuximq.net/ ++ ++ To compile it as a module, choose M here. If unsure, say N. ++ + config IP_NF_TARGET_TOS + tristate "TOS target support" + depends on IP_NF_MANGLE +diff -Nru linux-2.6.16/net/ipv4/netfilter/Makefile linux-2.6.16-imq/net/ipv4/netfilter/Makefile +--- linux-2.6.16/net/ipv4/netfilter/Makefile 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv4/netfilter/Makefile 2006-03-25 21:06:00.000000000 +0000 +@@ -64,6 +64,7 @@ + obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o + obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o + obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o ++obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o + obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o + obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o + obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o +diff -Nru linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.16-imq/net/ipv4/netfilter/ipt_IMQ.c +--- linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv4/netfilter/ipt_IMQ.c 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,80 @@ ++/* ++ * This target marks packets to be enqueued to an imq device ++ */ ++#include ++#include ++#include ++#include ++#include ++ ++static unsigned int imq_target(struct sk_buff **pskb, ++ const struct net_device *in, ++ const struct net_device *out, ++ unsigned int hooknum, ++ const void *targinfo, ++ void *userdata) ++{ ++ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo; ++ ++ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; ++ ++ return IPT_CONTINUE; ++} ++ ++static int imq_checkentry(const char *tablename, ++ const struct ipt_entry *e, ++ void *targinfo, ++ unsigned int targinfosize, ++ unsigned int hook_mask) ++{ ++ struct ipt_imq_info *mr; ++ ++ if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) { ++ printk(KERN_WARNING "IMQ: invalid targinfosize\n"); ++ return 0; ++ } ++ mr = (struct ipt_imq_info*)targinfo; ++ ++ if (strcmp(tablename, "mangle") != 0) { ++ printk(KERN_WARNING ++ "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n", ++ tablename); ++ return 0; ++ } ++ ++ if (mr->todev > IMQ_MAX_DEVS) { ++ printk(KERN_WARNING ++ "IMQ: invalid device specified, highest is %u\n", ++ IMQ_MAX_DEVS); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static struct ipt_target ipt_imq_reg = { ++ .name = "IMQ", ++ .target = imq_target, ++ .checkentry = imq_checkentry, ++ .me = THIS_MODULE ++}; ++ ++static int __init init(void) ++{ ++ if (ipt_register_target(&ipt_imq_reg)) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static void __exit fini(void) ++{ ++ ipt_unregister_target(&ipt_imq_reg); ++} ++ ++module_init(init); ++module_exit(fini); ++ ++MODULE_AUTHOR("http://www.linuximq.net"); ++MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); ++MODULE_LICENSE("GPL"); +diff -Nru linux-2.6.16/net/ipv6/netfilter/Kconfig linux-2.6.16-imq/net/ipv6/netfilter/Kconfig +--- linux-2.6.16/net/ipv6/netfilter/Kconfig 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv6/netfilter/Kconfig 2006-03-25 21:54:48.000000000 +0000 +@@ -183,6 +183,15 @@ + + To compile it as a module, choose M here. If unsure, say N. + ++config IP6_NF_TARGET_IMQ ++ tristate "IMQ target support" ++ depends on IP6_NF_MANGLE ++ help ++ This option adds a `IMQ' target which is used to specify if and ++ to which imq device packets should get enqueued/dequeued. ++ ++ To compile it as a module, choose M here. If unsure, say N. ++ + config IP6_NF_TARGET_HL + tristate 'HL (hoplimit) target support' + depends on IP6_NF_MANGLE +diff -Nru linux-2.6.16/net/ipv6/netfilter/Makefile linux-2.6.16-imq/net/ipv6/netfilter/Makefile +--- linux-2.6.16/net/ipv6/netfilter/Makefile 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv6/netfilter/Makefile 2006-03-25 21:07:08.000000000 +0000 +@@ -15,6 +15,7 @@ + obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o + obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o + obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o ++obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o + obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o + obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o + obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o +diff -Nru linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.16-imq/net/ipv6/netfilter/ip6t_IMQ.c +--- linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.16-imq/net/ipv6/netfilter/ip6t_IMQ.c 2006-03-25 20:57:14.000000000 +0000 +@@ -0,0 +1,80 @@ ++/* ++ * This target marks packets to be enqueued to an imq device ++ */ ++#include ++#include ++#include ++#include ++#include ++ ++static unsigned int imq_target(struct sk_buff **pskb, ++ unsigned int hooknum, ++ const struct net_device *in, ++ const struct net_device *out, ++ const void *targinfo, ++ void *userdata) ++{ ++ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo; ++ ++ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; ++ ++ return IP6T_CONTINUE; ++} ++ ++static int imq_checkentry(const char *tablename, ++ const struct ip6t_entry *e, ++ void *targinfo, ++ unsigned int targinfosize, ++ unsigned int hook_mask) ++{ ++ struct ip6t_imq_info *mr; ++ ++ if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) { ++ printk(KERN_WARNING "IMQ: invalid targinfosize\n"); ++ return 0; ++ } ++ mr = (struct ip6t_imq_info*)targinfo; ++ ++ if (strcmp(tablename, "mangle") != 0) { ++ printk(KERN_WARNING ++ "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n", ++ tablename); ++ return 0; ++ } ++ ++ if (mr->todev > IMQ_MAX_DEVS) { ++ printk(KERN_WARNING ++ "IMQ: invalid device specified, highest is %u\n", ++ IMQ_MAX_DEVS); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static struct ip6t_target ip6t_imq_reg = { ++ .name = "IMQ", ++ .target = imq_target, ++ .checkentry = imq_checkentry, ++ .me = THIS_MODULE ++}; ++ ++static int __init init(void) ++{ ++ if (ip6t_register_target(&ip6t_imq_reg)) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static void __exit fini(void) ++{ ++ ip6t_unregister_target(&ip6t_imq_reg); ++} ++ ++module_init(init); ++module_exit(fini); ++ ++MODULE_AUTHOR("http://www.linuximq.net"); ++MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); ++MODULE_LICENSE("GPL"); +diff -Nru linux-2.6.16/net/sched/sch_generic.c linux-2.6.16-imq/net/sched/sch_generic.c +--- linux-2.6.16/net/sched/sch_generic.c 2006-03-20 05:53:29.000000000 +0000 ++++ linux-2.6.16-imq/net/sched/sch_generic.c 2006-03-25 20:57:14.000000000 +0000 +@@ -29,6 +29,9 @@ + #include + #include + #include ++#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) ++#include ++#endif + #include + #include + #include +@@ -136,7 +139,13 @@ + + if (!netif_queue_stopped(dev)) { + int ret; +- if (netdev_nit) ++ ++ if (netdev_nit ++#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) ++ && !(skb->imq_flags & IMQ_F_ENQUEUE) ++#endif ++ ) ++ + dev_queue_xmit_nit(skb, dev); + + ret = dev->hard_start_xmit(skb, dev); diff --git a/src/patches/linux-2.6.21-img2.diff b/src/patches/linux-2.6.21-img2.diff deleted file mode 100644 index ef975afab..000000000 --- a/src/patches/linux-2.6.21-img2.diff +++ /dev/null @@ -1,840 +0,0 @@ -diff -Nru linux-2.6.21.1-orig/drivers/net/Kconfig linux-2.6.21.1/drivers/net/Kconfig ---- linux-2.6.21.1-orig/drivers/net/Kconfig 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/drivers/net/Kconfig 2007-06-02 21:43:55.000000000 +0000 -@@ -96,6 +96,129 @@ - To compile this driver as a module, choose M here: the module - will be called eql. If unsure, say N. - -+config IMQ -+ tristate "IMQ (intermediate queueing device) support" -+ depends on NETDEVICES && NETFILTER -+ ---help--- -+ The IMQ device(s) is used as placeholder for QoS queueing -+ disciplines. Every packet entering/leaving the IP stack can be -+ directed through the IMQ device where it's enqueued/dequeued to the -+ attached qdisc. This allows you to treat network devices as classes -+ and distribute bandwidth among them. Iptables is used to specify -+ through which IMQ device, if any, packets travel. -+ -+ More information at: http://www.linuximq.net/ -+ -+ To compile this driver as a module, choose M here: the module -+ will be called imq. If unsure, say N. -+ -+choice -+ prompt "IMQ behavior (PRE/POSTROUTING)" -+ depends on IMQ -+ default IMQ_BEHAVIOR_BA -+ help -+ -+ This settings defines how IMQ behaves in respect to its -+ hooking in PREROUTING and POSTROUTING. -+ -+ IMQ can work in any of the following ways: -+ -+ PREROUTING | POSTROUTING -+ -----------------|------------------- -+ #1 After NAT | After NAT -+ #2 After NAT | Before NAT -+ #3 Before NAT | After NAT -+ #4 Before NAT | Before NAT -+ -+ The default behavior is to hook before NAT on PREROUTING -+ and after NAT on POSTROUTING (#3). -+ -+ This settings are specially usefull when trying to use IMQ -+ to shape NATed clients. -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ -+config IMQ_BEHAVIOR_AA -+ bool "IMQ AA" -+ help -+ This settings defines how IMQ behaves in respect to its -+ hooking in PREROUTING and POSTROUTING. -+ -+ Choosing this option will make IMQ hook like this: -+ -+ PREROUTING: After NAT -+ POSTROUTING: After NAT -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ -+config IMQ_BEHAVIOR_AB -+ bool "IMQ AB" -+ help -+ This settings defines how IMQ behaves in respect to its -+ hooking in PREROUTING and POSTROUTING. -+ -+ Choosing this option will make IMQ hook like this: -+ -+ PREROUTING: After NAT -+ POSTROUTING: Before NAT -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ -+config IMQ_BEHAVIOR_BA -+ bool "IMQ BA" -+ help -+ This settings defines how IMQ behaves in respect to its -+ hooking in PREROUTING and POSTROUTING. -+ -+ Choosing this option will make IMQ hook like this: -+ -+ PREROUTING: Before NAT -+ POSTROUTING: After NAT -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ -+config IMQ_BEHAVIOR_BB -+ bool "IMQ BB" -+ help -+ This settings defines how IMQ behaves in respect to its -+ hooking in PREROUTING and POSTROUTING. -+ -+ Choosing this option will make IMQ hook like this: -+ -+ PREROUTING: Before NAT -+ POSTROUTING: Before NAT -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ -+endchoice -+ -+config IMQ_NUM_DEVS -+ -+ int "Number of IMQ devices" -+ range 2 8 -+ depends on IMQ -+ default "2" -+ help -+ -+ This settings defines how many IMQ devices will be -+ created. -+ -+ The default value is 2. -+ -+ More information can be found at: www.linuximq.net -+ -+ If not sure leave the default settings alone. -+ - config TUN - tristate "Universal TUN/TAP device driver support" - select CRC32 -diff -Nru linux-2.6.21.1-orig/drivers/net/Makefile linux-2.6.21.1/drivers/net/Makefile ---- linux-2.6.21.1-orig/drivers/net/Makefile 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/drivers/net/Makefile 2007-06-02 21:43:55.000000000 +0000 -@@ -124,6 +124,7 @@ - obj-$(CONFIG_SLHC) += slhc.o - - obj-$(CONFIG_DUMMY) += dummy.o -+obj-$(CONFIG_IMQ) += imq.o - obj-$(CONFIG_IFB) += ifb.o - obj-$(CONFIG_DE600) += de600.o - obj-$(CONFIG_DE620) += de620.o -diff -Nru linux-2.6.21.1-orig/drivers/net/imq.c linux-2.6.21.1/drivers/net/imq.c ---- linux-2.6.21.1-orig/drivers/net/imq.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/drivers/net/imq.c 2007-06-02 21:43:55.000000000 +0000 -@@ -0,0 +1,402 @@ -+/* -+ * Pseudo-driver for the intermediate queue device. -+ * -+ * 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. -+ * -+ * Authors: Patrick McHardy, -+ * -+ * The first version was written by Martin Devera, -+ * -+ * Credits: Jan Rafaj -+ * - Update patch to 2.4.21 -+ * Sebastian Strollo -+ * - Fix "Dead-loop on netdevice imq"-issue -+ * Marcel Sebek -+ * - Update to 2.6.2-rc1 -+ * -+ * After some time of inactivity there is a group taking care -+ * of IMQ again: http://www.linuximq.net -+ * -+ * -+ * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including -+ * the following changes: -+ * -+ * - Correction of ipv6 support "+"s issue (Hasso Tepper) -+ * - Correction of imq_init_devs() issue that resulted in -+ * kernel OOPS unloading IMQ as module (Norbert Buchmuller) -+ * - Addition of functionality to choose number of IMQ devices -+ * during kernel config (Andre Correa) -+ * - Addition of functionality to choose how IMQ hooks on -+ * PRE and POSTROUTING (after or before NAT) (Andre Correa) -+ * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa) -+ * -+ * -+ * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were -+ * released with almost no problems. 2.6.14-x was released -+ * with some important changes: nfcache was removed; After -+ * some weeks of trouble we figured out that some IMQ fields -+ * in skb were missing in skbuff.c - skb_clone and copy_skb_header. -+ * These functions are correctly patched by this new patch version. -+ * -+ * Thanks for all who helped to figure out all the problems with -+ * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX, -+ * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully -+ * I didn't forget anybody). I apologize again for my lack of time. -+ * -+ * More info at: http://www.linuximq.net/ (Andre Correa) -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+ #include -+#endif -+#include -+#include -+ -+extern int qdisc_restart1(struct net_device *dev); -+ -+static nf_hookfn imq_nf_hook; -+ -+static struct nf_hook_ops imq_ingress_ipv4 = { -+ .hook = imq_nf_hook, -+ .owner = THIS_MODULE, -+ .pf = PF_INET, -+ .hooknum = NF_IP_PRE_ROUTING, -+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) -+ .priority = NF_IP_PRI_MANGLE + 1 -+#else -+ .priority = NF_IP_PRI_NAT_DST + 1 -+#endif -+}; -+ -+static struct nf_hook_ops imq_egress_ipv4 = { -+ .hook = imq_nf_hook, -+ .owner = THIS_MODULE, -+ .pf = PF_INET, -+ .hooknum = NF_IP_POST_ROUTING, -+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA) -+ .priority = NF_IP_PRI_LAST -+#else -+ .priority = NF_IP_PRI_NAT_SRC - 1 -+#endif -+}; -+ -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+static struct nf_hook_ops imq_ingress_ipv6 = { -+ .hook = imq_nf_hook, -+ .owner = THIS_MODULE, -+ .pf = PF_INET6, -+ .hooknum = NF_IP6_PRE_ROUTING, -+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) -+ .priority = NF_IP6_PRI_MANGLE + 1 -+#else -+ .priority = NF_IP6_PRI_NAT_DST + 1 -+#endif -+}; -+ -+static struct nf_hook_ops imq_egress_ipv6 = { -+ .hook = imq_nf_hook, -+ .owner = THIS_MODULE, -+ .pf = PF_INET6, -+ .hooknum = NF_IP6_POST_ROUTING, -+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA) -+ .priority = NF_IP6_PRI_LAST -+#else -+ .priority = NF_IP6_PRI_NAT_SRC - 1 -+#endif -+}; -+#endif -+ -+#if defined(CONFIG_IMQ_NUM_DEVS) -+static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS; -+#else -+static unsigned int numdevs = 2; -+#endif -+ -+static struct net_device *imq_devs; -+ -+static struct net_device_stats *imq_get_stats(struct net_device *dev) -+{ -+ return (struct net_device_stats *)dev->priv; -+} -+ -+/* called for packets kfree'd in qdiscs at places other than enqueue */ -+static void imq_skb_destructor(struct sk_buff *skb) -+{ -+ struct nf_info *info = skb->nf_info; -+ -+ if (info) { -+ if (info->indev) -+ dev_put(info->indev); -+ if (info->outdev) -+ dev_put(info->outdev); -+ kfree(info); -+ } -+} -+ -+static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev) -+{ -+ struct net_device_stats *stats = (struct net_device_stats*) dev->priv; -+ -+ stats->tx_bytes += skb->len; -+ stats->tx_packets++; -+ -+ skb->imq_flags = 0; -+ skb->destructor = NULL; -+ -+ dev->trans_start = jiffies; -+ nf_reinject(skb, skb->nf_info, NF_ACCEPT); -+ return 0; -+} -+ -+static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data) -+{ -+ struct net_device *dev; -+ struct net_device_stats *stats; -+ struct sk_buff *skb2 = NULL; -+ struct Qdisc *q; -+ unsigned int index = skb->imq_flags&IMQ_F_IFMASK; -+ int ret = -1; -+ -+ if (index > numdevs) -+ return -1; -+ -+ dev = imq_devs + index; -+ if (!(dev->flags & IFF_UP)) { -+ skb->imq_flags = 0; -+ nf_reinject(skb, info, NF_ACCEPT); -+ return 0; -+ } -+ dev->last_rx = jiffies; -+ -+ if (skb->destructor) { -+ skb2 = skb; -+ skb = skb_clone(skb, GFP_ATOMIC); -+ if (!skb) -+ return -1; -+ } -+ skb->nf_info = info; -+ -+ stats = (struct net_device_stats *)dev->priv; -+ stats->rx_bytes+= skb->len; -+ stats->rx_packets++; -+ -+ spin_lock_bh(&dev->queue_lock); -+ q = dev->qdisc; -+ if (q->enqueue) { -+ q->enqueue(skb_get(skb), q); -+ if (skb_shared(skb)) { -+ skb->destructor = imq_skb_destructor; -+ kfree_skb(skb); -+ ret = 0; -+ } -+ } -+ if (spin_is_locked(&dev->_xmit_lock)) -+ netif_schedule(dev); -+ else -+ while (!netif_queue_stopped(dev) && qdisc_restart1(dev) < 0) -+ /* NOTHING */; -+ -+ spin_unlock_bh(&dev->queue_lock); -+ -+ if (skb2) -+ kfree_skb(ret ? skb : skb2); -+ -+ return ret; -+} -+ -+static struct nf_queue_handler nfqh = { -+ .name = "imq", -+ .outfn = imq_nf_queue, -+}; -+ -+static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb, -+ const struct net_device *indev, -+ const struct net_device *outdev, -+ int (*okfn)(struct sk_buff *)) -+{ -+ if ((*pskb)->imq_flags & IMQ_F_ENQUEUE) -+ return NF_QUEUE; -+ -+ return NF_ACCEPT; -+} -+ -+ -+static int __init imq_init_hooks(void) -+{ -+ int err; -+ -+ err = nf_register_queue_handler(PF_INET, &nfqh); -+ if (err > 0) -+ goto err1; -+ if ((err = nf_register_hook(&imq_ingress_ipv4))) -+ goto err2; -+ if ((err = nf_register_hook(&imq_egress_ipv4))) -+ goto err3; -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+ if ((err = nf_register_queue_handler(PF_INET6, &nfqh))) -+ goto err4; -+ if ((err = nf_register_hook(&imq_ingress_ipv6))) -+ goto err5; -+ if ((err = nf_register_hook(&imq_egress_ipv6))) -+ goto err6; -+#endif -+ -+ return 0; -+ -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+err6: -+ nf_unregister_hook(&imq_ingress_ipv6); -+err5: -+ nf_unregister_queue_handler(PF_INET6); -+err4: -+ nf_unregister_hook(&imq_egress_ipv6); -+#endif -+err3: -+ nf_unregister_hook(&imq_ingress_ipv4); -+err2: -+ nf_unregister_queue_handler(PF_INET); -+err1: -+ return err; -+} -+ -+static void __exit imq_unhook(void) -+{ -+ nf_unregister_hook(&imq_ingress_ipv4); -+ nf_unregister_hook(&imq_egress_ipv4); -+ nf_unregister_queue_handler(PF_INET); -+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) -+ nf_unregister_hook(&imq_ingress_ipv6); -+ nf_unregister_hook(&imq_egress_ipv6); -+ nf_unregister_queue_handler(PF_INET6); -+#endif -+} -+ -+static int __init imq_dev_init(struct net_device *dev) -+{ -+ dev->hard_start_xmit = imq_dev_xmit; -+ dev->type = ARPHRD_VOID; -+ dev->mtu = 1500; -+ dev->tx_queue_len = 30; -+ dev->flags = IFF_NOARP; -+ dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL); -+ if (dev->priv == NULL) -+ return -ENOMEM; -+ memset(dev->priv, 0, sizeof(struct net_device_stats)); -+ dev->get_stats = imq_get_stats; -+ -+ return 0; -+} -+ -+static void imq_dev_uninit(struct net_device *dev) -+{ -+ kfree(dev->priv); -+} -+ -+static int __init imq_init_devs(void) -+{ -+ struct net_device *dev; -+ int i,j; -+ j = numdevs; -+ -+ if (!numdevs || numdevs > IMQ_MAX_DEVS) { -+ printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n", -+ IMQ_MAX_DEVS); -+ return -EINVAL; -+ } -+ -+ imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL); -+ if (!imq_devs) -+ return -ENOMEM; -+ memset(imq_devs, 0, sizeof(struct net_device) * numdevs); -+ -+ /* we start counting at zero */ -+ numdevs--; -+ -+ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) { -+ SET_MODULE_OWNER(dev); -+ strcpy(dev->name, "imq%d"); -+ dev->init = imq_dev_init; -+ dev->uninit = imq_dev_uninit; -+ -+ if (register_netdev(dev) < 0) -+ goto err_register; -+ } -+ printk(KERN_INFO "IMQ starting with %u devices...\n", j); -+ return 0; -+ -+err_register: -+ for (; i; i--) -+ unregister_netdev(--dev); -+ kfree(imq_devs); -+ return -EIO; -+} -+ -+static void imq_cleanup_devs(void) -+{ -+ int i; -+ struct net_device *dev = imq_devs; -+ -+ for (i = 0; i <= numdevs; i++) -+ unregister_netdev(dev++); -+ -+ kfree(imq_devs); -+} -+ -+static int __init imq_init_module(void) -+{ -+ int err; -+ -+ if ((err = imq_init_devs())) { -+ printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n"); -+ return err; -+ } -+ if ((err = imq_init_hooks())) { -+ printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n"); -+ imq_cleanup_devs(); -+ return err; -+ } -+ -+ printk(KERN_INFO "IMQ driver loaded successfully.\n"); -+ -+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB) -+ printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n"); -+#else -+ printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n"); -+#endif -+#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB) -+ printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n"); -+#else -+ printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n"); -+#endif -+ -+ return 0; -+} -+ -+static void __exit imq_cleanup_module(void) -+{ -+ imq_unhook(); -+ imq_cleanup_devs(); -+ printk(KERN_INFO "IMQ driver unloaded successfully.\n"); -+} -+ -+ -+module_init(imq_init_module); -+module_exit(imq_cleanup_module); -+ -+module_param(numdevs, int, 0); -+MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)"); -+MODULE_AUTHOR("http://www.linuximq.net"); -+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); -+MODULE_LICENSE("GPL"); -diff -Nru linux-2.6.21.1-orig/include/linux/imq.h linux-2.6.21.1/include/linux/imq.h ---- linux-2.6.21.1-orig/include/linux/imq.h 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/include/linux/imq.h 2007-06-02 21:43:55.000000000 +0000 -@@ -0,0 +1,9 @@ -+#ifndef _IMQ_H -+#define _IMQ_H -+ -+#define IMQ_MAX_DEVS 16 -+ -+#define IMQ_F_IFMASK 0x7f -+#define IMQ_F_ENQUEUE 0x80 -+ -+#endif /* _IMQ_H */ -diff -Nru linux-2.6.21.1-orig/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.21.1/include/linux/netfilter_ipv4/ipt_IMQ.h ---- linux-2.6.21.1-orig/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/include/linux/netfilter_ipv4/ipt_IMQ.h 2007-06-02 21:43:55.000000000 +0000 -@@ -0,0 +1,8 @@ -+#ifndef _IPT_IMQ_H -+#define _IPT_IMQ_H -+ -+struct ipt_imq_info { -+ unsigned int todev; /* target imq device */ -+}; -+ -+#endif /* _IPT_IMQ_H */ -diff -Nru linux-2.6.21.1-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.21.1/include/linux/netfilter_ipv6/ip6t_IMQ.h ---- linux-2.6.21.1-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/include/linux/netfilter_ipv6/ip6t_IMQ.h 2007-06-02 21:43:55.000000000 +0000 -@@ -0,0 +1,8 @@ -+#ifndef _IP6T_IMQ_H -+#define _IP6T_IMQ_H -+ -+struct ip6t_imq_info { -+ unsigned int todev; /* target imq device */ -+}; -+ -+#endif /* _IP6T_IMQ_H */ -diff -Nru linux-2.6.21.1-orig/include/linux/skbuff.h linux-2.6.21.1/include/linux/skbuff.h ---- linux-2.6.21.1-orig/include/linux/skbuff.h 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/include/linux/skbuff.h 2007-06-02 21:43:55.000000000 +0000 -@@ -294,6 +294,10 @@ - #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) - struct sk_buff *nfct_reasm; - #endif -+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE) -+ unsigned char imq_flags; -+ struct nf_info *nf_info; -+#endif - #ifdef CONFIG_BRIDGE_NETFILTER - struct nf_bridge_info *nf_bridge; - #endif -diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/Kconfig linux-2.6.21.1/net/ipv4/netfilter/Kconfig ---- linux-2.6.21.1-orig/net/ipv4/netfilter/Kconfig 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/net/ipv4/netfilter/Kconfig 2007-06-02 21:43:55.000000000 +0000 -@@ -565,6 +565,17 @@ - - To compile it as a module, choose M here. If unsure, say N. - -+config IP_NF_TARGET_IMQ -+ tristate "IMQ target support" -+ depends on IP_NF_MANGLE -+ help -+ This option adds a `IMQ' target which is used to specify if and -+ to which IMQ device packets should get enqueued/dequeued. -+ -+ For more information visit: http://www.linuximq.net/ -+ -+ To compile it as a module, choose M here. If unsure, say N. -+ - config IP_NF_TARGET_TOS - tristate "TOS target support" - depends on IP_NF_MANGLE -diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/Makefile linux-2.6.21.1/net/ipv4/netfilter/Makefile ---- linux-2.6.21.1-orig/net/ipv4/netfilter/Makefile 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/net/ipv4/netfilter/Makefile 2007-06-02 21:43:55.000000000 +0000 -@@ -96,6 +96,7 @@ - obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o - obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o - obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o -+obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o - obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o - obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o - obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o -diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.21.1/net/ipv4/netfilter/ipt_IMQ.c ---- linux-2.6.21.1-orig/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/net/ipv4/netfilter/ipt_IMQ.c 2007-06-02 21:44:24.000000000 +0000 -@@ -0,0 +1,70 @@ -+/* -+ * This target marks packets to be enqueued to an imq device -+ */ -+#include -+#include -+#include -+#include -+#include -+ -+static unsigned int imq_target(struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ unsigned int hooknum, -+ const struct xt_target *target, -+ const void *targinfo) -+{ -+ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo; -+ -+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; -+ -+ return XT_CONTINUE; -+} -+ -+static int imq_checkentry(const char *tablename, -+ const void *e, -+ const struct xt_target *target, -+ void *targinfo, -+ unsigned int hook_mask) -+{ -+ struct ipt_imq_info *mr; -+ -+ mr = (struct ipt_imq_info*)targinfo; -+ -+ if (mr->todev > IMQ_MAX_DEVS) { -+ printk(KERN_WARNING -+ "IMQ: invalid device specified, highest is %u\n", -+ IMQ_MAX_DEVS); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct xt_target ipt_imq_reg = { -+ .name = "IMQ", -+ .family = AF_INET, -+ .target = imq_target, -+ .targetsize = sizeof(struct ipt_imq_info), -+ .checkentry = imq_checkentry, -+ .me = THIS_MODULE, -+ .table = "mangle" -+}; -+ -+static int __init init(void) -+{ -+ return xt_register_target(&ipt_imq_reg); -+} -+ -+static void __exit fini(void) -+{ -+ xt_unregister_target(&ipt_imq_reg); -+} -+ -+module_init(init); -+module_exit(fini); -+ -+MODULE_AUTHOR("http://www.linuximq.net"); -+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); -+MODULE_LICENSE("GPL"); -+ -Binary files linux-2.6.21.1-orig/net/ipv6/netfilter/.ip6t_IMQ.swp and linux-2.6.21.1/net/ipv6/netfilter/.ip6t_IMQ.swp differ -diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/Kconfig linux-2.6.21.1/net/ipv6/netfilter/Kconfig ---- linux-2.6.21.1-orig/net/ipv6/netfilter/Kconfig 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/net/ipv6/netfilter/Kconfig 2007-06-02 21:43:55.000000000 +0000 -@@ -173,6 +173,15 @@ - - To compile it as a module, choose M here. If unsure, say N. - -+config IP6_NF_TARGET_IMQ -+ tristate "IMQ target support" -+ depends on IP6_NF_MANGLE -+ help -+ This option adds a `IMQ' target which is used to specify if and -+ to which imq device packets should get enqueued/dequeued. -+ -+ To compile it as a module, choose M here. If unsure, say N. -+ - config IP6_NF_TARGET_HL - tristate 'HL (hoplimit) target support' - depends on IP6_NF_MANGLE -diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/Makefile linux-2.6.21.1/net/ipv6/netfilter/Makefile ---- linux-2.6.21.1-orig/net/ipv6/netfilter/Makefile 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/net/ipv6/netfilter/Makefile 2007-06-02 21:43:55.000000000 +0000 -@@ -13,6 +13,7 @@ - obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o - obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o - obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o -+obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o - obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o - obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o - obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o -diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.21.1/net/ipv6/netfilter/ip6t_IMQ.c ---- linux-2.6.21.1-orig/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 00:00:00.000000000 +0000 -+++ linux-2.6.21.1/net/ipv6/netfilter/ip6t_IMQ.c 2007-06-02 21:45:36.000000000 +0000 -@@ -0,0 +1,70 @@ -+/* -+ * This target marks packets to be enqueued to an imq device -+ */ -+#include -+#include -+#include -+#include -+#include -+ -+static unsigned int imq_target(struct sk_buff **pskb, -+ const struct net_device *in, -+ const struct net_device *out, -+ unsigned int hooknum, -+ const struct xt_target *target, -+ const void *targinfo) -+{ -+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo; -+ -+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE; -+ -+ return XT_CONTINUE; -+} -+ -+static int imq_checkentry(const char *tablename, -+ const void *entry, -+ const struct xt_target *target, -+ void *targinfo, -+ unsigned int hook_mask) -+{ -+ struct ip6t_imq_info *mr; -+ -+ mr = (struct ip6t_imq_info*)targinfo; -+ -+ if (mr->todev > IMQ_MAX_DEVS) { -+ printk(KERN_WARNING -+ "IMQ: invalid device specified, highest is %u\n", -+ IMQ_MAX_DEVS); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct xt_target ip6t_imq_reg = { -+ .name = "IMQ", -+ .family = AF_INET6, -+ .target = imq_target, -+ .targetsize = sizeof(struct ip6t_imq_info), -+ .table = "mangle", -+ .checkentry = imq_checkentry, -+ .me = THIS_MODULE -+}; -+ -+static int __init init(void) -+{ -+ return xt_register_target(&ip6t_imq_reg); -+} -+ -+static void __exit fini(void) -+{ -+ xt_unregister_target(&ip6t_imq_reg); -+} -+ -+module_init(init); -+module_exit(fini); -+ -+MODULE_AUTHOR("http://www.linuximq.net"); -+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information."); -+MODULE_LICENSE("GPL"); -+ -diff -Nru linux-2.6.21.1-orig/net/sched/sch_generic.c linux-2.6.21.1/net/sched/sch_generic.c ---- linux-2.6.21.1-orig/net/sched/sch_generic.c 2007-04-27 21:49:26.000000000 +0000 -+++ linux-2.6.21.1/net/sched/sch_generic.c 2007-06-02 21:43:55.000000000 +0000 -@@ -87,7 +87,6 @@ - - NOTE: Called under dev->queue_lock with locally disabled BH. - */ -- - static inline int qdisc_restart(struct net_device *dev) - { - struct Qdisc *q = dev->qdisc; -@@ -181,6 +180,11 @@ - return q->q.qlen; - } - -+int qdisc_restart1(struct net_device *dev) -+{ -+ return qdisc_restart(dev); -+} -+ - void __qdisc_run(struct net_device *dev) - { - if (unlikely(dev->qdisc == &noop_qdisc)) -@@ -617,3 +621,4 @@ - EXPORT_SYMBOL(qdisc_reset); - EXPORT_SYMBOL(qdisc_lock_tree); - EXPORT_SYMBOL(qdisc_unlock_tree); -+EXPORT_SYMBOL(qdisc_restart1); diff --git a/src/patches/reiser4-for-2.6.22-2.patch b/src/patches/reiser4-for-2.6.16-5.patch similarity index 87% rename from src/patches/reiser4-for-2.6.22-2.patch rename to src/patches/reiser4-for-2.6.16-5.patch index 8f79f8d2b..0a62c8631 100644 --- a/src/patches/reiser4-for-2.6.22-2.patch +++ b/src/patches/reiser4-for-2.6.16-5.patch @@ -1,37 +1,16 @@ -The same as reiser4-for-2.6.22.patch plus a fix for file conversion -related bug wich caused metadata corruption when REISER4_DEBUG is on. - -diff -urN linux-2.6.22.orig/arch/i386/lib/usercopy.c linux-2.6.22/arch/i386/lib/usercopy.c ---- linux-2.6.22.orig/arch/i386/lib/usercopy.c 2007-07-21 00:32:46.973831675 +0400 -+++ linux-2.6.22/arch/i386/lib/usercopy.c 2007-07-29 00:25:34.800676805 +0400 -@@ -817,6 +817,7 @@ - #endif - return n; - } -+EXPORT_SYMBOL(__copy_from_user_ll_nocache); - - unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *from, - unsigned long n) -@@ -831,6 +832,7 @@ - #endif - return n; - } -+EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero); - - /** - * copy_to_user: - Copy a block of data into user space. -diff -urN linux-2.6.22.orig/Documentation/Changes linux-2.6.22/Documentation/Changes ---- linux-2.6.22.orig/Documentation/Changes 2007-07-21 00:31:57.012856483 +0400 -+++ linux-2.6.22/Documentation/Changes 2007-07-29 00:25:34.800676805 +0400 -@@ -36,6 +36,7 @@ +Index: linux-2.6.16/Documentation/Changes +=================================================================== +--- linux-2.6.16.orig/Documentation/Changes ++++ linux-2.6.16/Documentation/Changes +@@ -54,6 +54,7 @@ o module-init-tools 0.9.10 o e2fsprogs 1.29 # tune2fs o jfsutils 1.1.3 # fsck.jfs -V o reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs +o reiser4progs 1.0.0 # fsck.reiser4 -V o xfsprogs 2.6.0 # xfs_db -V - o pcmciautils 004 # pccardctl -V - o quota-tools 3.09 # quota -V -@@ -144,6 +145,13 @@ + o pcmciautils 004 + o pcmcia-cs 3.1.21 # cardmgr -V +@@ -163,6 +164,13 @@ The reiserfsprogs package should be used versions of mkreiserfs, resize_reiserfs, debugreiserfs and reiserfsck. These utils work on both i386 and alpha platforms. @@ -45,7 +24,7 @@ diff -urN linux-2.6.22.orig/Documentation/Changes linux-2.6.22/Documentation/Cha Xfsprogs -------- -@@ -322,6 +330,10 @@ +@@ -344,6 +352,10 @@ Reiserfsprogs ------------- o @@ -56,9 +35,10 @@ diff -urN linux-2.6.22.orig/Documentation/Changes linux-2.6.22/Documentation/Cha Xfsprogs -------- o -diff -urN linux-2.6.22.orig/Documentation/filesystems/reiser4.txt linux-2.6.22/Documentation/filesystems/reiser4.txt ---- linux-2.6.22.orig/Documentation/filesystems/reiser4.txt 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/Documentation/filesystems/reiser4.txt 2007-07-29 00:25:34.800676805 +0400 +Index: linux-2.6.16/Documentation/filesystems/reiser4.txt +=================================================================== +--- /dev/null ++++ linux-2.6.16/Documentation/filesystems/reiser4.txt @@ -0,0 +1,75 @@ +Reiser4 filesystem +================== @@ -135,10 +115,36 @@ diff -urN linux-2.6.22.orig/Documentation/filesystems/reiser4.txt linux-2.6.22/D +dont_load_bitmap + Don't load all bitmap blocks at mount time, it is useful for + machines with tiny RAM and large disks. -diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c ---- linux-2.6.22.orig/fs/fs-writeback.c 2007-07-21 00:32:04.502801671 +0400 -+++ linux-2.6.22/fs/fs-writeback.c 2007-07-29 00:25:34.808678876 +0400 -@@ -296,8 +296,6 @@ +Index: linux-2.6.16/fs/Kconfig +=================================================================== +--- linux-2.6.16.orig/fs/Kconfig ++++ linux-2.6.16/fs/Kconfig +@@ -177,6 +177,8 @@ config FS_MBCACHE + default y if EXT2_FS=y || EXT3_FS=y + default m if EXT2_FS=m || EXT3_FS=m + ++source "fs/reiser4/Kconfig" ++ + config REISERFS_FS + tristate "Reiserfs support" + help +Index: linux-2.6.16/fs/Makefile +=================================================================== +--- linux-2.6.16.orig/fs/Makefile ++++ linux-2.6.16/fs/Makefile +@@ -51,6 +51,7 @@ obj-$(CONFIG_PROFILING) += dcookies.o + + # Do not add any filesystems before this line + obj-$(CONFIG_REISERFS_FS) += reiserfs/ ++obj-$(CONFIG_REISER4_FS) += reiser4/ + obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3 + obj-$(CONFIG_JBD) += jbd/ + obj-$(CONFIG_EXT2_FS) += ext2/ +Index: linux-2.6.16/fs/fs-writeback.c +=================================================================== +--- linux-2.6.16.orig/fs/fs-writeback.c ++++ linux-2.6.16/fs/fs-writeback.c +@@ -286,8 +286,6 @@ __writeback_single_inode(struct inode *i * WB_SYNC_HOLD is a hack for sys_sync(): reattach the inode to sb->s_dirty so * that it can be located for waiting on in __writeback_single_inode(). * @@ -147,7 +153,7 @@ diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c * If `bdi' is non-zero then we're being asked to writeback a specific queue. * This function assumes that the blockdev superblock's inodes are backed by * a variety of queues, so all inodes are searched. For other superblocks, -@@ -313,11 +311,13 @@ +@@ -303,11 +301,13 @@ __writeback_single_inode(struct inode *i * on the writer throttling path, and we get decent balancing between many * throttled threads: we don't want them all piling up on __wait_on_inode. */ @@ -163,7 +169,7 @@ diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c if (!wbc->for_kupdate || list_empty(&sb->s_io)) list_splice_init(&sb->s_dirty, &sb->s_io); -@@ -397,8 +397,19 @@ +@@ -387,8 +387,19 @@ sync_sb_inodes(struct super_block *sb, s if (wbc->nr_to_write <= 0) break; } @@ -183,7 +189,7 @@ diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c /* * Start writeback of dirty pagecache data against all unlocked inodes. -@@ -439,11 +450,8 @@ +@@ -429,11 +440,8 @@ restart: * be unmounted by the time it is released. */ if (down_read_trylock(&sb->s_umount)) { @@ -196,7 +202,7 @@ diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c up_read(&sb->s_umount); } spin_lock(&sb_lock); -@@ -481,9 +489,7 @@ +@@ -469,9 +477,7 @@ void sync_inodes_sb(struct super_block * (inodes_stat.nr_inodes - inodes_stat.nr_unused) + nr_dirty + nr_unstable; wbc.nr_to_write += wbc.nr_to_write / 2; /* Bit more for luck */ @@ -206,33 +212,282 @@ diff -urN linux-2.6.22.orig/fs/fs-writeback.c linux-2.6.22/fs/fs-writeback.c } /* -diff -urN linux-2.6.22.orig/fs/Kconfig linux-2.6.22/fs/Kconfig ---- linux-2.6.22.orig/fs/Kconfig 2007-07-21 00:32:57.540575927 +0400 -+++ linux-2.6.22/fs/Kconfig 2007-07-29 00:25:34.812679911 +0400 -@@ -272,6 +272,8 @@ - default y if EXT2_FS=y || EXT3_FS=y || EXT4DEV_FS=y - default m if EXT2_FS=m || EXT3_FS=m || EXT4DEV_FS=m - -+source "fs/reiser4/Kconfig" +Index: linux-2.6.16/fs/reiser4/Kconfig +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/Kconfig +@@ -0,0 +1,31 @@ ++config REISER4_FS ++ tristate "Reiser4 (EXPERIMENTAL)" ++ depends on EXPERIMENTAL ++ select ZLIB_INFLATE ++ select ZLIB_DEFLATE ++ help ++ Reiser4 is a filesystem that performs all filesystem operations ++ as atomic transactions, which means that it either performs a ++ write, or it does not, and in the event of a crash it does not ++ partially perform it or corrupt it. + - config REISERFS_FS - tristate "Reiserfs support" - help -diff -urN linux-2.6.22.orig/fs/Makefile linux-2.6.22/fs/Makefile ---- linux-2.6.22.orig/fs/Makefile 2007-07-21 00:32:57.544576967 +0400 -+++ linux-2.6.22/fs/Makefile 2007-07-29 00:25:34.812679911 +0400 -@@ -66,6 +66,7 @@ - - # Do not add any filesystems before this line - obj-$(CONFIG_REISERFS_FS) += reiserfs/ -+obj-$(CONFIG_REISER4_FS) += reiser4/ - obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3 - obj-$(CONFIG_EXT4DEV_FS) += ext4/ # Before ext2 so root fs can be ext4dev - obj-$(CONFIG_JBD) += jbd/ -diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c ---- linux-2.6.22.orig/fs/reiser4/as_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/as_ops.c 2007-07-29 00:25:34.816680947 +0400 -@@ -0,0 +1,337 @@ ++ It stores files in dancing trees, which are like balanced trees but ++ faster. It packs small files together so that they share blocks ++ without wasting space. This means you can use it to store really ++ small files. It also means that it saves you disk space. It avoids ++ hassling you with anachronisms like having a maximum number of ++ inodes, and wasting space if you use less than that number. ++ ++ Reiser4 is a distinct filesystem type from reiserfs (V3). ++ It's therefore not possible to use reiserfs file systems ++ with reiser4. ++ ++ To learn more about reiser4, go to http://www.namesys.com ++ ++config REISER4_DEBUG ++ bool "Enable reiser4 debug mode" ++ depends on REISER4_FS ++ help ++ Don't use this unless you are debugging reiser4. ++ ++ If unsure, say N. +Index: linux-2.6.16/fs/reiser4/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/Makefile +@@ -0,0 +1,100 @@ ++# ++# reiser4/Makefile ++# ++ ++obj-$(CONFIG_REISER4_FS) += reiser4.o ++ ++reiser4-y := \ ++ debug.o \ ++ jnode.o \ ++ znode.o \ ++ key.o \ ++ pool.o \ ++ tree_mod.o \ ++ estimate.o \ ++ carry.o \ ++ carry_ops.o \ ++ lock.o \ ++ tree.o \ ++ context.o \ ++ tap.o \ ++ coord.o \ ++ block_alloc.o \ ++ txnmgr.o \ ++ kassign.o \ ++ flush.o \ ++ wander.o \ ++ eottl.o \ ++ search.o \ ++ page_cache.o \ ++ seal.o \ ++ dscale.o \ ++ flush_queue.o \ ++ ktxnmgrd.o \ ++ blocknrset.o \ ++ super.o \ ++ super_ops.o \ ++ fsdata.o \ ++ export_ops.o \ ++ oid.o \ ++ tree_walk.o \ ++ inode.o \ ++ vfs_ops.o \ ++ as_ops.o \ ++ entd.o\ ++ readahead.o \ ++ status_flags.o \ ++ init_super.o \ ++ safe_link.o \ ++ \ ++ plugin/plugin.o \ ++ plugin/plugin_set.o \ ++ plugin/node/node.o \ ++ plugin/object.o \ ++ plugin/cluster.o \ ++ plugin/inode_ops.o \ ++ plugin/inode_ops_rename.o \ ++ plugin/file_ops.o \ ++ plugin/file_ops_readdir.o \ ++ plugin/file_plugin_common.o \ ++ plugin/file/file.o \ ++ plugin/file/tail_conversion.o \ ++ plugin/file/symlink.o \ ++ plugin/file/cryptcompress.o \ ++ plugin/dir_plugin_common.o \ ++ plugin/dir/hashed_dir.o \ ++ plugin/dir/seekable_dir.o \ ++ plugin/node/node40.o \ ++ \ ++ plugin/crypto/cipher.o \ ++ plugin/crypto/digest.o \ ++ \ ++ plugin/compress/minilzo.o \ ++ plugin/compress/compress.o \ ++ plugin/compress/compress_mode.o \ ++ \ ++ plugin/item/static_stat.o \ ++ plugin/item/sde.o \ ++ plugin/item/cde.o \ ++ plugin/item/blackbox.o \ ++ plugin/item/internal.o \ ++ plugin/item/tail.o \ ++ plugin/item/ctail.o \ ++ plugin/item/extent.o \ ++ plugin/item/extent_item_ops.o \ ++ plugin/item/extent_file_ops.o \ ++ plugin/item/extent_flush_ops.o \ ++ \ ++ plugin/hash.o \ ++ plugin/fibration.o \ ++ plugin/tail_policy.o \ ++ plugin/item/item.o \ ++ \ ++ plugin/security/perm.o \ ++ plugin/space/bitmap.o \ ++ \ ++ plugin/disk_format/disk_format40.o \ ++ plugin/disk_format/disk_format.o \ ++ \ ++ plugin/regular.o ++ +Index: linux-2.6.16/fs/reiser4/README +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/README +@@ -0,0 +1,125 @@ ++[LICENSING] ++ ++Reiser4 is hereby licensed under the GNU General ++Public License version 2. ++ ++Source code files that contain the phrase "licensing governed by ++reiser4/README" are "governed files" throughout this file. Governed ++files are licensed under the GPL. The portions of them owned by Hans ++Reiser, or authorized to be licensed by him, have been in the past, ++and likely will be in the future, licensed to other parties under ++other licenses. If you add your code to governed files, and don't ++want it to be owned by Hans Reiser, put your copyright label on that ++code so the poor blight and his customers can keep things straight. ++All portions of governed files not labeled otherwise are owned by Hans ++Reiser, and by adding your code to it, widely distributing it to ++others or sending us a patch, and leaving the sentence in stating that ++licensing is governed by the statement in this file, you accept this. ++It will be a kindness if you identify whether Hans Reiser is allowed ++to license code labeled as owned by you on your behalf other than ++under the GPL, because he wants to know if it is okay to do so and put ++a check in the mail to you (for non-trivial improvements) when he ++makes his next sale. He makes no guarantees as to the amount if any, ++though he feels motivated to motivate contributors, and you can surely ++discuss this with him before or after contributing. You have the ++right to decline to allow him to license your code contribution other ++than under the GPL. ++ ++Further licensing options are available for commercial and/or other ++interests directly from Hans Reiser: reiser@namesys.com. If you interpret ++the GPL as not allowing those additional licensing options, you read ++it wrongly, and Richard Stallman agrees with me, when carefully read ++you can see that those restrictions on additional terms do not apply ++to the owner of the copyright, and my interpretation of this shall ++govern for this license. ++ ++[END LICENSING] ++ ++Reiser4 is a file system based on dancing tree algorithms, and is ++described at http://www.namesys.com ++ ++mkfs.reiser4 and other utilities are on our webpage or wherever your ++Linux provider put them. You really want to be running the latest ++version off the website if you use fsck. ++ ++Yes, if you update your reiser4 kernel module you do have to ++recompile your kernel, most of the time. The errors you get will be ++quite cryptic if your forget to do so. ++ ++Hideous Commercial Pitch: Spread your development costs across other OS ++vendors. Select from the best in the world, not the best in your ++building, by buying from third party OS component suppliers. Leverage ++the software component development power of the internet. Be the most ++aggressive in taking advantage of the commercial possibilities of ++decentralized internet development, and add value through your branded ++integration that you sell as an operating system. Let your competitors ++be the ones to compete against the entire internet by themselves. Be ++hip, get with the new economic trend, before your competitors do. Send ++email to reiser@namesys.com ++ ++Hans Reiser was the primary architect of Reiser4, but a whole team ++chipped their ideas in. He invested everything he had into Namesys ++for 5.5 dark years of no money before Reiser3 finally started to work well ++enough to bring in money. He owns the copyright. ++ ++DARPA was the primary sponsor of Reiser4. DARPA does not endorse ++Reiser4, it merely sponsors it. DARPA is, in solely Hans's personal ++opinion, unique in its willingness to invest into things more ++theoretical than the VC community can readily understand, and more ++longterm than allows them to be sure that they will be the ones to ++extract the economic benefits from. DARPA also integrated us into a ++security community that transformed our security worldview. ++ ++Vladimir Saveliev is our lead programmer, with us from the beginning, ++and he worked long hours writing the cleanest code. This is why he is ++now the lead programmer after years of commitment to our work. He ++always made the effort to be the best he could be, and to make his ++code the best that it could be. What resulted was quite remarkable. I ++don't think that money can ever motivate someone to work the way he ++did, he is one of the most selfless men I know. ++ ++Alexander Lyamin was our sysadmin, and helped to educate us in ++security issues. Moscow State University and IMT were very generous ++in the internet access they provided us, and in lots of other little ++ways that a generous institution can be. ++ ++Alexander Zarochentcev (sometimes known as zam, or sasha), wrote the ++locking code, the block allocator, and finished the flushing code. ++His code is always crystal clean and well structured. ++ ++Nikita Danilov wrote the core of the balancing code, the core of the ++plugins code, and the directory code. He worked a steady pace of long ++hours that produced a whole lot of well abstracted code. He is our ++senior computer scientist. ++ ++Vladimir Demidov wrote the parser. Writing an in kernel parser is ++something very few persons have the skills for, and it is thanks to ++him that we can say that the parser is really not so big compared to ++various bits of our other code, and making a parser work in the kernel ++was not so complicated as everyone would imagine mainly because it was ++him doing it... ++ ++Joshua McDonald wrote the transaction manager, and the flush code. ++The flush code unexpectedly turned out be extremely hairy for reasons ++you can read about on our web page, and he did a great job on an ++extremely difficult task. ++ ++Nina Reiser handled our accounting, government relations, and much ++more. ++ ++Ramon Reiser developed our website. ++ ++Beverly Palmer drew our graphics. ++ ++Vitaly Fertman developed librepair, userspace plugins repair code, fsck ++and worked with Umka on developing libreiser4 and userspace plugins. ++ ++Yury Umanets (aka Umka) developed libreiser4, userspace plugins and ++userspace tools (reiser4progs). ++ ++Oleg Drokin (aka Green) is the release manager who fixes everything. ++It is so nice to have someone like that on the team. He (plus Chris ++and Jeff) make it possible for the entire rest of the Namesys team to ++focus on Reiser4, and he fixed a whole lot of Reiser4 bugs also. It ++is just amazing to watch his talent for spotting bugs in action. ++ +Index: linux-2.6.16/fs/reiser4/as_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/as_ops.c +@@ -0,0 +1,392 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Interface to VFS. Reiser4 address_space_operations are defined here. */ @@ -286,7 +541,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + * @page: page to be dirtied + * + * Operation of struct address_space_operations. This implementation is used by -+ * unix and cryptcompress file plugins. ++ * unix and crc file plugins. + * + * This is called when reiser4 page gets dirtied outside of reiser4, for + * example, when dirty bit is moved from pte to physical page. @@ -301,11 +556,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + /* this page can be unformatted only */ + assert("vs-1734", (page->mapping && + page->mapping->host && -+ reiser4_get_super_fake(page->mapping->host->i_sb) != ++ get_super_fake(page->mapping->host->i_sb) != + page->mapping->host -+ && reiser4_get_cc_fake(page->mapping->host->i_sb) != ++ && get_cc_fake(page->mapping->host->i_sb) != + page->mapping->host -+ && reiser4_get_bitmap_fake(page->mapping->host->i_sb) != ++ && get_bitmap_fake(page->mapping->host->i_sb) != + page->mapping->host)); + + if (!TestSetPageDirty(page)) { @@ -318,8 +573,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + if (page->mapping) { + assert("vs-1652", page->mapping == mapping); + if (mapping_cap_account_dirty(mapping)) -+ inc_zone_page_state(page, -+ NR_FILE_DIRTY); ++ inc_page_state(nr_dirty); + radix_tree_tag_set(&mapping->page_tree, + page->index, + PAGECACHE_TAG_REISER4_MOVED); @@ -331,6 +585,64 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + return 0; +} + ++static int filler(void *vp, struct page *page) ++{ ++ return page->mapping->a_ops->readpage(vp, page); ++} ++ ++/** ++ * reiser4_readpages - submit read for a set of pages ++ * @file: file to read ++ * @mapping: address space ++ * @pages: list of pages to submit read for ++ * @nr_pages: number of pages no the list ++ * ++ * Operation of struct address_space_operations. This implementation is used by ++ * unix and crc file plugins. ++ * ++ * Calls read_cache_pages or readpages hook if it is set. ++ */ ++int ++reiser4_readpages(struct file *file, struct address_space *mapping, ++ struct list_head *pages, unsigned nr_pages) ++{ ++ reiser4_context *ctx; ++ reiser4_file_fsdata *fsdata; ++ ++ ctx = init_context(mapping->host->i_sb); ++ if (IS_ERR(ctx)) ++ return PTR_ERR(ctx); ++ ++ fsdata = reiser4_get_file_fsdata(file); ++ if (IS_ERR(fsdata)) { ++ reiser4_exit_context(ctx); ++ return PTR_ERR(fsdata); ++ } ++ ++ if (fsdata->ra2.readpages) ++ fsdata->ra2.readpages(mapping, pages, fsdata->ra2.data); ++ else { ++ /* ++ * filler (reiser4 readpage method) may involve tree search ++ * which is not allowed when lock stack is not clean. If lock ++ * stack is not clean - do nothing. ++ */ ++ if (lock_stack_isclean(get_current_lock_stack())) ++ read_cache_pages(mapping, pages, filler, file); ++ else { ++ while (!list_empty(pages)) { ++ struct page *victim; ++ ++ victim = list_entry(pages->prev, struct page, lru); ++ list_del(&victim->lru); ++ page_cache_release(victim); ++ } ++ } ++ } ++ reiser4_exit_context(ctx); ++ return 0; ++} ++ +/* ->invalidatepage method for reiser4 */ + +/* @@ -347,7 +659,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + * @offset: starting offset for partial invalidation + * + */ -+void reiser4_invalidatepage(struct page *page, unsigned long offset) ++int reiser4_invalidatepage(struct page *page, unsigned long offset) +{ + int ret = 0; + reiser4_context *ctx; @@ -368,9 +680,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + * + * After many troubles with vmtruncate() based truncate (including + * races with flush, tail conversion, etc.) it was re-written in the -+ * top-to-bottom style: items are killed in reiser4_cut_tree_object() -+ * and pages belonging to extent are invalidated in kill_hook_extent(). -+ * So probably now additional call to capture is not needed here. ++ * top-to-bottom style: items are killed in cut_tree_object() and ++ * pages belonging to extent are invalidated in kill_hook_extent(). So ++ * probably now additional call to capture is not needed here. + */ + + assert("nikita-3137", PageLocked(page)); @@ -384,23 +696,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + * during mount) it is simpler to let ->invalidatepage to be called on + * them. Check for this, and do nothing. + */ -+ if (reiser4_get_super_fake(inode->i_sb) == inode) -+ return; -+ if (reiser4_get_cc_fake(inode->i_sb) == inode) -+ return; -+ if (reiser4_get_bitmap_fake(inode->i_sb) == inode) -+ return; ++ if (get_super_fake(inode->i_sb) == inode) ++ return 0; ++ if (get_cc_fake(inode->i_sb) == inode) ++ return 0; ++ if (get_bitmap_fake(inode->i_sb) == inode) ++ return 0; + assert("vs-1426", PagePrivate(page)); + assert("vs-1427", + page->mapping == jnode_get_mapping(jnode_by_page(page))); + assert("", jprivate(page) != NULL); + assert("", ergo(inode_file_plugin(inode) != -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID), -+ offset == 0)); ++ file_plugin_by_id(CRC_FILE_PLUGIN_ID), offset == 0)); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) -+ return; ++ return PTR_ERR(ctx); + + node = jprivate(page); + spin_lock_jnode(node); @@ -410,11 +721,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + jref(node); + JF_SET(node, JNODE_HEARD_BANSHEE); + page_clear_jnode(page, node); -+ reiser4_uncapture_jnode(node); ++ uncapture_jnode(node); + unhash_unformatted_jnode(node); + jput(node); + reiser4_exit_context(ctx); -+ return; ++ return 0; + } + spin_unlock_jnode(node); + @@ -429,7 +740,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + JF_SET(node, JNODE_HEARD_BANSHEE); + /* page cannot be detached from jnode concurrently, because it + * is locked */ -+ reiser4_uncapture_page(page); ++ uncapture_page(page); + + /* this detaches page from jnode, so that jdelete will not try + * to lock page which is already locked */ @@ -442,6 +753,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + } + + reiser4_exit_context(ctx); ++ return 0; +} + +/* help function called from reiser4_releasepage(). It returns true if jnode @@ -466,7 +778,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + * clean, not it atom yet, and still having fake block number. For + * example, node just created in jinit_new(). + */ -+ if (reiser4_blocknr_is_fake(jnode_get_block(node))) ++ if (blocknr_is_fake(jnode_get_block(node))) + return 0; + + /* @@ -514,7 +826,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + assert("nikita-2257", PagePrivate(page)); + assert("nikita-2259", PageLocked(page)); + assert("nikita-2892", !PageWriteback(page)); -+ assert("nikita-3019", reiser4_schedulable()); ++ assert("nikita-3019", schedulable()); + + /* NOTE-NIKITA: this can be called in the context of reiser4 call. It + is not clear what to do in this case. A lot of deadlocks seems be @@ -528,8 +840,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + if (PageDirty(page)) + return 0; + -+ /* extra page reference is used by reiser4 to protect -+ * jnode<->page link from this ->releasepage(). */ + if (page_count(page) > 3) + return 0; + @@ -556,7 +866,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + } else { + spin_unlock(&(node->load)); + spin_unlock_jnode(node); -+ assert("nikita-3020", reiser4_schedulable()); ++ assert("nikita-3020", schedulable()); + return 0; + } +} @@ -570,10 +880,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/as_ops.c linux-2.6.22/fs/reiser4/as_ops.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/block_alloc.c ---- linux-2.6.22.orig/fs/reiser4/block_alloc.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/block_alloc.c 2007-07-29 00:25:34.816680947 +0400 -@@ -0,0 +1,1137 @@ +Index: linux-2.6.16/fs/reiser4/block_alloc.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/block_alloc.c +@@ -0,0 +1,1139 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "debug.h" @@ -695,20 +1006,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + impossible to overload this counter during one transaction life. */ + +/* Initialize a blocknr hint. */ -+void reiser4_blocknr_hint_init(reiser4_blocknr_hint * hint) ++void blocknr_hint_init(reiser4_blocknr_hint * hint) +{ + memset(hint, 0, sizeof(reiser4_blocknr_hint)); +} + +/* Release any resources of a blocknr hint. */ -+void reiser4_blocknr_hint_done(reiser4_blocknr_hint * hint UNUSED_ARG) ++void blocknr_hint_done(reiser4_blocknr_hint * hint UNUSED_ARG) +{ + /* No resources should be freed in current blocknr_hint implementation. */ +} + +/* see above for explanation of fake block number. */ +/* Audited by: green(2002.06.11) */ -+int reiser4_blocknr_is_fake(const reiser4_block_nr * da) ++int blocknr_is_fake(const reiser4_block_nr * da) +{ + /* The reason for not simply returning result of '&' operation is that + while return value is (possibly 32bit) int, the reiser4_block_nr is @@ -794,13 +1105,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo +/* super block has 6 counters: free, used, grabbed, fake allocated + (formatted and unformatted) and flush reserved. Their sum must be + number of blocks on a device. This function checks this */ -+int reiser4_check_block_counters(const struct super_block *super) ++int check_block_counters(const struct super_block *super) +{ + __u64 sum; + + sum = reiser4_grabbed_blocks(super) + reiser4_free_blocks(super) + + reiser4_data_blocks(super) + reiser4_fake_allocated(super) + -+ reiser4_fake_allocated_unformatted(super) + reiser4_flush_reserved(super) + ++ reiser4_fake_allocated_unformatted(super) + flush_reserved(super) + + reiser4_clustered_blocks(super); + if (reiser4_block_count(super) != sum) { + printk("super block counters: " @@ -813,7 +1124,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + (unsigned long long)reiser4_fake_allocated(super), + (unsigned long long) + reiser4_fake_allocated_unformatted(super), -+ (unsigned long long)reiser4_flush_reserved(super), ++ (unsigned long long)flush_reserved(super), + (unsigned long long)reiser4_clustered_blocks(super), + (unsigned long long)sum, + (unsigned long long)reiser4_block_count(super)); @@ -871,7 +1182,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + ctx->grabbed_initially = count; +#endif + -+ assert("nikita-2986", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2986", check_block_counters(ctx->super)); + + /* disable grab space in current context */ + ctx->grab_enabled = 0; @@ -921,7 +1232,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + * Solution is to reserve 5% of disk space for truncates and + * unlinks. Specifically, normal space grabbing requests don't grab space from + * reserved area. Only requests with BA_RESERVED bit in flags are allowed to -+ * drain it. Per super block delete mutex is used to allow only one ++ * drain it. Per super block delete_sema semaphore is used to allow only one + * thread at a time to grab from reserved area. + * + * Grabbing from reserved area should always be performed with BA_CAN_COMMIT @@ -936,9 +1247,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + + assert("nikita-3175", flags & BA_CAN_COMMIT); + -+ /* Check the delete mutex already taken by us, we assume that ++ /* Check the delete semaphore already taken by us, we assume that + * reading of machine word is atomic. */ -+ if (sbinfo->delete_mutex_owner == current) { ++ if (sbinfo->delete_sema_owner == current) { + if (reiser4_grab_space + (count, (flags | BA_RESERVED) & ~BA_CAN_COMMIT)) { + warning("zam-1003", @@ -951,9 +1262,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + } + + if (reiser4_grab_space(count, flags)) { -+ mutex_lock(&sbinfo->delete_mutex); -+ assert("nikita-2929", sbinfo->delete_mutex_owner == NULL); -+ sbinfo->delete_mutex_owner = current; ++ down(&sbinfo->delete_sema); ++ assert("nikita-2929", sbinfo->delete_sema_owner == NULL); ++ sbinfo->delete_sema_owner = current; + + if (reiser4_grab_space(count, flags | BA_RESERVED)) { + warning("zam-833", @@ -971,9 +1282,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + reiser4_super_info_data *info; + + info = get_super_private(super); -+ if (info->delete_mutex_owner == current) { -+ info->delete_mutex_owner = NULL; -+ mutex_unlock(&info->delete_mutex); ++ if (info->delete_sema_owner == current) { ++ info->delete_sema_owner = NULL; ++ up(&info->delete_sema); + } +} + @@ -1002,7 +1313,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo = grabbed2fake_allocated_head(1); + sbinfo->blocks_fake_allocated++; + -+ assert("vs-922", reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("vs-922", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1019,7 +1330,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo = grabbed2fake_allocated_head(count); + sbinfo->blocks_fake_allocated_unformatted += count; + -+ assert("vs-9221", reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("vs-9221", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1038,7 +1349,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sub_from_sb_grabbed(sbinfo, count); + sbinfo->blocks_clustered += count; + -+ assert("edward-504", reiser4_check_block_counters(ctx->super)); ++ assert("edward-504", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1056,7 +1367,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sub_from_cluster_reserved(sbinfo, count); + sbinfo->blocks_grabbed += count; + -+ assert("edward-505", reiser4_check_block_counters(ctx->super)); ++ assert("edward-505", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); + add_to_ctx_grabbed(ctx, count); @@ -1067,11 +1378,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + reiser4_context *ctx; + reiser4_super_info_data *sbinfo; + ++ assert("edward-503", get_current_context()->grabbed_blocks == 0); ++ + ctx = get_current_context(); + sbinfo = get_super_private(ctx->super); ++ spin_lock_reiser4_super(sbinfo); + -+ cluster_reserved2grabbed(count); -+ grabbed2free(ctx, sbinfo, count); ++ sub_from_cluster_reserved(sbinfo, count); ++ sbinfo->blocks_free += count; ++ ++ assert("edward-502", check_block_counters(ctx->super)); ++ ++ spin_unlock_reiser4_super(sbinfo); +} + +static DEFINE_SPINLOCK(fake_lock); @@ -1123,8 +1441,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + +/* adjust sb block counters, if real (on-disk) block allocation immediately + follows grabbing of free disk space. */ -+static void grabbed2used(reiser4_context *ctx, reiser4_super_info_data *sbinfo, -+ __u64 count) ++void grabbed2used(reiser4_context *ctx, reiser4_super_info_data *sbinfo, ++ __u64 count) +{ + sub_from_ctx_grabbed(ctx, count); + @@ -1133,27 +1451,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sub_from_sb_grabbed(sbinfo, count); + sbinfo->blocks_used += count; + -+ assert("nikita-2679", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2679", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} + +/* adjust sb block counters when @count unallocated blocks get mapped to disk */ -+static void fake_allocated2used(reiser4_super_info_data *sbinfo, __u64 count, -+ reiser4_ba_flags_t flags) ++void fake_allocated2used(reiser4_super_info_data *sbinfo, __u64 count, ++ reiser4_ba_flags_t flags) +{ + spin_lock_reiser4_super(sbinfo); + + sub_from_sb_fake_allocated(sbinfo, count, flags); + sbinfo->blocks_used += count; + -+ assert("nikita-2680", -+ reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("nikita-2680", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} + -+static void flush_reserved2used(txn_atom * atom, __u64 count) ++void flush_reserved2used(txn_atom * atom, __u64 count) +{ + reiser4_super_info_data *sbinfo; + @@ -1168,8 +1485,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sub_from_sb_flush_reserved(sbinfo, count); + sbinfo->blocks_used += count; + -+ assert("zam-789", -+ reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("zam-789", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1181,7 +1497,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo +{ + reiser4_super_info_data *sbinfo = get_super_private(s); + -+ assert("nikita-3342", !reiser4_blocknr_is_fake(block)); ++ assert("nikita-3342", !blocknr_is_fake(block)); + + spin_lock_reiser4_super(sbinfo); + if (*block < sbinfo->block_count) { @@ -1253,8 +1569,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + } + + ret = -+ sa_alloc_blocks(reiser4_get_space_allocator(ctx->super), -+ hint, (int)needed, blk, len); ++ sa_alloc_blocks(get_space_allocator(ctx->super), hint, (int)needed, ++ blk, len); + + if (!ret) { + assert("zam-680", *blk < reiser4_block_count(ctx->super)); @@ -1314,8 +1630,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + + sub_from_sb_used(sbinfo, count); + -+ assert("nikita-2681", -+ reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("nikita-2681", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1335,8 +1650,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + /*add_to_sb_flush_reserved(sbinfo, count); */ + sub_from_sb_used(sbinfo, count); + -+ assert("nikita-2681", -+ reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("nikita-2681", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1350,12 +1664,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + + spin_lock_reiser4_super(sbinfo); + -+ assert("nikita-2682", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2682", check_block_counters(ctx->super)); + + sbinfo->blocks_grabbed += count; + sub_from_sb_fake_allocated(sbinfo, count, flags & BA_FORMATTED); + -+ assert("nikita-2683", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2683", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1403,7 +1717,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + + sub_from_sb_grabbed(sbinfo, count); + sbinfo->blocks_free += count; -+ assert("nikita-2684", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2684", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1427,7 +1741,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo->blocks_flush_reserved += count; + sub_from_sb_grabbed(sbinfo, count); + -+ assert("vpf-292", reiser4_check_block_counters(ctx->super)); ++ assert("vpf-292", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1461,7 +1775,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo->blocks_grabbed += count; + sub_from_sb_flush_reserved(sbinfo, count); + -+ assert("vpf-292", reiser4_check_block_counters(ctx->super)); ++ assert("vpf-292", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1493,7 +1807,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo->blocks_grabbed += count; + sub_from_sb_used(sbinfo, count); + -+ assert("nikita-2685", reiser4_check_block_counters(ctx->super)); ++ assert("nikita-2685", check_block_counters(ctx->super)); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1506,8 +1820,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sbinfo->blocks_free += count; + sub_from_sb_used(sbinfo, count); + -+ assert("nikita-2685", -+ reiser4_check_block_counters(reiser4_get_current_sb())); ++ assert("nikita-2685", check_block_counters(reiser4_get_current_sb())); + + spin_unlock_reiser4_super(sbinfo); +} @@ -1560,7 +1873,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + if (REISER4_DEBUG) { + assert("zam-431", *len != 0); + assert("zam-432", *start != 0); -+ assert("zam-558", !reiser4_blocknr_is_fake(start)); ++ assert("zam-558", !blocknr_is_fake(start)); + + spin_lock_reiser4_super(sbinfo); + assert("zam-562", *start < sbinfo->block_count); @@ -1593,8 +1906,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + + } else { + assert("zam-425", get_current_super_private() != NULL); -+ sa_dealloc_blocks(reiser4_get_space_allocator(ctx->super), -+ *start, *len); ++ sa_dealloc_blocks(get_space_allocator(ctx->super), *start, ++ *len); + + if (flags & BA_PERMANENT) { + /* These blocks were counted as allocated, we have to revert it @@ -1637,7 +1950,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo +} + +/* wrappers for block allocator plugin methods */ -+int reiser4_pre_commit_hook(void) ++int pre_commit_hook(void) +{ + assert("zam-502", get_current_super_private() != NULL); + sa_pre_commit_hook(); @@ -1678,7 +1991,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + return 0; +} + -+void reiser4_post_commit_hook(void) ++void post_commit_hook(void) +{ + txn_atom *atom; + @@ -1694,7 +2007,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + sa_post_commit_hook(); +} + -+void reiser4_post_write_back_hook(void) ++void post_write_back_hook(void) +{ + assert("zam-504", get_current_super_private() != NULL); + @@ -1711,9 +2024,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.c linux-2.6.22/fs/reiser4/blo + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.h linux-2.6.22/fs/reiser4/block_alloc.h ---- linux-2.6.22.orig/fs/reiser4/block_alloc.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/block_alloc.h 2007-07-29 00:25:34.820681982 +0400 +Index: linux-2.6.16/fs/reiser4/block_alloc.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/block_alloc.h @@ -0,0 +1,175 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -1799,8 +2113,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.h linux-2.6.22/fs/reiser4/blo + +typedef enum reiser4_ba_flags reiser4_ba_flags_t; + -+extern void reiser4_blocknr_hint_init(reiser4_blocknr_hint * hint); -+extern void reiser4_blocknr_hint_done(reiser4_blocknr_hint * hint); ++extern void blocknr_hint_init(reiser4_blocknr_hint * hint); ++extern void blocknr_hint_done(reiser4_blocknr_hint * hint); +extern void update_blocknr_hint_default(const struct super_block *, + const reiser4_block_nr *); +extern void get_blocknr_hint_default(reiser4_block_nr *); @@ -1857,13 +2171,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.h linux-2.6.22/fs/reiser4/blo + +extern void flush_reserved2grabbed(txn_atom * atom, __u64 count); + -+extern int reiser4_blocknr_is_fake(const reiser4_block_nr * da); ++extern int blocknr_is_fake(const reiser4_block_nr * da); + +extern void grabbed2cluster_reserved(int count); +extern void cluster_reserved2grabbed(int count); +extern void cluster_reserved2free(int count); + -+extern int reiser4_check_block_counters(const struct super_block *); ++extern int check_block_counters(const struct super_block *); + +#if REISER4_DEBUG + @@ -1875,9 +2189,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.h linux-2.6.22/fs/reiser4/blo + +#endif + -+extern int reiser4_pre_commit_hook(void); -+extern void reiser4_post_commit_hook(void); -+extern void reiser4_post_write_back_hook(void); ++extern int pre_commit_hook(void); ++extern void post_commit_hook(void); ++extern void post_write_back_hook(void); + +#endif /* __FS_REISER4_BLOCK_ALLOC_H__ */ + @@ -1890,9 +2204,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/block_alloc.h linux-2.6.22/fs/reiser4/blo + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/blocknrset.c ---- linux-2.6.22.orig/fs/reiser4/blocknrset.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/blocknrset.c 2007-07-29 00:25:34.820681982 +0400 +Index: linux-2.6.16/fs/reiser4/blocknrset.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/blocknrset.c @@ -0,0 +1,368 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -1924,8 +2239,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + * extent; atom's wandered map is also stored as a blocknr set, blocknr pairs + * there represent a (real block) -> (wandered block) mapping. */ + -+/* Protection: blocknr sets belong to reiser4 atom, and -+ * their modifications are performed with the atom lock held */ ++typedef struct blocknr_pair blocknr_pair; + +/* The total size of a blocknr_set_entry. */ +#define BLOCKNR_SET_ENTRY_SIZE 128 @@ -1978,7 +2292,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + blocknr_set_entry *e; + + if ((e = (blocknr_set_entry *) kmalloc(sizeof(blocknr_set_entry), -+ reiser4_ctx_gfp_mask_get())) == NULL) ++ get_gfp_mask())) == NULL) + return NULL; + + bse_init(e); @@ -2005,14 +2319,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + +/* Get a pair of block numbers */ +/* Audited by: green(2002.06.11) */ -+static inline struct blocknr_pair *bse_get_pair(blocknr_set_entry * bse, -+ unsigned pno) ++static inline blocknr_pair *bse_get_pair(blocknr_set_entry * bse, unsigned pno) +{ + assert("green-1", BLOCKNR_SET_ENTRIES_NUMBER >= 2 * (pno + 1)); + -+ return (struct blocknr_pair *) (bse->entries + -+ BLOCKNR_SET_ENTRIES_NUMBER - -+ 2 * (pno + 1)); ++ return (blocknr_pair *) (bse->entries + BLOCKNR_SET_ENTRIES_NUMBER - ++ 2 * (pno + 1)); +} + +/* Add a pair of block numbers to a blocknr_set_entry */ @@ -2021,7 +2333,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc +bse_put_pair(blocknr_set_entry * bse, const reiser4_block_nr * a, + const reiser4_block_nr * b) +{ -+ struct blocknr_pair *pair; ++ blocknr_pair *pair; + + assert("jmacd-5100", bse_avail(bse) >= 2 && a != NULL && b != NULL); + @@ -2042,7 +2354,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + returned with the atom unlocked for the operation to be tried again. If + the operation succeeds, 0 is returned. If new_bsep is non-NULL and not + used during the call, it will be freed automatically. */ -+static int blocknr_set_add(txn_atom *atom, struct list_head *bset, ++static int blocknr_set_add(txn_atom *atom, blocknr_set *bset, + blocknr_set_entry **new_bsep, const reiser4_block_nr *a, + const reiser4_block_nr *b) +{ @@ -2052,8 +2364,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + assert("jmacd-5101", a != NULL); + + entries_needed = (b == NULL) ? 1 : 2; -+ if (list_empty(bset) || -+ bse_avail(list_entry(bset->next, blocknr_set_entry, link)) < entries_needed) { ++ if (list_empty(&bset->entries) || ++ bse_avail(list_entry(bset->entries.next, blocknr_set_entry, link)) < entries_needed) { + /* See if a bse was previously allocated. */ + if (*new_bsep == NULL) { + spin_unlock_atom(atom); @@ -2063,13 +2375,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + } + + /* Put it on the head of the list. */ -+ list_add(&((*new_bsep)->link), bset); ++ list_add(&((*new_bsep)->link), &bset->entries); + + *new_bsep = NULL; + } + + /* Add the single or pair. */ -+ bse = list_entry(bset->next, blocknr_set_entry, link); ++ bse = list_entry(bset->entries.next, blocknr_set_entry, link); + if (b == NULL) { + bse_put_single(bse, a); + } else { @@ -2093,7 +2405,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + properly freed. */ +int +blocknr_set_add_extent(txn_atom * atom, -+ struct list_head * bset, ++ blocknr_set * bset, + blocknr_set_entry ** new_bsep, + const reiser4_block_nr * start, + const reiser4_block_nr * len) @@ -2111,7 +2423,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + properly freed. */ +int +blocknr_set_add_pair(txn_atom * atom, -+ struct list_head * bset, ++ blocknr_set * bset, + blocknr_set_entry ** new_bsep, const reiser4_block_nr * a, + const reiser4_block_nr * b) +{ @@ -2120,18 +2432,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc +} + +/* Initialize a blocknr_set. */ -+void blocknr_set_init(struct list_head *bset) ++void blocknr_set_init(blocknr_set *bset) +{ -+ INIT_LIST_HEAD(bset); ++ INIT_LIST_HEAD(&bset->entries); +} + +/* Release the entries of a blocknr_set. */ -+void blocknr_set_destroy(struct list_head *bset) ++void blocknr_set_destroy(blocknr_set *bset) +{ + blocknr_set_entry *bse; + -+ while (!list_empty(bset)) { -+ bse = list_entry(bset->next, blocknr_set_entry, link); ++ while (!list_empty_careful(&bset->entries)) { ++ bse = list_entry(bset->entries.next, blocknr_set_entry, link); + list_del_init(&bse->link); + bse_free(bse); + } @@ -2147,23 +2459,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + actual processing of this set. Testing this kind of stuff right here is + also complicated by the fact that these sets are not sorted and going + through whole set on each element addition is going to be CPU-heavy task */ -+void blocknr_set_merge(struct list_head * from, struct list_head * into) ++void blocknr_set_merge(blocknr_set * from, blocknr_set * into) +{ + blocknr_set_entry *bse_into = NULL; + + /* If @from is empty, no work to perform. */ -+ if (list_empty(from)) ++ if (list_empty_careful(&from->entries)) { + return; ++ } ++ + /* If @into is not empty, try merging partial-entries. */ -+ if (!list_empty(into)) { ++ if (!list_empty_careful(&into->entries)) { + + /* Neither set is empty, pop the front to members and try to combine them. */ + blocknr_set_entry *bse_from; + unsigned into_avail; + -+ bse_into = list_entry(into->next, blocknr_set_entry, link); ++ bse_into = list_entry(into->entries.next, blocknr_set_entry, link); + list_del_init(&bse_into->link); -+ bse_from = list_entry(from->next, blocknr_set_entry, link); ++ bse_from = list_entry(from->entries.next, blocknr_set_entry, link); + list_del_init(&bse_from->link); + + /* Combine singles. */ @@ -2178,8 +2492,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + /* Combine pairs. */ + for (; into_avail > 1 && bse_from->nr_pairs != 0; + into_avail -= 2) { -+ struct blocknr_pair *pair = -+ bse_get_pair(bse_from, --bse_from->nr_pairs); ++ blocknr_pair *pair = ++ bse_get_pair(bse_from, --bse_from->nr_pairs); + bse_put_pair(bse_into, &pair->a, &pair->b); + } + @@ -2191,21 +2505,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + it could have one slot avail and bse_from has one + pair left). Push it back onto the list. bse_from + becomes bse_into, which will be the new partial. */ -+ list_add(&bse_into->link, into); ++ list_add(&bse_into->link, &into->entries); + bse_into = bse_from; + } + } + + /* Splice lists together. */ -+ list_splice_init(from, into->prev); ++ list_splice_init(&from->entries, into->entries.prev); + + /* Add the partial entry back to the head of the list. */ -+ if (bse_into != NULL) -+ list_add(&bse_into->link, into); ++ if (bse_into != NULL) { ++ list_add(&bse_into->link, &into->entries); ++ } +} + +/* Iterate over all blocknr set elements. */ -+int blocknr_set_iterator(txn_atom *atom, struct list_head *bset, ++int blocknr_set_iterator(txn_atom *atom, blocknr_set *bset, + blocknr_set_actor_f actor, void *data, int delete) +{ + @@ -2216,8 +2531,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + assert("zam-431", bset != 0); + assert("zam-432", actor != NULL); + -+ entry = list_entry(bset->next, blocknr_set_entry, link); -+ while (bset != &entry->link) { ++ entry = list_entry(bset->entries.next, blocknr_set_entry, link); ++ while (&bset->entries != &entry->link) { + blocknr_set_entry *tmp = list_entry(entry->link.next, blocknr_set_entry, link); + unsigned int i; + int ret; @@ -2262,10 +2577,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/blocknrset.c linux-2.6.22/fs/reiser4/bloc + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c ---- linux-2.6.22.orig/fs/reiser4/carry.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/carry.c 2007-07-29 00:25:34.820681982 +0400 -@@ -0,0 +1,1391 @@ +Index: linux-2.6.16/fs/reiser4/carry.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/carry.c +@@ -0,0 +1,1381 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* Functions to "carry" tree modification(s) upward. */ +/* Tree is modified one level at a time. As we modify a level we accumulate a @@ -2329,7 +2645,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + // COP_UPDATE --- update delimiting key in least + // common ancestor of two + -+ op = reiser4_post_carry( &lowest_level, operation, node, 0 ); ++ op = post_carry( &lowest_level, operation, node, 0 ); + if( IS_ERR( op ) || ( op == NULL ) ) { + handle error + } else { @@ -2348,7 +2664,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + + .... + -+ // note, that last argument to reiser4_post_carry() is non-null ++ // note, that last argument to post_carry() is non-null + // here, because @op is to be applied to the parent of @node, rather + // than to the @node itself as in the previous case. + @@ -2385,8 +2701,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + 2. whole balancing logic is implemented here, in particular, insertion + logic is coded in make_space(). + -+ 3. special cases like insertion (reiser4_add_tree_root()) or deletion -+ (reiser4_kill_tree_root()) of tree root and morphing of paste into insert ++ 3. special cases like insertion (add_tree_root()) or deletion ++ (kill_tree_root()) of tree root and morphing of paste into insert + (insert_paste()) have to be handled. + + 4. there is non-trivial interdependency between allocation of new nodes @@ -2436,6 +2752,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c +static void fatal_carry_error(carry_level * doing, int ecode); +static int add_new_root(carry_level * level, carry_node * node, znode * fake); + ++ +static void print_level(const char *prefix, carry_level * level); + +#if REISER4_DEBUG @@ -2457,11 +2774,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + For usage, see comment at the top of fs/reiser4/carry.c + +*/ -+int reiser4_carry(carry_level * doing /* set of carry operations to be -+ * performed */ , -+ carry_level * done /* set of nodes, already performed -+ * at the previous level. -+ * NULL in most cases */) ++int carry(carry_level * doing /* set of carry operations to be performed */ , ++ carry_level * done /* set of nodes, already performed at the ++ * previous level. NULL in most cases */ ) +{ + int result = 0; + /* queue of new requests */ @@ -2535,7 +2850,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + init_carry_level(todo, doing->pool); + + /* give other threads chance to run */ -+ reiser4_preempt_point(); ++ preempt_point(); + } + done_carry_level(done); + @@ -2626,7 +2941,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + for_all_nodes(doing, scan, tmp_scan) { + znode *node; + -+ node = reiser4_carry_real(scan); ++ node = carry_real(scan); + assert("nikita-2547", node != NULL); + if (node_is_empty(node)) { + result = @@ -2654,14 +2969,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + caller to guarantee proper ordering of node queue. + +*/ -+carry_op * reiser4_post_carry(carry_level * level /* queue where new operation -+ * is to be posted at */ , -+ carry_opcode op /* opcode of operation */ , -+ znode * node /* node on which this operation -+ * will operate */ , -+ int apply_to_parent_p /* whether operation will -+ * operate directly on @node -+ * or on it parent. */) ++carry_op *post_carry(carry_level * level /* queue where new operation is to ++ * be posted at */ , ++ carry_opcode op /* opcode of operation */ , ++ znode * node /* node on which this operation ++ * will operate */ , ++ int apply_to_parent_p /* whether operation will operate ++ * directly on @node or on it ++ * parent. */ ) +{ + carry_op *result; + carry_node *child; @@ -2672,7 +2987,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + result = add_op(level, POOLO_LAST, NULL); + if (IS_ERR(result)) + return result; -+ child = reiser4_add_carry(level, POOLO_LAST, NULL); ++ child = add_carry(level, POOLO_LAST, NULL); + if (IS_ERR(child)) { + reiser4_pool_free(&level->pool->op_pool, &result->header); + return (carry_op *) child; @@ -2707,7 +3022,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + carry_pool *pool; + + assert("", size >= sizeof(carry_pool) + 3 * sizeof(carry_level)); -+ pool = kmalloc(size, reiser4_ctx_gfp_mask_get()); ++ pool = kmalloc(size, get_gfp_mask()); + if (pool == NULL) + return ERR_PTR(RETERR(-ENOMEM)); + @@ -2735,17 +3050,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + automatically. To control ordering use @order and @reference parameters. + +*/ -+carry_node *reiser4_add_carry_skip(carry_level * level /* &carry_level to add -+ * node to */ , -+ pool_ordering order /* where to insert: -+ * at the beginning of -+ * @level, -+ * before @reference, -+ * after @reference, -+ * at the end of @level -+ */ , -+ carry_node * reference/* reference node for -+ * insertion */) ++carry_node *add_carry_skip(carry_level * level /* &carry_level to add node ++ * to */ , ++ pool_ordering order /* where to insert: at the ++ * beginning of @level, ++ * before @reference, after ++ * @reference, at the end ++ * of @level */ , ++ carry_node * reference /* reference node for ++ * insertion */ ) +{ + ON_DEBUG(carry_node * orig_ref = reference); + @@ -2768,12 +3081,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + } + assert("nikita-2209", + ergo(orig_ref != NULL, -+ reiser4_carry_real(reference) == -+ reiser4_carry_real(orig_ref))); -+ return reiser4_add_carry(level, order, reference); ++ carry_real(reference) == carry_real(orig_ref))); ++ return add_carry(level, order, reference); +} + -+carry_node *reiser4_add_carry(carry_level * level /* &carry_level to add node ++carry_node *add_carry(carry_level * level /* &carry_level to add node + * to */ , + pool_ordering order /* where to insert: at the + * beginning of @level, before @@ -2785,9 +3097,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + carry_node *result; + + result = -+ (carry_node *) reiser4_add_obj(&level->pool->node_pool, -+ &level->nodes, -+ order, &reference->header); ++ (carry_node *) add_obj(&level->pool->node_pool, &level->nodes, ++ order, &reference->header); + if (!IS_ERR(result) && (result != NULL)) + ++level->nodes_num; + return result; @@ -2810,8 +3121,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + carry_op *result; + + result = -+ (carry_op *) reiser4_add_obj(&level->pool->op_pool, &level->ops, -+ order, &reference->header); ++ (carry_op *) add_obj(&level->pool->op_pool, &level->ops, order, ++ &reference->header); + if (!IS_ERR(result) && (result != NULL)) + ++level->ops_num; + return result; @@ -2836,16 +3147,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + assert("nikita-1614", node != NULL); + assert("nikita-1615", kin != NULL); + assert("nikita-1616", LOCK_CNT_GTZ(rw_locked_tree)); -+ assert("nikita-1619", ergo(reiser4_carry_real(node) != NULL, -+ ZF_ISSET(reiser4_carry_real(node), -+ JNODE_ORPHAN))); ++ assert("nikita-1619", ergo(carry_real(node) != NULL, ++ ZF_ISSET(carry_real(node), JNODE_ORPHAN))); ++ + for (scan = node;; + scan = list_entry(scan->header.level_linkage.prev, carry_node, + header.level_linkage)) { + assert("nikita-1617", &kin->nodes != &scan->header.level_linkage); + if ((scan->node != node->node) && + !ZF_ISSET(scan->node, JNODE_ORPHAN)) { -+ assert("nikita-1618", reiser4_carry_real(scan) != NULL); ++ assert("nikita-1618", carry_real(scan) != NULL); + break; + } + } @@ -2879,13 +3190,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + assert("nikita-2203", node != NULL); + + for_all_nodes(level, scan, tmp_scan) { -+ if (reiser4_carry_real(scan) == node) ++ if (carry_real(scan) == node) + return scan; + } + return NULL; +} + -+znode *reiser4_carry_real(const carry_node * node) ++znode *carry_real(const carry_node * node) +{ + assert("nikita-3061", node != NULL); + @@ -2924,12 +3235,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + reference = insert_carry_node(doing, todo, node); + assert("nikita-2997", reference != NULL); + -+ return reiser4_add_carry(todo, POOLO_BEFORE, reference); ++ return add_carry(todo, POOLO_BEFORE, reference); +} + -+/* like reiser4_post_carry(), but designed to be called from node plugin methods. -+ This function is different from reiser4_post_carry() in that it finds proper -+ place to insert node in the queue. */ ++/* like post_carry(), but designed to be called from node plugin methods. ++ This function is different from post_carry() in that it finds proper place ++ to insert node in the queue. */ +carry_op *node_post_carry(carry_plugin_info * info /* carry parameters + * passed down to node + * plugin */ , @@ -2947,8 +3258,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + assert("nikita-2208", info->todo != NULL); + + if (info->doing == NULL) -+ return reiser4_post_carry(info->todo, op, node, -+ apply_to_parent_p); ++ return post_carry(info->todo, op, node, apply_to_parent_p); + + result = add_op(info->todo, POOLO_LAST, NULL); + if (IS_ERR(result)) @@ -3066,8 +3376,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + spot = NULL; + /* update delimiting keys */ + for_all_nodes(level, node, tmp_node) { -+ if (reiser4_carry_real(node) != spot) { -+ spot = reiser4_carry_real(node); ++ if (carry_real(node) != spot) { ++ spot = carry_real(node); + sync_dkeys(spot); + } + } @@ -3080,10 +3390,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + for_all_nodes_back(level, node, tmp_node) { + /* all allocated nodes should be already linked to their + parents at this moment. */ -+ assert("nikita-1631", -+ ergo(!failure, !ZF_ISSET(reiser4_carry_real(node), -+ JNODE_ORPHAN))); -+ ON_DEBUG(check_dkeys(reiser4_carry_real(node))); ++ assert("nikita-1631", ergo(!failure, !ZF_ISSET(carry_real(node), ++ JNODE_ORPHAN))); ++ ON_DEBUG(check_dkeys(carry_real(node))); + unlock_carry_node(level, node, failure); + } + level->new_root = NULL; @@ -3124,7 +3433,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c +int lock_carry_node_tail(carry_node * node /* node to complete locking of */ ) +{ + assert("nikita-1052", node != NULL); -+ assert("nikita-1187", reiser4_carry_real(node) != NULL); ++ assert("nikita-1187", carry_real(node) != NULL); + assert("nikita-1188", !node->unlock); + + node->unlock = 1; @@ -3136,7 +3445,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + + Corresponding zrelse() is in unlock_carry_node() + */ -+ return zload(reiser4_carry_real(node)); ++ return zload(carry_real(node)); +} + +/* lock carry node @@ -3272,7 +3581,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + + assert("nikita-884", node != NULL); + -+ real_node = reiser4_carry_real(node); ++ real_node = carry_real(node); + /* pair to zload() in lock_carry_node_tail() */ + zrelse(real_node); + if (node->unlock && (real_node != NULL)) { @@ -3355,7 +3664,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + + This function itself only manages changes in carry structures and delegates + all hard work (allocation of znode for new root, changes of parent and -+ sibling pointers to the reiser4_add_tree_root(). ++ sibling pointers to the add_tree_root(). + + Locking: old tree root is locked by carry at this point. Fake znode is also + locked. @@ -3381,7 +3690,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + tree root right now. + */ + if (level->new_root == NULL) -+ level->new_root = reiser4_add_tree_root(node->node, fake); ++ level->new_root = add_tree_root(node->node, fake); + if (!IS_ERR(level->new_root)) { + assert("nikita-1210", znode_is_root(level->new_root)); + node->deallocate = 1; @@ -3403,7 +3712,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + Allocate new znode, add it into carry queue and post into @todo queue + request to add pointer to new node into its parent. + -+ This is carry related routing that calls reiser4_new_node() to allocate new ++ This is carry related routing that calls new_node() to allocate new + node. +*/ +carry_node *add_new_znode(znode * brother /* existing left neighbor of new @@ -3436,15 +3745,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + + */ + -+ fresh = reiser4_add_carry_skip(doing, -+ ref ? POOLO_AFTER : POOLO_LAST, ref); ++ fresh = add_carry_skip(doing, ref ? POOLO_AFTER : POOLO_LAST, ref); + if (IS_ERR(fresh)) + return fresh; + + fresh->deallocate = 1; + fresh->free = 1; + -+ new_znode = reiser4_new_node(brother, znode_get_level(brother)); ++ new_znode = new_node(brother, znode_get_level(brother)); + if (IS_ERR(new_znode)) + /* @fresh will be deallocated automatically by error + handling code in the caller. */ @@ -3456,15 +3764,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + ZF_SET(new_znode, JNODE_ORPHAN); + fresh->node = new_znode; + -+ while (ZF_ISSET(reiser4_carry_real(ref), JNODE_ORPHAN)) { ++ while (ZF_ISSET(carry_real(ref), JNODE_ORPHAN)) { + ref = carry_node_prev(ref); + assert("nikita-1606", !carry_node_end(doing, ref)); + } + + info.todo = todo; + info.doing = doing; -+ add_pointer = node_post_carry(&info, COP_INSERT, -+ reiser4_carry_real(ref), 1); ++ add_pointer = node_post_carry(&info, COP_INSERT, carry_real(ref), 1); + if (IS_ERR(add_pointer)) { + /* no need to deallocate @new_znode here: it will be + deallocated during carry error handling. */ @@ -3515,8 +3822,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + right = node->node; + left = carry_node_prev(node)->node; + } else { -+ right = reiser4_carry_real(node); -+ left = reiser4_carry_real(carry_node_prev(node)); ++ right = carry_real(node); ++ left = carry_real(carry_node_prev(node)); + } + if (right == NULL || left == NULL) + continue; @@ -3596,8 +3903,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + case COP_PASTE: + print_coord("\tcoord", + op->u.insert.d ? op->u.insert.d->coord : NULL, 0); -+ reiser4_print_key("\tkey", -+ op->u.insert.d ? op->u.insert.d->key : NULL); ++ print_key("\tkey", op->u.insert.d ? op->u.insert.d->key : NULL); + print_carry("\tchild", op->u.insert.child); + break; + case COP_DELETE: @@ -3657,9 +3963,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.c linux-2.6.22/fs/reiser4/carry.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h ---- linux-2.6.22.orig/fs/reiser4/carry.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/carry.h 2007-07-29 00:25:34.824683017 +0400 +Index: linux-2.6.16/fs/reiser4/carry.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/carry.h @@ -0,0 +1,442 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -3690,7 +3997,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h +*/ +typedef struct carry_node { + /* pool linkage */ -+ struct reiser4_pool_header header; ++ reiser4_pool_header header; + + /* base node from which real_node is calculated. See + fs/reiser4/carry.c:lock_carry_node(). */ @@ -3876,7 +4183,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h +*/ +typedef struct carry_op { + /* pool linkage */ -+ struct reiser4_pool_header header; ++ reiser4_pool_header header; + carry_opcode op; + /* node on which operation is to be performed: + @@ -3950,9 +4257,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h +/* &carry_op_pool - preallocated pool of carry operations, and nodes */ +typedef struct carry_pool { + carry_op op[CARRIES_POOL_SIZE]; -+ struct reiser4_pool op_pool; ++ reiser4_pool op_pool; + carry_node node[NODES_LOCKED_POOL_SIZE]; -+ struct reiser4_pool node_pool; ++ reiser4_pool node_pool; +} carry_pool; + +/* &carry_tree_level - carry process on given level @@ -3975,8 +4282,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h + int nodes_num; + /* new root created on this level, if any */ + znode *new_root; -+ /* This is set by caller (insert_by_key(), rreiser4_esize_item(), etc.) -+ when they want ->tracked to automagically wander to the node where ++ /* This is set by caller (insert_by_key(), resize_item(), etc.) when ++ they want ->tracked to automagically wander to the node where + insertion point moved after insert or paste. + */ + carry_track_type track_type; @@ -3992,12 +4299,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h + carry_level *todo; +}; + -+int reiser4_carry(carry_level * doing, carry_level * done); ++int carry(carry_level * doing, carry_level * done); + -+carry_node *reiser4_add_carry(carry_level * level, pool_ordering order, -+ carry_node * reference); -+carry_node *reiser4_add_carry_skip(carry_level * level, pool_ordering order, -+ carry_node * reference); ++carry_node *add_carry(carry_level * level, pool_ordering order, ++ carry_node * reference); ++carry_node *add_carry_skip(carry_level * level, pool_ordering order, ++ carry_node * reference); + +extern carry_node *insert_carry_node(carry_level * doing, + carry_level * todo, const znode * node); @@ -4007,8 +4314,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h + +extern void init_carry_level(carry_level * level, carry_pool * pool); + -+extern carry_op *reiser4_post_carry(carry_level * level, carry_opcode op, -+ znode * node, int apply_to_parent); ++extern carry_op *post_carry(carry_level * level, carry_opcode op, znode * node, ++ int apply_to_parent); +extern carry_op *node_post_carry(carry_plugin_info * info, carry_opcode op, + znode * node, int apply_to_parent_p); + @@ -4017,7 +4324,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h + +carry_node *find_carry_node(carry_level * level, const znode * node); + -+extern znode *reiser4_carry_real(const carry_node * node); ++extern znode *carry_real(const carry_node * node); + +/* helper macros to iterate over carry queues */ + @@ -4103,10 +4410,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry.h linux-2.6.22/fs/reiser4/carry.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry_ops.c ---- linux-2.6.22.orig/fs/reiser4/carry_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/carry_ops.c 2007-07-29 00:25:34.828684053 +0400 -@@ -0,0 +1,2131 @@ +Index: linux-2.6.16/fs/reiser4/carry_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/carry_ops.c +@@ -0,0 +1,2103 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* implementation of carry operations */ @@ -4160,11 +4468,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + tree = current_tree; + read_lock_tree(tree); + /* first, check whether left neighbor is already in a @doing queue */ -+ if (reiser4_carry_real(node)->left != NULL) { ++ if (carry_real(node)->left != NULL) { + /* NOTE: there is locking subtlety here. Look into + * find_right_neighbor() for more info */ -+ if (find_carry_node(doing, -+ reiser4_carry_real(node)->left) != NULL) { ++ if (find_carry_node(doing, carry_real(node)->left) != NULL) { + read_unlock_tree(tree); + left = node; + do { @@ -4172,14 +4479,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + carry_node, header.level_linkage); + assert("nikita-3408", !carry_node_end(doing, + left)); -+ } while (reiser4_carry_real(left) == -+ reiser4_carry_real(node)); ++ } while (carry_real(left) == carry_real(node)); + return left; + } + } + read_unlock_tree(tree); + -+ left = reiser4_add_carry_skip(doing, POOLO_BEFORE, node); ++ left = add_carry_skip(doing, POOLO_BEFORE, node); + if (IS_ERR(left)) + return left; + @@ -4191,8 +4497,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + flags |= GN_NO_ALLOC; + + /* then, feeling lucky, peek left neighbor in the cache. */ -+ result = reiser4_get_left_neighbor(&left->lock_handle, -+ reiser4_carry_real(node), ++ result = reiser4_get_left_neighbor(&left->lock_handle, carry_real(node), + ZNODE_WRITE_LOCK, flags); + if (result == 0) { + /* ok, node found and locked. */ @@ -4245,7 +4550,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + tree = current_tree; + read_lock_tree(tree); + /* first, check whether right neighbor is already in a @doing queue */ -+ if (reiser4_carry_real(node)->right != NULL) { ++ if (carry_real(node)->right != NULL) { + /* + * Tree lock is taken here anyway, because, even if _outcome_ + * of (find_carry_node() != NULL) doesn't depends on @@ -4266,8 +4571,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + * couldn't change, because node cannot be inserted between + * locked neighbors. + */ -+ if (find_carry_node(doing, -+ reiser4_carry_real(node)->right) != NULL) { ++ if (find_carry_node(doing, carry_real(node)->right) != NULL) { + read_unlock_tree(tree); + /* + * What we are doing here (this is also applicable to @@ -4303,8 +4607,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + carry_node, header.level_linkage); + assert("nikita-3408", !carry_node_end(doing, + right)); -+ } while (reiser4_carry_real(right) == -+ reiser4_carry_real(node)); ++ } while (carry_real(right) == carry_real(node)); + return right; + } + } @@ -4316,12 +4619,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + + /* then, try to lock right neighbor */ + init_lh(&lh); -+ result = reiser4_get_right_neighbor(&lh, -+ reiser4_carry_real(node), ++ result = reiser4_get_right_neighbor(&lh, carry_real(node), + ZNODE_WRITE_LOCK, flags); + if (result == 0) { + /* ok, node found and locked. */ -+ right = reiser4_add_carry_skip(doing, POOLO_AFTER, node); ++ right = add_carry_skip(doing, POOLO_AFTER, node); + if (!IS_ERR(right)) { + right->node = lh.node; + move_lh(&right->lock_handle, &lh); @@ -4416,11 +4718,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + assert("nikita-941", op != NULL); + assert("nikita-942", op->op == COP_INSERT); + -+ node = reiser4_carry_real(op->node); ++ node = carry_real(op->node); + assert("nikita-943", node != NULL); + assert("nikita-944", node_plugin_by_node(node) != NULL); + -+ child = reiser4_carry_real(op->u.insert.child); ++ child = carry_real(op->u.insert.child); + result = + find_new_child_ptr(node, child, op->u.insert.brother, + op->u.insert.d->coord); @@ -4463,13 +4765,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + insertion_node = op->u.insert.d->coord->node; + /* if insertion point was actually moved into new node, + update carry node pointer in operation. */ -+ if (insertion_node != reiser4_carry_real(op->node)) { ++ if (insertion_node != carry_real(op->node)) { + op->node = target; -+ assert("nikita-2540", -+ reiser4_carry_real(target) == insertion_node); ++ assert("nikita-2540", carry_real(target) == insertion_node); + } + assert("nikita-2541", -+ reiser4_carry_real(op->node) == op->u.insert.d->coord->node); ++ carry_real(op->node) == op->u.insert.d->coord->node); + return insertion_node; +} + @@ -4532,7 +4833,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + op->op == COP_INSERT || + op->op == COP_PASTE || op->op == COP_EXTENT); + assert("nikita-1607", -+ reiser4_carry_real(op->node) == op->u.insert.d->coord->node); ++ carry_real(op->node) == op->u.insert.d->coord->node); + + flags = op->u.insert.flags; + @@ -4585,8 +4886,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + /* shift everything possible on the left of and + including insertion coord into the left neighbor */ + result = carry_shift_data(LEFT_SIDE, coord, -+ reiser4_carry_real(left), -+ doing, todo, ++ carry_real(left), doing, todo, + flags & COPI_GO_LEFT); + + /* reget node from coord: shift_left() might move @@ -4618,7 +4918,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + excluding insertion coord into the right neighbor + */ + result = carry_shift_data(RIGHT_SIDE, coord, -+ reiser4_carry_real(right), ++ carry_real(right), + doing, todo, + flags & COPI_GO_RIGHT); + /* reget node from coord: shift_right() might move @@ -4663,7 +4963,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + + /* Try to shift into new node. */ + result = lock_carry_node(doing, fresh); -+ zput(reiser4_carry_real(fresh)); ++ zput(carry_real(fresh)); + if (result != 0) { + warning("nikita-947", + "Cannot lock new node: %i", result); @@ -4686,26 +4986,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + (blk_alloc > 0) || + coord_is_after_rightmost(op->u.insert.d->coord); + -+ if (gointo && -+ op->op == COP_PASTE && -+ coord_is_existing_item(op->u.insert.d->coord) && -+ is_solid_item((item_plugin_by_coord(op->u.insert.d->coord)))) { -+ /* paste into solid (atomic) item, which can contain -+ only one unit, so we need to shift it right, where -+ insertion point supposed to be */ -+ -+ assert("edward-1444", op->u.insert.d->data->iplug == -+ item_plugin_by_id(STATIC_STAT_DATA_ID)); -+ assert("edward-1445", -+ op->u.insert.d->data->length > -+ node_plugin_by_node(coord->node)->free_space -+ (coord->node)); -+ -+ op->u.insert.d->coord->between = BEFORE_UNIT; -+ } -+ -+ result = carry_shift_data(RIGHT_SIDE, coord, -+ reiser4_carry_real(fresh), ++ result = carry_shift_data(RIGHT_SIDE, coord, carry_real(fresh), + doing, todo, gointo); + /* if insertion point was actually moved into new node, + update carry node pointer in operation. */ @@ -4737,7 +5018,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + result = -E_NODE_FULL; + } + assert("nikita-1622", ergo(result == 0, -+ reiser4_carry_real(op->node) == coord->node)); ++ carry_real(op->node) == coord->node)); + assert("nikita-2616", coord == op->u.insert.d->coord); + if (result == 0) + result = make_space_tail(op, doing, orig_node); @@ -4824,7 +5105,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + /* NOTE-NIKITA Lookup bias is fixed to FIND_EXACT. Complain + if you need something else. */ + op->u.insert.d->coord = coord; -+ node = reiser4_carry_real(op->node); ++ node = carry_real(op->node); + intra_node = node_plugin_by_node(node)->lookup + (node, op->u.insert.d->key, FIND_EXACT, + op->u.insert.d->coord); @@ -4844,9 +5125,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + op->u.insert.d = cdata; + op->u.insert.d->coord = coord; + op->u.insert.d->data = data; -+ op->u.insert.d->coord->node = reiser4_carry_real(op->node); ++ op->u.insert.d->coord->node = carry_real(op->node); + result = find_new_child_coord(op); -+ child = reiser4_carry_real(op->u.insert.child); ++ child = carry_real(op->u.insert.child); + if (result != NS_NOT_FOUND) { + warning("nikita-993", + "Cannot find a place for child pointer: %i", @@ -4877,8 +5158,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + moved into another node. Handle this by creating new carry + node for insertion point if necessary. + */ -+ if (reiser4_carry_real(op->node) != -+ op->u.insert.d->coord->node) { ++ if (carry_real(op->node) != op->u.insert.d->coord->node) { + pool_ordering direction; + znode *z1; + znode *z2; @@ -4890,7 +5170,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + * moved. Do this by comparing delimiting keys. + */ + z1 = op->u.insert.d->coord->node; -+ z2 = reiser4_carry_real(op->node); ++ z2 = carry_real(op->node); + if (keyle(leftmost_key_in_node(z1, &k1), + leftmost_key_in_node(z2, &k2))) + /* insertion point moved to the left */ @@ -4899,8 +5179,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + /* insertion point moved to the right */ + direction = POOLO_AFTER; + -+ op->node = reiser4_add_carry_skip(doing, -+ direction, op->node); ++ op->node = add_carry_skip(doing, direction, op->node); + if (IS_ERR(op->node)) + return PTR_ERR(op->node); + op->node->node = op->u.insert.d->coord->node; @@ -4922,7 +5201,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + op->u.insert.d->data->arg = op->u.insert.brother; + } else { + assert("vs-243", op->u.insert.d->coord != NULL); -+ op->u.insert.d->coord->node = reiser4_carry_real(op->node); ++ op->u.insert.d->coord->node = carry_real(op->node); + } + + /* find free space. */ @@ -5080,10 +5359,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + orig = flow_insert_point(op)->node; + /* try to shift content of node @orig from its head upto insert point + including insertion point into the left neighbor */ -+ carry_shift_data(LEFT_SIDE, flow_insert_point(op), -+ reiser4_carry_real(left), doing, todo, -+ 1 /* including insert point */); -+ if (reiser4_carry_real(left) != flow_insert_point(op)->node) { ++ carry_shift_data(LEFT_SIDE, flow_insert_point(op), carry_real(left), doing, todo, 1 /* including insert ++ * point */ ); ++ if (carry_real(left) != flow_insert_point(op)->node) { + /* insertion point did not move */ + return 1; + } @@ -5122,9 +5400,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + if (right) { + /* shift everything possible on the right of but excluding + insertion coord into the right neighbor */ -+ carry_shift_data(RIGHT_SIDE, flow_insert_point(op), -+ reiser4_carry_real(right), doing, todo, -+ 0 /* not including insert point */); ++ carry_shift_data(RIGHT_SIDE, flow_insert_point(op), carry_real(right), doing, todo, 0 /* not ++ * including ++ * insert ++ * point */ ); + } else { + /* right neighbor either does not exist or is unformatted + node */ @@ -5161,15 +5440,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + return PTR_ERR(new); + } + result = lock_carry_node(doing, new); -+ zput(reiser4_carry_real(new)); ++ zput(carry_real(new)); + if (unlikely(result)) { + return result; + } + op->u.insert_flow.new_nodes++; + if (!coord_is_after_rightmost(flow_insert_point(op))) { -+ carry_shift_data(RIGHT_SIDE, flow_insert_point(op), -+ reiser4_carry_real(new), doing, todo, -+ 0 /* not including insert point */); ++ carry_shift_data(RIGHT_SIDE, flow_insert_point(op), carry_real(new), doing, todo, 0 /* not ++ * including ++ * insert ++ * point */ ); ++ + assert("vs-901", + coord_is_after_rightmost(flow_insert_point(op))); + @@ -5185,7 +5466,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + return PTR_ERR(new); + } + result = lock_carry_node(doing, new); -+ zput(reiser4_carry_real(new)); ++ zput(carry_real(new)); + if (unlikely(result)) { + return result; + } @@ -5193,8 +5474,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + } + + /* move insertion point to new node */ -+ coord_init_before_first_item(flow_insert_point(op), -+ reiser4_carry_real(new)); ++ coord_init_before_first_item(flow_insert_point(op), carry_real(new)); + op->node = new; + return 0; +} @@ -5363,9 +5643,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + coord_init_zero(&coord); + coord_init_zero(&coord2); + -+ parent = reiser4_carry_real(op->node); ++ parent = carry_real(op->node); + child = op->u.delete.child ? -+ reiser4_carry_real(op->u.delete.child) : op->node->node; ++ carry_real(op->u.delete.child) : op->node->node; + tree = znode_get_tree(child); + read_lock_tree(tree); + @@ -5395,8 +5675,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + node_num_items(parent) == 1) { + /* Delimiting key manipulations. */ + write_lock_dk(tree); -+ znode_set_ld_key(child, znode_set_ld_key(parent, reiser4_min_key())); -+ znode_set_rd_key(child, znode_set_rd_key(parent, reiser4_max_key())); ++ znode_set_ld_key(child, znode_set_ld_key(parent, min_key())); ++ znode_set_rd_key(child, znode_set_rd_key(parent, max_key())); + ZF_SET(child, JNODE_DKSET); + write_unlock_dk(tree); + @@ -5445,7 +5725,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + /* don't kill roots at and lower than twig level */ + znode_get_level(parent) > REISER4_MIN_TREE_HEIGHT && + node_num_items(parent) == 1) { -+ result = reiser4_kill_tree_root(coord.node); ++ result = kill_tree_root(coord.node); + } + + return result < 0 ? : 0; @@ -5471,7 +5751,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + info.doing = doing; + info.todo = todo; + -+ nplug = node_plugin_by_node(reiser4_carry_real(op->node)); ++ nplug = node_plugin_by_node(carry_real(op->node)); + if (op->u.cut_or_kill.is_cut) + result = nplug->cut(op->u.cut_or_kill.u.cut, &info); + else @@ -5897,7 +6177,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + if (lchild != NULL) { + assert("nikita-1001", lchild->parent); + assert("nikita-1003", !lchild->left); -+ left = reiser4_carry_real(lchild); ++ left = carry_real(lchild); + } else + left = NULL; + @@ -6037,7 +6317,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + if (carry_node_end(level, neighbor)) + /* list head is reached */ + return NULL; -+ if (reiser4_carry_real(neighbor) != reiser4_carry_real(node)) ++ if (carry_real(neighbor) != carry_real(node)) + return neighbor; + } +} @@ -6238,9 +6518,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.c linux-2.6.22/fs/reiser4/carry + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.h linux-2.6.22/fs/reiser4/carry_ops.h ---- linux-2.6.22.orig/fs/reiser4/carry_ops.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/carry_ops.h 2007-07-29 00:25:34.828684053 +0400 +Index: linux-2.6.16/fs/reiser4/carry_ops.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/carry_ops.h @@ -0,0 +1,42 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -6284,10 +6565,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/carry_ops.h linux-2.6.22/fs/reiser4/carry + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context.c ---- linux-2.6.22.orig/fs/reiser4/context.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/context.c 2007-07-29 00:25:34.832685088 +0400 -@@ -0,0 +1,288 @@ +Index: linux-2.6.16/fs/reiser4/context.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/context.c +@@ -0,0 +1,278 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Manipulation of reiser4_context */ @@ -6309,9 +6591,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + * + * In such situations "child" context acts like dummy: all activity is + * actually performed in the top level context, and get_current_context() -+ * always returns top level context. -+ * Of course, reiser4_init_context()/reiser4_done_context() have to be properly -+ * nested any way. ++ * always returns top level context. Of course, init_context()/done_context() ++ * have to be properly nested any way. + * + * Note that there is an important difference between reiser4 uses + * ->fs_context and the way other file systems use it. Other file systems @@ -6331,8 +6612,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context +#include /* balance_dirty_pages() */ +#include + -+static void _reiser4_init_context(reiser4_context * context, -+ struct super_block *super) ++ ++static void _init_context(reiser4_context * context, struct super_block *super) +{ + memset(context, 0, sizeof(*context)); + @@ -6345,7 +6626,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + + init_lock_stack(&context->stack); + -+ reiser4_txn_begin(context); ++ txn_begin(context); + + /* initialize head of tap list */ + INIT_LIST_HEAD(&context->taps); @@ -6360,7 +6641,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + This function should be called at the beginning of reiser4 part of + syscall. +*/ -+reiser4_context * reiser4_init_context(struct super_block * super) ++reiser4_context *init_context(struct super_block *super /* super block we are going to ++ * work with */ ) +{ + reiser4_context *context; + @@ -6379,7 +6661,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + if (context == NULL) + return ERR_PTR(RETERR(-ENOMEM)); + -+ _reiser4_init_context(context, super); ++ _init_context(context, super); + return context; +} + @@ -6392,7 +6674,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + assert("nikita-3358", super->s_op == NULL || is_reiser4_super(super)); + assert("vs-12", !is_in_reiser4_context()); + -+ _reiser4_init_context(context, super); ++ _init_context(context, super); + context->on_stack = 1; + return; +} @@ -6455,7 +6737,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + thread released all locks and closed transcrash etc. + +*/ -+static void reiser4_done_context(reiser4_context * context /* context being released */ ) ++static void done_context(reiser4_context * context /* context being released */ ) +{ + assert("nikita-860", context != NULL); + assert("nikita-859", context->magic == context_magic); @@ -6467,10 +6749,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + if (context->nr_children == 0) { + assert("jmacd-673", context->trans == NULL); + assert("jmacd-1002", lock_stack_isclean(&context->stack)); -+ assert("nikita-1936", reiser4_no_counters_are_held()); -+ assert("nikita-2626", list_empty_careful(reiser4_taps_list())); ++ assert("nikita-1936", no_counters_are_held()); ++ assert("nikita-2626", list_empty_careful(taps_list())); + assert("zam-1004", ergo(get_super_private(context->super), -+ get_super_private(context->super)->delete_mutex_owner != ++ get_super_private(context->super)->delete_sema_owner != + current)); + + /* release all grabbed but as yet unused blocks */ @@ -6512,11 +6794,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + */ +void reiser4_exit_context(reiser4_context * context) +{ -+ assert("nikita-3021", reiser4_schedulable()); ++ assert("nikita-3021", schedulable()); + + if (context->nr_children == 0) { + if (!context->nobalance) { -+ reiser4_txn_restart(context); ++ txn_restart(context); + balance_dirty_pages_at(context); + } + @@ -6538,12 +6820,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + spin_unlock_atom(atom); + } + } -+ reiser4_txn_end(context); ++ txn_end(context); + } -+ reiser4_done_context(context); ++ done_context(context); +} + -+void reiser4_ctx_gfp_mask_set(void) ++void set_gfp_mask(void) +{ + reiser4_context *ctx; + @@ -6556,16 +6838,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + ctx->gfp_mask = GFP_NOFS; +} + -+void reiser4_ctx_gfp_mask_force (gfp_t mask) -+{ -+ reiser4_context *ctx; -+ ctx = get_current_context(); -+ -+ assert("edward-1454", ctx != NULL); -+ -+ ctx->gfp_mask = mask; -+} -+ +/* + * Local variables: + * c-indentation-style: "K&R" @@ -6576,9 +6848,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.c linux-2.6.22/fs/reiser4/context + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context.h ---- linux-2.6.22.orig/fs/reiser4/context.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/context.h 2007-07-29 00:25:34.832685088 +0400 +Index: linux-2.6.16/fs/reiser4/context.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/context.h @@ -0,0 +1,228 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -6599,6 +6872,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context +#include +#include /* for struct task_struct */ + ++ +/* reiser4 per-thread context */ +struct reiser4_context { + /* magic constant. For identification of reiser4 contexts. */ @@ -6641,7 +6915,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context + * ->i_mutex */ + unsigned int nobalance:1; + -+ /* this bit is used on reiser4_done_context to decide whether context is ++ /* this bit is used on done_context to decide whether context is + kmalloc-ed and has to be kfree-ed */ + unsigned int on_stack:1; + @@ -6658,7 +6932,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context +#if REISER4_DEBUG + /* debugging information about reiser4 locks held by the current + * thread */ -+ reiser4_lock_cnt_info locks; ++ lock_counters_info locks; + struct task_struct *task; /* so we can easily find owner of the stack */ + + /* @@ -6688,7 +6962,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context +#define current_blocksize reiser4_get_current_sb()->s_blocksize +#define current_blocksize_bits reiser4_get_current_sb()->s_blocksize_bits + -+extern reiser4_context *reiser4_init_context(struct super_block *); ++extern reiser4_context *init_context(struct super_block *); +extern void init_stack_context(reiser4_context *, struct super_block *); +extern void reiser4_exit_context(reiser4_context *); + @@ -6727,7 +7001,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context + return get_context(current); +} + -+static inline gfp_t reiser4_ctx_gfp_mask_get(void) ++static inline gfp_t get_gfp_mask(void) +{ + reiser4_context *ctx; + @@ -6735,8 +7009,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context + return (ctx == NULL) ? GFP_KERNEL : ctx->gfp_mask; +} + -+void reiser4_ctx_gfp_mask_set(void); -+void reiser4_ctx_gfp_mask_force (gfp_t mask); ++void set_gfp_mask(void); + +/* + * true if current thread is in the write-out mode. Thread enters write-out @@ -6808,10 +7081,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/context.h linux-2.6.22/fs/reiser4/context + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c ---- linux-2.6.22.orig/fs/reiser4/coord.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/coord.c 2007-07-29 00:25:34.832685088 +0400 -@@ -0,0 +1,935 @@ +Index: linux-2.6.16/fs/reiser4/coord.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/coord.c +@@ -0,0 +1,937 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "forward.h" @@ -7382,6 +7656,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c +} + +#if REISER4_DEBUG ++#define DEBUG_COORD_FIELDS (sizeof(c1->plug_v) + sizeof(c1->body_v)) ++#else ++#define DEBUG_COORD_FIELDS (0) ++#endif ++ +int coords_equal(const coord_t * c1, const coord_t * c2) +{ + assert("nikita-2840", c1 != NULL); @@ -7392,7 +7671,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c + c1->item_pos == c2->item_pos && + c1->unit_pos == c2->unit_pos && c1->between == c2->between; +} -+#endif /* REISER4_DEBUG */ + +/* If coord_is_after_rightmost return NCOORD_ON_THE_RIGHT, if coord_is_after_leftmost + return NCOORD_ON_THE_LEFT, otherwise return NCOORD_INSIDE. */ @@ -7493,7 +7771,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c + return 0; +} + -+#if REISER4_DEBUG +/* Returns true if the coordinates are positioned at adjacent units, regardless of + before-after or item boundaries. */ +int coord_are_neighbors(coord_t * c1, coord_t * c2) @@ -7532,7 +7809,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c + return 0; + } +} -+#endif /* REISER4_DEBUG */ + +/* Assuming two coordinates are positioned in the same node, return COORD_CMP_ON_RIGHT, + COORD_CMP_ON_LEFT, or COORD_CMP_SAME depending on c1's position relative to c2. */ @@ -7747,9 +8023,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.c linux-2.6.22/fs/reiser4/coord.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/coord.h linux-2.6.22/fs/reiser4/coord.h ---- linux-2.6.22.orig/fs/reiser4/coord.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/coord.h 2007-07-29 00:25:34.832685088 +0400 +Index: linux-2.6.16/fs/reiser4/coord.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/coord.h @@ -0,0 +1,389 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -8140,10 +8417,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/coord.h linux-2.6.22/fs/reiser4/coord.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c ---- linux-2.6.22.orig/fs/reiser4/debug.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/debug.c 2007-07-29 00:25:34.836686123 +0400 -@@ -0,0 +1,308 @@ +Index: linux-2.6.16/fs/reiser4/debug.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/debug.c +@@ -0,0 +1,300 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -8155,17 +8433,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * + * panicking: reiser4_do_panic(), reiser4_print_prefix(). + * -+ * locking: -+ * reiser4_schedulable(), reiser4_lock_counters(), print_lock_counters(), -+ * reiser4_no_counters_are_held(), reiser4_commit_check_locks() ++ * locking: schedulable(), lock_counters(), print_lock_counters(), ++ * no_counters_are_held(), commit_check_locks() + * -+ * error code monitoring (see comment before RETERR macro): -+ * reiser4_return_err(), reiser4_report_err(). ++ * error code monitoring (see comment before RETERR macro): return_err(), ++ * report_err(). + * + * stack back-tracing: fill_backtrace() + * -+ * miscellaneous: reiser4_preempt_point(), call_on_each_assert(), -+ * reiser4_debugtrap(). ++ * miscellaneous: preempt_point(), call_on_each_assert(), debugtrap(). + * + */ + @@ -8186,13 +8462,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c +#include +#include + -+#if 0 +#if REISER4_DEBUG -+static void reiser4_report_err(void); ++static void report_err(void); +#else -+#define reiser4_report_err() noop ++#define report_err() noop +#endif -+#endif /* 0 */ + +/* + * global buffer where message given to reiser4_panic is formatted. @@ -8243,7 +8517,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + panic("%s", panic_buf); +} + -+#if 0 +void +reiser4_print_prefix(const char *level, int reperr, const char *mid, + const char *function, const char *file, int lineno) @@ -8261,15 +8534,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + printk("%sreiser4[%.16s(%i)]: %s (%s:%i)[%s]:\n", + level, comm, pid, function, file, lineno, mid); + if (reperr) -+ reiser4_report_err(); ++ report_err(); +} -+#endif /* 0 */ + +/* Preemption point: this should be called periodically during long running + operations (carry, allocate, and squeeze are best examples) */ -+int reiser4_preempt_point(void) ++int preempt_point(void) +{ -+ assert("nikita-3008", reiser4_schedulable()); ++ assert("nikita-3008", schedulable()); + cond_resched(); + return signal_pending(current); +} @@ -8280,7 +8552,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + constraints and various assertions. + +*/ -+reiser4_lock_cnt_info *reiser4_lock_counters(void) ++lock_counters_info *lock_counters(void) +{ + reiser4_context *ctx = get_current_context(); + assert("jmacd-1123", ctx != NULL); @@ -8291,7 +8563,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * print human readable information about locks held by the reiser4 context. + */ +static void print_lock_counters(const char *prefix, -+ const reiser4_lock_cnt_info * info) ++ const lock_counters_info * info) +{ + printk("%s: jnode: %i, tree: %i (r:%i,w:%i), dk: %i (r:%i,w:%i)\n" + "jload: %i, " @@ -8325,11 +8597,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c +} + +/* check that no spinlocks are held */ -+int reiser4_schedulable(void) ++int schedulable(void) +{ + if (get_current_context_check() != NULL) { + if (!LOCK_CNT_NIL(spin_locked)) { -+ print_lock_counters("in atomic", reiser4_lock_counters()); ++ print_lock_counters("in atomic", lock_counters()); + return 0; + } + } @@ -8339,11 +8611,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c +/* + * return true, iff no locks are held. + */ -+int reiser4_no_counters_are_held(void) ++int no_counters_are_held(void) +{ -+ reiser4_lock_cnt_info *counters; ++ lock_counters_info *counters; + -+ counters = reiser4_lock_counters(); ++ counters = lock_counters(); + return + (counters->spin_locked_zlock == 0) && + (counters->spin_locked_jnode == 0) && @@ -8368,9 +8640,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * return true, iff transaction commit can be done under locks held by the + * current thread. + */ -+int reiser4_commit_check_locks(void) ++int commit_check_locks(void) +{ -+ reiser4_lock_cnt_info *counters; ++ lock_counters_info *counters; + int inode_sem_r; + int inode_sem_w; + int result; @@ -8380,12 +8652,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * held during commit. + */ + -+ counters = reiser4_lock_counters(); ++ counters = lock_counters(); + inode_sem_r = counters->inode_sem_r; + inode_sem_w = counters->inode_sem_w; + + counters->inode_sem_r = counters->inode_sem_w = 0; -+ result = reiser4_no_counters_are_held(); ++ result = no_counters_are_held(); + counters->inode_sem_r = inode_sem_r; + counters->inode_sem_w = inode_sem_w; + return result; @@ -8395,7 +8667,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * fill "error site" in the current reiser4 context. See comment before RETERR + * macro for more details. + */ -+void reiser4_return_err(int code, const char *file, int line) ++void return_err(int code, const char *file, int line) +{ + if (code < 0 && is_in_reiser4_context()) { + reiser4_context *ctx = get_current_context(); @@ -8408,11 +8680,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + } +} + -+#if 0 +/* -+ * report error information recorder by reiser4_return_err(). ++ * report error information recorder by return_err(). + */ -+static void reiser4_report_err(void) ++static void report_err(void) +{ + reiser4_context *ctx = get_current_context_check(); + @@ -8423,7 +8694,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + } + } +} -+#endif /* 0 */ + +#endif /* REISER4_DEBUG */ + @@ -8433,7 +8703,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + * this functions just drops into kernel debugger. It is a convenient place to + * put breakpoint in. + */ -+void reiser4_debugtrap(void) ++void debugtrap(void) +{ + /* do nothing. Put break point here. */ +#if defined(CONFIG_KGDB) && !defined(CONFIG_REISER4_FS_MODULE) @@ -8452,9 +8722,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.c linux-2.6.22/fs/reiser4/debug.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h ---- linux-2.6.22.orig/fs/reiser4/debug.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/debug.h 2007-07-29 00:25:34.836686123 +0400 +Index: linux-2.6.16/fs/reiser4/debug.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/debug.h @@ -0,0 +1,350 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -8528,7 +8799,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + +#define ON_DEBUG( exp ) exp + -+extern int reiser4_schedulable(void); ++extern int schedulable(void); +extern void call_on_each_assert(void); + +#else @@ -8538,7 +8809,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h +#define assert( label, cond ) noop +#define check_me( label, expr ) ( ( void ) ( expr ) ) +#define ON_DEBUG( exp ) -+#define reiser4_schedulable() might_sleep() ++#define schedulable() might_sleep() + +/* REISER4_DEBUG */ +#endif @@ -8546,7 +8817,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h +#if REISER4_DEBUG +/* per-thread information about lock acquired by this thread. Used by lock + * ordering checking in spin_macros.h */ -+typedef struct reiser4_lock_cnt_info { ++typedef struct lock_counters_info { + int rw_locked_tree; + int read_locked_tree; + int write_locked_tree; @@ -8579,38 +8850,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + int d_refs; + int x_refs; + int t_refs; -+} reiser4_lock_cnt_info; ++} lock_counters_info; + -+extern struct reiser4_lock_cnt_info *reiser4_lock_counters(void); ++extern lock_counters_info *lock_counters(void); +#define IN_CONTEXT(a, b) (is_in_reiser4_context() ? (a) : (b)) + +/* increment lock-counter @counter, if present */ -+#define LOCK_CNT_INC(counter) \ -+ IN_CONTEXT(++(reiser4_lock_counters()->counter), 0) ++#define LOCK_CNT_INC(counter) IN_CONTEXT(++(lock_counters()->counter), 0) + +/* decrement lock-counter @counter, if present */ -+#define LOCK_CNT_DEC(counter) \ -+ IN_CONTEXT(--(reiser4_lock_counters()->counter), 0) ++#define LOCK_CNT_DEC(counter) IN_CONTEXT(--(lock_counters()->counter), 0) + +/* check that lock-counter is zero. This is for use in assertions */ -+#define LOCK_CNT_NIL(counter) \ -+ IN_CONTEXT(reiser4_lock_counters()->counter == 0, 1) ++#define LOCK_CNT_NIL(counter) IN_CONTEXT(lock_counters()->counter == 0, 1) + +/* check that lock-counter is greater than zero. This is for use in + * assertions */ -+#define LOCK_CNT_GTZ(counter) \ -+ IN_CONTEXT(reiser4_lock_counters()->counter > 0, 1) -+#define LOCK_CNT_LT(counter,n) \ -+ IN_CONTEXT(reiser4_lock_counters()->counter < n, 1) ++#define LOCK_CNT_GTZ(counter) IN_CONTEXT(lock_counters()->counter > 0, 1) ++#define LOCK_CNT_LT(counter,n) IN_CONTEXT(lock_counters()->counter < n, 1) + +#else /* REISER4_DEBUG */ + +/* no-op versions on the above */ + -+typedef struct reiser4_lock_cnt_info { -+} reiser4_lock_cnt_info; ++typedef struct lock_counters_info { ++} lock_counters_info; + -+#define reiser4_lock_counters() ((reiser4_lock_cnt_info *)NULL) ++#define lock_counters() ((lock_counters_info *)NULL) +#define LOCK_CNT_INC(counter) noop +#define LOCK_CNT_DEC(counter) noop +#define LOCK_CNT_NIL(counter) (1) @@ -8681,15 +8947,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h +extern void reiser4_do_panic(const char *format, ...) + __attribute__ ((noreturn, format(printf, 1, 2))); + -+extern int reiser4_preempt_point(void); ++extern void reiser4_print_prefix(const char *level, int reperr, const char *mid, ++ const char *function, ++ const char *file, int lineno); ++ ++extern int preempt_point(void); +extern void reiser4_print_stats(void); + ++ +#if REISER4_DEBUG -+extern int reiser4_no_counters_are_held(void); -+extern int reiser4_commit_check_locks(void); ++extern int no_counters_are_held(void); ++extern int commit_check_locks(void); +#else -+#define reiser4_no_counters_are_held() (1) -+#define reiser4_commit_check_locks() (1) ++#define no_counters_are_held() (1) ++#define commit_check_locks() (1) +#endif + +/* true if @i is power-of-two. Useful for rate-limited warnings, etc. */ @@ -8705,16 +8976,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + +#if KERNEL_DEBUGGER + -+extern void reiser4_debugtrap(void); ++extern void debugtrap(void); + +/* + * Check condition @cond and drop into kernel debugger (kgdb) if it's true. If + * kgdb is not compiled in, do nothing. + */ -+#define DEBUGON(cond) \ -+({ \ -+ if (unlikely(cond)) \ -+ reiser4_debugtrap(); \ ++#define DEBUGON(cond) \ ++({ \ ++ if (unlikely(cond)) \ ++ debugtrap(); \ +}) +#else +#define DEBUGON(cond) noop @@ -8743,9 +9014,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + * + * RETERR() macro fills a backtrace in reiser4_context. This back-trace is + * printed in error and warning messages. Moreover, it's possible to put a -+ * conditional breakpoint in reiser4_return_err (low-level function called -+ * by RETERR() to do the actual work) to break into debugger immediately -+ * when particular error happens. ++ * conditional breakpoint in return_err (low-level function called by RETERR() ++ * to do the actual work) to break into debugger immediately when particular ++ * error happens. + * + */ + @@ -8760,18 +9031,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + int line; /* source file line, filled by __LINE__ */ +} err_site; + -+extern void reiser4_return_err(int code, const char *file, int line); ++extern void return_err(int code, const char *file, int line); + +/* + * fill &get_current_context()->err_site with error information. + */ -+#define RETERR(code) \ -+({ \ -+ typeof(code) __code; \ -+ \ -+ __code = (code); \ -+ reiser4_return_err(__code, __FILE__, __LINE__); \ -+ __code; \ ++#define RETERR(code) \ ++({ \ ++ typeof(code) __code; \ ++ \ ++ __code = (code); \ ++ return_err(__code, __FILE__, __LINE__); \ ++ __code; \ +}) + +#else @@ -8806,10 +9077,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/debug.h linux-2.6.22/fs/reiser4/debug.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/dformat.h linux-2.6.22/fs/reiser4/dformat.h ---- linux-2.6.22.orig/fs/reiser4/dformat.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/dformat.h 2007-07-29 00:25:34.836686123 +0400 -@@ -0,0 +1,70 @@ +Index: linux-2.6.16/fs/reiser4/dformat.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/dformat.h +@@ -0,0 +1,71 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Formats of on-disk data and conversion functions. */ @@ -8829,6 +9101,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/dformat.h linux-2.6.22/fs/reiser4/dformat +#include +#include + ++ +typedef __u8 d8; +typedef __le16 d16; +typedef __le32 d32; @@ -8880,9 +9153,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/dformat.h linux-2.6.22/fs/reiser4/dformat + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/dscale.c linux-2.6.22/fs/reiser4/dscale.c ---- linux-2.6.22.orig/fs/reiser4/dscale.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/dscale.c 2007-07-29 00:25:34.836686123 +0400 +Index: linux-2.6.16/fs/reiser4/dscale.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/dscale.c @@ -0,0 +1,174 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -9058,9 +9332,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/dscale.c linux-2.6.22/fs/reiser4/dscale.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/dscale.h linux-2.6.22/fs/reiser4/dscale.h ---- linux-2.6.22.orig/fs/reiser4/dscale.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/dscale.h 2007-07-29 00:25:34.836686123 +0400 +Index: linux-2.6.16/fs/reiser4/dscale.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/dscale.h @@ -0,0 +1,27 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -9089,10 +9364,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/dscale.h linux-2.6.22/fs/reiser4/dscale.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c ---- linux-2.6.22.orig/fs/reiser4/entd.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/entd.c 2007-07-29 00:25:34.840687159 +0400 -@@ -0,0 +1,335 @@ +Index: linux-2.6.16/fs/reiser4/entd.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/entd.c +@@ -0,0 +1,356 @@ +/* Copyright 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -9117,7 +9393,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c +#include /* bdi_write_congested */ +#include +#include -+#include ++ ++#define LLONG_MAX ((long long)(~0ULL>>1)) + +#define DEF_PRIORITY 12 +#define MAX_ENTD_ITERS 10 @@ -9133,13 +9410,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + "ent:%s%s", super->s_id, (state)) + +/** -+ * reiser4_init_entd - initialize entd context and start kernel daemon ++ * init_entd - initialize entd context and start kernel daemon + * @super: super block to start ent thread for + * + * Creates entd contexts, starts kernel thread and waits until it + * initializes. + */ -+int reiser4_init_entd(struct super_block *super) ++int init_entd(struct super_block *super) +{ + entd_context *ctx; + @@ -9163,10 +9440,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + return 0; +} + -+static void put_wbq(struct wbq *rq) ++static void __put_wbq(entd_context *ent, struct wbq *rq) +{ -+ iput(rq->mapping->host); -+ complete(&rq->completion); ++ up(&rq->sem); +} + +/* ent should be locked */ @@ -9174,7 +9450,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c +{ + struct wbq *wbq; + -+ if (list_empty(&ent->todo_list)) ++ if (list_empty_careful(&ent->todo_list)) + return NULL; + + ent->nr_todo_reqs --; @@ -9183,6 +9459,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + return wbq; +} + ++static void wakeup_all_wbq(entd_context * ent) ++{ ++ struct wbq *rq; ++ ++ spin_lock(&ent->guard); ++ while ((rq = __get_wbq(ent)) != NULL) ++ __put_wbq(ent, rq); ++ spin_unlock(&ent->guard); ++} ++ +/* ent thread function */ +static int entd(void *arg) +{ @@ -9204,9 +9490,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + + spin_lock(&ent->guard); + while (ent->nr_todo_reqs != 0) { -+ struct wbq *rq; ++ struct wbq *rq, *next; + -+ assert("", list_empty(&ent->done_list)); ++ assert("", list_empty_careful(&ent->done_list)); + + /* take request from the queue head */ + rq = __get_wbq(ent); @@ -9217,19 +9503,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + entd_set_comm("!"); + entd_flush(super, rq); + -+ put_wbq(rq); ++ iput(rq->mapping->host); ++ up(&(rq->sem)); + + /* + * wakeup all requestors and iput their inodes + */ + spin_lock(&ent->guard); -+ while (!list_empty(&ent->done_list)) { -+ rq = list_entry(ent->done_list.next, struct wbq, link); -+ list_del_init(&rq->link); ++ list_for_each_entry_safe(rq, next, &ent->done_list, link) { ++ list_del_init(&(rq->link)); + ent->nr_done_reqs --; + spin_unlock(&ent->guard); ++ + assert("", rq->written == 1); -+ put_wbq(rq); ++ iput(rq->mapping->host); ++ up(&(rq->sem)); + spin_lock(&ent->guard); + } + } @@ -9253,18 +9541,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + finish_wait(&ent->wait, &__wait); + } + } ++ spin_lock(&ent->guard); + BUG_ON(ent->nr_todo_reqs != 0); ++ spin_unlock(&ent->guard); ++ wakeup_all_wbq(ent); + return 0; +} + +/** -+ * reiser4_done_entd - stop entd kernel thread ++ * done_entd - stop entd kernel thread + * @super: super block to stop ent thread for + * + * It is called on umount. Sends stop signal to entd and wait until it handles + * it. + */ -+void reiser4_done_entd(struct super_block *super) ++void done_entd(struct super_block *super) +{ + entd_context *ent; + @@ -9277,7 +9568,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + +/* called at the beginning of jnode_flush to register flusher thread with ent + * daemon */ -+void reiser4_enter_flush(struct super_block *super) ++void enter_flush(struct super_block *super) +{ + entd_context *ent; + @@ -9295,7 +9586,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c +} + +/* called at the end of jnode_flush */ -+void reiser4_leave_flush(struct super_block *super) ++void leave_flush(struct super_block *super) +{ + entd_context *ent; + int wake_up_ent; @@ -9327,19 +9618,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + ctx.entd = 1; + ctx.gfp_mask = GFP_NOFS; + -+ rq->wbc->range_start = page_offset(rq->page); -+ rq->wbc->range_end = rq->wbc->range_start + -+ (ENTD_CAPTURE_APAGE_BURST << PAGE_CACHE_SHIFT); ++ rq->wbc->start = rq->page->index << PAGE_CACHE_SHIFT; ++ rq->wbc->end = (rq->page->index + ENTD_CAPTURE_APAGE_BURST) << PAGE_CACHE_SHIFT; + tmp = rq->wbc->nr_to_write; + rq->mapping->a_ops->writepages(rq->mapping, rq->wbc); + + if (rq->wbc->nr_to_write > 0) { -+ rq->wbc->range_start = 0; -+ rq->wbc->range_end = LLONG_MAX; ++ rq->wbc->start = 0; ++ rq->wbc->end = LLONG_MAX; + generic_sync_sb_inodes(super, rq->wbc); + } + rq->wbc->nr_to_write = ENTD_CAPTURE_APAGE_BURST; -+ reiser4_writeout(super, rq->wbc); ++ writeout(super, rq->wbc); + + context_set_commit_async(&ctx); + reiser4_exit_context(&ctx); @@ -9372,7 +9662,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + * page. Re-dirty page before unlocking so that if ent thread fails to + * write it - it will remain dirty + */ -+ reiser4_set_page_dirty_internal(page); ++ set_page_dirty_internal(page); + + /* + * pin inode in memory, unlock page, entd_flush will iput. We can not @@ -9392,7 +9682,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + rq.mapping = inode->i_mapping; + rq.node = NULL; + rq.written = 0; -+ init_completion(&rq.completion); ++ sema_init(&rq.sem, 0); + + /* add request to entd's list of writepage requests */ + spin_lock(&ent->guard); @@ -9404,7 +9694,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + spin_unlock(&ent->guard); + + /* wait until entd finishes */ -+ wait_for_completion(&rq.completion); ++ down(&rq.sem); ++ ++ /* ++ * spin until entd thread which did up(&rq.sem) does not need rq ++ * anymore ++ */ ++ spin_lock(&ent->guard); ++ spin_unlock(&ent->guard); + + if (rq.written) + /* Eventually ENTD has written the page to disk. */ @@ -9428,9 +9725,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.c linux-2.6.22/fs/reiser4/entd.c + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/entd.h linux-2.6.22/fs/reiser4/entd.h ---- linux-2.6.22.orig/fs/reiser4/entd.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/entd.h 2007-07-29 00:25:34.840687159 +0400 +Index: linux-2.6.16/fs/reiser4/entd.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/entd.h @@ -0,0 +1,90 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -9456,7 +9754,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.h linux-2.6.22/fs/reiser4/entd.h + struct writeback_control *wbc; + struct page *page; + struct address_space *mapping; -+ struct completion completion; ++ struct semaphore sem; + jnode *node; /* set if ent thread captured requested page */ + int written; /* set if ent thread wrote requested page */ +}; @@ -9499,11 +9797,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.h linux-2.6.22/fs/reiser4/entd.h +#endif +} entd_context; + -+extern int reiser4_init_entd(struct super_block *); -+extern void reiser4_done_entd(struct super_block *); ++extern int init_entd(struct super_block *); ++extern void done_entd(struct super_block *); + -+extern void reiser4_enter_flush(struct super_block *); -+extern void reiser4_leave_flush(struct super_block *); ++extern void enter_flush(struct super_block *); ++extern void leave_flush(struct super_block *); + +extern int write_page_by_ent(struct page *, struct writeback_control *); +extern int wbq_available(void); @@ -9522,10 +9820,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/entd.h linux-2.6.22/fs/reiser4/entd.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c ---- linux-2.6.22.orig/fs/reiser4/eottl.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/eottl.c 2007-07-29 00:25:34.840687159 +0400 -@@ -0,0 +1,509 @@ +Index: linux-2.6.16/fs/reiser4/eottl.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/eottl.c +@@ -0,0 +1,510 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "forward.h" @@ -9795,7 +10094,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c + + assert("vs-49827", znode_contains_key_lock(insert_coord->node, key)); + tree = znode_get_tree(insert_coord->node); -+ node = reiser4_new_node(insert_coord->node, LEAF_LEVEL); ++ node = new_node(insert_coord->node, LEAF_LEVEL); + if (IS_ERR(node)) + return PTR_ERR(node); + @@ -9823,7 +10122,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c + item = (reiser4_item_data *) (todo + 3); + cdata = (carry_insert_data *) (item + 1); + -+ op = reiser4_post_carry(todo, COP_INSERT, insert_coord->node, 0); ++ op = post_carry(todo, COP_INSERT, insert_coord->node, 0); + if (!IS_ERR(op)) { + cdata->coord = insert_coord; + cdata->key = key; @@ -9837,7 +10136,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c + todo->track_type = CARRY_TRACK_CHANGE; + todo->tracked = lh; + -+ result = reiser4_carry(todo, NULL); ++ result = carry(todo, NULL); + if (result == 0) { + /* + * pin node in memory. This is necessary for @@ -9876,7 +10175,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c + write_unlock_tree(tree); + result = + connect_znode(insert_coord, node); -+ ON_DEBUG(if (result == 0) check_dkeys(node);); ++ if (result == 0) ++ ON_DEBUG(check_dkeys(node)); + + done_lh(lh); + move_lh(lh, &local_lh); @@ -10035,10 +10335,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/eottl.c linux-2.6.22/fs/reiser4/eottl.c + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/estimate.c linux-2.6.22/fs/reiser4/estimate.c ---- linux-2.6.22.orig/fs/reiser4/estimate.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/estimate.c 2007-07-29 00:25:34.840687159 +0400 -@@ -0,0 +1,120 @@ +Index: linux-2.6.16/fs/reiser4/estimate.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/estimate.c +@@ -0,0 +1,111 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "debug.h" @@ -10134,19 +10435,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/estimate.c linux-2.6.22/fs/reiser4/estima + return estimate_cluster(inode, 0); /* 44, for 64K-cluster */ +} + -+/* How many nodes occupied by a disk cluster might get dirty. -+ Note that this estimation is not precise (i.e. disk cluster -+ can occupy more nodes). -+ Q: Why we don't use precise estimation? -+ A: 1.Because precise estimation is fairly bad: 65536 nodes -+ for 64K logical cluster, it means 256M of dead space on -+ a partition -+ 2.It is a very rare case when disk cluster occupies more -+ nodes then this estimation returns. -+*/ ++/* how many nodes occupied by a disk cluster might get dirty */ +reiser4_block_nr estimate_dirty_cluster(struct inode * inode) +{ -+ return cluster_nrpages(inode) + 4; ++ return 2 + cluster_nrpages(inode); +} + +/* Make Linus happy. @@ -10159,16 +10451,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/estimate.c linux-2.6.22/fs/reiser4/estima + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/export_ops.c linux-2.6.22/fs/reiser4/export_ops.c ---- linux-2.6.22.orig/fs/reiser4/export_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/export_ops.c 2007-07-29 00:25:34.840687159 +0400 -@@ -0,0 +1,295 @@ +Index: linux-2.6.16/fs/reiser4/export_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/export_ops.c +@@ -0,0 +1,296 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + * reiser4/README */ + +#include "inode.h" +#include "plugin/plugin.h" + ++ +/* + * Supported file-handle types + */ @@ -10203,7 +10497,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/export_ops.c linux-2.6.22/fs/reiser4/expo + + /* identifier of object plugin is stored in the first two bytes, + * followed by... */ -+ fplug = file_plugin_by_disk_id(reiser4_get_tree(s), (d16 *) addr); ++ fplug = file_plugin_by_disk_id(get_tree(s), (d16 *) addr); + if (fplug != NULL) { + addr += sizeof(d16); + obj->plugin = fplug; @@ -10238,7 +10532,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/export_ops.c linux-2.6.22/fs/reiser4/expo + char *addr; + int with_parent; + -+ ctx = reiser4_init_context(super); ++ ctx = init_context(super); + if (IS_ERR(ctx)) + return (struct dentry *)ctx; + @@ -10369,7 +10663,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/export_ops.c linux-2.6.22/fs/reiser4/expo + need += delta; + } + -+ ctx = reiser4_init_context(dentry->d_inode->i_sb); ++ ctx = init_context(dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -10458,10 +10752,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/export_ops.c linux-2.6.22/fs/reiser4/expo + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c ---- linux-2.6.22.orig/fs/reiser4/flush.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/flush.c 2007-07-29 00:25:34.000000000 +0400 -@@ -0,0 +1,3625 @@ +Index: linux-2.6.16/fs/reiser4/flush.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/flush.c +@@ -0,0 +1,3626 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* The design document for this file is at http://www.namesys.com/v4/v4.html. */ @@ -10879,7 +11174,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + load_count * parent_zh, + znode_lock_mode mode, int try); +static int neighbor_in_slum(znode * node, lock_handle * right_lock, sideof side, -+ znode_lock_mode mode, int check_dirty, int expected); ++ znode_lock_mode mode, int check_dirty); +static int znode_same_parents(znode * a, znode * b); + +static int znode_check_flushprepped(znode * node) @@ -10916,7 +11211,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + struct backing_dev_info *bdi; + + sb = reiser4_get_current_sb(); -+ bdi = reiser4_get_super_fake(sb)->i_mapping->backing_dev_info; ++ bdi = get_super_fake(sb)->i_mapping->backing_dev_info; + return bdi_write_congested(bdi); +} + @@ -10934,7 +11229,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + if (check_write_congestion()) + return 0; + -+ ret = reiser4_write_fq(pos->fq, pos->nr_written, ++ ret = write_fq(pos->fq, pos->nr_written, + WRITEOUT_SINGLE_STREAM | WRITEOUT_FOR_PAGE_RECLAIM); + return ret; +} @@ -10972,7 +11267,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + assert("zam-1020", node_is_empty(node)); + assert("zam-1023", znode_is_wlocked(node)); + -+ return reiser4_delete_node(node, &smallest_removed, NULL, 1); ++ return delete_node(node, &smallest_removed, NULL, 1); +} + +/* Prepare flush position for alloc_pos_and_ancestors() and squalloc() */ @@ -11123,15 +11418,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + jnode *leftmost_in_slum = NULL; + + assert("jmacd-76619", lock_stack_isclean(get_current_lock_stack())); -+ assert("nikita-3022", reiser4_schedulable()); ++ assert("nikita-3022", schedulable()); + ++ /* lock ordering: delete_sema and flush_sema are unordered */ + assert("nikita-3185", -+ get_current_super_private()->delete_mutex_owner != current); ++ get_current_super_private()->delete_sema_owner != current); + + /* allocate right_scan, left_scan and flush_pos */ + right_scan = -+ kmalloc(2 * sizeof(*right_scan) + sizeof(*flush_pos), -+ reiser4_ctx_gfp_mask_get()); ++ kmalloc(2 * sizeof(*right_scan) + sizeof(*flush_pos), get_gfp_mask()); + if (right_scan == NULL) + return RETERR(-ENOMEM); + left_scan = right_scan + 1; @@ -11139,13 +11434,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + sb = reiser4_get_current_sb(); + sbinfo = get_super_private(sb); ++ if (!reiser4_is_set(sb, REISER4_MTFLUSH)) { ++ down(&sbinfo->flush_sema); ++ } + + /* Flush-concurrency debug code */ +#if REISER4_DEBUG + atomic_inc(&flush_cnt); +#endif + -+ reiser4_enter_flush(sb); ++ enter_flush(sb); + + /* Initialize a flush position. */ + pos_init(flush_pos); @@ -11336,7 +11634,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + ON_DEBUG(atomic_dec(&flush_cnt)); + -+ reiser4_leave_flush(sb); ++ leave_flush(sb); ++ ++ if (!reiser4_is_set(sb, REISER4_MTFLUSH)) ++ up(&sbinfo->flush_sema); + + return ret; +} @@ -11429,6 +11730,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + return node; +} + ++ +/* Flush some nodes of current atom, usually slum, return -E_REPEAT if there are more nodes + * to flush, return 0 if atom's dirty lists empty and keep current atom locked, return + * other errors as they are. */ @@ -11448,7 +11750,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + nr_to_write = LONG_MAX; + while (1) { -+ ret = reiser4_fq_by_atom(*atom, &fq); ++ ret = fq_by_atom(*atom, &fq); + if (ret != -E_REPEAT) + break; + *atom = get_current_atom_locked(); @@ -11461,10 +11763,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + /* parallel flushers limit */ + if (sinfo->tmgr.atom_max_flushers != 0) { + while ((*atom)->nr_flushers >= sinfo->tmgr.atom_max_flushers) { -+ /* An reiser4_atom_send_event() call is inside -+ reiser4_fq_put_nolock() which is called when flush is -+ finished and nr_flushers is decremented. */ -+ reiser4_atom_wait_event(*atom); ++ /* An atom_send_event() call is inside fq_put_nolock() which is ++ called when flush is finished and nr_flushers is ++ decremented. */ ++ atom_wait_event(*atom); + *atom = get_current_atom_locked(); + } + } @@ -11480,8 +11782,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + if (node == NULL) { + if (nr_queued == 0) { + (*atom)->nr_flushers--; -+ reiser4_fq_put_nolock(fq); -+ reiser4_atom_send_event(*atom); ++ fq_put_nolock(fq); ++ atom_send_event(*atom); + /* current atom remains locked */ + writeout_mode_disable(); + return 0; @@ -11498,13 +11800,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + } + + ret = -+ reiser4_write_fq(fq, nr_submitted, ++ write_fq(fq, nr_submitted, + WRITEOUT_SINGLE_STREAM | WRITEOUT_FOR_PAGE_RECLAIM); + + *atom = get_current_atom_locked(); + (*atom)->nr_flushers--; -+ reiser4_fq_put_nolock(fq); -+ reiser4_atom_send_event(*atom); ++ fq_put_nolock(fq); ++ atom_send_event(*atom); + spin_unlock_atom(*atom); + + writeout_mode_disable(); @@ -11530,8 +11832,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + reiser4_block_nr dist; + + assert("jmacd-7710", *pblk != 0 && *nblk != 0); -+ assert("jmacd-7711", !reiser4_blocknr_is_fake(pblk)); -+ assert("jmacd-7712", !reiser4_blocknr_is_fake(nblk)); ++ assert("jmacd-7711", !blocknr_is_fake(pblk)); ++ assert("jmacd-7712", !blocknr_is_fake(nblk)); + + /* Distance is the absolute value. */ + dist = (*pblk > *nblk) ? (*pblk - *nblk) : (*nblk - *pblk); @@ -11593,7 +11895,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + nblk = *jnode_get_block(node); + -+ if (reiser4_blocknr_is_fake(&nblk)) ++ if (blocknr_is_fake(&nblk)) + /* child is unallocated, mark parent dirty */ + return 1; + @@ -11942,13 +12244,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + ON_DEBUG(vp = shift_check_prepare(left, coord.node)); + + /* stop_key is used to find what was copied and what to cut */ -+ stop_key = *reiser4_min_key(); ++ stop_key = *min_key(); + ret = squalloc_extent(left, &coord, pos, &stop_key); + if (ret != SQUEEZE_CONTINUE) { + ON_DEBUG(kfree(vp)); + break; + } -+ assert("vs-1465", !keyeq(&stop_key, reiser4_min_key())); ++ assert("vs-1465", !keyeq(&stop_key, min_key())); + + /* Helper function to do the cutting. */ + set_key_offset(&stop_key, get_key_offset(&stop_key) - 1); @@ -12352,17 +12654,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + } + + while (1) { -+ int expected; -+ expected = should_convert_next_node(pos); -+ ret = neighbor_in_slum(pos->lock.node, &right_lock, RIGHT_SIDE, -+ ZNODE_WRITE_LOCK, !expected, expected); -+ if (ret) { -+ if (expected) -+ warning("edward-1495", -+ "Expected neighbor not found (ret = %d). Fsck?", -+ ret); ++ ret = ++ neighbor_in_slum(pos->lock.node, &right_lock, RIGHT_SIDE, ++ ZNODE_WRITE_LOCK, ++ !should_convert_next_node(pos, ++ right_lock. ++ node)); ++ if (ret) + break; -+ } + + /* we don't prep(allocate) nodes for flushing twice. This can be suboptimal, or it + * can be optimal. For now we choose to live with the risk that it will @@ -12370,7 +12669,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + * smarter. */ + if (znode_check_flushprepped(right_lock.node) + && !znode_convertible(right_lock.node)) { -+ assert("edward-1005", !should_convert_next_node(pos)); ++ assert("edward-1005", ++ !should_convert_next_node(pos, right_lock.node)); + pos_stop(pos); + break; + } @@ -12378,6 +12678,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + ret = incr_load_count_znode(&right_load, right_lock.node); + if (ret) + break; ++ + if (should_convert_node(pos, right_lock.node)) { + ret = convert_node(pos, right_lock.node); + if (ret) @@ -12398,7 +12699,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + break; + + if (znode_check_flushprepped(right_lock.node)) { -+ if (should_convert_next_node(pos)) { ++ if (should_convert_next_node(pos, right_lock.node)) { + /* in spite of flushprepped status of the node, + its right slum neighbor should be converted */ + assert("edward-953", convert_data(pos)); @@ -12434,6 +12735,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + ret = lock_parent_and_allocate_znode(right_lock.node, pos); + if (ret) + break; ++ + if (should_terminate_squalloc(pos)) { + set_item_convert_count(pos, 0); + break; @@ -12446,7 +12748,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + if (ret) + break; + } -+ check_convert_info(pos); ++ ++ assert("edward-1006", !convert_data(pos) || !item_convert_data(pos)); ++ + done_load_count(&right_load); + done_lh(&right_lock); + @@ -12542,7 +12846,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + while (pos_valid(pos) && coord_is_existing_unit(&pos->coord) + && item_is_extent(&pos->coord)) { -+ ret = reiser4_alloc_extent(pos); ++ ret = alloc_extent(pos); + if (ret) { + break; + } @@ -12930,7 +13234,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + grabbed = get_current_context()->grabbed_blocks; + ret = reiser4_grab_space_force(tree->height, BA_RESERVED); + assert("nikita-3003", ret == 0); /* reserved space is exhausted. Ask Hans. */ -+ ret = reiser4_carry(todo, NULL /* previous level */ ); ++ ret = carry(todo, NULL /* previous level */ ); + grabbed2free_mark(grabbed); + } else { + /* Shifting impossible, we return appropriate result code */ @@ -13041,7 +13345,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + ret = reiser4_grab_space_force(tree->height, BA_RESERVED); + assert("nikita-3003", ret == 0); /* reserved space is exhausted. Ask Hans. */ + -+ ret = reiser4_carry(todo, NULL /* previous level */ ); ++ ret = carry(todo, NULL /* previous level */ ); + grabbed2free_mark(grabbed); + } + @@ -13096,8 +13400,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + reiser4_block_nr dist; + reiser4_block_nr nblk = *znode_get_block(node); + -+ assert("jmacd-6172", !reiser4_blocknr_is_fake(&nblk)); -+ assert("jmacd-6173", !reiser4_blocknr_is_fake(&pos->preceder.blk)); ++ assert("jmacd-6172", !blocknr_is_fake(&nblk)); ++ assert("jmacd-6173", !blocknr_is_fake(&pos->preceder.blk)); + assert("jmacd-6174", pos->preceder.blk != 0); + + if (pos->preceder.blk == nblk - 1) { @@ -13150,7 +13454,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + check_preceder(pos->preceder.blk); + pos->alloc_cnt += 1; + -+ assert("jmacd-4277", !reiser4_blocknr_is_fake(&pos->preceder.blk)); ++ assert("jmacd-4277", !blocknr_is_fake(&pos->preceder.blk)); + + return 0; +} @@ -13195,7 +13499,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + return ret; + + if (ZF_ISSET(node, JNODE_CREATED)) { -+ assert("zam-816", reiser4_blocknr_is_fake(znode_get_block(node))); ++ assert("zam-816", blocknr_is_fake(znode_get_block(node))); + pos->preceder.block_stage = BLOCK_UNALLOCATED; + } else { + pos->preceder.block_stage = BLOCK_GRABBED; @@ -13439,26 +13743,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + lock_handle * lock, /* lock on starting point */ + sideof side, /* left or right direction we seek the next node in */ + znode_lock_mode mode, /* kind of lock we want */ -+ int check_dirty, /* true if the neighbor should be dirty */ -+ int use_upper_levels /* get neighbor by going though -+ upper levels */) -+{ ++ int check_dirty) ++{ /* true if the neighbor should be dirty */ + int ret; -+ int flags; + + assert("jmacd-6334", znode_is_connected(node)); + -+ flags = GN_SAME_ATOM | (side == LEFT_SIDE ? GN_GO_LEFT : 0); -+ if (use_upper_levels) -+ flags |= GN_CAN_USE_UPPER_LEVELS; ++ ret = ++ reiser4_get_neighbor(lock, node, mode, ++ GN_SAME_ATOM | (side == ++ LEFT_SIDE ? GN_GO_LEFT : 0)); + -+ ret = reiser4_get_neighbor(lock, node, mode, flags); + if (ret) { + /* May return -ENOENT or -E_NO_NEIGHBOR. */ + /* FIXME(C): check EINVAL, E_DEADLOCK */ + if (ret == -ENOENT) { + ret = RETERR(-E_NO_NEIGHBOR); + } ++ + return ret; + } + if (!check_dirty) @@ -13515,7 +13817,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c +} + +/* Returns true if flush scanning is finished. */ -+int reiser4_scan_finished(flush_scan * scan) ++int scan_finished(flush_scan * scan) +{ + return scan->stop || (scan->direction == RIGHT_SIDE && + scan->count >= scan->max_count); @@ -13523,7 +13825,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + +/* Return true if the scan should continue to the @tonode. True if the node meets the + same_slum_check condition. If not, deref the "left" node and stop the scan. */ -+int reiser4_scan_goto(flush_scan * scan, jnode * tonode) ++int scan_goto(flush_scan * scan, jnode * tonode) +{ + int go = same_slum_check(scan->node, tonode, 1, 0); + @@ -13551,7 +13853,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + scan->node = node; + scan->count += add_count; + -+ /* This next stmt is somewhat inefficient. The reiser4_scan_extent() code could ++ /* This next stmt is somewhat inefficient. The scan_extent_coord code could + delay this update step until it finishes and update the parent_coord only once. + It did that before, but there was a bug and this was the easiest way to make it + correct. */ @@ -13565,7 +13867,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c +} + +/* Return true if scanning in the leftward direction. */ -+int reiser4_scanning_left(flush_scan * scan) ++int scanning_left(flush_scan * scan) +{ + return scan->direction == LEFT_SIDE; +} @@ -13678,7 +13980,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + } + /* This loop expects to start at a formatted position and performs chaining of + formatted regions */ -+ while (!reiser4_scan_finished(scan)) { ++ while (!scan_finished(scan)) { + + ret = scan_formatted(scan); + if (ret != 0) { @@ -13715,7 +14017,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + * there is already lock held by this thread, + * jnode_lock_parent_coord() should use try-lock. + */ -+ try = reiser4_scanning_left(scan) ++ try = scanning_left(scan) + && !lock_stack_isclean(get_current_lock_stack()); + /* Need the node locked to get the parent lock, We have to + take write lock since there is at least one call path @@ -13723,8 +14025,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + ret = + longterm_lock_znode(&lock, JZNODE(scan->node), + ZNODE_WRITE_LOCK, -+ reiser4_scanning_left(scan) ? -+ ZNODE_LOCK_LOPRI : ++ scanning_left(scan) ? ZNODE_LOCK_LOPRI : + ZNODE_LOCK_HIPRI); + if (ret != 0) + /* EINVAL or E_DEADLOCK here mean... try again! At this point we've @@ -13786,7 +14087,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + int ret; + znode *neighbor = NULL; + -+ assert("jmacd-1401", !reiser4_scan_finished(scan)); ++ assert("jmacd-1401", !scan_finished(scan)); + + do { + znode *node = JZNODE(scan->node); @@ -13804,8 +14105,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + left sibling while the tree lock is released, but the flush-scan count + does not need to be precise. Thus, we release the tree lock as soon as + we get the neighboring node. */ -+ neighbor = -+ reiser4_scanning_left(scan) ? node->left : node->right; ++ neighbor = scanning_left(scan) ? node->left : node->right; + if (neighbor != NULL) { + zref(neighbor); + } @@ -13820,7 +14120,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + + /* Check the condition for going left, break if it is not met. This also + releases (jputs) the neighbor if false. */ -+ if (!reiser4_scan_goto(scan, ZJNODE(neighbor))) { ++ if (!scan_goto(scan, ZJNODE(neighbor))) { + break; + } + @@ -13830,13 +14130,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + return ret; + } + -+ } while (!reiser4_scan_finished(scan)); ++ } while (!scan_finished(scan)); + + /* If neighbor is NULL then we reached the end of a formatted region, or else the + sibling is out of memory, now check for an extent to the left (as long as + LEAF_LEVEL). */ + if (neighbor != NULL || jnode_get_level(scan->node) != LEAF_LEVEL -+ || reiser4_scan_finished(scan)) { ++ || scan_finished(scan)) { + scan->stop = 1; + return 0; + } @@ -13871,7 +14171,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + /* set initial item id */ + iplug = item_plugin_by_coord(&scan->parent_coord); + -+ for (; !reiser4_scan_finished(scan); scan_this_coord = 1) { ++ for (; !scan_finished(scan); scan_this_coord = 1) { + if (scan_this_coord) { + /* Here we expect that unit is scannable. it would not be so due + * to race with extent->tail conversion. */ @@ -13886,7 +14186,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + if (ret != 0) + goto exit; + -+ if (reiser4_scan_finished(scan)) { ++ if (scan_finished(scan)) { + checkchild(scan); + break; + } @@ -13922,13 +14222,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + if (coord_is_after_sideof_unit(&next_coord, scan->direction)) { + /* We take the write lock because we may start flushing from this + * coordinate. */ -+ ret = neighbor_in_slum(next_coord.node, -+ &next_lock, -+ scan->direction, -+ ZNODE_WRITE_LOCK, -+ 1 /* check dirty */, -+ 0 /* don't go though upper -+ levels */); ++ ret = ++ neighbor_in_slum(next_coord.node, &next_lock, ++ scan->direction, ZNODE_WRITE_LOCK, ++ 1 /* check dirty */ ); + if (ret == -E_NO_NEIGHBOR) { + scan->stop = 1; + ret = 0; @@ -13970,7 +14267,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + || jnode_is_znode(child)); + + /* See if it is dirty, part of the same atom. */ -+ if (!reiser4_scan_goto(scan, child)) { ++ if (!scan_goto(scan, child)) { + checkchild(scan); + break; + } @@ -13993,8 +14290,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + } + } + -+ assert("jmacd-6233", -+ reiser4_scan_finished(scan) || jnode_is_znode(scan->node)); ++ assert("jmacd-6233", scan_finished(scan) || jnode_is_znode(scan->node)); + exit: + checkchild(scan); + race: /* skip the above check */ @@ -14020,7 +14316,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + init_lh(&pos->lock); + init_load_count(&pos->load); + -+ reiser4_blocknr_hint_init(&pos->preceder); ++ blocknr_hint_init(&pos->preceder); +} + +/* The flush loop inside squalloc periodically checks pos_valid to @@ -14044,7 +14340,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c +static void pos_done(flush_pos_t * pos) +{ + pos_stop(pos); -+ reiser4_blocknr_hint_done(&pos->preceder); ++ blocknr_hint_done(&pos->preceder); + if (convert_data(pos)) + free_convert_data(pos); +} @@ -14067,12 +14363,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c +} + +/* Return the flush_position's block allocator hint. */ -+reiser4_blocknr_hint *reiser4_pos_hint(flush_pos_t * pos) ++reiser4_blocknr_hint *pos_hint(flush_pos_t * pos) +{ + return &pos->preceder; +} + -+flush_queue_t * reiser4_pos_fq(flush_pos_t * pos) ++flush_queue_t *pos_fq(flush_pos_t * pos) +{ + return pos->fq; +} @@ -14087,10 +14383,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.c linux-2.6.22/fs/reiser4/flush.c + LocalWords: preceder + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h ---- linux-2.6.22.orig/fs/reiser4/flush.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/flush.h 2007-07-29 00:25:34.864693371 +0400 -@@ -0,0 +1,295 @@ +Index: linux-2.6.16/fs/reiser4/flush.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/flush.h +@@ -0,0 +1,274 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* DECLARATIONS: */ @@ -14149,19 +14446,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h + reiser4_block_nr preceder_blk; +}; + -+struct convert_item_info { ++typedef struct convert_item_info { + dc_item_stat d_cur; /* disk cluster state of the current item */ + dc_item_stat d_next; /* disk cluster state of the next slum item */ + struct inode *inode; + flow_t flow; -+}; ++} convert_item_info_t; + -+struct convert_info { ++typedef struct convert_info { + int count; /* for squalloc terminating */ ++ reiser4_cluster_t clust; /* transform cluster */ + item_plugin *iplug; /* current item plugin */ -+ struct convert_item_info *itm; /* current item info */ -+ struct cluster_handle clust; /* transform cluster */ -+}; ++ convert_item_info_t *itm; /* current item info */ ++} convert_info_t; + +typedef enum flush_position_state { + POS_INVALID, /* Invalid or stopped pos, do not continue slum @@ -14201,7 +14498,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h + + znode *prev_twig; /* previous parent pointer value, used to catch + * processing of new twig node */ -+ struct convert_info *sq; /* convert info */ ++ convert_info_t *sq; /* convert info */ + + unsigned long pos_in_unit; /* for extents only. Position + within an extent unit of first @@ -14226,27 +14523,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h + return pos->sq->iplug; +} + -+static inline struct convert_info *convert_data(flush_pos_t * pos) ++static inline convert_info_t *convert_data(flush_pos_t * pos) +{ + return pos->sq; +} + -+static inline struct convert_item_info *item_convert_data(flush_pos_t * pos) ++static inline convert_item_info_t *item_convert_data(flush_pos_t * pos) +{ + assert("edward-955", convert_data(pos)); + return pos->sq->itm; +} + -+static inline struct tfm_cluster * tfm_cluster_sq(flush_pos_t * pos) ++static inline tfm_cluster_t *tfm_cluster_sq(flush_pos_t * pos) +{ + return &pos->sq->clust.tc; +} + -+static inline struct tfm_stream * tfm_stream_sq(flush_pos_t * pos, -+ tfm_stream_id id) ++static inline tfm_stream_t *tfm_stream_sq(flush_pos_t * pos, tfm_stream_id id) +{ + assert("edward-854", pos->sq != NULL); -+ return get_tfm_stream(tfm_cluster_sq(pos), id); ++ return tfm_stream(tfm_cluster_sq(pos), id); +} + +static inline int chaining_data_present(flush_pos_t * pos) @@ -14312,7 +14608,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h +} + +/* true if there is attached convert item info */ -+static inline int should_convert_next_node(flush_pos_t * pos) ++static inline int should_convert_next_node(flush_pos_t * pos, znode * node) +{ + return convert_data(pos) && item_convert_data(pos); +} @@ -14326,43 +14622,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h + item_convert_count(pos) >= SQUALLOC_THRESHOLD; +} + -+#if 1 -+#define check_convert_info(pos) \ -+do { \ -+ if (unlikely(should_convert_next_node(pos))){ \ -+ warning("edward-1006", "unprocessed chained data"); \ -+ printk("d_cur = %d, d_next = %d, flow.len = %llu\n", \ -+ item_convert_data(pos)->d_cur, \ -+ item_convert_data(pos)->d_next, \ -+ item_convert_data(pos)->flow.length); \ -+ printk("inode %llu, size = %llu, cluster %lu\n", \ -+ (unsigned long long)get_inode_oid \ -+ (item_convert_data(pos)->inode), \ -+ i_size_read(item_convert_data(pos)->inode), \ -+ convert_data(pos)->clust.index); \ -+ } \ -+} while (0) -+#else -+#define check_convert_info(pos) -+#endif /* REISER4_DEBUG */ -+ +void free_convert_data(flush_pos_t * pos); +/* used in extent.c */ +int scan_set_current(flush_scan * scan, jnode * node, unsigned add_size, + const coord_t * parent); -+int reiser4_scan_finished(flush_scan * scan); -+int reiser4_scanning_left(flush_scan * scan); -+int reiser4_scan_goto(flush_scan * scan, jnode * tonode); ++int scan_finished(flush_scan * scan); ++int scanning_left(flush_scan * scan); ++int scan_goto(flush_scan * scan, jnode * tonode); +txn_atom *atom_locked_by_fq(flush_queue_t * fq); -+int reiser4_alloc_extent(flush_pos_t *flush_pos); ++int alloc_extent(flush_pos_t *flush_pos); +squeeze_result squalloc_extent(znode *left, const coord_t *, flush_pos_t *, + reiser4_key *stop_key); -+extern int reiser4_init_fqs(void); -+extern void reiser4_done_fqs(void); ++extern int init_fqs(void); ++extern void done_fqs(void); + +#if REISER4_DEBUG + -+extern void reiser4_check_fq(const txn_atom *atom); ++extern void check_fq(const txn_atom *atom); +extern atomic_t flush_cnt; + +#define check_preceder(blk) \ @@ -14386,10 +14662,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush.h linux-2.6.22/fs/reiser4/flush.h + LocalWords: preceder + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flush_queue.c ---- linux-2.6.22.orig/fs/reiser4/flush_queue.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/flush_queue.c 2007-07-29 00:25:34.864693371 +0400 -@@ -0,0 +1,680 @@ +Index: linux-2.6.16/fs/reiser4/flush_queue.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/flush_queue.c +@@ -0,0 +1,681 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "debug.h" @@ -14494,20 +14771,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + + INIT_LIST_HEAD(ATOM_FQ_LIST(fq)); + -+ init_waitqueue_head(&fq->wait); ++ sema_init(&fq->io_sem, 0); + spin_lock_init(&fq->guard); +} + +/* slab for flush queues */ -+static struct kmem_cache *fq_slab; ++static kmem_cache_t *fq_slab; ++ + +/** -+ * reiser4_init_fqs - create flush queue cache ++ * init_fqs - create flush queue cache + * + * Initializes slab cache of flush queues. It is part of reiser4 module + * initialization. + */ -+int reiser4_init_fqs(void) ++int init_fqs(void) +{ + fq_slab = kmem_cache_create("fq", + sizeof(flush_queue_t), @@ -14518,11 +14796,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu +} + +/** -+ * reiser4_done_fqs - delete flush queue cache ++ * done_fqs - delete flush queue cache + * + * This is called on reiser4 module unloading or system shutdown. + */ -+void reiser4_done_fqs(void) ++void done_fqs(void) +{ + destroy_reiser4_cache(&fq_slab); +} @@ -14582,7 +14860,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu +} + +/* */ -+static void mark_jnode_queued(flush_queue_t * fq, jnode * node) ++void mark_jnode_queued(flush_queue_t * fq, jnode * node) +{ + JF_SET(node, JNODE_FLUSH_QUEUED); + count_enqueued_node(fq); @@ -14624,15 +14902,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + + spin_unlock_atom(fq->atom); + -+ assert("nikita-3013", reiser4_schedulable()); ++ assert("nikita-3013", schedulable()); + + super = reiser4_get_current_sb(); + + /* FIXME: this is instead of blk_run_queues() */ -+ blk_run_address_space(reiser4_get_super_fake(super)->i_mapping); ++ blk_run_address_space(get_super_fake(super)->i_mapping); + + if (!(super->s_flags & MS_RDONLY)) -+ wait_event(fq->wait, atomic_read(&fq->nr_submitted) == 0); ++ down(&fq->io_sem); + + /* Ask the caller to re-acquire the locks and call this + function again. Note: this technique is commonly used in @@ -14661,7 +14939,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + detach_fq(fq); + done_fq(fq); + -+ reiser4_atom_send_event(atom); ++ atom_send_event(atom); + + return 0; +} @@ -14690,7 +14968,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + reiser4_handle_error(); + + if (ret) { -+ reiser4_fq_put(fq); ++ fq_put(fq); + return ret; + } + @@ -14717,7 +14995,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + ret = finish_all_fq(atom, &nr_io_errors); + if (ret != -EBUSY) + break; -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + } + } while (ret == -E_REPEAT); + @@ -14752,7 +15030,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu +} + +/* support for atom fusion operation */ -+void reiser4_fuse_fq(txn_atom *to, txn_atom *from) ++void fuse_fq(txn_atom *to, txn_atom *from) +{ + flush_queue_t *fq; + @@ -14833,9 +15111,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + atomic_add(nr_errors, &fq->nr_errors); + + /* If all write requests registered in this "fq" are done we up -+ * the waiter. */ ++ * the semaphore. */ + if (atomic_sub_and_test(bio->bi_vcnt, &fq->nr_submitted)) -+ wake_up(&fq->wait); ++ up(&fq->io_sem); + } + + bio_put(bio); @@ -14889,7 +15167,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + } + + if (--atom->nr_running_queues == 0) -+ reiser4_atom_send_event(atom); ++ atom_send_event(atom); + + spin_unlock_atom(atom); +} @@ -14899,7 +15177,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + @fq: flush queue object which contains jnodes we can (and will) write. + @return: number of submitted blocks (>=0) if success, otherwise -- an error + code (<0). */ -+int reiser4_write_fq(flush_queue_t * fq, long *nr_submitted, int flags) ++int write_fq(flush_queue_t * fq, long *nr_submitted, int flags) +{ + int ret; + txn_atom *atom; @@ -14911,7 +15189,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + if (atom->nr_running_queues == 0 + || !(flags & WRITEOUT_SINGLE_STREAM)) + break; -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + } + + atom->nr_running_queues++; @@ -14979,13 +15257,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + return RETERR(-E_REPEAT); +} + -+int reiser4_fq_by_atom(txn_atom * atom, flush_queue_t ** new_fq) ++int fq_by_atom(txn_atom * atom, flush_queue_t ** new_fq) +{ -+ return fq_by_atom_gfp(atom, new_fq, reiser4_ctx_gfp_mask_get()); ++ return fq_by_atom_gfp(atom, new_fq, get_gfp_mask()); +} + -+/* A wrapper around reiser4_fq_by_atom for getting a flush queue -+ object for current atom, if success fq->atom remains locked. */ ++/* A wrapper around fq_by_atom for getting a flush queue object for current ++ * atom, if success fq->atom remains locked. */ +flush_queue_t *get_fq_for_current_atom(void) +{ + flush_queue_t *fq = NULL; @@ -14994,7 +15272,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + + do { + atom = get_current_atom_locked(); -+ ret = reiser4_fq_by_atom(atom, &fq); ++ ret = fq_by_atom(atom, &fq); + } while (ret == -E_REPEAT); + + if (ret) @@ -15003,7 +15281,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu +} + +/* Releasing flush queue object after exclusive use */ -+void reiser4_fq_put_nolock(flush_queue_t *fq) ++void fq_put_nolock(flush_queue_t *fq) +{ + assert("zam-747", fq->atom != NULL); + assert("zam-902", list_empty_careful(ATOM_FQ_LIST(fq))); @@ -15012,7 +15290,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + ON_DEBUG(fq->owner = NULL); +} + -+void reiser4_fq_put(flush_queue_t * fq) ++void fq_put(flush_queue_t * fq) +{ + txn_atom *atom; + @@ -15021,8 +15299,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + + assert("zam-746", atom != NULL); + -+ reiser4_fq_put_nolock(fq); -+ reiser4_atom_send_event(atom); ++ fq_put_nolock(fq); ++ atom_send_event(atom); + + spin_unlock(&(fq->guard)); + spin_unlock_atom(atom); @@ -15038,7 +15316,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + +#if REISER4_DEBUG + -+void reiser4_check_fq(const txn_atom *atom) ++void check_fq(const txn_atom *atom) +{ + /* check number of nodes on all atom's flush queues */ + flush_queue_t *fq; @@ -15070,10 +15348,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/flush_queue.c linux-2.6.22/fs/reiser4/flu + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward.h ---- linux-2.6.22.orig/fs/reiser4/forward.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/forward.h 2007-07-29 00:25:34.864693371 +0400 -@@ -0,0 +1,252 @@ +Index: linux-2.6.16/fs/reiser4/forward.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/forward.h +@@ -0,0 +1,258 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Forward declarations. Thank you Kernighan. */ @@ -15091,10 +15370,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward +typedef struct flow flow_t; +typedef struct coord coord_t; +typedef struct tree_access_pointer tap_t; ++typedef struct item_coord item_coord; ++typedef struct shift_params shift_params; +typedef struct reiser4_object_create_data reiser4_object_create_data; +typedef union reiser4_plugin reiser4_plugin; +typedef __u16 reiser4_plugin_id; -+typedef __u64 reiser4_plugin_groups; +typedef struct item_plugin item_plugin; +typedef struct jnode_plugin jnode_plugin; +typedef struct reiser4_item_data reiser4_item_data; @@ -15112,6 +15392,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward +typedef struct reiser4_dir_entry_desc reiser4_dir_entry_desc; +typedef struct reiser4_context reiser4_context; +typedef struct carry_level carry_level; ++typedef struct blocknr_set blocknr_set; +typedef struct blocknr_set_entry blocknr_set_entry; +/* super_block->s_fs_info points to this */ +typedef struct reiser4_super_info_data reiser4_super_info_data; @@ -15133,6 +15414,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward + +typedef struct ktxnmgrd_context ktxnmgrd_context; + ++typedef struct reiser4_xattr_plugin reiser4_xattr_plugin; ++ +struct inode; +struct page; +struct file; @@ -15314,6 +15597,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward + OVRWR_LIST +} atom_list; + ++ ++ +/* __REISER4_FORWARD_H__ */ +#endif + @@ -15326,10 +15611,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/forward.h linux-2.6.22/fs/reiser4/forward + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c ---- linux-2.6.22.orig/fs/reiser4/fsdata.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/fsdata.c 2007-07-29 00:25:34.868694406 +0400 -@@ -0,0 +1,808 @@ +Index: linux-2.6.16/fs/reiser4/fsdata.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/fsdata.c +@@ -0,0 +1,803 @@ +/* Copyright 2001, 2002, 2003, 2004, 2005 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -15338,7 +15624,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + + +/* cache or dir_cursors */ -+static struct kmem_cache *d_cursor_cache; ++static kmem_cache_t *d_cursor_cache; +static struct shrinker *d_cursor_shrinker; + +/* list of unused cursors */ @@ -15386,12 +15672,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_init_d_cursor - create d_cursor cache ++ * init_d_cursor - create d_cursor cache + * + * Initializes slab cache of d_cursors. It is part of reiser4 module + * initialization. + */ -+int reiser4_init_d_cursor(void) ++int init_d_cursor(void) +{ + d_cursor_cache = kmem_cache_create("d_cursor", sizeof(dir_cursor), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); @@ -15416,11 +15702,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_done_d_cursor - delete d_cursor cache and d_cursor shrinker ++ * done_d_cursor - delete d_cursor cache and d_cursor shrinker + * + * This is called on reiser4 module unloading or system shutdown. + */ -+void reiser4_done_d_cursor(void) ++void done_d_cursor(void) +{ + BUG_ON(d_cursor_shrinker == NULL); + remove_shrinker(d_cursor_shrinker); @@ -15432,14 +15718,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +#define D_CURSOR_TABLE_SIZE (256) + +static inline unsigned long -+d_cursor_hash(d_cursor_hash_table *table, const struct d_cursor_key *key) ++d_cursor_hash(d_cursor_hash_table *table, const d_cursor_key *key) +{ + assert("nikita-3555", IS_POW(D_CURSOR_TABLE_SIZE)); + return (key->oid + key->cid) & (D_CURSOR_TABLE_SIZE - 1); +} + -+static inline int d_cursor_eq(const struct d_cursor_key *k1, -+ const struct d_cursor_key *k2) ++static inline int d_cursor_eq(const d_cursor_key *k1, const d_cursor_key *k2) +{ + return k1->cid == k2->cid && k1->oid == k2->oid; +} @@ -15448,41 +15733,40 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * define functions to manipulate reiser4 super block's hash table of + * dir_cursors + */ -+#define KMALLOC(size) kmalloc((size), reiser4_ctx_gfp_mask_get()) ++#define KMALLOC(size) kmalloc((size), get_gfp_mask()) +#define KFREE(ptr, size) kfree(ptr) +TYPE_SAFE_HASH_DEFINE(d_cursor, + dir_cursor, -+ struct d_cursor_key, -+ key, hash, d_cursor_hash, d_cursor_eq); ++ d_cursor_key, key, hash, d_cursor_hash, d_cursor_eq); +#undef KFREE +#undef KMALLOC + +/** -+ * reiser4_init_super_d_info - initialize per-super-block d_cursor resources ++ * init_super_d_info - initialize per-super-block d_cursor resources + * @super: super block to initialize + * + * Initializes per-super-block d_cursor's hash table and radix tree. It is part + * of mount. + */ -+int reiser4_init_super_d_info(struct super_block *super) ++int init_super_d_info(struct super_block *super) +{ -+ struct d_cursor_info *p; ++ d_cursor_info *p; + + p = &get_super_private(super)->d_info; + -+ INIT_RADIX_TREE(&p->tree, reiser4_ctx_gfp_mask_get()); ++ INIT_RADIX_TREE(&p->tree, get_gfp_mask()); + return d_cursor_hash_init(&p->table, D_CURSOR_TABLE_SIZE); +} + +/** -+ * reiser4_done_super_d_info - release per-super-block d_cursor resources ++ * done_super_d_info - release per-super-block d_cursor resources + * @super: super block being umounted + * + * It is called on umount. Kills all directory cursors attached to suoer block. + */ -+void reiser4_done_super_d_info(struct super_block *super) ++void done_super_d_info(struct super_block *super) +{ -+ struct d_cursor_info *d_info; ++ d_cursor_info *d_info; + dir_cursor *cursor, *next; + + d_info = &get_super_private(super)->d_info; @@ -15567,7 +15851,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +/* + * return d_cursor data for the file system @inode is in. + */ -+static inline struct d_cursor_info *d_info(struct inode *inode) ++static inline d_cursor_info *d_info(struct inode *inode) +{ + return &get_super_private(inode->i_sb)->d_info; +} @@ -15575,8 +15859,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +/* + * lookup d_cursor in the per-super-block radix tree. + */ -+static inline dir_cursor *lookup(struct d_cursor_info * info, -+ unsigned long index) ++static inline dir_cursor *lookup(d_cursor_info * info, unsigned long index) +{ + return (dir_cursor *) radix_tree_lookup(&info->tree, index); +} @@ -15660,9 +15943,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * cursor. */ + fsdata = create_fsdata(NULL); + if (fsdata != NULL) { -+ result = radix_tree_preload(reiser4_ctx_gfp_mask_get()); ++ result = radix_tree_preload(get_gfp_mask()); + if (result == 0) { -+ struct d_cursor_info *info; ++ d_cursor_info *info; + oid_t oid; + + info = d_info(inode); @@ -15716,7 +15999,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + dir_cursor *start; + struct list_head *head; + reiser4_context *ctx; -+ struct d_cursor_info *info; ++ d_cursor_info *info; + + /* this can be called by + * @@ -15724,7 +16007,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * + * without reiser4_context + */ -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) { + warning("vs-23", "failed to init context"); + return; @@ -15783,38 +16066,38 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_dispose_cursors - removes cursors from inode's list ++ * dispose_cursors - removes cursors from inode's list + * @inode: inode to dispose cursors of + * + * For each of cursors corresponding to @inode - removes reiser4_file_fsdata + * attached to cursor from inode's readdir list. This is called when inode is + * removed from the memory by memory pressure. + */ -+void reiser4_dispose_cursors(struct inode *inode) ++void dispose_cursors(struct inode *inode) +{ + process_cursors(inode, CURSOR_DISPOSE); +} + +/** -+ * reiser4_load_cursors - attach cursors to inode ++ * load_cursors - attach cursors to inode + * @inode: inode to load cursors to + * + * For each of cursors corresponding to @inode - attaches reiser4_file_fsdata + * attached to cursor to inode's readdir list. This is done when inode is + * loaded into memory. + */ -+void reiser4_load_cursors(struct inode *inode) ++void load_cursors(struct inode *inode) +{ + process_cursors(inode, CURSOR_LOAD); +} + +/** -+ * reiser4_kill_cursors - kill all inode cursors ++ * kill_cursors - kill all inode cursors + * @inode: inode to kill cursors of + * + * Frees all cursors for this inode. This is called when inode is destroyed. + */ -+void reiser4_kill_cursors(struct inode *inode) ++void kill_cursors(struct inode *inode) +{ + process_cursors(inode, CURSOR_KILL); +} @@ -15833,14 +16116,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_get_dir_fpos - ++ * get_dir_fpos - + * @dir: + * + * Calculates ->fpos from user-supplied cookie. Normally it is dir->f_pos, but + * in the case of stateless directory operation (readdir-over-nfs), client id + * was encoded in the high bits of cookie and should me masked off. + */ -+loff_t reiser4_get_dir_fpos(struct file *dir) ++loff_t get_dir_fpos(struct file *dir) +{ + if (file_is_stateless(dir)) + return dir->f_pos & CID_MASK; @@ -15849,13 +16132,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_attach_fsdata - try to attach fsdata ++ * try_to_attach_fsdata - ??? + * @file: + * @inode: + * + * Finds or creates cursor for readdir-over-nfs. + */ -+int reiser4_attach_fsdata(struct file *file, struct inode *inode) ++int try_to_attach_fsdata(struct file *file, struct inode *inode) +{ + loff_t pos; + int result; @@ -15874,15 +16157,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * first call to readdir (or rewind to the beginning of + * directory) + */ -+ cursor = kmem_cache_alloc(d_cursor_cache, -+ reiser4_ctx_gfp_mask_get()); ++ cursor = kmem_cache_alloc(d_cursor_cache, get_gfp_mask()); + if (cursor != NULL) + result = insert_cursor(cursor, file, inode); + else + result = RETERR(-ENOMEM); + } else { + /* try to find existing cursor */ -+ struct d_cursor_key key; ++ d_cursor_key key; + + key.cid = pos >> CID_SHIFT; + key.oid = get_inode_oid(inode); @@ -15911,12 +16193,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_detach_fsdata - ??? ++ * detach_fsdata - ??? + * @file: + * + * detach fsdata, if necessary + */ -+void reiser4_detach_fsdata(struct file *file) ++void detach_fsdata(struct file *file) +{ + struct inode *inode; + @@ -15930,33 +16212,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/* slab for reiser4_dentry_fsdata */ -+static struct kmem_cache *dentry_fsdata_cache; ++static kmem_cache_t *dentry_fsdata_cache; + +/** -+ * reiser4_init_dentry_fsdata - create cache of dentry_fsdata ++ * init_dentry_fsdata - create cache of dentry_fsdata + * + * Initializes slab cache of structures attached to denty->d_fsdata. It is + * part of reiser4 module initialization. + */ -+int reiser4_init_dentry_fsdata(void) ++int init_dentry_fsdata(void) +{ + dentry_fsdata_cache = kmem_cache_create("dentry_fsdata", -+ sizeof(struct reiser4_dentry_fsdata), -+ 0, -+ SLAB_HWCACHE_ALIGN | -+ SLAB_RECLAIM_ACCOUNT, NULL, -+ NULL); ++ sizeof(reiser4_dentry_fsdata), ++ 0, ++ SLAB_HWCACHE_ALIGN | ++ SLAB_RECLAIM_ACCOUNT, NULL, ++ NULL); + if (dentry_fsdata_cache == NULL) + return RETERR(-ENOMEM); + return 0; +} + +/** -+ * reiser4_done_dentry_fsdata - delete cache of dentry_fsdata ++ * done_dentry_fsdata - delete cache of dentry_fsdata + * + * This is called on reiser4 module unloading or system shutdown. + */ -+void reiser4_done_dentry_fsdata(void) ++void done_dentry_fsdata(void) +{ + destroy_reiser4_cache(&dentry_fsdata_cache); +} @@ -15968,17 +16250,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * Allocates if necessary and returns per-dentry data that we attach to each + * dentry. + */ -+struct reiser4_dentry_fsdata *reiser4_get_dentry_fsdata(struct dentry *dentry) ++reiser4_dentry_fsdata *reiser4_get_dentry_fsdata(struct dentry *dentry) +{ + assert("nikita-1365", dentry != NULL); + + if (dentry->d_fsdata == NULL) { + dentry->d_fsdata = kmem_cache_alloc(dentry_fsdata_cache, -+ reiser4_ctx_gfp_mask_get()); ++ get_gfp_mask()); + if (dentry->d_fsdata == NULL) + return ERR_PTR(RETERR(-ENOMEM)); -+ memset(dentry->d_fsdata, 0, -+ sizeof(struct reiser4_dentry_fsdata)); ++ memset(dentry->d_fsdata, 0, sizeof(reiser4_dentry_fsdata)); + } + return dentry->d_fsdata; +} @@ -15997,16 +16278,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + } +} + ++ +/* slab for reiser4_file_fsdata */ -+static struct kmem_cache *file_fsdata_cache; ++static kmem_cache_t *file_fsdata_cache; + +/** -+ * reiser4_init_file_fsdata - create cache of reiser4_file_fsdata ++ * init_file_fsdata - create cache of reiser4_file_fsdata + * + * Initializes slab cache of structures attached to file->private_data. It is + * part of reiser4 module initialization. + */ -+int reiser4_init_file_fsdata(void) ++int init_file_fsdata(void) +{ + file_fsdata_cache = kmem_cache_create("file_fsdata", + sizeof(reiser4_file_fsdata), @@ -16019,11 +16301,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +} + +/** -+ * reiser4_done_file_fsdata - delete cache of reiser4_file_fsdata ++ * done_file_fsdata - delete cache of reiser4_file_fsdata + * + * This is called on reiser4 module unloading or system shutdown. + */ -+void reiser4_done_file_fsdata(void) ++void done_file_fsdata(void) +{ + destroy_reiser4_cache(&file_fsdata_cache); +} @@ -16038,8 +16320,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c +{ + reiser4_file_fsdata *fsdata; + -+ fsdata = kmem_cache_alloc(file_fsdata_cache, -+ reiser4_ctx_gfp_mask_get()); ++ fsdata = kmem_cache_alloc(file_fsdata_cache, get_gfp_mask()); + if (fsdata != NULL) { + memset(fsdata, 0, sizeof *fsdata); + fsdata->ra1.max_window_size = VM_MAX_READAHEAD * 1024; @@ -16138,10 +16419,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.c linux-2.6.22/fs/reiser4/fsdata.c + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h ---- linux-2.6.22.orig/fs/reiser4/fsdata.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/fsdata.h 2007-07-29 00:25:34.868694406 +0400 -@@ -0,0 +1,205 @@ +Index: linux-2.6.16/fs/reiser4/fsdata.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/fsdata.h +@@ -0,0 +1,218 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -16173,31 +16455,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + */ + +/* logical position within directory */ -+struct dir_pos { ++typedef struct { + /* key of directory entry (actually, part of a key sufficient to + identify directory entry) */ + de_id dir_entry_key; + /* ordinal number of directory entry among all entries with the same + key. (Starting from 0.) */ + unsigned pos; -+}; ++} dir_pos; + -+struct readdir_pos { ++typedef struct { + /* f_pos corresponding to this readdir position */ + __u64 fpos; + /* logical position within directory */ -+ struct dir_pos position; ++ dir_pos position; + /* logical number of directory entry within + directory */ + __u64 entry_no; -+}; ++} readdir_pos; + +/* + * this is used to speed up lookups for directory entry: on initial call to + * ->lookup() seal and coord of directory entry (if found, that is) are stored + * in struct dentry and reused later to avoid tree traversals. + */ -+struct de_location { ++typedef struct de_location { + /* seal covering directory entry */ + seal_t entry_seal; + /* coord of directory entry */ @@ -16205,7 +16487,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + /* ordinal number of directory entry among all entries with the same + key. (Starting from 0.) */ + int pos; -+}; ++} de_location; + +/** + * reiser4_dentry_fsdata - reiser4-specific data attached to dentries @@ -16215,22 +16497,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + * Currently it only contains cached location (hint) of directory entry, but + * it is expected that other information will be accumulated here. + */ -+struct reiser4_dentry_fsdata { ++typedef struct reiser4_dentry_fsdata { + /* + * here will go fields filled by ->lookup() to speedup next + * create/unlink, like blocknr of znode with stat-data, or key of + * stat-data. + */ -+ struct de_location dec; ++ de_location dec; + int stateless; /* created through reiser4_decode_fh, needs special + * treatment in readdir. */ -+}; ++} reiser4_dentry_fsdata; + -+extern int reiser4_init_dentry_fsdata(void); -+extern void reiser4_done_dentry_fsdata(void); -+extern struct reiser4_dentry_fsdata *reiser4_get_dentry_fsdata(struct dentry *); ++extern int init_dentry_fsdata(void); ++extern void done_dentry_fsdata(void); ++extern reiser4_dentry_fsdata *reiser4_get_dentry_fsdata(struct dentry *); +extern void reiser4_free_dentry_fsdata(struct dentry *dentry); + ++ +/** + * reiser4_file_fsdata - reiser4-specific data attached to file->private_data + * @@ -16253,7 +16536,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + * position in directory. It is updated each time directory is + * modified + */ -+ struct readdir_pos readdir; ++ readdir_pos readdir; + /* head of this list is reiser4_inode->lists.readdir_list */ + struct list_head linkage; + } dir; @@ -16261,24 +16544,34 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + struct { + hint_t hint; + } reg; ++ /* */ ++ struct { ++ /* this is called by reiser4_readpages if set */ ++ void (*readpages) (struct address_space *, ++ struct list_head * pages, void *data); ++ /* reiser4_readpaextended coord. It is set by read_extent before ++ calling page_cache_readahead */ ++ void *data; ++ } ra2; + struct reiser4_file_ra_state ra1; + +} reiser4_file_fsdata; + -+extern int reiser4_init_file_fsdata(void); -+extern void reiser4_done_file_fsdata(void); ++extern int init_file_fsdata(void); ++extern void done_file_fsdata(void); +extern reiser4_file_fsdata *reiser4_get_file_fsdata(struct file *); +extern void reiser4_free_file_fsdata(struct file *); + ++ +/* + * d_cursor is reiser4_file_fsdata not attached to struct file. d_cursors are + * used to address problem reiser4 has with readdir accesses via NFS. See + * plugin/file_ops_readdir.c for more details. + */ -+struct d_cursor_key{ ++typedef struct { + __u16 cid; + __u64 oid; -+}; ++} d_cursor_key; + +/* + * define structures d_cursor_hash_table d_cursor_hash_link which are used to @@ -16287,6 +16580,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h +typedef struct dir_cursor dir_cursor; +TYPE_SAFE_HASH_DECLARE(d_cursor, dir_cursor); + ++typedef struct d_cursor_info d_cursor_info; ++ +struct dir_cursor { + int ref; + reiser4_file_fsdata *fsdata; @@ -16299,29 +16594,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + * cursors if there are more than one cursor of the same objectid + */ + struct list_head list; -+ struct d_cursor_key key; -+ struct d_cursor_info *info; ++ d_cursor_key key; ++ d_cursor_info *info; + /* list of unused cursors */ + struct list_head alist; +}; + -+extern int reiser4_init_d_cursor(void); -+extern void reiser4_done_d_cursor(void); ++extern int init_d_cursor(void); ++extern void done_d_cursor(void); ++ ++extern int init_super_d_info(struct super_block *); ++extern void done_super_d_info(struct super_block *); + -+extern int reiser4_init_super_d_info(struct super_block *); -+extern void reiser4_done_super_d_info(struct super_block *); ++extern loff_t get_dir_fpos(struct file *); ++extern int try_to_attach_fsdata(struct file *, struct inode *); ++extern void detach_fsdata(struct file *); + -+extern loff_t reiser4_get_dir_fpos(struct file *); -+extern int reiser4_attach_fsdata(struct file *, struct inode *); -+extern void reiser4_detach_fsdata(struct file *); + +/* these are needed for "stateless" readdir. See plugin/file_ops_readdir.c for + more details */ -+void reiser4_dispose_cursors(struct inode *inode); -+void reiser4_load_cursors(struct inode *inode); -+void reiser4_kill_cursors(struct inode *inode); -+void reiser4_adjust_dir_file(struct inode *dir, const struct dentry *de, -+ int offset, int adj); ++void dispose_cursors(struct inode *inode); ++void load_cursors(struct inode *inode); ++void kill_cursors(struct inode *inode); ++void adjust_dir_file(struct inode *dir, const struct dentry *de, int offset, int adj); + +/* + * this structure is embedded to reise4_super_info_data. It maintains d_cursors @@ -16347,10 +16642,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/fsdata.h linux-2.6.22/fs/reiser4/fsdata.h + * fill-column: 120 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init_super.c ---- linux-2.6.22.orig/fs/reiser4/init_super.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/init_super.c 2007-07-29 00:25:34.868694406 +0400 -@@ -0,0 +1,752 @@ +Index: linux-2.6.16/fs/reiser4/init_super.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/init_super.c +@@ -0,0 +1,739 @@ +/* Copyright by Hans Reiser, 2003 */ + +#include "super.h" @@ -16359,6 +16655,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + +#include + ++ +/** + * init_fs_info - allocate reiser4 specific super block + * @super: super block of filesystem @@ -16366,12 +16663,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + * Allocates and initialize reiser4_super_info_data, attaches it to + * super->s_fs_info, initializes structures maintaining d_cursor-s. + */ -+int reiser4_init_fs_info(struct super_block *super) ++int init_fs_info(struct super_block *super) +{ + reiser4_super_info_data *sbinfo; + -+ sbinfo = kmalloc(sizeof(reiser4_super_info_data), -+ reiser4_ctx_gfp_mask_get()); ++ sbinfo = kmalloc(sizeof(reiser4_super_info_data), get_gfp_mask()); + if (!sbinfo) + return RETERR(-ENOMEM); + @@ -16382,33 +16678,34 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + ON_DEBUG(INIT_LIST_HEAD(&sbinfo->all_jnodes)); + ON_DEBUG(spin_lock_init(&sbinfo->all_guard)); + -+ mutex_init(&sbinfo->delete_mutex); ++ sema_init(&sbinfo->delete_sema, 1); ++ sema_init(&sbinfo->flush_sema, 1); + spin_lock_init(&(sbinfo->guard)); + + /* initialize per-super-block d_cursor resources */ -+ reiser4_init_super_d_info(super); ++ init_super_d_info(super); + + return 0; +} + +/** -+ * reiser4_done_fs_info - free reiser4 specific super block ++ * done_fs_info - free reiser4 specific super block + * @super: super block of filesystem + * + * Performs some sanity checks, releases structures maintaining d_cursor-s, + * frees reiser4_super_info_data. + */ -+void reiser4_done_fs_info(struct super_block *super) ++void done_fs_info(struct super_block *super) +{ + assert("zam-990", super->s_fs_info != NULL); + + /* release per-super-block d_cursor resources */ -+ reiser4_done_super_d_info(super); ++ done_super_d_info(super); + + /* make sure that there are not jnodes already */ + assert("", list_empty(&get_super_private(super)->all_jnodes)); + assert("", get_current_context()->trans->atom == NULL); -+ reiser4_check_block_counters(super); ++ check_block_counters(super); + kfree(super->s_fs_info); + super->s_fs_info = NULL; +} @@ -16438,15 +16735,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + OPT_ONEOF, +} opt_type_t; + -+#if 0 -+struct opt_bitmask_bit { ++typedef struct opt_bitmask_bit { + const char *bit_name; + int bit_nr; -+}; -+#endif ++} opt_bitmask_bit; + +/* description of option parseable by parse_option() */ -+struct opt_desc { ++typedef struct opt_desc { + /* option name. + + parsed portion of string has a form "name=value". @@ -16479,10 +16774,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + struct { + void *addr; + int nr_bits; -+ //struct opt_bitmask_bit *bits; ++ opt_bitmask_bit *bits; + } bitmask; + } u; -+}; ++} opt_desc_t; + +/** + * parse_option - parse one option @@ -16496,7 +16791,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + * +-- opt_string + * Figures out option type and handles option correspondingly. + */ -+static int parse_option(char *opt_string, struct opt_desc *opt) ++static int parse_option(char *opt_string, opt_desc_t *opt) +{ + char *val_start; + int result; @@ -16581,7 +16876,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + * + * Parses comma separated list of reiser4 mount options. + */ -+static int parse_options(char *opt_string, struct opt_desc *opts, int nr_opts) ++static int parse_options(char *opt_string, opt_desc_t *opts, int nr_opts) +{ + int result; + @@ -16647,17 +16942,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init +#define MAX_NR_OPTIONS (30) + +/** -+ * reiser4_init_super_data - initialize reiser4 private super block ++ * init_super_data - initialize reiser4 private super block + * @super: super block to initialize + * @opt_string: list of reiser4 mount options + * + * Sets various reiser4 parameters to default values. Parses mount options and + * overwrites default settings. + */ -+int reiser4_init_super_data(struct super_block *super, char *opt_string) ++int init_super_data(struct super_block *super, char *opt_string) +{ + int result; -+ struct opt_desc *opts, *p; ++ opt_desc_t *opts, *p; + reiser4_super_info_data *sbinfo = get_super_private(super); + + /* initialize super, export, dentry operations */ @@ -16698,8 +16993,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + sbinfo->ra_params.flags = 0; + + /* allocate memory for structure describing reiser4 mount options */ -+ opts = kmalloc(sizeof(struct opt_desc) * MAX_NR_OPTIONS, -+ reiser4_ctx_gfp_mask_get()); ++ opts = kmalloc(sizeof(opt_desc_t) * MAX_NR_OPTIONS, get_gfp_mask()); + if (opts == NULL) + return RETERR(-ENOMEM); + @@ -16716,9 +17010,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + +#define PUSH_OPT(...) \ +do { \ -+ struct opt_desc o = __VA_ARGS__; \ -+ OPT_ARRAY_CHECK; \ -+ *p ++ = o; \ ++ opt_desc_t o = __VA_ARGS__; \ ++ OPT_ARRAY_CHECK; \ ++ *p ++ = o; \ +} while (0) + +#define PUSH_SB_FIELD_OPT(field, format) PUSH_OPT(SB_FIELD_OPT(field, format)) @@ -16794,6 +17088,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + PUSH_BIT_OPT("bsdgroups", REISER4_BSD_GID); + /* turn on 32 bit times */ + PUSH_BIT_OPT("32bittimes", REISER4_32_BIT_TIMES); ++ /* turn off concurrent flushing */ ++ PUSH_BIT_OPT("mtflush", REISER4_MTFLUSH); + /* + * Don't load all bitmap blocks at mount time, it is useful for + * machines with tiny RAM and large disks. @@ -16864,18 +17160,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + warning("nikita-2497", "optimal_io_size is too small"); + return RETERR(-EINVAL); + } ++ ++ /* disable single-threaded flush as it leads to deadlock */ ++ sbinfo->fs_flags |= (1 << REISER4_MTFLUSH); + return result; +} + +/** -+ * reiser4_init_read_super - read reiser4 master super block ++ * init_read_super - read reiser4 master super block + * @super: super block to fill + * @silent: if 0 - print warnings + * + * Reads reiser4 master super block either from predefined location or from + * location specified by altsuper mount option, initializes disk format plugin. + */ -+int reiser4_init_read_super(struct super_block *super, int silent) ++int init_read_super(struct super_block *super, int silent) +{ + struct buffer_head *super_bh; + struct reiser4_master_sb *master_sb; @@ -17004,33 +17303,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + }, + [PSET_COMPRESSION_MODE] = { + .type = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, -+ .id = CONVX_COMPRESSION_MODE_ID ++ .id = COL_16_COMPRESSION_MODE_ID + }, + [PSET_CLUSTER] = { + .type = REISER4_CLUSTER_PLUGIN_TYPE, + .id = CLUSTER_64K_ID + }, -+ [PSET_CREATE] = { -+ .type = REISER4_FILE_PLUGIN_TYPE, -+ .id = UNIX_FILE_PLUGIN_ID ++ [PSET_REGULAR_ENTRY] = { ++ .type = REISER4_REGULAR_PLUGIN_TYPE, ++ .id = UF_REGULAR_ID + } +}; + +/* access to default plugin table */ -+reiser4_plugin *get_default_plugin(pset_member memb) ++static reiser4_plugin *get_default_plugin(pset_member memb) +{ + return plugin_by_id(default_plugins[memb].type, + default_plugins[memb].id); +} + +/** -+ * reiser4_init_root_inode - obtain inode of root directory ++ * init_root_inode - obtain inode of root directory + * @super: super block of filesystem + * + * Obtains inode of root directory (reading it from disk), initializes plugin + * set it was not initialized. + */ -+int reiser4_init_root_inode(struct super_block *super) ++int init_root_inode(struct super_block *super) +{ + reiser4_super_info_data *sbinfo = get_super_private(super); + struct inode *inode; @@ -17050,46 +17349,30 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + + if (!is_inode_loaded(inode)) { + pset_member memb; -+ plugin_set *pset; + -+ pset = reiser4_inode_data(inode)->pset; + for (memb = 0; memb < PSET_LAST; ++memb) { ++ reiser4_plugin *plug; + -+ if (aset_get(pset, memb) != NULL) -+ continue; -+ -+ result = grab_plugin_pset(inode, NULL, memb); ++ plug = get_default_plugin(memb); ++ result = grab_plugin_from(inode, memb, plug); + if (result != 0) + break; -+ -+ reiser4_inode_clr_flag(inode, REISER4_SDLEN_KNOWN); + } + + if (result == 0) { + if (REISER4_DEBUG) { ++ plugin_set *pset; ++ ++ pset = reiser4_inode_data(inode)->pset; + for (memb = 0; memb < PSET_LAST; ++memb) + assert("nikita-3500", -+ aset_get(pset, memb) != NULL); ++ pset_get(pset, memb) != NULL); + } + } else + warning("nikita-3448", "Cannot set plugins of root: %i", + result); + reiser4_iget_complete(inode); -+ -+ /* As the default pset kept in the root dir may has been changed -+ (length is unknown), call update_sd. */ -+ if (!reiser4_inode_get_flag(inode, REISER4_SDLEN_KNOWN)) { -+ result = reiser4_grab_space( -+ inode_file_plugin(inode)->estimate.update(inode), -+ BA_CAN_COMMIT); -+ -+ if (result == 0) -+ result = reiser4_update_sd(inode); -+ -+ all_grabbed2free(); -+ } + } -+ + super->s_maxbytes = MAX_LFS_FILESIZE; + return result; +} @@ -17103,10 +17386,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/init_super.c linux-2.6.22/fs/reiser4/init + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c ---- linux-2.6.22.orig/fs/reiser4/inode.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/inode.c 2007-07-29 00:25:34.872695441 +0400 -@@ -0,0 +1,709 @@ +Index: linux-2.6.16/fs/reiser4/inode.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/inode.c +@@ -0,0 +1,727 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Inode specific operations. */ @@ -17132,11 +17416,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + +/* return reiser4 internal tree which inode belongs to */ +/* Audited by: green(2002.06.17) */ -+reiser4_tree *reiser4_tree_by_inode(const struct inode *inode /* inode queried */ ) ++reiser4_tree *tree_by_inode(const struct inode *inode /* inode queried */ ) +{ + assert("nikita-256", inode != NULL); + assert("nikita-257", inode->i_sb != NULL); -+ return reiser4_get_tree(inode->i_sb); ++ return get_tree(inode->i_sb); +} + +/* return reiser4-specific inode flags */ @@ -17147,22 +17431,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c +} + +/* set reiser4-specific flag @f in @inode */ -+void reiser4_inode_set_flag(struct inode *inode, reiser4_file_plugin_flags f) ++void inode_set_flag(struct inode *inode, reiser4_file_plugin_flags f) +{ + assert("nikita-2248", inode != NULL); + set_bit((int)f, inode_flags(inode)); +} + +/* clear reiser4-specific flag @f in @inode */ -+void reiser4_inode_clr_flag(struct inode *inode, reiser4_file_plugin_flags f) ++void inode_clr_flag(struct inode *inode, reiser4_file_plugin_flags f) +{ + assert("nikita-2250", inode != NULL); + clear_bit((int)f, inode_flags(inode)); +} + +/* true if reiser4-specific flag @f is set in @inode */ -+int reiser4_inode_get_flag(const struct inode *inode, -+ reiser4_file_plugin_flags f) ++int inode_get_flag(const struct inode *inode, reiser4_file_plugin_flags f) +{ + assert("nikita-2251", inode != NULL); + return test_bit((int)f, inode_flags(inode)); @@ -17288,7 +17571,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + case S_IFREG: + assert("vs-46", fplug != NULL); + assert("vs-43", (fplug->h.id == UNIX_FILE_PLUGIN_ID || -+ fplug->h.id == CRYPTCOMPRESS_FILE_PLUGIN_ID)); ++ fplug->h.id == CRC_FILE_PLUGIN_ID)); + inode->i_op = &file_plugins[fplug->h.id].inode_ops; + inode->i_fop = &file_plugins[fplug->h.id].file_ops; + inode->i_mapping->a_ops = &file_plugins[fplug->h.id].as_ops; @@ -17303,8 +17586,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + return 0; +} + -+/* Initialize inode from disk data. Called with inode locked. -+ Return inode locked. */ ++/* initialize inode from disk data. Called with inode locked. ++ Return inode locked. */ +static int init_inode(struct inode *inode /* inode to intialise */ , + coord_t * coord /* coord of stat data */ ) +{ @@ -17334,12 +17617,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + state = reiser4_inode_data(inode); + /* call stat-data plugin method to load sd content into inode */ + result = iplug->s.sd.init_inode(inode, body, length); -+ set_plugin(&state->pset, PSET_SD, item_plugin_to_plugin(iplug)); ++ plugin_set_sd(&state->pset, iplug); + if (result == 0) { + result = setup_inode_ops(inode, NULL); -+ if (result == 0 && inode->i_sb->s_root && -+ inode->i_sb->s_root->d_inode) -+ result = finish_pset(inode); ++ if (result == 0 && ++ inode->i_sb->s_root && inode->i_sb->s_root->d_inode) { ++ struct inode *root; ++ pset_member ind; ++ ++ /* take missing plugins from file-system defaults */ ++ root = inode->i_sb->s_root->d_inode; ++ /* file and directory plugins are already initialized. */ ++ for (ind = PSET_DIR + 1; ind < PSET_LAST; ++ind) { ++ result = grab_plugin(inode, root, ind); ++ if (result != 0) ++ break; ++ } ++ if (result != 0) { ++ warning("nikita-3447", ++ "Cannot set up plugins for %lli", ++ (unsigned long long) ++ get_inode_oid(inode)); ++ } ++ } + } + zrelse(coord->node); + return result; @@ -17376,7 +17676,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + if (result == 0) { + /* initialize stat-data seal */ + spin_lock_inode(inode); -+ reiser4_seal_init(&info->sd_seal, &coord, key); ++ seal_init(&info->sd_seal, &coord, key); + info->sd_coord = coord; + spin_unlock_inode(inode); + @@ -17388,7 +17688,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + 0); + /* load detached directory cursors for stateless + * directory readers (NFS). */ -+ reiser4_load_cursors(inode); ++ load_cursors(inode); + + /* Check the opened inode for consistency. */ + result = @@ -17462,29 +17762,35 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c +/* hook for kmem_cache_create */ +void loading_init_once(reiser4_inode * info) +{ -+ mutex_init(&info->loading); ++ sema_init(&info->loading, 1); +} + +/* for reiser4_alloc_inode */ +void loading_alloc(reiser4_inode * info) +{ -+ assert("vs-1717", !mutex_is_locked(&info->loading)); ++#if REISER4_DEBUG ++ assert("vs-1717", down_trylock(&info->loading) == 0); ++ up(&info->loading); ++#endif +} + +/* for reiser4_destroy */ +void loading_destroy(reiser4_inode * info) +{ -+ assert("vs-1717a", !mutex_is_locked(&info->loading)); ++#if REISER4_DEBUG ++ assert("vs-1717", down_trylock(&info->loading) == 0); ++ up(&info->loading); ++#endif +} + -+static void loading_begin(reiser4_inode * info) ++static void loading_down(reiser4_inode * info) +{ -+ mutex_lock(&info->loading); ++ down(&info->loading); +} + -+static void loading_end(reiser4_inode * info) ++static void loading_up(reiser4_inode * info) +{ -+ mutex_unlock(&info->loading); ++ up(&info->loading); +} + +/** @@ -17494,7 +17800,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + * @silent: + * + * This is our helper function a la iget(). This is be called by -+ * lookup_common() and reiser4_read_super(). Return inode locked or error ++ * reiser4_lookup() and reiser4_read_super(). Return inode locked or error + * encountered. + */ +struct inode *reiser4_iget(struct super_block *super, const reiser4_key *key, @@ -17519,7 +17825,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + return ERR_PTR(RETERR(-ENOMEM)); + if (is_bad_inode(inode)) { + warning("nikita-304", "Bad inode found"); -+ reiser4_print_key("key", key); ++ print_key("key", key); + iput(inode); + return ERR_PTR(RETERR(-EIO)); + } @@ -17533,7 +17839,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + is the reiser4 repacker, see repacker-related functions in + plugin/item/extent.c */ + if (!is_inode_loaded(inode)) { -+ loading_begin(info); ++ loading_down(info); + if (!is_inode_loaded(inode)) { + /* locking: iget5_locked returns locked inode */ + assert("nikita-1941", !is_inode_loaded(inode)); @@ -17545,7 +17851,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + read_inode() to read stat data from the disk */ + result = read_inode(inode, key, silent); + } else -+ loading_end(info); ++ loading_up(info); + } + + if (inode->i_state & I_NEW) @@ -17553,7 +17859,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + + if (is_bad_inode(inode)) { + assert("vs-1717", result != 0); -+ loading_end(info); ++ loading_up(info); + iput(inode); + inode = ERR_PTR(result); + } else if (REISER4_DEBUG) { @@ -17563,8 +17869,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + build_sd_key(inode, &found_key); + if (!keyeq(&found_key, key)) { + warning("nikita-305", "Wrong key in sd"); -+ reiser4_print_key("sought for", key); -+ reiser4_print_key("found", &found_key); ++ print_key("sought for", key); ++ print_key("found", &found_key); + } + if (inode->i_nlink == 0) { + warning("nikita-3559", "Unlinked inode found: %llu\n", @@ -17581,8 +17887,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + assert("zam-988", is_reiser4_inode(inode)); + + if (!is_inode_loaded(inode)) { -+ reiser4_inode_set_flag(inode, REISER4_LOADED); -+ loading_end(reiser4_inode_data(inode)); ++ inode_set_flag(inode, REISER4_LOADED); ++ loading_up(reiser4_inode_data(inode)); + } +} + @@ -17591,7 +17897,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + assert("nikita-1934", inode != NULL); + + /* clear LOADED bit */ -+ reiser4_inode_clr_flag(inode, REISER4_LOADED); ++ inode_clr_flag(inode, REISER4_LOADED); + make_bad_inode(inode); + return; +} @@ -17608,6 +17914,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + return reiser4_inode_data(inode)->pset->dir; +} + ++#if 0 ++perm_plugin *inode_perm_plugin(const struct inode * inode) ++{ ++ assert("nikita-1999", inode != NULL); ++ return reiser4_inode_data(inode)->pset->perm; ++} ++#endif /* 0 */ ++ +formatting_plugin *inode_formatting_plugin(const struct inode * inode) +{ + assert("nikita-2000", inode != NULL); @@ -17651,10 +17965,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + return reiser4_inode_data(inode)->pset->cluster; +} + -+file_plugin *inode_create_plugin(const struct inode * inode) ++regular_plugin *inode_regular_plugin(const struct inode * inode) +{ + assert("edward-1329", inode != NULL); -+ return reiser4_inode_data(inode)->pset->create; ++ return reiser4_inode_data(inode)->pset->regular_entry; +} + +digest_plugin *inode_digest_plugin(const struct inode * inode) @@ -17675,12 +17989,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + return reiser4_inode_data(inode)->pset->dir_item; +} + -+file_plugin *child_create_plugin(const struct inode * inode) -+{ -+ assert("edward-1329", inode != NULL); -+ return reiser4_inode_data(inode)->hset->create; -+} -+ +void inode_set_extension(struct inode *inode, sd_ext_bits ext) +{ + reiser4_inode *state; @@ -17693,29 +18001,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + state->extmask |= 1 << ext; + /* force re-calculation of stat-data length on next call to + update_sd(). */ -+ reiser4_inode_clr_flag(inode, REISER4_SDLEN_KNOWN); ++ inode_clr_flag(inode, REISER4_SDLEN_KNOWN); +} + -+void inode_clr_extension(struct inode *inode, sd_ext_bits ext) ++void ++inode_set_plugin(struct inode *inode, reiser4_plugin * plug, pset_member memb) +{ -+ reiser4_inode *state; -+ -+ assert("vpf-1926", inode != NULL); -+ assert("vpf-1927", ext < LAST_SD_EXTENSION); -+ assert("vpf-1928", spin_inode_is_locked(inode)); ++ assert("nikita-2718", inode != NULL); ++ assert("nikita-2719", plug != NULL); + -+ state = reiser4_inode_data(inode); -+ state->extmask &= ~(1 << ext); -+ /* force re-calculation of stat-data length on next call to -+ update_sd(). */ -+ reiser4_inode_clr_flag(inode, REISER4_SDLEN_KNOWN); ++ reiser4_inode_data(inode)->plugin_mask |= (1 << memb); +} + +void inode_check_scale_nolock(struct inode *inode, __u64 old, __u64 new) +{ + assert("edward-1287", inode != NULL); + if (!dscale_fit(old, new)) -+ reiser4_inode_clr_flag(inode, REISER4_SDLEN_KNOWN); ++ inode_clr_flag(inode, REISER4_SDLEN_KNOWN); + return; +} + @@ -17768,7 +18070,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + blk = reiser4_inode_data(inode)->vroot; + spin_unlock_inode(inode); + if (!disk_addr_eq(&UBER_TREE_ADDR, &blk)) -+ result = zlook(reiser4_tree_by_inode(inode), &blk); ++ result = zlook(tree_by_inode(inode), &blk); + else + result = NULL; + return result; @@ -17783,7 +18085,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + +#if REISER4_DEBUG + -+void reiser4_inode_invariant(const struct inode *inode) ++void inode_invariant(const struct inode *inode) +{ + assert("nikita-3077", spin_inode_is_locked(inode)); +} @@ -17816,10 +18118,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.c linux-2.6.22/fs/reiser4/inode.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h ---- linux-2.6.22.orig/fs/reiser4/inode.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/inode.h 2007-07-29 00:25:34.872695441 +0400 -@@ -0,0 +1,449 @@ +Index: linux-2.6.16/fs/reiser4/inode.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/inode.h +@@ -0,0 +1,430 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Inode functions. */ @@ -17863,7 +18166,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + REISER4_IMMUTABLE = 2, + /* inode was read from storage */ + REISER4_LOADED = 3, -+ /* this bit is set for symlinks. inode->i_private points to target ++ /* this bit is set for symlinks. inode->u.generic_ip points to target + name of symlink. */ + REISER4_GENERIC_PTR_USED = 4, + /* set if size of stat-data item for this inode is known. If this is @@ -17879,10 +18182,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + * kill-hook of tail items. It is never cleared once set. This bit is + * modified and inspected under i_mutex. */ + REISER4_HAS_MMAP = 8, ++ + REISER4_PART_MIXED = 9, -+ REISER4_PART_IN_CONV = 10, -+ /* This flag indicates that file plugin conversion is in progress */ -+ REISER4_FILE_CONV_IN_PROGRESS = 11 ++ REISER4_PART_IN_CONV = 10 +} reiser4_file_plugin_flags; + +/* state associated with each inode. @@ -17922,11 +18224,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h +struct reiser4_inode { + /* spin lock protecting fields of this structure. */ + spinlock_t guard; -+ /* main plugin set that control the file -+ (see comments in plugin/plugin_set.c) */ ++ /* object plugins */ + plugin_set *pset; -+ /* plugin set for inheritance -+ (see comments in plugin/plugin_set.c) */ ++ /* plugins set for inheritance */ + plugin_set *hset; + /* high 32 bits of object id */ + oid_hi_t oid_hi; @@ -17943,8 +18243,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + __u64 extmask; + /* bitmask of non-default plugins for this inode */ + __u16 plugin_mask; -+ /* bitmask of set heir plugins for this inode. */ -+ __u16 heir_mask; + union { + struct list_head readdir_list; + struct list_head not_used; @@ -17953,16 +18251,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + unsigned long flags; + union { + /* fields specific to unix_file plugin */ -+ struct unix_file_info unix_file_info; -+ /* fields specific to cryptcompress file plugin */ -+ struct cryptcompress_info cryptcompress_info; ++ unix_file_info_t unix_file_info; ++ /* fields specific to cryptcompress plugin */ ++ cryptcompress_info_t cryptcompress_info; + } file_plugin_data; + -+ /* this semaphore is to serialize readers and writers of @pset->file -+ * when file plugin conversion is enabled -+ */ -+ struct rw_semaphore conv_sem; -+ + /* tree of jnodes. Phantom jnodes (ones not attched to any atom) are + tagged in that tree by EFLUSH_TAG_ANONYMOUS */ + struct radix_tree_root jnodes_tree; @@ -17974,33 +18267,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + /* block number of virtual root for this object. See comment above + * fs/reiser4/search.c:handle_vroot() */ + reiser4_block_nr vroot; -+ struct mutex loading; ++ struct semaphore loading; +}; + +void loading_init_once(reiser4_inode *); +void loading_alloc(reiser4_inode *); +void loading_destroy(reiser4_inode *); + -+struct reiser4_inode_object { ++typedef struct reiser4_inode_object { + /* private part */ + reiser4_inode p; + /* generic fields not specific to reiser4, but used by VFS */ + struct inode vfs_inode; -+}; ++} reiser4_inode_object; + +/* return pointer to the reiser4 specific portion of @inode */ +static inline reiser4_inode *reiser4_inode_data(const struct inode *inode + /* inode queried */ ) +{ + assert("nikita-254", inode != NULL); -+ return &container_of(inode, struct reiser4_inode_object, vfs_inode)->p; ++ return &container_of(inode, reiser4_inode_object, vfs_inode)->p; +} + +static inline struct inode *inode_by_reiser4_inode(const reiser4_inode * + r4_inode /* inode queried */ + ) +{ -+ return &container_of(r4_inode, struct reiser4_inode_object, p)->vfs_inode; ++ return &container_of(r4_inode, reiser4_inode_object, p)->vfs_inode; +} + +/* @@ -18073,23 +18366,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h +#endif + +/* return inode in which @uf_info is embedded */ -+static inline struct inode * -+unix_file_info_to_inode(const struct unix_file_info * uf_info) ++static inline struct inode *unix_file_info_to_inode(const unix_file_info_t * ++ uf_info) +{ -+ return &container_of(uf_info, struct reiser4_inode_object, ++ return &container_of(uf_info, reiser4_inode_object, + p.file_plugin_data.unix_file_info)->vfs_inode; +} + ++ +extern ino_t oid_to_ino(oid_t oid) __attribute__ ((const)); +extern ino_t oid_to_uino(oid_t oid) __attribute__ ((const)); + -+extern reiser4_tree *reiser4_tree_by_inode(const struct inode *inode); ++extern reiser4_tree *tree_by_inode(const struct inode *inode); + +#if REISER4_DEBUG -+extern void reiser4_inode_invariant(const struct inode *inode); ++extern void inode_invariant(const struct inode *inode); +extern int inode_has_no_jnodes(reiser4_inode *); +#else -+#define reiser4_inode_invariant(inode) noop ++#define inode_invariant(inode) noop +#endif + +static inline int spin_inode_is_locked(const struct inode *inode) @@ -18117,7 +18411,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + LOCK_CNT_INC(spin_locked_inode); + LOCK_CNT_INC(spin_locked); + -+ reiser4_inode_invariant(inode); ++ inode_invariant(inode); +} + +/** @@ -18133,7 +18427,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + assert("nikita-1375", LOCK_CNT_GTZ(spin_locked_inode)); + assert("nikita-1376", LOCK_CNT_GTZ(spin_locked)); + -+ reiser4_inode_invariant(inode); ++ inode_invariant(inode); + + LOCK_CNT_DEC(spin_locked_inode); + LOCK_CNT_DEC(spin_locked); @@ -18141,6 +18435,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + spin_unlock(&reiser4_inode_data(inode)->guard); +} + ++ +extern znode *inode_get_vroot(struct inode *inode); +extern void inode_set_vroot(struct inode *inode, znode * vroot); + @@ -18152,17 +18447,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h +extern struct inode *reiser4_iget(struct super_block *super, + const reiser4_key * key, int silent); +extern void reiser4_iget_complete(struct inode *inode); -+extern void reiser4_inode_set_flag(struct inode *inode, reiser4_file_plugin_flags f); -+extern void reiser4_inode_clr_flag(struct inode *inode, reiser4_file_plugin_flags f); -+extern int reiser4_inode_get_flag(const struct inode *inode, -+ reiser4_file_plugin_flags f); ++extern void inode_set_flag(struct inode *inode, reiser4_file_plugin_flags f); ++extern void inode_clr_flag(struct inode *inode, reiser4_file_plugin_flags f); ++extern int inode_get_flag(const struct inode *inode, ++ reiser4_file_plugin_flags f); + +/* has inode been initialized? */ +static inline int +is_inode_loaded(const struct inode *inode /* inode queried */ ) +{ + assert("nikita-1120", inode != NULL); -+ return reiser4_inode_get_flag(inode, REISER4_LOADED); ++ return inode_get_flag(inode, REISER4_LOADED); +} + +extern file_plugin *inode_file_plugin(const struct inode *inode); @@ -18176,29 +18471,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h +extern compression_mode_plugin *inode_compression_mode_plugin(const struct inode + *inode); +extern cluster_plugin *inode_cluster_plugin(const struct inode *inode); -+extern file_plugin *inode_create_plugin(const struct inode *inode); ++extern regular_plugin *inode_regular_plugin(const struct inode *inode); +extern item_plugin *inode_sd_plugin(const struct inode *inode); +extern item_plugin *inode_dir_item_plugin(const struct inode *inode); -+extern file_plugin *child_create_plugin(const struct inode *inode); + ++extern void inode_set_plugin(struct inode *inode, ++ reiser4_plugin * plug, pset_member memb); +extern void reiser4_make_bad_inode(struct inode *inode); + +extern void inode_set_extension(struct inode *inode, sd_ext_bits ext); -+extern void inode_clr_extension(struct inode *inode, sd_ext_bits ext); +extern void inode_check_scale(struct inode *inode, __u64 old, __u64 new); +extern void inode_check_scale_nolock(struct inode * inode, __u64 old, __u64 new); + -+#define INODE_SET_SIZE(i, value) \ -+({ \ -+ struct inode *__i; \ -+ typeof(value) __v; \ -+ \ -+ __i = (i); \ -+ __v = (value); \ -+ inode_check_scale(__i, __i->i_size, __v); \ -+ i_size_write(__i, __v); \ -+}) -+ +/* + * update field @field in inode @i to contain value @value. + */ @@ -18231,7 +18515,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + -- __i->field; \ +}) + -+/* See comment before reiser4_readdir_common() for description. */ ++/* See comment before readdir_common() for description. */ +static inline struct list_head *get_readdir_list(const struct inode *inode) +{ + return &reiser4_inode_data(inode)->lists.readdir_list; @@ -18269,9 +18553,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/inode.h linux-2.6.22/fs/reiser4/inode.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/ioctl.h linux-2.6.22/fs/reiser4/ioctl.h ---- linux-2.6.22.orig/fs/reiser4/ioctl.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/ioctl.h 2007-07-29 00:25:34.872695441 +0400 +Index: linux-2.6.16/fs/reiser4/ioctl.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/ioctl.h @@ -0,0 +1,41 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -18314,10 +18599,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ioctl.h linux-2.6.22/fs/reiser4/ioctl.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c ---- linux-2.6.22.orig/fs/reiser4/jnode.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/jnode.c 2007-07-29 00:25:34.876696477 +0400 -@@ -0,0 +1,1924 @@ +Index: linux-2.6.16/fs/reiser4/jnode.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/jnode.c +@@ -0,0 +1,1921 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ +/* Jnode manipulation functions. */ @@ -18439,11 +18725,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +#include +#include +#include ++#include /* for vmalloc(), vfree() */ +#include +#include /* for struct address_space */ +#include /* for inode_lock */ + -+static struct kmem_cache *_jnode_slab = NULL; ++static kmem_cache_t *_jnode_slab = NULL; + +static void jnode_set_type(jnode * node, jnode_type type); +static int jdelete(jnode * node); @@ -18462,8 +18749,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +/* hash table support */ + +/* compare two jnode keys for equality. Used by hash-table macros */ -+static inline int jnode_key_eq(const struct jnode_key * k1, -+ const struct jnode_key * k2) ++static inline int jnode_key_eq(const jnode_key_t * k1, const jnode_key_t * k2) +{ + assert("nikita-2350", k1 != NULL); + assert("nikita-2351", k2 != NULL); @@ -18472,8 +18758,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +} + +/* Hash jnode by its key (inode plus offset). Used by hash-table macros */ -+static inline __u32 jnode_key_hashfn(j_hash_table * table, -+ const struct jnode_key * key) ++static inline __u32 ++jnode_key_hashfn(j_hash_table * table, const jnode_key_t * key) +{ + assert("nikita-2352", key != NULL); + assert("nikita-3346", IS_POW(table->_buckets)); @@ -18483,10 +18769,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +} + +/* The hash table definition */ -+#define KMALLOC(size) reiser4_vmalloc(size) ++#define KMALLOC(size) vmalloc(size) +#define KFREE(ptr, size) vfree(ptr) -+TYPE_SAFE_HASH_DEFINE(j, jnode, struct jnode_key, key.j, link.j, -+ jnode_key_hashfn, jnode_key_eq); ++TYPE_SAFE_HASH_DEFINE(j, jnode, jnode_key_t, key.j, link.j, jnode_key_hashfn, ++ jnode_key_eq); +#undef KFREE +#undef KMALLOC + @@ -18611,7 +18897,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +/* exported functions to allocate/free jnode objects outside this file */ +jnode *jalloc(void) +{ -+ jnode *jal = kmem_cache_alloc(_jnode_slab, reiser4_ctx_gfp_mask_get()); ++ jnode *jal = kmem_cache_alloc(_jnode_slab, get_gfp_mask()); + return jal; +} + @@ -18691,7 +18977,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +/* look for jnode with given mapping and offset within hash table */ +jnode *jlookup(reiser4_tree * tree, oid_t objectid, unsigned long index) +{ -+ struct jnode_key jkey; ++ jnode_key_t jkey; + jnode *node; + + assert("nikita-2353", tree != NULL); @@ -18730,7 +19016,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + jnode *node; + + assert("vs-1694", mapping->host != NULL); -+ tree = reiser4_tree_by_inode(mapping->host); ++ tree = tree_by_inode(mapping->host); + + read_lock_tree(tree); + node = jfind_nolock(mapping, index); @@ -18842,7 +19128,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + +/* remove jnode from hash table and from inode's tree of jnodes. This is used in + reiser4_invalidatepage and in kill_hook_extent -> truncate_inode_jnodes -> -+ reiser4_uncapture_jnode */ ++ uncapture_jnode */ +void unhash_unformatted_jnode(jnode * node) +{ + assert("vs-1445", jnode_is_unformatted(node)); @@ -18857,9 +19143,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + * allocate new jnode, insert it, and also insert into radix tree for the + * given inode/mapping. + */ -+static jnode *find_get_jnode(reiser4_tree * tree, -+ struct address_space *mapping, -+ oid_t oid, unsigned long index) ++jnode *find_get_jnode(reiser4_tree * tree, struct address_space *mapping, ++ oid_t oid, unsigned long index) +{ + jnode *result; + jnode *shadow; @@ -18870,7 +19155,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + if (unlikely(result == NULL)) + return ERR_PTR(RETERR(-ENOMEM)); + -+ preload = radix_tree_preload(reiser4_ctx_gfp_mask_get()); ++ preload = radix_tree_preload(get_gfp_mask()); + if (preload != 0) + return ERR_PTR(preload); + @@ -18923,7 +19208,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + if (likely(result != NULL)) + return jref(result); + -+ tree = reiser4_tree_by_page(pg); ++ tree = tree_by_page(pg); + + /* check hash-table first */ + result = jfind(pg->mapping, pg->index); @@ -18935,8 +19220,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + return result; + } + -+ /* since page is locked, jnode should be allocated with GFP_NOFS flag */ -+ reiser4_ctx_gfp_mask_force(GFP_NOFS); + result = find_get_jnode(tree, pg->mapping, oid, pg->index); + if (unlikely(IS_ERR(result))) + return result; @@ -18957,7 +19240,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + assert("umka-176", pg != NULL); + assert("nikita-2394", PageLocked(pg)); + -+ result = do_jget(reiser4_tree_by_page(pg), pg); ++ result = do_jget(tree_by_page(pg), pg); + + if (REISER4_DEBUG && !IS_ERR(result)) { + assert("nikita-3210", result == jprivate(pg)); @@ -19019,7 +19302,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + page_cache_release(page); +} + -+#if 0 +/* it is only used in one place to handle error */ +void +page_detach_jnode(struct page *page, struct address_space *mapping, @@ -19039,7 +19321,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + } + unlock_page(page); +} -+#endif /* 0 */ + +/* return @node page locked. + @@ -19111,7 +19392,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + +/* Lock a page attached to jnode, create and attach page to jnode if it had no + * one. */ -+static struct page *jnode_get_page_locked(jnode * node, gfp_t gfp_flags) ++struct page *jnode_get_page_locked(jnode * node, gfp_t gfp_flags) +{ + struct page *page; + @@ -19154,7 +19435,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + unlock_page(page); + return 0; + } -+ return reiser4_page_io(page, node, READ, reiser4_ctx_gfp_mask_get()); ++ return page_io(page, node, READ, get_gfp_mask()); +} + +#if REISER4_DEBUG @@ -19197,7 +19478,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + int result = 0; + int parsed; + -+ assert("nikita-3010", reiser4_schedulable()); ++ assert("nikita-3010", schedulable()); + + prefetchw(&node->pg); + @@ -19271,7 +19552,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +{ + struct page *page; + -+ page = jnode_get_page_locked(node, reiser4_ctx_gfp_mask_get()); ++ page = jnode_get_page_locked(node, get_gfp_mask()); + if (IS_ERR(page)) + return PTR_ERR(page); + @@ -19387,6 +19668,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + rcu_read_unlock(); + return; + } ++ assert("edward-1432", node->page_count == 0); ++ + r_i_p = !JF_TEST_AND_SET(node, JNODE_RIP); + /* + * if r_i_p is true, we were first to set JNODE_RIP on this node. In @@ -19506,7 +19789,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c +static struct address_space *mapping_znode(const jnode * node) +{ + /* all znodes belong to fake inode */ -+ return reiser4_get_super_fake(jnode_get_tree(node)->super)->i_mapping; ++ return get_super_fake(jnode_get_tree(node)->super)->i_mapping; +} + +/* ->index() method for znodes */ @@ -19662,7 +19945,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + znode *clone; + + assert("vs-1430", jnode_is_znode(node)); -+ clone = zalloc(reiser4_ctx_gfp_mask_get()); ++ clone = zalloc(get_gfp_mask()); + if (clone == NULL) + return ERR_PTR(RETERR(-ENOMEM)); + zinit(clone, NULL, current_tree); @@ -19972,7 +20255,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + jnode_free(node, jtype); + /* @node is no longer valid pointer */ + if (page != NULL) -+ reiser4_drop_page(page); ++ drop_page(page); + } else { + /* busy check failed: reference was acquired by concurrent + * thread. */ @@ -20028,7 +20311,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + write_unlock_tree(tree); + jnode_free(node, jtype); + if (page != NULL) { -+ reiser4_drop_page(page); ++ drop_page(page); + } + } else { + /* busy check failed: reference was acquired by concurrent @@ -20053,7 +20336,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + functionality (these j-nodes are not in any hash table) just for reading + from and writing to disk. */ + -+jnode *reiser4_alloc_io_head(const reiser4_block_nr * block) ++jnode *alloc_io_head(const reiser4_block_nr * block) +{ + jnode *jal = jalloc(); + @@ -20067,7 +20350,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + return jal; +} + -+void reiser4_drop_io_head(jnode * node) ++void drop_io_head(jnode * node) +{ + assert("zam-648", jnode_get_type(node) == JNODE_IO_HEAD); + @@ -20175,7 +20458,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + ("%s: %p: state: %lx: [%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s], level: %i," + " block: %s, d_count: %d, x_count: %d, " + "pg: %p, atom: %p, lock: %i:%i, type: %s, ", prefix, node, -+ node->state, ++ node->state, + jnode_state_name(node, JNODE_PARSED), + jnode_state_name(node, JNODE_HEARD_BANSHEE), + jnode_state_name(node, JNODE_LEFT_CONNECTED), @@ -20242,10 +20525,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.c linux-2.6.22/fs/reiser4/jnode.c + fill-column: 80 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h ---- linux-2.6.22.orig/fs/reiser4/jnode.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/jnode.h 2007-07-29 00:25:34.876696477 +0400 -@@ -0,0 +1,702 @@ +Index: linux-2.6.16/fs/reiser4/jnode.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/jnode.h +@@ -0,0 +1,711 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -20260,7 +20544,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h +#include "key.h" +#include "debug.h" +#include "dformat.h" -+#include "page_cache.h" +#include "context.h" + +#include "plugin/plugin.h" @@ -20280,11 +20563,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h +/* declare hash table of znodes */ +TYPE_SAFE_HASH_DECLARE(z, znode); + -+struct jnode_key { ++typedef struct { + __u64 objectid; + unsigned long index; + struct address_space *mapping; -+}; ++} jnode_key_t; + +/* + Jnode is the "base class" of other nodes in reiser4. It is also happens to @@ -20374,7 +20657,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + /* znodes are hashed by block number */ + reiser4_block_nr z; + /* unformatted nodes are hashed by mapping plus offset */ -+ struct jnode_key j; ++ jnode_key_t j; + } key; + + /* THIRD CACHE LINE */ @@ -20418,6 +20701,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + /* 88 */ reiser4_plugin_id parent_item_id; + /* 92 */ +#if REISER4_DEBUG ++ /* number of pages referenced by the jnode (meaningful while capturing of ++ page clusters) */ ++ int page_count; + /* list of all jnodes for debugging purposes. */ + struct list_head jnodes; + /* how many times this jnode was written in one transaction */ @@ -20595,8 +20881,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h +extern jnode *jnode_by_page(struct page *pg) NONNULL; +extern jnode *jnode_of_page(struct page *pg) NONNULL; +void jnode_attach_page(jnode * node, struct page *pg); ++jnode *find_get_jnode(reiser4_tree * tree, ++ struct address_space *mapping, oid_t oid, ++ unsigned long index); + +void unhash_unformatted_jnode(jnode *); ++struct page *jnode_get_page_locked(jnode *, gfp_t gfp_flags); +extern jnode *page_next_jnode(jnode * node) NONNULL; +extern void jnode_init(jnode * node, reiser4_tree * tree, jnode_type) NONNULL; +extern void jnode_make_dirty(jnode * node) NONNULL; @@ -20644,8 +20934,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h +} + +/* Jnode flush interface. */ -+extern reiser4_blocknr_hint *reiser4_pos_hint(flush_pos_t * pos); -+extern flush_queue_t *reiser4_pos_fq(flush_pos_t * pos); ++extern reiser4_blocknr_hint *pos_hint(flush_pos_t * pos); ++extern flush_queue_t *pos_fq(flush_pos_t * pos); + +/* FIXME-VS: these are used in plugin/item/extent.c */ + @@ -20732,6 +21022,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + return atomic_read(&node->d_count) > 0; +} + ++extern void page_detach_jnode(struct page *page, ++ struct address_space *mapping, ++ unsigned long index) NONNULL; +extern void page_clear_jnode(struct page *page, jnode * node) NONNULL; + +static inline void jnode_set_reloc(jnode * node) @@ -20747,7 +21040,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + +static inline int jload(jnode *node) +{ -+ return jload_gfp(node, reiser4_ctx_gfp_mask_get(), 1); ++ return jload_gfp(node, get_gfp_mask(), 1); +} + +extern int jinit_new(jnode *, gfp_t) NONNULL; @@ -20758,8 +21051,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + +void jload_prefetch(jnode *); + -+extern jnode *reiser4_alloc_io_head(const reiser4_block_nr * block) NONNULL; -+extern void reiser4_drop_io_head(jnode * node) NONNULL; ++extern jnode *alloc_io_head(const reiser4_block_nr * block) NONNULL; ++extern void drop_io_head(jnode * node) NONNULL; + +static inline reiser4_tree *jnode_get_tree(const jnode * node) +{ @@ -20901,7 +21194,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h +{ + assert("jmacd-509", node != NULL); + assert("jmacd-510", atomic_read(&node->x_count) > 0); -+ assert("zam-926", reiser4_schedulable()); ++ assert("zam-926", schedulable()); + LOCK_CNT_DEC(x_refs); + + rcu_read_lock(); @@ -20912,7 +21205,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + jput_final(node); + } else + rcu_read_unlock(); -+ assert("nikita-3473", reiser4_schedulable()); ++ assert("nikita-3473", schedulable()); +} + +extern void jrelse(jnode * node); @@ -20948,10 +21241,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/jnode.h linux-2.6.22/fs/reiser4/jnode.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/kassign.c linux-2.6.22/fs/reiser4/kassign.c ---- linux-2.6.22.orig/fs/reiser4/kassign.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/kassign.c 2007-07-29 00:25:34.880697512 +0400 -@@ -0,0 +1,661 @@ +Index: linux-2.6.16/fs/reiser4/kassign.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/kassign.c +@@ -0,0 +1,659 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -21171,7 +21465,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.c linux-2.6.22/fs/reiser4/kassign + + assert("nikita-2863", key != NULL); + if (get_key_type(key) != KEY_FILE_NAME_MINOR) -+ reiser4_print_key("oops", key); ++ print_key("oops", key); + assert("nikita-2864", get_key_type(key) == KEY_FILE_NAME_MINOR); + + if (REISER4_LARGE_KEY) @@ -21216,7 +21510,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.c linux-2.6.22/fs/reiser4/kassign + +/* opposite to pack_string(). Takes value produced by pack_string(), restores + * string encoded in it and stores result in @buf */ -+char * reiser4_unpack_string(__u64 value, char *buf) ++char *unpack_string(__u64 value, char *buf) +{ + do { + *buf = value >> (64 - 8); @@ -21237,13 +21531,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.c linux-2.6.22/fs/reiser4/kassign + + c = buf; + if (REISER4_LARGE_KEY) { -+ c = reiser4_unpack_string(get_key_ordering(key) & -+ ~fibration_mask, c); -+ c = reiser4_unpack_string(get_key_fulloid(key), c); ++ c = unpack_string(get_key_ordering(key) & ~fibration_mask, c); ++ c = unpack_string(get_key_fulloid(key), c); + } else -+ c = reiser4_unpack_string(get_key_fulloid(key) & -+ ~fibration_mask, c); -+ reiser4_unpack_string(get_key_offset(key), c); ++ c = unpack_string(get_key_fulloid(key) & ~fibration_mask, c); ++ unpack_string(get_key_offset(key), c); + return buf; +} + @@ -21613,9 +21905,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.c linux-2.6.22/fs/reiser4/kassign + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/kassign.h linux-2.6.22/fs/reiser4/kassign.h ---- linux-2.6.22.orig/fs/reiser4/kassign.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/kassign.h 2007-07-29 00:25:34.880697512 +0400 +Index: linux-2.6.16/fs/reiser4/kassign.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/kassign.h @@ -0,0 +1,110 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -21711,7 +22004,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.h linux-2.6.22/fs/reiser4/kassign +extern int is_longname_key(const reiser4_key * key); +extern int is_longname(const char *name, int len); +extern char *extract_name_from_key(const reiser4_key * key, char *buf); -+extern char *reiser4_unpack_string(__u64 value, char *buf); ++extern char *unpack_string(__u64 value, char *buf); +extern void complete_entry_key(const struct inode *dir, const char *name, + int len, reiser4_key *result); + @@ -21727,45 +22020,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/kassign.h linux-2.6.22/fs/reiser4/kassign + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/Kconfig linux-2.6.22/fs/reiser4/Kconfig ---- linux-2.6.22.orig/fs/reiser4/Kconfig 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/Kconfig 2007-07-29 00:25:34.880697512 +0400 -@@ -0,0 +1,32 @@ -+config REISER4_FS -+ tristate "Reiser4 (EXPERIMENTAL)" -+ depends on EXPERIMENTAL -+ select ZLIB_INFLATE -+ select ZLIB_DEFLATE -+ select CRYPTO -+ help -+ Reiser4 is a filesystem that performs all filesystem operations -+ as atomic transactions, which means that it either performs a -+ write, or it does not, and in the event of a crash it does not -+ partially perform it or corrupt it. -+ -+ It stores files in dancing trees, which are like balanced trees but -+ faster. It packs small files together so that they share blocks -+ without wasting space. This means you can use it to store really -+ small files. It also means that it saves you disk space. It avoids -+ hassling you with anachronisms like having a maximum number of -+ inodes, and wasting space if you use less than that number. -+ -+ Reiser4 is a distinct filesystem type from reiserfs (V3). -+ It's therefore not possible to use reiserfs file systems -+ with reiser4. -+ -+ To learn more about reiser4, go to http://www.namesys.com -+ -+config REISER4_DEBUG -+ bool "Enable reiser4 debug mode" -+ depends on REISER4_FS -+ help -+ Don't use this unless you are debugging reiser4. -+ -+ If unsure, say N. -diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c ---- linux-2.6.22.orig/fs/reiser4/key.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/key.c 2007-07-29 00:25:34.880697512 +0400 +Index: linux-2.6.16/fs/reiser4/key.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/key.c @@ -0,0 +1,137 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -21808,13 +22066,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c +} + +/* minimal possible key in the tree. Return pointer to the static storage. */ -+const reiser4_key *reiser4_min_key(void) ++const reiser4_key *min_key(void) +{ + return &MINIMAL_KEY; +} + +/* maximum possible key in the tree. Return pointer to the static storage. */ -+const reiser4_key *reiser4_max_key(void) ++const reiser4_key *max_key(void) +{ + return &MAXIMAL_KEY; +} @@ -21840,7 +22098,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c +} + +/* debugging aid: print human readable information about key */ -+void reiser4_print_key(const char *prefix /* prefix to print */ , ++void print_key(const char *prefix /* prefix to print */ , + const reiser4_key * key /* key to print */ ) +{ + /* turn bold on */ @@ -21870,8 +22128,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c + char *c; + + c = buf; -+ c = reiser4_unpack_string(get_key_ordering(key), c); -+ reiser4_unpack_string(get_key_fulloid(key), c); ++ c = unpack_string(get_key_ordering(key), c); ++ unpack_string(get_key_fulloid(key), c); + printk("[%s", buf); + if (is_longname_key(key)) + /* @@ -21882,7 +22140,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c + /* + * whole name is stored in the key. + */ -+ reiser4_unpack_string(get_key_offset(key), buf); ++ unpack_string(get_key_offset(key), buf); + printk("%s]\n", buf); + } + } else { @@ -21904,9 +22162,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.c linux-2.6.22/fs/reiser4/key.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/key.h linux-2.6.22/fs/reiser4/key.h ---- linux-2.6.22.orig/fs/reiser4/key.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/key.h 2007-07-29 00:25:34.884698547 +0400 +Index: linux-2.6.16/fs/reiser4/key.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/key.h @@ -0,0 +1,384 @@ +/* Copyright 2000, 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -22136,8 +22395,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.h linux-2.6.22/fs/reiser4/key.h +void reiser4_key_init(reiser4_key * key); + +/* minimal possible key in the tree. Return pointer to the static storage. */ -+extern const reiser4_key *reiser4_min_key(void); -+extern const reiser4_key *reiser4_max_key(void); ++extern const reiser4_key *min_key(void); ++extern const reiser4_key *max_key(void); + +/* helper macro for keycmp() */ +#define KEY_DIFF(k1, k2, field) \ @@ -22275,9 +22534,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.h linux-2.6.22/fs/reiser4/key.h +#define KEY_BUF_LEN (80) + +#if REISER4_DEBUG -+extern void reiser4_print_key(const char *prefix, const reiser4_key * key); ++extern void print_key(const char *prefix, const reiser4_key * key); +#else -+#define reiser4_print_key(p,k) noop ++#define print_key(p,k) noop +#endif + +/* __FS_REISERFS_KEY_H__ */ @@ -22292,10 +22551,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/key.h linux-2.6.22/fs/reiser4/key.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmgrd.c ---- linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/ktxnmgrd.c 2007-07-29 00:25:34.884698547 +0400 -@@ -0,0 +1,215 @@ +Index: linux-2.6.16/fs/reiser4/ktxnmgrd.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/ktxnmgrd.c +@@ -0,0 +1,214 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* Transaction manager daemon. */ + @@ -22333,7 +22593,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmg +#include +#include +#include -+#include + +static int scan_mgr(struct super_block *); + @@ -22413,13 +22672,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmg +#undef set_comm + +/** -+ * reiser4_init_ktxnmgrd - initialize ktxnmgrd context and start kernel daemon ++ * init_ktxnmgrd - initialize ktxnmgrd context and start kernel daemon + * @super: pointer to super block + * + * Allocates and initializes ktxnmgrd_context, attaches it to transaction + * manager. Starts kernel txnmgr daemon. This is called on mount. + */ -+int reiser4_init_ktxnmgrd(struct super_block *super) ++int init_ktxnmgrd(struct super_block *super) +{ + txn_mgr *mgr; + ktxnmgrd_context *ctx; @@ -22428,7 +22687,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmg + + assert("zam-1014", mgr->daemon == NULL); + -+ ctx = kmalloc(sizeof(ktxnmgrd_context), reiser4_ctx_gfp_mask_get()); ++ ctx = kmalloc(sizeof(ktxnmgrd_context), get_gfp_mask()); + if (ctx == NULL) + return RETERR(-ENOMEM); + @@ -22485,12 +22744,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmg +} + +/** -+ * reiser4_done_ktxnmgrd - stop kernel thread and frees ktxnmgrd context ++ * done_ktxnmgrd - stop kernel thread and frees ktxnmgrd context + * @mgr: + * + * This is called on umount. Stops ktxnmgrd and free t + */ -+void reiser4_done_ktxnmgrd(struct super_block *super) ++void done_ktxnmgrd(struct super_block *super) +{ + txn_mgr *mgr; + @@ -22511,9 +22770,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.c linux-2.6.22/fs/reiser4/ktxnmg + * fill-column: 120 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.h linux-2.6.22/fs/reiser4/ktxnmgrd.h ---- linux-2.6.22.orig/fs/reiser4/ktxnmgrd.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/ktxnmgrd.h 2007-07-29 00:25:34.884698547 +0400 +Index: linux-2.6.16/fs/reiser4/ktxnmgrd.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/ktxnmgrd.h @@ -0,0 +1,52 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -22549,8 +22809,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.h linux-2.6.22/fs/reiser4/ktxnmg + unsigned int rescan:1; +}; + -+extern int reiser4_init_ktxnmgrd(struct super_block *); -+extern void reiser4_done_ktxnmgrd(struct super_block *); ++extern int init_ktxnmgrd(struct super_block *); ++extern void done_ktxnmgrd(struct super_block *); + +extern void ktxnmgrd_kick(txn_mgr * mgr); +extern int is_current_ktxnmgrd(void); @@ -22567,10 +22827,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/ktxnmgrd.h linux-2.6.22/fs/reiser4/ktxnmg + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c ---- linux-2.6.22.orig/fs/reiser4/lock.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/lock.c 2007-07-29 00:25:34.884698547 +0400 -@@ -0,0 +1,1232 @@ +Index: linux-2.6.16/fs/reiser4/lock.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/lock.c +@@ -0,0 +1,1261 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -22778,17 +23039,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + +/* Znode lock and capturing intertwining. */ +/* In current implementation we capture formatted nodes before locking -+ them. Take a look on longterm lock znode, reiser4_try_capture() request -+ precedes locking requests. The longterm_lock_znode function unconditionally -+ captures znode before even checking of locking conditions. ++ them. Take a look on longterm lock znode, try_capture() request precedes ++ locking requests. The longterm_lock_znode function unconditionally captures ++ znode before even checking of locking conditions. + + Another variant is to capture znode after locking it. It was not tested, but + at least one deadlock condition is supposed to be there. One thread has -+ locked a znode (Node-1) and calls reiser4_try_capture() for it. -+ reiser4_try_capture() sleeps because znode's atom has CAPTURE_WAIT state. -+ Second thread is a flushing thread, its current atom is the atom Node-1 -+ belongs to. Second thread wants to lock Node-1 and sleeps because Node-1 -+ is locked by the first thread. The described situation is a deadlock. */ ++ locked a znode (Node-1) and calls try_capture() for it. Try_capture() sleeps ++ because znode's atom has CAPTURE_WAIT state. Second thread is a flushing ++ thread, its current atom is the atom Node-1 belongs to. Second thread wants ++ to lock Node-1 and sleeps because Node-1 is locked by the first thread. The ++ described situation is a deadlock. */ + +#include "debug.h" +#include "txnmgr.h" @@ -22849,7 +23110,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + /* add lock handle to the end of lock_stack's list of locks */ + list_add_tail(&handle->locks_link, &owner->locks); + ON_DEBUG(owner->nr_locks++); -+ reiser4_ctx_gfp_mask_set(); ++ set_gfp_mask(); + + /* add lock handle to the head of znode's list of owners */ + list_add(&handle->owners_link, &node->lock.owners); @@ -22868,7 +23129,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + /* remove lock handle from lock_stack's list of locks */ + list_del(&handle->locks_link); + ON_DEBUG(handle->owner->nr_locks--); -+ reiser4_ctx_gfp_mask_set(); ++ set_gfp_mask(); + assert("reiser4-6", + ergo(list_empty_careful(&handle->owner->locks), + handle->owner->nr_locks == 0)); @@ -22886,7 +23147,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c +/* Actually locks an object knowing that we are able to do this */ +static void lock_object(lock_stack * owner) +{ -+ struct lock_request *request; ++ lock_request *request; + znode *node; + + request = &owner->request; @@ -22923,6 +23184,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + assert("nikita-1841", owner == get_current_lock_stack()); + assert_spin_locked(&(node->lock.guard)); + ++ + lh = list_entry(node->lock.owners.next, lock_handle, owners_link); + ret = (lh->owner == owner); + @@ -23124,6 +23386,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + list_del(&requestor->requestors_link); +} + ++ +static void invalidate_all_lock_requests(znode * node) +{ + lock_stack *requestor, *tmp; @@ -23186,7 +23449,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + */ + + /* was this lock of hi or lo priority */ -+ hipri = oldowner->curpri ? 1 : 0; ++ hipri = oldowner->curpri ? -1 : 0; + /* number of readers */ + readers = node->lock.nr_readers; + /* +1 if write lock, -1 if read lock */ @@ -23199,8 +23462,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + assert("zam-101", znode_is_locked(node)); + + /* Adjust a number of high priority owners of this lock */ -+ assert("nikita-1836", node->lock.nr_hipri_owners >= hipri); -+ node->lock.nr_hipri_owners -= hipri; ++ node->lock.nr_hipri_owners += hipri; ++ assert("nikita-1836", node->lock.nr_hipri_owners >= 0); + + /* Handle znode deallocation on last write-lock release. */ + if (znode_is_wlocked_once(node)) { @@ -23288,7 +23551,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + node = owner->request.node; + lock = &node->lock; + -+ assert("nikita-3340", reiser4_schedulable()); ++ assert("nikita-3340", schedulable()); + assert("nikita-3341", request_is_deadlock_safe(node, + ZNODE_READ_LOCK, + ZNODE_LOCK_LOPRI)); @@ -23298,7 +23561,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + + if (likely(result != -EINVAL)) { + spin_lock_znode(node); -+ result = reiser4_try_capture(ZJNODE(node), ZNODE_READ_LOCK, 0); ++ result = try_capture(ZJNODE(node), ZNODE_READ_LOCK, 0); + spin_unlock_znode(node); + spin_lock_zlock(lock); + if (unlikely(result != 0)) { @@ -23342,7 +23605,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + /* Check that the lock handle is initialized and isn't already being + * used. */ + assert("jmacd-808", handle->owner == NULL); -+ assert("nikita-3026", reiser4_schedulable()); ++ assert("nikita-3026", schedulable()); + assert("nikita-3219", request_is_deadlock_safe(node, mode, request)); + assert("zam-1056", atomic_read(&ZJNODE(node)->x_count) > 0); + /* long term locks are not allowed in the VM contexts (->writepage(), @@ -23426,7 +23689,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + * 1. read of aligned word is atomic with respect to writes to + * this word + * -+ * 2. false negatives are handled in reiser4_try_capture(). ++ * 2. false negatives are handled in try_capture(). + * + * 3. false positives are impossible. + * @@ -23454,8 +23717,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + * + * Suppose node->atom == NULL, that is, node was un-captured + * between T1, and T3. But un-capturing of formatted node is -+ * always preceded by the call to reiser4_invalidate_lock(), -+ * which marks znode as JNODE_IS_DYING under zlock spin ++ * always preceded by the call to invalidate_lock(), which ++ * marks znode as JNODE_IS_DYING under zlock spin + * lock. Contradiction, because can_lock_object() above checks + * for JNODE_IS_DYING. Hence, node->atom != NULL at T3. + * @@ -23478,13 +23741,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + /* + * unlock zlock spin lock here. It is possible for + * longterm_unlock_znode() to sneak in here, but there -+ * is no harm: reiser4_invalidate_lock() will mark znode -+ * as JNODE_IS_DYING and this will be noted by ++ * is no harm: invalidate_lock() will mark znode as ++ * JNODE_IS_DYING and this will be noted by + * can_lock_object() below. + */ + spin_unlock_zlock(lock); + spin_lock_znode(node); -+ ret = reiser4_try_capture(ZJNODE(node), mode, cap_flags); ++ ret = try_capture(ZJNODE(node), mode, cap_flags); + spin_unlock_znode(node); + spin_lock_zlock(lock); + if (unlikely(ret != 0)) { @@ -23505,13 +23768,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + + /* This time, a return of (ret == 0) means we can lock, so we + should break out of the loop. */ -+ if (likely(ret != -E_REPEAT || non_blocking)) ++ if (likely(ret != -E_REPEAT || non_blocking)) { + break; ++ } + + /* Lock is unavailable, we have to wait. */ -+ ret = reiser4_prepare_to_sleep(owner); -+ if (unlikely(ret != 0)) ++ ++ /* By having semaphore initialization here we cannot lose ++ wakeup signal even if it comes after `nr_signaled' field ++ check. */ ++ ret = prepare_to_sleep(owner); ++ if (unlikely(ret != 0)) { + break; ++ } + + assert_spin_locked(&(node->lock.guard)); + if (hipri) { @@ -23533,7 +23802,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + a znode ... */ + spin_unlock_zlock(lock); + /* ... and sleep */ -+ reiser4_go_to_sleep(owner); ++ go_to_sleep(owner); + if (owner->request.mode == ZNODE_NO_LOCK) + goto request_is_done; + spin_lock_zlock(lock); @@ -23554,10 +23823,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + +/* lock object invalidation means changing of lock object state to `INVALID' + and waiting for all other processes to cancel theirs lock requests. */ -+void reiser4_invalidate_lock(lock_handle * handle /* path to lock -+ * owner and lock -+ * object is being -+ * invalidated. */ ) ++void invalidate_lock(lock_handle * handle /* path to lock ++ * owner and lock ++ * object is being ++ * invalidated. */ ) +{ + znode *node = handle->node; + lock_stack *owner = handle->owner; @@ -23590,7 +23859,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + INIT_LIST_HEAD(&owner->requestors_link); + spin_lock_init(&owner->sguard); + owner->curpri = 1; -+ init_waitqueue_head(&owner->wait); ++ sema_init(&owner->sema, 0); +} + +/* Initializes lock object. */ @@ -23658,7 +23927,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c +} + +/* after getting -E_DEADLOCK we unlock znodes until this function returns false */ -+int reiser4_check_deadlock(void) ++int check_deadlock(void) +{ + lock_stack *owner = get_current_lock_stack(); + return atomic_read(&owner->nr_signaled) != 0; @@ -23666,9 +23935,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + +/* Before going to sleep we re-check "release lock" requests which might come from threads with hi-pri lock + priorities. */ -+int reiser4_prepare_to_sleep(lock_stack * owner) ++int prepare_to_sleep(lock_stack * owner) +{ + assert("nikita-1847", owner == get_current_lock_stack()); ++ /* NOTE(Zam): We cannot reset the lock semaphore here because it may ++ clear wake-up signal. The initial design was to re-check all ++ conditions under which we continue locking, release locks or sleep ++ until conditions are changed. However, even lock.c does not follow ++ that design. So, wake-up signal which is stored in semaphore state ++ could we loosen by semaphore reset. The less complex scheme without ++ resetting the semaphore is enough to not to loose wake-ups. ++ ++ if (0) { ++ ++ NOTE-NIKITA: I commented call to sema_init() out hoping ++ that it is the reason or thread sleeping in ++ down(&owner->sema) without any other thread running. ++ ++ Anyway, it is just an optimization: is semaphore is not ++ reinitialised at this point, in the worst case ++ longterm_lock_znode() would have to iterate its loop once ++ more. ++ spin_lock_stack(owner); ++ sema_init(&owner->sema, 0); ++ spin_unlock_stack(owner); ++ } ++ */ + + /* We return -E_DEADLOCK if one or more "give me the lock" messages are + * counted in nr_signaled */ @@ -23682,18 +23974,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c +/* Wakes up a single thread */ +void __reiser4_wake_up(lock_stack * owner) +{ -+ atomic_set(&owner->wakeup, 1); -+ wake_up(&owner->wait); ++ up(&owner->sema); +} + +/* Puts a thread to sleep */ -+void reiser4_go_to_sleep(lock_stack * owner) ++void go_to_sleep(lock_stack * owner) +{ + /* Well, we might sleep here, so holding of any spinlocks is no-no */ -+ assert("nikita-3027", reiser4_schedulable()); -+ -+ wait_event(owner->wait, atomic_read(&owner->wakeup)); -+ atomic_set(&owner->wakeup, 0); ++ assert("nikita-3027", schedulable()); ++ /* return down_interruptible(&owner->sema); */ ++ down(&owner->sema); +} + +int lock_stack_isclean(lock_stack * owner) @@ -23803,10 +24093,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.c linux-2.6.22/fs/reiser4/lock.c + fill-column: 79 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h ---- linux-2.6.22.orig/fs/reiser4/lock.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/lock.h 2007-07-29 00:25:34.888699583 +0400 -@@ -0,0 +1,249 @@ +Index: linux-2.6.16/fs/reiser4/lock.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/lock.h +@@ -0,0 +1,272 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Long term locking data structures. See lock.c for details. */ @@ -23827,7 +24118,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h +#include +#include /* for PAGE_CACHE_SIZE */ +#include -+#include ++#include + +/* Per-znode lock object */ +struct zlock { @@ -23904,7 +24195,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + struct list_head owners_link; +}; + -+struct lock_request { ++typedef struct lock_request { + /* A pointer to uninitialized link object */ + lock_handle *handle; + /* A pointer to the object we want to lock */ @@ -23913,7 +24204,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + znode_lock_mode mode; + /* how dispatch_lock_requests() returns lock request result code */ + int ret_code; -+}; ++} lock_request; + +/* A lock stack structure for accumulating locks owned by a process */ +struct lock_stack { @@ -23939,18 +24230,40 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + This is only accessed by the current thread and thus requires no + locking. + */ -+ struct lock_request request; -+ /* the following two fields are the lock stack's -+ * synchronization object to use with the standard linux/wait.h -+ * interface. See reiser4_go_to_sleep and __reiser4_wake_up for -+ * usage details. */ -+ wait_queue_head_t wait; -+ atomic_t wakeup; ++ lock_request request; ++ /* It is a lock_stack's synchronization object for when process sleeps ++ when requested lock not on this lock_stack but which it wishes to ++ add to this lock_stack is not immediately available. It is used ++ instead of wait_queue_t object due to locking problems (lost wake ++ up). "lost wakeup" occurs when process is waken up before he actually ++ becomes 'sleepy' (through sleep_on()). Using of semaphore object is ++ simplest way to avoid that problem. ++ ++ A semaphore is used in the following way: only the process that is ++ the owner of the lock_stack initializes it (to zero) and calls ++ down(sema) on it. Usually this causes the process to sleep on the ++ semaphore. Other processes may wake him up by calling up(sema). The ++ advantage to a semaphore is that up() and down() calls are not ++ required to preserve order. Unlike wait_queue it works when process ++ is woken up before getting to sleep. ++ ++ NOTE-NIKITA: Transaction manager is going to have condition variables ++ (&kcondvar_t) anyway, so this probably will be replaced with ++ one in the future. ++ ++ After further discussion, Nikita has shown me that Zam's implementation is ++ exactly a condition variable. The znode's {zguard,requestors_list} represents ++ condition variable and the lock_stack's {sguard,semaphore} guards entry and ++ exit from the condition variable's wait queue. But the existing code can't ++ just be replaced with a more general abstraction, and I think its fine the way ++ it is. */ ++ struct semaphore sema; +#if REISER4_DEBUG + int nr_locks; /* number of lock handles in the above list */ +#endif +}; + ++ +/* + User-visible znode locking functions +*/ @@ -23962,7 +24275,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + +extern void longterm_unlock_znode(lock_handle * handle); + -+extern int reiser4_check_deadlock(void); ++extern int check_deadlock(void); + +extern lock_stack *get_current_lock_stack(void); + @@ -23990,8 +24303,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h +extern void move_lh(lock_handle * new, lock_handle * old); +extern void copy_lh(lock_handle * new, lock_handle * old); + -+extern int reiser4_prepare_to_sleep(lock_stack * owner); -+extern void reiser4_go_to_sleep(lock_stack * owner); ++extern int prepare_to_sleep(lock_stack * owner); ++extern void go_to_sleep(lock_stack * owner); +extern void __reiser4_wake_up(lock_stack * owner); + +extern int lock_stack_isclean(lock_stack * owner); @@ -23999,7 +24312,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h +/* zlock object state check macros: only used in assertions. Both forms imply that the + lock is held by the current thread. */ +extern int znode_is_write_locked(const znode *); -+extern void reiser4_invalidate_lock(lock_handle *); ++extern void invalidate_lock(lock_handle *); + +/* lock ordering is: first take zlock spin lock, then lock stack spin lock */ +#define spin_ordering_pred_stack(stack) \ @@ -24027,6 +24340,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + spin_unlock(&(stack->sguard)); +} + ++ +static inline void reiser4_wake_up(lock_stack * owner) +{ + spin_lock_stack(owner); @@ -24056,112 +24370,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/lock.h linux-2.6.22/fs/reiser4/lock.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/Makefile linux-2.6.22/fs/reiser4/Makefile ---- linux-2.6.22.orig/fs/reiser4/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/Makefile 2007-07-29 00:25:34.888699583 +0400 -@@ -0,0 +1,99 @@ -+# -+# reiser4/Makefile -+# -+ -+obj-$(CONFIG_REISER4_FS) += reiser4.o -+ -+reiser4-y := \ -+ debug.o \ -+ jnode.o \ -+ znode.o \ -+ key.o \ -+ pool.o \ -+ tree_mod.o \ -+ estimate.o \ -+ carry.o \ -+ carry_ops.o \ -+ lock.o \ -+ tree.o \ -+ context.o \ -+ tap.o \ -+ coord.o \ -+ block_alloc.o \ -+ txnmgr.o \ -+ kassign.o \ -+ flush.o \ -+ wander.o \ -+ eottl.o \ -+ search.o \ -+ page_cache.o \ -+ seal.o \ -+ dscale.o \ -+ flush_queue.o \ -+ ktxnmgrd.o \ -+ blocknrset.o \ -+ super.o \ -+ super_ops.o \ -+ fsdata.o \ -+ export_ops.o \ -+ oid.o \ -+ tree_walk.o \ -+ inode.o \ -+ vfs_ops.o \ -+ as_ops.o \ -+ entd.o\ -+ readahead.o \ -+ status_flags.o \ -+ init_super.o \ -+ safe_link.o \ -+ \ -+ plugin/plugin.o \ -+ plugin/plugin_set.o \ -+ plugin/node/node.o \ -+ plugin/object.o \ -+ plugin/cluster.o \ -+ plugin/inode_ops.o \ -+ plugin/inode_ops_rename.o \ -+ plugin/file_ops.o \ -+ plugin/file_ops_readdir.o \ -+ plugin/file_plugin_common.o \ -+ plugin/file/file.o \ -+ plugin/file/tail_conversion.o \ -+ plugin/file/file_conversion.o \ -+ plugin/file/symlink.o \ -+ plugin/file/cryptcompress.o \ -+ plugin/dir_plugin_common.o \ -+ plugin/dir/hashed_dir.o \ -+ plugin/dir/seekable_dir.o \ -+ plugin/node/node40.o \ -+ \ -+ plugin/crypto/cipher.o \ -+ plugin/crypto/digest.o \ -+ \ -+ plugin/compress/minilzo.o \ -+ plugin/compress/compress.o \ -+ plugin/compress/compress_mode.o \ -+ \ -+ plugin/item/static_stat.o \ -+ plugin/item/sde.o \ -+ plugin/item/cde.o \ -+ plugin/item/blackbox.o \ -+ plugin/item/internal.o \ -+ plugin/item/tail.o \ -+ plugin/item/ctail.o \ -+ plugin/item/extent.o \ -+ plugin/item/extent_item_ops.o \ -+ plugin/item/extent_file_ops.o \ -+ plugin/item/extent_flush_ops.o \ -+ \ -+ plugin/hash.o \ -+ plugin/fibration.o \ -+ plugin/tail_policy.o \ -+ plugin/item/item.o \ -+ \ -+ plugin/security/perm.o \ -+ plugin/space/bitmap.o \ -+ \ -+ plugin/disk_format/disk_format40.o \ -+ plugin/disk_format/disk_format.o -+ -diff -urN linux-2.6.22.orig/fs/reiser4/oid.c linux-2.6.22/fs/reiser4/oid.c ---- linux-2.6.22.orig/fs/reiser4/oid.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/oid.c 2007-07-29 00:25:34.888699583 +0400 +Index: linux-2.6.16/fs/reiser4/oid.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/oid.c @@ -0,0 +1,141 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -24304,34 +24516,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/oid.c linux-2.6.22/fs/reiser4/oid.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page_cache.c ---- linux-2.6.22.orig/fs/reiser4/page_cache.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/page_cache.c 2007-07-29 00:25:34.888699583 +0400 -@@ -0,0 +1,730 @@ +Index: linux-2.6.16/fs/reiser4/page_cache.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/page_cache.c +@@ -0,0 +1,712 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + +/* Memory pressure hooks. Fake inodes handling. */ -+ -+/* GLOSSARY -+ -+ . Formatted and unformatted nodes. -+ Elements of reiser4 balanced tree to store data and metadata. -+ Unformatted nodes are pointed to by extent pointers. Such nodes -+ are used to store data of large objects. Unlike unformatted nodes, -+ formatted ones have associated format described by node4X plugin. -+ -+ . Jnode (or journal node) -+ The in-memory header which is used to track formatted and unformatted -+ nodes, bitmap nodes, etc. In particular, jnodes are used to track -+ transactional information associated with each block(see reiser4/jnode.c -+ for details). -+ -+ . Znode -+ The in-memory header which is used to track formatted nodes. Contains -+ embedded jnode (see reiser4/znode.c for details). -+*/ -+ +/* We store all file system meta data (and data, of course) in the page cache. + + What does this mean? In stead of using bread/brelse we create special @@ -24362,8 +24555,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + 1. when jnode-to-page mapping is established (by jnode_attach_page()), page + reference counter is increased. + -+ 2. when jnode-to-page mapping is destroyed (by page_clear_jnode(), page -+ reference counter is decreased. ++ 2. when jnode-to-page mapping is destroyed (by jnode_detach_page() and ++ page_detach_jnode()), page reference counter is decreased. + + 3. on jload() reference counter on jnode page is increased, page is + kmapped and `referenced'. @@ -24534,13 +24727,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page +} + +/** -+ * reiser4_init_formatted_fake - iget inodes for formatted nodes and bitmaps ++ * init_formatted_fake - iget inodes for formatted nodes and bitmaps + * @super: super block to init fake inode for + * + * Initializes fake inode to which formatted nodes are bound in the page cache + * and inode for bitmaps. + */ -+int reiser4_init_formatted_fake(struct super_block *super) ++int init_formatted_fake(struct super_block *super) +{ + struct inode *fake; + struct inode *bitmap; @@ -24578,19 +24771,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page +} + +/** -+ * reiser4_done_formatted_fake - release inode used by formatted nodes and bitmaps ++ * done_formatted_fake - release inode used by formatted nodes and bitmaps + * @super: super block to init fake inode for + * + * Releases inodes which were used as address spaces of bitmap and formatted + * nodes. + */ -+void reiser4_done_formatted_fake(struct super_block *super) ++void done_formatted_fake(struct super_block *super) +{ + reiser4_super_info_data *sinfo; + + sinfo = get_super_private_nocheck(super); + + if (sinfo->fake != NULL) { ++ assert("vs-1426", sinfo->fake->i_data.nrpages == 0); + iput(sinfo->fake); + sinfo->fake = NULL; + } @@ -24619,7 +24813,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page +} + +/* return tree @page is in */ -+reiser4_tree *reiser4_tree_by_page(const struct page *page /* page to query */ ) ++reiser4_tree *tree_by_page(const struct page *page /* page to query */ ) +{ + assert("nikita-2461", page != NULL); + return &get_super_private(page->mapping->host->i_sb)->tree; @@ -24686,12 +24880,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + struct page *page /* page to read */ ) +{ + assert("nikita-2412", PagePrivate(page) && jprivate(page)); -+ return reiser4_page_io(page, jprivate(page), READ, -+ reiser4_ctx_gfp_mask_get()); ++ return page_io(page, jprivate(page), READ, get_gfp_mask()); +} + +/** -+ * reiser4_page_io - submit single-page bio request ++ * page_io - submit single-page bio request + * @page: page to perform io for + * @node: jnode of page + * @rw: read or write @@ -24699,7 +24892,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + * + * Submits single page read or write. + */ -+int reiser4_page_io(struct page *page, jnode *node, int rw, gfp_t gfp) ++int page_io(struct page *page, jnode *node, int rw, gfp_t gfp) +{ + struct bio *bio; + int result; @@ -24719,7 +24912,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + bio = page_bio(page, node, rw, gfp); + if (!IS_ERR(bio)) { + if (rw == WRITE) { -+ set_page_writeback(page); ++ SetPageWriteback(page); + unlock_page(page); + } + reiser4_submit_bio(rw, bio); @@ -24761,7 +24954,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + spin_unlock_jnode(node); + + assert("nikita-2275", blocknr != (reiser4_block_nr) 0); -+ assert("nikita-2276", !reiser4_blocknr_is_fake(&blocknr)); ++ assert("nikita-2276", !blocknr_is_fake(&blocknr)); + + bio->bi_bdev = super->s_bdev; + /* fill bio->bi_sector before calling bio_add_page(), because @@ -24785,7 +24978,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page +} + +/* this function is internally called by jnode_make_dirty() */ -+int reiser4_set_page_dirty_internal(struct page *page) ++int set_page_dirty_internal(struct page *page) +{ + struct address_space *mapping; + @@ -24794,18 +24987,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + + if (!TestSetPageDirty(page)) { + if (mapping_cap_account_dirty(mapping)) -+ inc_zone_page_state(page, NR_FILE_DIRTY); ++ inc_page_state(nr_dirty); + + __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); + } + + /* znode must be dirty ? */ -+ if (mapping->host == reiser4_get_super_fake(mapping->host->i_sb)) ++ if (mapping->host == get_super_fake(mapping->host->i_sb)) + assert("", JF_ISSET(jprivate(page), JNODE_DIRTY)); + return 0; +} + -+#if 0 ++#if REISER4_DEBUG ++ ++/** ++ * can_hit_entd ++ * ++ * This is used on ++ */ +static int can_hit_entd(reiser4_context *ctx, struct super_block *s) +{ + if (ctx == NULL || ((unsigned long)ctx->magic) != context_magic) @@ -24820,6 +25019,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + return 0; + return 1; +} ++ +#endif + +/** @@ -24841,7 +25041,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + s = page->mapping->host->i_sb; + ctx = get_current_context_check(); + -+ //assert("", can_hit_entd(ctx, s)); ++ assert("", can_hit_entd(ctx, s)); ++ + return write_page_by_ent(page, wbc); +} + @@ -24903,7 +25104,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + +/* called just before page is released (no longer used by reiser4). Callers: + jdelete() and extent2tail(). */ -+void reiser4_drop_page(struct page *page) ++void drop_page(struct page *page) +{ + assert("nikita-2181", PageLocked(page)); + clear_page_dirty_for_io(page); @@ -24911,12 +25112,45 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page +#if defined(PG_skipped) + ClearPageSkipped(page); +#endif -+ unlock_page(page); ++ if (page->mapping != NULL) { ++ remove_from_page_cache(page); ++ unlock_page(page); ++ page_cache_release(page); ++ } else ++ unlock_page(page); ++} ++ ++/* this is called by truncate_jnodes_range which in its turn is always called ++ after truncate_mapping_pages_range. Therefore, here jnode can not have ++ page. New pages can not be created because truncate_jnodes_range goes under ++ exclusive access on file obtained, where as new page creation requires ++ non-exclusive access obtained */ ++static void invalidate_unformatted(jnode * node) ++{ ++ struct page *page; ++ ++ spin_lock_jnode(node); ++ page = node->pg; ++ if (page) { ++ loff_t from, to; ++ ++ page_cache_get(page); ++ spin_unlock_jnode(node); ++ /* FIXME: use truncate_complete_page instead */ ++ from = (loff_t) page->index << PAGE_CACHE_SHIFT; ++ to = from + PAGE_CACHE_SIZE - 1; ++ truncate_inode_pages_range(page->mapping, from, to); ++ page_cache_release(page); ++ } else { ++ JF_SET(node, JNODE_HEARD_BANSHEE); ++ uncapture_jnode(node); ++ unhash_unformatted_jnode(node); ++ } +} + +#define JNODE_GANG_SIZE (16) + -+/* find all jnodes from range specified and invalidate them */ ++/* find all eflushed jnodes from range specified and invalidate them */ +static int +truncate_jnodes_range(struct inode *inode, pgoff_t from, pgoff_t count) +{ @@ -24926,20 +25160,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + unsigned long index; + unsigned long end; + -+ if (inode_file_plugin(inode) == -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)) -+ /* -+ * No need to get rid of jnodes here: if the single jnode of -+ * page cluster did not have page, then it was found and killed -+ * before in -+ * truncate_complete_page_cluster()->jput()->jput_final(), -+ * otherwise it will be dropped by reiser4_invalidatepage() -+ */ -+ return 0; + truncated_jnodes = 0; + + info = reiser4_inode_data(inode); -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + + index = from; + end = from + count; @@ -24970,18 +25194,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + node = gang[i]; + if (node != NULL) { + index = max(index, index_jnode(node)); -+ spin_lock_jnode(node); -+ assert("edward-1457", node->pg == NULL); -+ /* this is always called after -+ truncate_inode_pages_range(). Therefore, here -+ jnode can not have page. New pages can not be -+ created because truncate_jnodes_range goes -+ under exclusive access on file obtained, -+ where as new page creation requires -+ non-exclusive access obtained */ -+ JF_SET(node, JNODE_HEARD_BANSHEE); -+ reiser4_uncapture_jnode(node); -+ unhash_unformatted_jnode(node); ++ invalidate_unformatted(node); + truncated_jnodes++; + jput(node); + } else @@ -24993,27 +25206,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + return truncated_jnodes; +} + -+/* Truncating files in reiser4: problems and solutions. -+ -+ VFS calls fs's truncate after it has called truncate_inode_pages() -+ to get rid of pages corresponding to part of file being truncated. -+ In reiser4 it may cause existence of unallocated extents which do -+ not have jnodes. Flush code does not expect that. Solution of this -+ problem is straightforward. As vfs's truncate is implemented using -+ setattr operation, it seems reasonable to have ->setattr() that -+ will cut file body. However, flush code also does not expect dirty -+ pages without parent items, so it is impossible to cut all items, -+ then truncate all pages in two steps. We resolve this problem by -+ cutting items one-by-one. Each such fine-grained step performed -+ under longterm znode lock calls at the end ->kill_hook() method of -+ a killed item to remove its binded pages and jnodes. -+ -+ The following function is a common part of mentioned kill hooks. -+ Also, this is called before tail-to-extent conversion (to not manage -+ few copies of the data). -+*/ -+void reiser4_invalidate_pages(struct address_space *mapping, pgoff_t from, -+ unsigned long count, int even_cows) ++void ++reiser4_invalidate_pages(struct address_space *mapping, pgoff_t from, ++ unsigned long count, int even_cows) +{ + loff_t from_bytes, count_bytes; + @@ -25038,10 +25233,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.c linux-2.6.22/fs/reiser4/page + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.h linux-2.6.22/fs/reiser4/page_cache.h ---- linux-2.6.22.orig/fs/reiser4/page_cache.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/page_cache.h 2007-07-29 00:25:34.888699583 +0400 -@@ -0,0 +1,68 @@ +Index: linux-2.6.16/fs/reiser4/page_cache.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/page_cache.h +@@ -0,0 +1,62 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ +/* Memory pressure hooks. Fake inodes handling. See page_cache.c. */ @@ -25050,19 +25246,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.h linux-2.6.22/fs/reiser4/page +#define __REISER4_PAGE_CACHE_H__ + +#include "forward.h" -+#include "context.h" /* for reiser4_ctx_gfp_mask_get() */ ++#include "debug.h" + +#include /* for struct super_block, address_space */ +#include /* for struct page */ +#include /* for lock_page() */ -+#include /* for __vmalloc() */ + -+extern int reiser4_init_formatted_fake(struct super_block *); -+extern void reiser4_done_formatted_fake(struct super_block *); + -+extern reiser4_tree *reiser4_tree_by_page(const struct page *); ++extern int init_formatted_fake(struct super_block *); ++extern void done_formatted_fake(struct super_block *); ++ ++extern reiser4_tree *tree_by_page(const struct page *); + -+extern int reiser4_set_page_dirty_internal(struct page *); ++extern int set_page_dirty_internal(struct page *); + +#define reiser4_submit_bio(rw, bio) submit_bio((rw), (bio)) + @@ -25076,18 +25272,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.h linux-2.6.22/fs/reiser4/page + +#define jprivate(page) ((jnode *)page_private(page)) + -+extern int reiser4_page_io(struct page *, jnode *, int rw, gfp_t); -+extern void reiser4_drop_page(struct page *); ++extern int page_io(struct page *, jnode *, int rw, gfp_t); ++extern void drop_page(struct page *); +extern void reiser4_invalidate_pages(struct address_space *, pgoff_t from, + unsigned long count, int even_cows); +extern void capture_reiser4_inodes(struct super_block *, + struct writeback_control *); -+static inline void * reiser4_vmalloc (unsigned long size) -+{ -+ return __vmalloc(size, -+ reiser4_ctx_gfp_mask_get() | __GFP_HIGHMEM, -+ PAGE_KERNEL); -+} + +#define PAGECACHE_TAG_REISER4_MOVED PAGECACHE_TAG_DIRTY + @@ -25110,10 +25300,42 @@ diff -urN linux-2.6.22.orig/fs/reiser4/page_cache.h linux-2.6.22/fs/reiser4/page + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.c linux-2.6.22/fs/reiser4/plugin/cluster.c ---- linux-2.6.22.orig/fs/reiser4/plugin/cluster.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/cluster.c 2007-07-29 00:25:34.892700618 +0400 -@@ -0,0 +1,71 @@ +Index: linux-2.6.16/fs/reiser4/plugin/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/Makefile +@@ -0,0 +1,26 @@ ++obj-$(CONFIG_REISER4_FS) += plugins.o ++ ++plugins-objs := \ ++ plugin.o \ ++ plugin_set.o \ ++ object.o \ ++ inode_ops.o \ ++ inode_ops_rename.o \ ++ file_ops.o \ ++ file_ops_readdir.o \ ++ file_plugin_common.o \ ++ dir_plugin_common.o \ ++ digest.o \ ++ hash.o \ ++ fibration.o \ ++ tail_policy.o \ ++ regular.o ++ ++obj-$(CONFIG_REISER4_FS) += item/ ++obj-$(CONFIG_REISER4_FS) += file/ ++obj-$(CONFIG_REISER4_FS) += dir/ ++obj-$(CONFIG_REISER4_FS) += node/ ++obj-$(CONFIG_REISER4_FS) += compress/ ++obj-$(CONFIG_REISER4_FS) += space/ ++obj-$(CONFIG_REISER4_FS) += disk_format/ ++obj-$(CONFIG_REISER4_FS) += security/ +Index: linux-2.6.16/fs/reiser4/plugin/cluster.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/cluster.c +@@ -0,0 +1,66 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Contains reiser4 cluster plugins (see @@ -25124,26 +25346,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.c linux-2.6.22/fs/reiser4/ +#include "plugin.h" +#include "../inode.h" + -+static int change_cluster(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_cluster(struct inode *inode, reiser4_plugin * plugin) +{ ++ int result = 0; ++ + assert("edward-1324", inode != NULL); + assert("edward-1325", plugin != NULL); + assert("edward-1326", is_reiser4_inode(inode)); + assert("edward-1327", plugin->h.type_id == REISER4_CLUSTER_PLUGIN_TYPE); + -+ /* Can't change the cluster plugin for already existent regular files. */ -+ if (!plugin_of_group(inode_file_plugin(inode), REISER4_DIRECTORY_FILE)) -+ return RETERR(-EINVAL); -+ -+ /* If matches, nothing to change. */ -+ if (inode_hash_plugin(inode) != NULL && -+ inode_hash_plugin(inode)->h.id == plugin->h.id) -+ return 0; -+ -+ return aset_set_unsafe(&reiser4_inode_data(inode)->pset, -+ PSET_CLUSTER, plugin); ++ if (inode_file_plugin(inode)->h.id == DIRECTORY_FILE_PLUGIN_ID) ++ result = plugin_set_cluster(&reiser4_inode_data(inode)->pset, ++ &plugin->clust); ++ else ++ result = RETERR(-EINVAL); ++ return result; +} + +static reiser4_plugin_ops cluster_plugin_ops = { @@ -25185,14 +25402,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.c linux-2.6.22/fs/reiser4/ + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.h linux-2.6.22/fs/reiser4/plugin/cluster.h ---- linux-2.6.22.orig/fs/reiser4/plugin/cluster.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/cluster.h 2007-07-29 00:25:34.892700618 +0400 -@@ -0,0 +1,399 @@ +Index: linux-2.6.16/fs/reiser4/plugin/cluster.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/cluster.h +@@ -0,0 +1,316 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + -+/* This file contains size/offset translators, modulators -+ and other helper functions. */ ++/* This file contains page/cluster index translators and offset modulators ++ See http://www.namesys.com/cryptcompress_design.html for details */ + +#if !defined( __FS_REISER4_CLUSTER_H__ ) +#define __FS_REISER4_CLUSTER_H__ @@ -25260,43 +25478,47 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.h linux-2.6.22/fs/reiser4/ + return (loff_t) idx << inode_cluster_shift(inode); +} + -+static inline loff_t off_to_clust_to_off(loff_t off, struct inode *inode) ++static inline unsigned long count_to_nr(loff_t count, unsigned shift) +{ -+ return clust_to_off(off_to_clust(off, inode), inode); ++ return (count + (1UL << shift) - 1) >> shift; +} + -+static inline pgoff_t off_to_clust_to_pg(loff_t off, struct inode *inode) ++/* number of pages occupied by @count bytes */ ++static inline pgoff_t count_to_nrpages(loff_t count) +{ -+ return clust_to_pg(off_to_clust(off, inode), inode); ++ return count_to_nr(count, PAGE_CACHE_SHIFT); +} + -+static inline unsigned off_to_pgoff(loff_t off) ++/* number of clusters occupied by @count bytes */ ++static inline cloff_t count_to_nrclust(loff_t count, struct inode *inode) +{ -+ return off & (PAGE_CACHE_SIZE - 1); ++ return count_to_nr(count, inode_cluster_shift(inode)); +} + -+static inline unsigned off_to_cloff(loff_t off, struct inode *inode) ++/* number of clusters occupied by @count pages */ ++static inline cloff_t pgcount_to_nrclust(pgoff_t count, struct inode *inode) +{ -+ return off & ((loff_t) (inode_cluster_size(inode)) - 1); ++ return count_to_nr(count, cluster_nrpages_shift(inode)); +} + -+static inline pgoff_t offset_in_clust(struct page * page) ++static inline loff_t off_to_clust_to_off(loff_t off, struct inode *inode) +{ -+ assert("edward-1488", page != NULL); -+ assert("edward-1489", page->mapping != NULL); ++ return clust_to_off(off_to_clust(off, inode), inode); ++} + -+ return page_index(page) & ((cluster_nrpages(page->mapping->host)) - 1); ++static inline pgoff_t off_to_clust_to_pg(loff_t off, struct inode *inode) ++{ ++ return clust_to_pg(off_to_clust(off, inode), inode); +} + -+static inline int first_page_in_cluster(struct page * page) ++static inline unsigned off_to_pgoff(loff_t off) +{ -+ return offset_in_clust(page) == 0; ++ return off & (PAGE_CACHE_SIZE - 1); +} + -+static inline int last_page_in_cluster(struct page * page) ++static inline unsigned off_to_cloff(loff_t off, struct inode *inode) +{ -+ return offset_in_clust(page) == -+ cluster_nrpages(page->mapping->host) - 1; ++ return off & ((loff_t) (inode_cluster_size(inode)) - 1); +} + +static inline unsigned @@ -25305,192 +25527,108 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.h linux-2.6.22/fs/reiser4/ + return off_to_cloff(pg_to_off(idx), inode); +} + -+/*********************** Size translators **************************/ -+ -+/* Translate linear size. -+ * New units are (1 << @blk_shift) times larger, then old ones. -+ * In other words, calculate number of logical blocks, occupied -+ * by @count elements -+ */ -+static inline unsigned long size_in_blocks(loff_t count, unsigned blkbits) -+{ -+ return (count + (1UL << blkbits) - 1) >> blkbits; -+} -+ -+/* size in pages */ -+static inline pgoff_t size_in_pages(loff_t size) ++/* if @size != 0, returns index of the page ++ which contains the last byte of the file */ ++static inline pgoff_t size_to_pg(loff_t size) +{ -+ return size_in_blocks(size, PAGE_CACHE_SHIFT); ++ return (size ? off_to_pg(size - 1) : 0); +} + -+/* size in logical clusters */ -+static inline cloff_t size_in_lc(loff_t size, struct inode *inode) ++/* minimal index of the page which doesn't contain ++ file data */ ++static inline pgoff_t size_to_next_pg(loff_t size) +{ -+ return size_in_blocks(size, inode_cluster_shift(inode)); ++ return (size ? off_to_pg(size - 1) + 1 : 0); +} + -+/* size in pages to the size in page clusters */ -+static inline cloff_t sp_to_spcl(pgoff_t size, struct inode *inode) ++/* how many bytes of file of size @cnt can be contained ++ in page of index @idx */ ++static inline unsigned cnt_to_pgcnt(loff_t cnt, pgoff_t idx) +{ -+ return size_in_blocks(size, cluster_nrpages_shift(inode)); -+} -+ -+/*********************** Size modulators ***************************/ -+ -+/* -+ Modulate linear size by nominated block size and offset. -+ -+ The "finite" function (which is zero almost everywhere). -+ How much is a height of the figure at a position @pos, -+ when trying to construct rectangle of height (1 << @blkbits), -+ and square @size. -+ -+ ****** -+ ******* -+ ******* -+ ******* -+ ----------> pos -+*/ -+static inline unsigned __mbb(loff_t size, unsigned long pos, int blkbits) -+{ -+ unsigned end = size >> blkbits; -+ if (pos < end) -+ return 1U << blkbits; -+ if (unlikely(pos > end)) ++ if (idx > off_to_pg(cnt)) + return 0; -+ return size & ~(~0ull << blkbits); -+} -+ -+/* the same as above, but block size is page size */ -+static inline unsigned __mbp(loff_t size, pgoff_t pos) -+{ -+ return __mbb(size, pos, PAGE_CACHE_SHIFT); -+} -+ -+/* number of file's bytes in the nominated logical cluster */ -+static inline unsigned lbytes(cloff_t index, struct inode * inode) -+{ -+ return __mbb(i_size_read(inode), index, inode_cluster_shift(inode)); ++ if (idx < off_to_pg(cnt)) ++ return PAGE_CACHE_SIZE; ++ return off_to_pgoff(cnt); +} + -+/* number of file's bytes in the nominated page */ -+static inline unsigned pbytes(pgoff_t index, struct inode * inode) -+{ -+ return __mbp(i_size_read(inode), index); -+} -+ -+/* return true, if logical cluster is not occupied by the file */ -+static inline int new_logical_cluster(struct cluster_handle * clust, -+ struct inode *inode) ++/* how many bytes of file of size @cnt can be contained ++ in logical cluster of index @idx */ ++static inline unsigned cnt_to_clcnt(loff_t cnt, cloff_t idx, ++ struct inode *inode) +{ -+ return clust_to_off(clust->index, inode) >= i_size_read(inode); ++ if (idx > off_to_clust(cnt, inode)) ++ return 0; ++ if (idx < off_to_clust(cnt, inode)) ++ return inode_cluster_size(inode); ++ return off_to_cloff(cnt, inode); +} + -+/* return true, if pages @p1 and @p2 are of the same page cluster */ -+static inline int same_page_cluster(struct page * p1, struct page * p2) ++static inline unsigned ++fsize_to_count(reiser4_cluster_t * clust, struct inode *inode) +{ -+ assert("edward-1490", p1 != NULL); -+ assert("edward-1491", p2 != NULL); -+ assert("edward-1492", p1->mapping != NULL); -+ assert("edward-1493", p2->mapping != NULL); ++ assert("edward-288", clust != NULL); ++ assert("edward-289", inode != NULL); + -+ return (pg_to_clust(page_index(p1), p1->mapping->host) == -+ pg_to_clust(page_index(p2), p2->mapping->host)); ++ return cnt_to_clcnt(inode->i_size, clust->index, inode); +} + -+static inline int cluster_is_complete(struct cluster_handle * clust, -+ struct inode * inode) ++static inline int ++cluster_is_complete(reiser4_cluster_t * clust, struct inode * inode) +{ + return clust->tc.lsize == inode_cluster_size(inode); +} + -+static inline void reiser4_slide_init(struct reiser4_slide * win) ++static inline void reiser4_slide_init(reiser4_slide_t * win) +{ + assert("edward-1084", win != NULL); + memset(win, 0, sizeof *win); +} + -+static inline tfm_action -+cluster_get_tfm_act(struct tfm_cluster * tc) -+{ -+ assert("edward-1356", tc != NULL); -+ return tc->act; -+} -+ +static inline void -+cluster_set_tfm_act(struct tfm_cluster * tc, tfm_action act) ++tfm_cluster_init_act(tfm_cluster_t * tc, tfm_action act) +{ + assert("edward-1356", tc != NULL); + tc->act = act; +} + -+static inline void cluster_init_act(struct cluster_handle * clust, -+ tfm_action act, -+ struct reiser4_slide * window) -+{ ++static inline void ++cluster_init_act (reiser4_cluster_t * clust, tfm_action act, reiser4_slide_t * window){ + assert("edward-84", clust != NULL); + memset(clust, 0, sizeof *clust); -+ cluster_set_tfm_act(&clust->tc, act); ++ tfm_cluster_init_act(&clust->tc, act); + clust->dstat = INVAL_DISK_CLUSTER; + clust->win = window; +} + -+static inline void cluster_init_read(struct cluster_handle * clust, -+ struct reiser4_slide * window) -+{ -+ cluster_init_act (clust, TFMA_READ, window); -+} -+ -+static inline void cluster_init_write(struct cluster_handle * clust, -+ struct reiser4_slide * window) -+{ -+ cluster_init_act (clust, TFMA_WRITE, window); -+} -+ -+/* true if @p1 and @p2 are items of the same disk cluster */ -+static inline int same_disk_cluster(const coord_t * p1, const coord_t * p2) -+{ -+ /* drop this if you have other items to aggregate */ -+ assert("edward-1494", item_id_by_coord(p1) == CTAIL_ID); -+ -+ return item_plugin_by_coord(p1)->b.mergeable(p1, p2); -+} -+ -+static inline int dclust_get_extension_dsize(hint_t * hint) ++static inline void ++cluster_init_read(reiser4_cluster_t * clust, reiser4_slide_t * window) +{ -+ return hint->ext_coord.extension.ctail.dsize; ++ cluster_init_act (clust, TFM_READ_ACT, window); +} + -+static inline void dclust_set_extension_dsize(hint_t * hint, int dsize) ++static inline void ++cluster_init_write(reiser4_cluster_t * clust, reiser4_slide_t * window) +{ -+ hint->ext_coord.extension.ctail.dsize = dsize; ++ cluster_init_act (clust, TFM_WRITE_ACT, window); +} + -+static inline int dclust_get_extension_shift(hint_t * hint) ++static inline int dclust_get_extension(hint_t * hint) +{ + return hint->ext_coord.extension.ctail.shift; +} + -+static inline int dclust_get_extension_ncount(hint_t * hint) ++static inline void dclust_set_extension(hint_t * hint) +{ -+ return hint->ext_coord.extension.ctail.ncount; -+} -+ -+static inline void dclust_inc_extension_ncount(hint_t * hint) -+{ -+ hint->ext_coord.extension.ctail.ncount ++; -+} -+ -+static inline void dclust_init_extension(hint_t * hint) -+{ -+ memset(&hint->ext_coord.extension.ctail, 0, -+ sizeof(hint->ext_coord.extension.ctail)); ++ assert("edward-1270", ++ item_id_by_coord(&hint->ext_coord.coord) == CTAIL_ID); ++ hint->ext_coord.extension.ctail.shift = ++ cluster_shift_by_coord(&hint->ext_coord.coord); +} + +static inline int hint_is_unprepped_dclust(hint_t * hint) +{ -+ assert("edward-1451", hint_is_valid(hint)); -+ return dclust_get_extension_shift(hint) == (int)UCTAIL_SHIFT; ++ return dclust_get_extension(hint) == (int)UCTAIL_SHIFT; +} + +static inline void coord_set_between_clusters(coord_t * coord) @@ -25509,69 +25647,66 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.h linux-2.6.22/fs/reiser4/ +#endif +} + -+int reiser4_inflate_cluster(struct cluster_handle *, struct inode *); -+int find_disk_cluster(struct cluster_handle *, struct inode *, int read, ++int inflate_cluster(reiser4_cluster_t *, struct inode *); ++int find_cluster(reiser4_cluster_t *, struct inode *, int read, int write); ++void forget_cluster_pages(struct page **page, int nrpages); ++int flush_cluster_pages(reiser4_cluster_t *, jnode *, struct inode *); ++int deflate_cluster(reiser4_cluster_t *, struct inode *); ++void truncate_page_cluster(struct inode *inode, cloff_t start); ++void invalidate_hint_cluster(reiser4_cluster_t * clust); ++void put_hint_cluster(reiser4_cluster_t * clust, struct inode *inode, + znode_lock_mode mode); -+int checkout_logical_cluster(struct cluster_handle *, jnode *, struct inode *); -+int reiser4_deflate_cluster(struct cluster_handle *, struct inode *); -+void truncate_complete_page_cluster(struct inode *inode, cloff_t start, -+ int even_cows); -+void invalidate_hint_cluster(struct cluster_handle * clust); -+void put_hint_cluster(struct cluster_handle * clust, struct inode *inode, -+ znode_lock_mode mode); -+int get_disk_cluster_locked(struct cluster_handle * clust, struct inode * inode, ++int get_disk_cluster_locked(reiser4_cluster_t * clust, struct inode *inode, + znode_lock_mode lock_mode); -+void reset_cluster_params(struct cluster_handle * clust); -+int set_cluster_by_page(struct cluster_handle * clust, struct page * page, ++void reset_cluster_params(reiser4_cluster_t * clust); ++int set_cluster_by_page(reiser4_cluster_t * clust, struct page * page, + int count); -+int prepare_page_cluster(struct inode *inode, struct cluster_handle * clust, -+ rw_op rw); -+void __put_page_cluster(int from, int to, struct page ** pages, -+ struct inode * inode); -+void put_page_cluster(struct cluster_handle * clust, -+ struct inode * inode, rw_op rw); -+void put_cluster_handle(struct cluster_handle * clust); -+int grab_tfm_stream(struct inode *inode, struct tfm_cluster * tc, tfm_stream_id id); -+int tfm_cluster_is_uptodate(struct tfm_cluster * tc); -+void tfm_cluster_set_uptodate(struct tfm_cluster * tc); -+void tfm_cluster_clr_uptodate(struct tfm_cluster * tc); ++int prepare_page_cluster(struct inode *inode, reiser4_cluster_t * clust, ++ int capture); ++void release_cluster_pages(reiser4_cluster_t *); ++void put_cluster_handle(reiser4_cluster_t * clust); ++int grab_tfm_stream(struct inode *inode, tfm_cluster_t * tc, tfm_stream_id id); ++int tfm_cluster_is_uptodate(tfm_cluster_t * tc); ++void tfm_cluster_set_uptodate(tfm_cluster_t * tc); ++void tfm_cluster_clr_uptodate(tfm_cluster_t * tc); + +/* move cluster handle to the target position -+ specified by the page of index @pgidx */ -+static inline void move_cluster_forward(struct cluster_handle * clust, -+ struct inode *inode, -+ pgoff_t pgidx) ++ specified by the page of index @pgidx ++*/ ++static inline void ++move_cluster_forward(reiser4_cluster_t * clust, struct inode *inode, ++ pgoff_t pgidx, int *progress) +{ + assert("edward-1297", clust != NULL); + assert("edward-1298", inode != NULL); + + reset_cluster_params(clust); -+ if (clust->index_valid && ++ if (*progress && + /* Hole in the indices. Hint became invalid and can not be + used by find_cluster_item() even if seal/node versions + will coincide */ + pg_to_clust(pgidx, inode) != clust->index + 1) { -+ reiser4_unset_hint(clust->hint); ++ unset_hint(clust->hint); + invalidate_hint_cluster(clust); + } ++ *progress = 1; + clust->index = pg_to_clust(pgidx, inode); -+ clust->index_valid = 1; +} + -+static inline int alloc_clust_pages(struct cluster_handle * clust, -+ struct inode *inode) ++static inline int ++alloc_clust_pages(reiser4_cluster_t * clust, struct inode *inode) +{ + assert("edward-791", clust != NULL); + assert("edward-792", inode != NULL); + clust->pages = + kmalloc(sizeof(*clust->pages) << inode_cluster_shift(inode), -+ reiser4_ctx_gfp_mask_get()); ++ GFP_KERNEL); + if (!clust->pages) + return -ENOMEM; + return 0; +} + -+static inline void free_clust_pages(struct cluster_handle * clust) ++static inline void free_clust_pages(reiser4_cluster_t * clust) +{ + kfree(clust->pages); +} @@ -25588,10 +25723,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/cluster.h linux-2.6.22/fs/reiser4/ + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/fs/reiser4/plugin/compress/compress.c ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/compress.c 2007-07-29 00:25:34.892700618 +0400 -@@ -0,0 +1,381 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/Makefile +@@ -0,0 +1,6 @@ ++obj-$(CONFIG_REISER4_FS) += compress_plugins.o ++ ++compress_plugins-objs := \ ++ compress.o \ ++ minilzo.o \ ++ compress_mode.o +Index: linux-2.6.16/fs/reiser4/plugin/compress/compress.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/compress.c +@@ -0,0 +1,370 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* reiser4 compression transform plugins */ + @@ -25600,31 +25747,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f +#include "../plugin.h" +#include "minilzo.h" + ++#include +#include +#include +#include + -+static int change_compression(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_compression(struct inode *inode, reiser4_plugin * plugin) +{ + assert("edward-1316", inode != NULL); + assert("edward-1317", plugin != NULL); + assert("edward-1318", is_reiser4_inode(inode)); + assert("edward-1319", + plugin->h.type_id == REISER4_COMPRESSION_PLUGIN_TYPE); -+ -+ /* cannot change compression plugin of already existing regular object */ -+ if (!plugin_of_group(inode_file_plugin(inode), REISER4_DIRECTORY_FILE)) -+ return RETERR(-EINVAL); -+ -+ /* If matches, nothing to change. */ -+ if (inode_hash_plugin(inode) != NULL && -+ inode_hash_plugin(inode)->h.id == plugin->h.id) -+ return 0; -+ -+ return aset_set_unsafe(&reiser4_inode_data(inode)->pset, -+ PSET_COMPRESSION, plugin); ++ /* cannot change compression plugin of already existing object */ ++ return RETERR(-EINVAL); +} + +static reiser4_plugin_ops compression_plugin_ops = { @@ -25665,16 +25801,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f +#if REISER4_ZLIB + int ret = 0; + switch (act) { -+ case TFMA_WRITE: /* compress */ -+ coa = reiser4_vmalloc(zlib_deflate_workspacesize()); ++ case TFM_WRITE_ACT: /* compress */ ++ coa = vmalloc(zlib_deflate_workspacesize()); + if (!coa) { + ret = -ENOMEM; + break; + } + memset(coa, 0, zlib_deflate_workspacesize()); + break; -+ case TFMA_READ: /* decompress */ -+ coa = reiser4_vmalloc(zlib_inflate_workspacesize()); ++ case TFM_READ_ACT: /* decompress */ ++ coa = vmalloc(zlib_inflate_workspacesize()); + if (!coa) { + ret = -ENOMEM; + break; @@ -25700,10 +25836,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f + assert("edward-769", coa != NULL); + + switch (act) { -+ case TFMA_WRITE: /* compress */ ++ case TFM_WRITE_ACT: /* compress */ + vfree(coa); + break; -+ case TFMA_READ: /* decompress */ ++ case TFM_READ_ACT: /* decompress */ + vfree(coa); + break; + default: @@ -25841,14 +25977,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f + coa_t coa = NULL; + + switch (act) { -+ case TFMA_WRITE: /* compress */ -+ coa = reiser4_vmalloc(LZO_HEAP_SIZE(LZO1X_1_MEM_COMPRESS)); ++ case TFM_WRITE_ACT: /* compress */ ++ coa = vmalloc(LZO_HEAP_SIZE(LZO1X_1_MEM_COMPRESS)); + if (!coa) { + ret = -ENOMEM; + break; + } + memset(coa, 0, LZO_HEAP_SIZE(LZO1X_1_MEM_COMPRESS)); -+ case TFMA_READ: /* decompress */ ++ case TFM_READ_ACT: /* decompress */ + break; + default: + impossible("edward-877", @@ -25868,10 +26004,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f + assert("edward-879", coa != NULL); + + switch (act) { -+ case TFMA_WRITE: /* compress */ ++ case TFM_WRITE_ACT: /* compress */ + vfree(coa); + break; -+ case TFMA_READ: /* decompress */ ++ case TFM_READ_ACT: /* decompress */ + impossible("edward-1304", + "trying to free non-allocated workspace"); + default: @@ -25957,7 +26093,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f + .alloc = gzip1_alloc, + .free = gzip1_free, + .min_size_deflate = gzip1_min_size_deflate, -+ .checksum = reiser4_adler32, ++ .checksum = NULL, + .compress = gzip1_compress, + .decompress = gzip1_decompress + } @@ -25973,38 +26109,34 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.c linux-2.6.22/f + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.h linux-2.6.22/fs/reiser4/plugin/compress/compress.h ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/compress.h 2007-07-29 00:25:34.892700618 +0400 -@@ -0,0 +1,43 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/compress.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/compress.h +@@ -0,0 +1,38 @@ +#if !defined( __FS_REISER4_COMPRESS_H__ ) +#define __FS_REISER4_COMPRESS_H__ + +#include +#include + -+/* transform direction */ +typedef enum { -+ TFMA_READ, /* decrypt, decompress */ -+ TFMA_WRITE, /* encrypt, compress */ -+ TFMA_LAST ++ TFM_READ_ACT, ++ TFM_WRITE_ACT, ++ TFM_LAST_ACT +} tfm_action; + -+/* supported compression algorithms */ ++/* builtin compression plugins */ ++ +typedef enum { + LZO1_COMPRESSION_ID, + GZIP1_COMPRESSION_ID, + LAST_COMPRESSION_ID, +} reiser4_compression_id; + -+/* the same as pgoff, but units are page clusters */ +typedef unsigned long cloff_t; -+ -+/* working data of a (de)compression algorithm */ +typedef void *coa_t; -+ -+/* table for all supported (de)compression algorithms */ -+typedef coa_t coa_set[LAST_COMPRESSION_ID][TFMA_LAST]; ++typedef coa_t coa_set[LAST_COMPRESSION_ID][TFM_LAST_ACT]; + +__u32 reiser4_adler32(char *data, __u32 len); + @@ -26020,10 +26152,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress.h linux-2.6.22/f + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c linux-2.6.22/fs/reiser4/plugin/compress/compress_mode.c ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/compress_mode.c 2007-07-29 00:25:34.892700618 +0400 -@@ -0,0 +1,162 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/compress_mode.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/compress_mode.c +@@ -0,0 +1,163 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* This file contains Reiser4 compression mode plugins. + @@ -26035,6 +26168,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c linux-2.6 +#include "../../inode.h" +#include "../plugin.h" + ++static int should_deflate_test(struct inode * inode, cloff_t index) ++{ ++ return !test_bit(0, &index); ++} ++ +static int should_deflate_none(struct inode * inode, cloff_t index) +{ + return 0; @@ -26045,58 +26183,71 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c linux-2.6 + return compression_is_on(cryptcompress_inode_data(inode)); +} + -+static int discard_hook_ultim(struct inode *inode, cloff_t index) ++static int turn_off_compression(struct inode *inode, cloff_t index) +{ -+ turn_off_compression(cryptcompress_inode_data(inode)); ++ toggle_compression(cryptcompress_inode_data(inode), 0); + return 0; +} + -+static int discard_hook_lattd(struct inode *inode, cloff_t index) ++static int turn_on_compression(struct inode *inode, cloff_t index) +{ -+ struct cryptcompress_info * info = cryptcompress_inode_data(inode); -+ -+ assert("edward-1462", -+ get_lattice_factor(info) >= MIN_LATTICE_FACTOR && -+ get_lattice_factor(info) <= MAX_LATTICE_FACTOR); -+ -+ turn_off_compression(info); -+ if (get_lattice_factor(info) < MAX_LATTICE_FACTOR) -+ set_lattice_factor(info, get_lattice_factor(info) << 1); ++ toggle_compression(cryptcompress_inode_data(inode), 1); + return 0; +} + -+static int accept_hook_lattd(struct inode *inode, cloff_t index) ++static int turn_off_compression_on_zero(struct inode *inode, cloff_t index) +{ -+ turn_on_compression(cryptcompress_inode_data(inode)); -+ set_lattice_factor(cryptcompress_inode_data(inode), MIN_LATTICE_FACTOR); ++ assert("edward-1308", inode != NULL); ++ if (index == 0) ++ toggle_compression(cryptcompress_inode_data(inode), 0); + return 0; +} + -+/* Check on dynamic lattice, the adaptive compression modes which -+ defines the following behavior: -+ ++/* Check on lattice (COL) of some sparseness factor, ++ the family of adaptive compression modes which define ++ the following behavior: ++ + Compression is on: try to compress everything and turn + it off, whenever cluster is incompressible. -+ -+ Compression is off: try to compress clusters of indexes ++ ++ Compression is off: try to compress clusters of indexes + k * FACTOR (k = 0, 1, 2, ...) and turn it on, if some of -+ them is compressible. If incompressible, then increase FACTOR */ ++ them is compressible. */ + +/* check if @index belongs to one-dimensional lattice + of sparce factor @factor */ -+static int is_on_lattice(cloff_t index, int factor) ++static int check_on_lattice(cloff_t index, int factor) +{ + return (factor ? index % factor == 0: index == 0); +} + -+static int should_deflate_lattd(struct inode * inode, cloff_t index) -+{ -+ return should_deflate_common(inode, index) || -+ is_on_lattice(index, -+ get_lattice_factor -+ (cryptcompress_inode_data(inode))); ++#define DEFINE_CHECK_ON_LATTICE(FACTOR) \ ++ static int check_on_lattice_ ## FACTOR (struct inode * inode, \ ++ cloff_t index) \ ++{ \ ++ return should_deflate_common(inode, index) || \ ++ check_on_lattice(index, FACTOR); \ ++} ++ ++#define SUPPORT_COL_COMPRESSION_MODE(FACTOR, LABEL) \ ++[COL_ ## FACTOR ## _COMPRESSION_MODE_ID] = { \ ++ .h = { \ ++ .type_id = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, \ ++ .id = COL_ ## FACTOR ## _COMPRESSION_MODE_ID, \ ++ .pops = NULL, \ ++ .label = LABEL, \ ++ .desc = LABEL, \ ++ .linkage = {NULL, NULL} \ ++ }, \ ++ .should_deflate = check_on_lattice_ ## FACTOR, \ ++ .accept_hook = turn_on_compression, \ ++ .discard_hook = turn_off_compression \ +} + ++DEFINE_CHECK_ON_LATTICE(8) ++DEFINE_CHECK_ON_LATTICE(16) ++DEFINE_CHECK_ON_LATTICE(32) ++ +/* compression mode_plugins */ +compression_mode_plugin compression_mode_plugins[LAST_COMPRESSION_MODE_ID] = { + [NONE_COMPRESSION_MODE_ID] = { @@ -26105,72 +26256,55 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c linux-2.6 + .id = NONE_COMPRESSION_MODE_ID, + .pops = NULL, + .label = "none", -+ .desc = "Compress nothing", ++ .desc = "Don't compress", + .linkage = {NULL, NULL} + }, + .should_deflate = should_deflate_none, + .accept_hook = NULL, + .discard_hook = NULL + }, -+ /* Check-on-dynamic-lattice adaptive compression mode */ -+ [LATTD_COMPRESSION_MODE_ID] = { -+ .h = { -+ .type_id = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, -+ .id = LATTD_COMPRESSION_MODE_ID, -+ .pops = NULL, -+ .label = "lattd", -+ .desc = "Check on dynamic lattice", -+ .linkage = {NULL, NULL} -+ }, -+ .should_deflate = should_deflate_lattd, -+ .accept_hook = accept_hook_lattd, -+ .discard_hook = discard_hook_lattd -+ }, -+ /* Check-ultimately compression mode: -+ Turn off compression forever as soon as we meet -+ incompressible data */ -+ [ULTIM_COMPRESSION_MODE_ID] = { ++ /* Check-on-lattice adaptive compression modes */ ++ SUPPORT_COL_COMPRESSION_MODE(8, "col8"), ++ SUPPORT_COL_COMPRESSION_MODE(16, "col16"), ++ SUPPORT_COL_COMPRESSION_MODE(32, "col32"), ++ /* Turn off compression if logical cluster of index == 0 ++ is incompressible, then don't check anymore */ ++ [COZ_COMPRESSION_MODE_ID] = { + .h = { + .type_id = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, -+ .id = ULTIM_COMPRESSION_MODE_ID, ++ .id = COZ_COMPRESSION_MODE_ID, + .pops = NULL, -+ .label = "ultim", -+ .desc = "Check ultimately", ++ .label = "coz", ++ .desc = "Check on zero", + .linkage = {NULL, NULL} + }, + .should_deflate = should_deflate_common, + .accept_hook = NULL, -+ .discard_hook = discard_hook_ultim ++ .discard_hook = turn_off_compression_on_zero + }, -+ /* Force-to-compress-everything compression mode */ + [FORCE_COMPRESSION_MODE_ID] = { + .h = { + .type_id = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, + .id = FORCE_COMPRESSION_MODE_ID, + .pops = NULL, + .label = "force", -+ .desc = "Force to compress everything", ++ .desc = "Compress everything", + .linkage = {NULL, NULL} + }, + .should_deflate = NULL, + .accept_hook = NULL, + .discard_hook = NULL + }, -+ /* Convert-to-extent compression mode. -+ In this mode items will be converted to extents and management -+ will be passed to (classic) unix file plugin as soon as ->write() -+ detects that the first complete logical cluster (of index #0) is -+ incompressible. */ -+ [CONVX_COMPRESSION_MODE_ID] = { ++ [TEST_COMPRESSION_MODE_ID] = { + .h = { + .type_id = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, -+ .id = CONVX_COMPRESSION_MODE_ID, ++ .id = TEST_COMPRESSION_MODE_ID, + .pops = NULL, -+ .label = "conv", -+ .desc = "Convert to extent", ++ .label = "test", /* This mode is for benchmarks only */ ++ .desc = "Don't compress odd clusters", + .linkage = {NULL, NULL} + }, -+ .should_deflate = should_deflate_common, ++ .should_deflate = should_deflate_test, + .accept_hook = NULL, + .discard_hook = NULL + } @@ -26186,10 +26320,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/compress_mode.c linux-2.6 + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs/reiser4/plugin/compress/lzoconf.h ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/lzoconf.h 2007-07-29 00:25:34.896701653 +0400 -@@ -0,0 +1,216 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/lzoconf.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/lzoconf.h +@@ -0,0 +1,420 @@ +/* lzoconf.h -- configuration for the LZO real-time data compression library + adopted for reiser4 compression transform plugin. + @@ -26235,6 +26370,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs +#define LZO_VERSION_DATE "Jul 12 2002" + +/* internal Autoconf configuration file - only used when building LZO */ ++#if defined(LZO_HAVE_CONFIG_H) ++# include ++#endif ++#ifdef __cplusplus ++extern "C" { ++#endif + +/*********************************************************************** +// LZO requires a conforming @@ -26250,9 +26391,52 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs +// architecture defines +************************************************************************/ + ++#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2) ++# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) ++# define __LZO_WIN ++# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) ++# define __LZO_WIN ++# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) ++# define __LZO_WIN ++# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) ++# define __LZO_DOS ++# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) ++# define __LZO_OS2 ++# elif defined(__palmos__) ++# define __LZO_PALMOS ++# elif defined(__TOS__) || defined(__atarist__) ++# define __LZO_TOS ++# endif ++#endif ++ ++#if (UINT_MAX < LZO_0xffffffffL) ++# if defined(__LZO_WIN) ++# define __LZO_WIN16 ++# elif defined(__LZO_DOS) ++# define __LZO_DOS16 ++# elif defined(__LZO_PALMOS) ++# define __LZO_PALMOS16 ++# elif defined(__LZO_TOS) ++# define __LZO_TOS16 ++# elif defined(__C166__) ++# else ++ /* porting hint: for pure 16-bit architectures try compiling ++ * everything with -D__LZO_STRICT_16BIT */ ++# error "16-bit target not supported - contact me for porting hints" ++# endif ++#endif ++ +#if !defined(__LZO_i386) -+# if defined(__i386__) || defined(__386__) || defined(_M_IX86) ++# if defined(__LZO_DOS) || defined(__LZO_WIN16) +# define __LZO_i386 ++# elif defined(__i386__) || defined(__386__) || defined(_M_IX86) ++# define __LZO_i386 ++# endif ++#endif ++ ++#if defined(__LZO_STRICT_16BIT) ++# if (UINT_MAX < LZO_0xffffffffL) ++# include +# endif +#endif + @@ -26317,10 +26501,37 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs +// memory models +************************************************************************/ + ++/* Memory model for the public code segment. */ ++#if !defined(__LZO_CMODEL) ++# if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# define __LZO_CMODEL __far ++# elif defined(__LZO_i386) && defined(__WATCOMC__) ++# define __LZO_CMODEL __near ++# else ++# define __LZO_CMODEL ++# endif ++#endif ++ ++/* Memory model for the public data segment. */ ++#if !defined(__LZO_DMODEL) ++# if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# define __LZO_DMODEL __far ++# elif defined(__LZO_i386) && defined(__WATCOMC__) ++# define __LZO_DMODEL __near ++# else ++# define __LZO_DMODEL ++# endif ++#endif ++ +/* Memory model that allows to access memory at offsets of lzo_uint. */ +#if !defined(__LZO_MMODEL) +# if (LZO_UINT_MAX <= UINT_MAX) +# define __LZO_MMODEL ++# elif defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# define __LZO_MMODEL __huge ++# define LZO_999_UNSUPPORTED ++# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16) ++# define __LZO_MMODEL +# else +# error "__LZO_MMODEL" +# endif @@ -26344,10 +26555,134 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs +# define lzo_sizeof_dict_t sizeof(lzo_bytep) +#endif + -+typedef int (*lzo_compress_t) (const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); ++/*********************************************************************** ++// calling conventions and function types ++************************************************************************/ + ++/* linkage */ ++#if !defined(__LZO_EXTERN_C) ++# ifdef __cplusplus ++# define __LZO_EXTERN_C extern "C" ++# else ++# define __LZO_EXTERN_C extern ++# endif ++#endif ++ ++/* calling convention */ ++#if !defined(__LZO_CDECL) ++# if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# define __LZO_CDECL __LZO_CMODEL __cdecl ++# elif defined(__LZO_i386) && defined(_MSC_VER) ++# define __LZO_CDECL __LZO_CMODEL __cdecl ++# elif defined(__LZO_i386) && defined(__WATCOMC__) ++# define __LZO_CDECL __LZO_CMODEL __cdecl ++# else ++# define __LZO_CDECL __LZO_CMODEL ++# endif ++#endif ++#if !defined(__LZO_ENTRY) ++# define __LZO_ENTRY __LZO_CDECL ++#endif ++ ++/* C++ exception specification for extern "C" function types */ ++#if !defined(__cplusplus) ++# undef LZO_NOTHROW ++# define LZO_NOTHROW ++#elif !defined(LZO_NOTHROW) ++# define LZO_NOTHROW ++#endif ++ ++ typedef int ++ (__LZO_ENTRY * lzo_compress_t) (const lzo_byte * src, lzo_uint src_len, ++ lzo_byte * dst, lzo_uintp dst_len, ++ lzo_voidp wrkmem); ++ ++ typedef int ++ (__LZO_ENTRY * lzo_decompress_t) (const lzo_byte * src, ++ lzo_uint src_len, lzo_byte * dst, ++ lzo_uintp dst_len, lzo_voidp wrkmem); ++ ++ typedef int ++ (__LZO_ENTRY * lzo_optimize_t) (lzo_byte * src, lzo_uint src_len, ++ lzo_byte * dst, lzo_uintp dst_len, ++ lzo_voidp wrkmem); ++ ++ typedef int ++ (__LZO_ENTRY * lzo_compress_dict_t) (const lzo_byte * src, ++ lzo_uint src_len, lzo_byte * dst, ++ lzo_uintp dst_len, ++ lzo_voidp wrkmem, ++ const lzo_byte * dict, ++ lzo_uint dict_len); ++ ++ typedef int ++ (__LZO_ENTRY * lzo_decompress_dict_t) (const lzo_byte * src, ++ lzo_uint src_len, ++ lzo_byte * dst, ++ lzo_uintp dst_len, ++ lzo_voidp wrkmem, ++ const lzo_byte * dict, ++ lzo_uint dict_len); ++ ++/* assembler versions always use __cdecl */ ++ typedef int ++ (__LZO_CDECL * lzo_compress_asm_t) (const lzo_byte * src, ++ lzo_uint src_len, lzo_byte * dst, ++ lzo_uintp dst_len, ++ lzo_voidp wrkmem); ++ ++ typedef int ++ (__LZO_CDECL * lzo_decompress_asm_t) (const lzo_byte * src, ++ lzo_uint src_len, lzo_byte * dst, ++ lzo_uintp dst_len, ++ lzo_voidp wrkmem); ++ ++/* a progress indicator callback function */ ++ typedef void (__LZO_ENTRY * lzo_progress_callback_t) (lzo_uint, ++ lzo_uint); ++ ++/*********************************************************************** ++// export information ++************************************************************************/ ++ ++/* DLL export information */ ++#if !defined(__LZO_EXPORT1) ++# define __LZO_EXPORT1 ++#endif ++#if !defined(__LZO_EXPORT2) ++# define __LZO_EXPORT2 ++#endif ++ ++/* exported calling convention for C functions */ ++#if !defined(LZO_PUBLIC) ++# define LZO_PUBLIC(_rettype) \ ++ __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY ++#endif ++#if !defined(LZO_EXTERN) ++# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) ++#endif ++#if !defined(LZO_PRIVATE) ++# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY ++#endif ++ ++/* exported __cdecl calling convention for assembler functions */ ++#if !defined(LZO_PUBLIC_CDECL) ++# define LZO_PUBLIC_CDECL(_rettype) \ ++ __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL ++#endif ++#if !defined(LZO_EXTERN_CDECL) ++# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype) ++#endif ++ ++/* exported global variables (LZO currently uses no static variables and ++ * is fully thread safe) */ ++#if !defined(LZO_PUBLIC_VAR) ++# define LZO_PUBLIC_VAR(_type) \ ++ __LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL ++#endif ++#if !defined(LZO_EXTERN_VAR) ++# define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type) ++#endif + +/*********************************************************************** +// error codes and prototypes @@ -26377,12 +26712,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs + (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_compress_t)) -+ extern int __lzo_init2(unsigned, int, int, int, int, int, int, -+ int, int, int); ++ LZO_EXTERN(int) __lzo_init2(unsigned, int, int, int, int, int, int, ++ int, int, int); + +/* checksum functions */ -+extern lzo_uint32 lzo_crc32(lzo_uint32 _c, const lzo_byte * _buf, -+ lzo_uint _len); ++ LZO_EXTERN(lzo_uint32) ++ lzo_crc32(lzo_uint32 _c, const lzo_byte * _buf, lzo_uint _len); ++ +/* misc. */ + typedef union { + lzo_bytep p; @@ -26405,21 +26741,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/lzoconf.h linux-2.6.22/fs +/* deprecated - only for backward compatibility */ +#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size) + ++#ifdef __cplusplus ++} /* extern "C" */ ++#endif +#endif /* already included */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/Makefile linux-2.6.22/fs/reiser4/plugin/compress/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/Makefile 2007-07-29 00:25:34.896701653 +0400 -@@ -0,0 +1,6 @@ -+obj-$(CONFIG_REISER4_FS) += compress_plugins.o -+ -+compress_plugins-objs := \ -+ compress.o \ -+ minilzo.o \ -+ compress_mode.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs/reiser4/plugin/compress/minilzo.c ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/minilzo.c 2007-07-29 00:25:34.900702689 +0400 -@@ -0,0 +1,1967 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/minilzo.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/minilzo.c +@@ -0,0 +1,2155 @@ +/* minilzo.c -- mini subset of the LZO real-time data compression library + adopted for reiser4 compression transform plugin. + @@ -26466,23 +26796,48 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#define __LZO_IN_MINILZO +#define LZO_BUILD + ++#ifdef MINILZO_HAVE_CONFIG_H ++# include ++#endif ++ ++#undef LZO_HAVE_CONFIG_H +#include "minilzo.h" + +#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x1080) +# error "version mismatch in miniLZO source files" +#endif + ++#ifdef MINILZO_HAVE_CONFIG_H ++# define LZO_HAVE_CONFIG_H ++#endif ++ ++ +#ifndef __LZO_CONF_H +#define __LZO_CONF_H + ++#if !defined(__LZO_IN_MINILZO) ++# ifndef __LZOCONF_H ++# include ++# endif ++#endif ++ ++#if defined(__BOUNDS_CHECKING_ON) ++# include ++#else +# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt +# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) ++#endif + +# define HAVE_MEMCMP +# define HAVE_MEMCPY +# define HAVE_MEMMOVE +# define HAVE_MEMSET + ++#if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# define HAVE_MALLOC_H ++# define HAVE_HALLOC ++#endif ++ +#undef NDEBUG +#if !defined(LZO_DEBUG) +# define NDEBUG @@ -26492,6 +26847,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +# include +# endif +#endif ++# if 0 /* edward */ ++#include ++#endif /* edward */ + +#if !defined(LZO_COMPILE_TIME_ASSERT) +# define LZO_COMPILE_TIME_ASSERT(expr) \ @@ -26508,6 +26866,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +# endif +#endif + ++#if !defined(__inline__) && !defined(__GNUC__) ++# if defined(__cplusplus) ++# define __inline__ inline ++# else ++# define __inline__ ++# endif ++#endif ++ +#if defined(NO_MEMCMP) +# undef HAVE_MEMCMP +#endif @@ -26642,7 +27008,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +# endif +#endif + -+extern const lzo_uint32 _lzo_crc32_table[256]; ++__LZO_EXTERN_C const lzo_uint32 _lzo_crc32_table[256]; + +#define _LZO_STRINGIZE(x) #x +#define _LZO_MEXPAND(x) _LZO_STRINGIZE(x) @@ -26660,11 +27026,37 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#ifndef __LZO_PTR_H +#define __LZO_PTR_H + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++# include ++# if 1 && defined(__WATCOMC__) ++# include ++ __LZO_EXTERN_C unsigned char _HShift; ++# define __LZO_HShift _HShift ++# elif 1 && defined(_MSC_VER) ++ __LZO_EXTERN_C unsigned short __near _AHSHIFT; ++# define __LZO_HShift ((unsigned) &_AHSHIFT) ++# elif defined(__LZO_WIN16) ++# define __LZO_HShift 3 ++# else ++# define __LZO_HShift 12 ++# endif ++# if !defined(_FP_SEG) && defined(FP_SEG) ++# define _FP_SEG FP_SEG ++# endif ++# if !defined(_FP_OFF) && defined(FP_OFF) ++# define _FP_OFF FP_OFF ++# endif ++#endif ++ +#if !defined(lzo_ptrdiff_t) +# if (UINT_MAX >= LZO_0xffffffffL) -+typedef ptrdiff_t lzo_ptrdiff_t; ++ typedef ptrdiff_t lzo_ptrdiff_t; +# else -+typedef long lzo_ptrdiff_t; ++ typedef long lzo_ptrdiff_t; +# endif +#endif + @@ -26676,8 +27068,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#if !defined(__LZO_HAVE_PTR_T) +# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_LONG) +# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG) -+typedef unsigned long lzo_ptr_t; -+typedef long lzo_sptr_t; ++ typedef unsigned long lzo_ptr_t; ++ typedef long lzo_sptr_t; +# define __LZO_HAVE_PTR_T +# endif +# endif @@ -26685,8 +27077,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#if !defined(__LZO_HAVE_PTR_T) +# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED) +# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED) -+typedef unsigned int lzo_ptr_t; -+typedef int lzo_sptr_t; ++ typedef unsigned int lzo_ptr_t; ++ typedef int lzo_sptr_t; +# define __LZO_HAVE_PTR_T +# endif +# endif @@ -26694,8 +27086,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#if !defined(__LZO_HAVE_PTR_T) +# if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_SHORT) +# if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_SHORT) -+typedef unsigned short lzo_ptr_t; -+typedef short lzo_sptr_t; ++ typedef unsigned short lzo_ptr_t; ++ typedef short lzo_sptr_t; +# define __LZO_HAVE_PTR_T +# endif +# endif @@ -26704,64 +27096,90 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +# if defined(LZO_HAVE_CONFIG_H) || defined(SIZEOF_CHAR_P) +# error "no suitable type for lzo_ptr_t" +# else -+typedef unsigned long lzo_ptr_t; -+typedef long lzo_sptr_t; ++ typedef unsigned long lzo_ptr_t; ++ typedef long lzo_sptr_t; +# define __LZO_HAVE_PTR_T +# endif +#endif + ++#if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++#define PTR(a) ((lzo_bytep) (a)) ++#define PTR_ALIGNED_4(a) ((_FP_OFF(a) & 3) == 0) ++#define PTR_ALIGNED2_4(a,b) (((_FP_OFF(a) | _FP_OFF(b)) & 3) == 0) ++#else +#define PTR(a) ((lzo_ptr_t) (a)) +#define PTR_LINEAR(a) PTR(a) +#define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) +#define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) +#define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) +#define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) ++#endif + +#define PTR_LT(a,b) (PTR(a) < PTR(b)) +#define PTR_GE(a,b) (PTR(a) >= PTR(b)) +#define PTR_DIFF(a,b) ((lzo_ptrdiff_t) (PTR(a) - PTR(b))) +#define pd(a,b) ((lzo_uint) ((a)-(b))) + -+typedef union { -+ char a_char; -+ unsigned char a_uchar; -+ short a_short; -+ unsigned short a_ushort; -+ int a_int; -+ unsigned int a_uint; -+ long a_long; -+ unsigned long a_ulong; -+ lzo_int a_lzo_int; -+ lzo_uint a_lzo_uint; -+ lzo_int32 a_lzo_int32; -+ lzo_uint32 a_lzo_uint32; -+ ptrdiff_t a_ptrdiff_t; -+ lzo_ptrdiff_t a_lzo_ptrdiff_t; -+ lzo_ptr_t a_lzo_ptr_t; -+ lzo_voidp a_lzo_voidp; -+ void *a_void_p; -+ lzo_bytep a_lzo_bytep; -+ lzo_bytepp a_lzo_bytepp; -+ lzo_uintp a_lzo_uintp; -+ lzo_uint *a_lzo_uint_p; -+ lzo_uint32p a_lzo_uint32p; -+ lzo_uint32 *a_lzo_uint32_p; -+ unsigned char *a_uchar_p; -+ char *a_char_p; -+} lzo_full_align_t; ++ typedef union { ++ char a_char; ++ unsigned char a_uchar; ++ short a_short; ++ unsigned short a_ushort; ++ int a_int; ++ unsigned int a_uint; ++ long a_long; ++ unsigned long a_ulong; ++ lzo_int a_lzo_int; ++ lzo_uint a_lzo_uint; ++ lzo_int32 a_lzo_int32; ++ lzo_uint32 a_lzo_uint32; ++ ptrdiff_t a_ptrdiff_t; ++ lzo_ptrdiff_t a_lzo_ptrdiff_t; ++ lzo_ptr_t a_lzo_ptr_t; ++ lzo_voidp a_lzo_voidp; ++ void *a_void_p; ++ lzo_bytep a_lzo_bytep; ++ lzo_bytepp a_lzo_bytepp; ++ lzo_uintp a_lzo_uintp; ++ lzo_uint *a_lzo_uint_p; ++ lzo_uint32p a_lzo_uint32p; ++ lzo_uint32 *a_lzo_uint32_p; ++ unsigned char *a_uchar_p; ++ char *a_char_p; ++ } lzo_full_align_t; + ++#ifdef __cplusplus ++} ++#endif +#endif +#define LZO_DETERMINISTIC +#define LZO_DICT_USE_PTR ++#if defined(__LZO_DOS16) || defined(__LZO_WIN16) || defined(__LZO_STRICT_16BIT) ++# undef LZO_DICT_USE_PTR ++#endif ++#if defined(LZO_DICT_USE_PTR) +# define lzo_dict_t const lzo_bytep +# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++#else ++# define lzo_dict_t lzo_uint ++# define lzo_dict_p lzo_dict_t __LZO_MMODEL * ++#endif +#if !defined(lzo_moff_t) +#define lzo_moff_t lzo_uint +#endif +#endif +static lzo_ptr_t __lzo_ptr_linear(const lzo_voidp ptr) +{ -+ return PTR_LINEAR(ptr); ++ lzo_ptr_t p; ++ ++#if defined(__LZO_DOS16) || defined(__LZO_WIN16) ++ p = (((lzo_ptr_t) (_FP_SEG(ptr))) << (16 - __LZO_HShift)) + ++ (_FP_OFF(ptr)); ++#else ++ p = PTR_LINEAR(ptr); ++#endif ++ ++ return p; +} + +static unsigned __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) @@ -26786,11 +27204,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#ifndef __LZO_CONF_H +#endif + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ +#if 1 && defined(HAVE_MEMCPY) ++#if !defined(__LZO_DOS16) && !defined(__LZO_WIN16) ++ +#define MEMCPY8_DS(dest,src,len) \ + memcpy(dest,src,len); \ + dest += len; \ + src += len ++ ++#endif +#endif + +#if !defined(MEMCPY8_DS) @@ -26818,6 +27244,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + do *dest++ = *src++; \ + while (--len > 0) + ++ +#if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET) + +#define BZERO8_PTR(s,l,n) memset((s),0,(lzo_uint)(l)*(n)) @@ -26828,6 +27255,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) + +#endif ++ ++#ifdef __cplusplus ++} ++#endif ++ +#endif + +/* If you use the LZO library in a product, you *must* keep this @@ -26964,6 +27396,37 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#elif (USHRT_MAX >= LZO_0xffffffffL) + COMPILE_TIME_ASSERT(sizeof(short) > 4); +#endif ++#if 0 /* to make gcc happy -edward */ ++#if (UINT_MAX == 65535u) ++ COMPILE_TIME_ASSERT(sizeof(int) == 2); ++#elif (UINT_MAX == LZO_0xffffffffL) ++ COMPILE_TIME_ASSERT(sizeof(int) == 4); ++#elif (UINT_MAX >= LZO_0xffffffffL) ++ COMPILE_TIME_ASSERT(sizeof(int) > 4); ++#endif ++#if (ULONG_MAX == 65535ul) ++ COMPILE_TIME_ASSERT(sizeof(long) == 2); ++#elif (ULONG_MAX == LZO_0xffffffffL) ++ COMPILE_TIME_ASSERT(sizeof(long) == 4); ++#elif (ULONG_MAX >= LZO_0xffffffffL) ++ COMPILE_TIME_ASSERT(sizeof(long) > 4); ++#endif ++#if defined(SIZEOF_UNSIGNED) ++ COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED == sizeof(unsigned)); ++#endif ++#if defined(SIZEOF_UNSIGNED_LONG) ++ COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED_LONG == sizeof(unsigned long)); ++#endif ++#if defined(SIZEOF_UNSIGNED_SHORT) ++ COMPILE_TIME_ASSERT(SIZEOF_UNSIGNED_SHORT == sizeof(unsigned short)); ++#endif ++#if !defined(__LZO_IN_MINILZO) ++#if defined(SIZEOF_SIZE_T) ++ COMPILE_TIME_ASSERT(SIZEOF_SIZE_T == sizeof(size_t)); ++#endif ++#endif ++#endif /* -edward */ ++ + COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned char)); + COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned short)); + COMPILE_TIME_ASSERT(IS_UNSIGNED(unsigned)); @@ -26981,10 +27444,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + COMPILE_TIME_ASSERT(UINT_MAX == LZO_UTYPE_MAX(sizeof(unsigned))); + COMPILE_TIME_ASSERT(LONG_MAX == LZO_STYPE_MAX(sizeof(long))); + COMPILE_TIME_ASSERT(ULONG_MAX == LZO_UTYPE_MAX(sizeof(unsigned long))); ++ // COMPILE_TIME_ASSERT(SHRT_MAX == LZO_STYPE_MAX(sizeof(short))); /* edward */ + COMPILE_TIME_ASSERT(USHRT_MAX == LZO_UTYPE_MAX(sizeof(unsigned short))); + COMPILE_TIME_ASSERT(LZO_UINT32_MAX == + LZO_UTYPE_MAX(sizeof(lzo_uint32))); + COMPILE_TIME_ASSERT(LZO_UINT_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint))); ++#if !defined(__LZO_IN_MINILZO) ++ COMPILE_TIME_ASSERT(SIZE_T_MAX == LZO_UTYPE_MAX(sizeof(size_t))); ++#endif + + r &= __lzo_assert(LZO_BYTE(257) == 1); + @@ -27136,7 +27603,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + unsigned short b; + lzo_uint32 aa[4]; + unsigned char x[4 * sizeof(lzo_full_align_t)]; -+ } u; ++ } ++ u; + + COMPILE_TIME_ASSERT((int)((unsigned char)((signed char)-1)) == 255); + COMPILE_TIME_ASSERT((((unsigned char)128) << (int)(8 * sizeof(int) - 8)) @@ -27260,8 +27728,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + +#undef COMPILE_TIME_ASSERT + -+int __lzo_init2(unsigned v, int s1, int s2, int s3, int s4, int s5, -+ int s6, int s7, int s8, int s9) ++LZO_PUBLIC(int) ++ __lzo_init2(unsigned v, int s1, int s2, int s3, int s4, int s5, ++ int s6, int s7, int s8, int s9) +{ + int r; + @@ -27287,6 +27756,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + return r; +} + ++#if !defined(__LZO_IN_MINILZO) ++ ++LZO_EXTERN(int) ++ __lzo_init(unsigned v, int s1, int s2, int s3, int s4, int s5, int s6, int s7); ++ ++LZO_PUBLIC(int) ++__lzo_init(unsigned v, int s1, int s2, int s3, int s4, int s5, int s6, int s7) ++{ ++ if (v == 0 || v > 0x1010) ++ return LZO_E_ERROR; ++ return __lzo_init2(v, s1, s2, s3, s4, s5, -1, -1, s6, s7); ++} ++ ++#endif ++ +#define do_compress _lzo1x_1_do_compress + +#define LZO_NEED_DICT_H @@ -27301,6 +27785,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +# define LZO1X +#endif + ++#if !defined(__LZO_IN_MINILZO) ++#include ++#endif ++ +#define LZO_EOF_CODE +#undef LZO_DETERMINISTIC + @@ -27343,6 +27831,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#ifndef __LZO_DICT_H +#define __LZO_DICT_H + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ +#if !defined(D_BITS) && defined(DBITS) +# define D_BITS DBITS +#endif @@ -27481,19 +27973,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + +#if !defined(DVAL_ASSERT) +#if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG) -+static void DVAL_ASSERT(lzo_uint32 dv, const lzo_byte * p) -+{ -+ lzo_uint32 df; -+ DVAL_FIRST(df, (p)); -+ assert(DINDEX(dv, p) == DINDEX(df, p)); -+} ++ static void DVAL_ASSERT(lzo_uint32 dv, const lzo_byte * p) { ++ lzo_uint32 df; ++ DVAL_FIRST(df, (p)); ++ assert(DINDEX(dv, p) == DINDEX(df, p)); ++ } +#else +# define DVAL_ASSERT(dv,p) ((void) 0) +#endif +#endif + ++#if defined(LZO_DICT_USE_PTR) +# define DENTRY(p,in) (p) +# define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] ++#else ++# define DENTRY(p,in) ((lzo_uint) ((p)-(in))) ++# define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex] ++#endif + +#if (DD_BITS == 0) + @@ -27512,6 +28008,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + +#endif + ++#if defined(LZO_DICT_USE_PTR) ++ +#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ + (m_pos == NULL || (m_off = (lzo_moff_t) (ip - m_pos)) > max_offset) + @@ -27521,11 +28019,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + (m_off = (lzo_moff_t) PTR_DIFF(ip,m_pos)) <= 0 || \ + m_off > max_offset) )) + ++#else ++ ++#define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ ++ (m_off == 0 || \ ++ ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \ ++ (m_pos = (ip) - (m_off), 0) ) ++ ++#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ ++ ((lzo_moff_t) ((ip)-(in)) <= m_off || \ ++ ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \ ++ (m_pos = (ip) - (m_off), 0) ) ++ ++#endif ++ +#if defined(LZO_DETERMINISTIC) +# define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET +#else +# define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET +#endif ++ ++#ifdef __cplusplus ++} ++#endif +#endif +#endif +#endif @@ -27724,8 +28240,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs + return pd(in_end, ii); +} + -+int DO_COMPRESS(const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) ++LZO_PUBLIC(int) ++ DO_COMPRESS(const lzo_byte * in, lzo_uint in_len, ++ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) +{ + lzo_byte *op = out; + lzo_uint t; @@ -27882,8 +28399,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#endif + +#if defined(DO_DECOMPRESS) -+int DO_DECOMPRESS(const lzo_byte * in, lzo_uint in_len, -+ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) ++LZO_PUBLIC(int) ++ DO_DECOMPRESS(const lzo_byte * in, lzo_uint in_len, ++ lzo_byte * out, lzo_uintp out_len, lzo_voidp wrkmem) +#endif +{ + register lzo_byte *op; @@ -28387,10 +28905,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.c linux-2.6.22/fs +#endif + +/***** End of minilzo.c *****/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.h linux-2.6.22/fs/reiser4/plugin/compress/minilzo.h ---- linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/compress/minilzo.h 2007-07-29 00:25:34.900702689 +0400 -@@ -0,0 +1,70 @@ +Index: linux-2.6.16/fs/reiser4/plugin/compress/minilzo.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/compress/minilzo.h +@@ -0,0 +1,94 @@ +/* minilzo.h -- mini subset of the LZO real-time data compression library + adopted for reiser4 compression transform plugin. + @@ -28437,8 +28956,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.h linux-2.6.22/fs + +#define MINILZO_VERSION 0x1080 + ++#ifdef __LZOCONF_H ++# error "you cannot use both LZO and miniLZO" ++#endif ++ ++#undef LZO_HAVE_CONFIG_H +#include "lzoconf.h" + ++#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) ++# error "version mismatch in header files" ++#endif ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/*********************************************************************** ++// ++************************************************************************/ ++ +/* Memory required for the wrkmem parameter. + * When the required size is 0, you can also pass a NULL pointer. + */ @@ -28448,29 +28984,99 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/compress/minilzo.h linux-2.6.22/fs +#define LZO1X_MEM_DECOMPRESS (0) + +/* compression */ -+extern int lzo1x_1_compress(const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem); ++ LZO_EXTERN(int) ++ lzo1x_1_compress(const lzo_byte * src, lzo_uint src_len, ++ lzo_byte * dst, lzo_uintp dst_len, lzo_voidp wrkmem); ++ +/* decompression */ -+extern int lzo1x_decompress(const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem /* NOT USED */); ++ LZO_EXTERN(int) ++ lzo1x_decompress(const lzo_byte * src, lzo_uint src_len, ++ lzo_byte * dst, lzo_uintp dst_len, ++ lzo_voidp wrkmem /* NOT USED */ ); ++ +/* safe decompression with overrun testing */ -+extern int lzo1x_decompress_safe(const lzo_byte * src, lzo_uint src_len, -+ lzo_byte * dst, lzo_uintp dst_len, -+ lzo_voidp wrkmem /* NOT USED */ ); ++ LZO_EXTERN(int) ++ lzo1x_decompress_safe(const lzo_byte * src, lzo_uint src_len, ++ lzo_byte * dst, lzo_uintp dst_len, ++ lzo_voidp wrkmem /* NOT USED */ ); + ++#ifdef __cplusplus ++} /* extern "C" */ ++#endif +#endif /* already included */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.c linux-2.6.22/fs/reiser4/plugin/crypto/cipher.c ---- linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/crypto/cipher.c 2007-07-29 00:25:34.900702689 +0400 -@@ -0,0 +1,37 @@ +Index: linux-2.6.16/fs/reiser4/plugin/crypto/cipher.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/crypto/cipher.c +@@ -0,0 +1,116 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, + licensing governed by reiser4/README */ +/* Reiser4 cipher transform plugins */ + +#include "../../debug.h" +#include "../plugin.h" ++#include "../file/cryptcompress.h" ++#include ++#include ++ ++#define MIN_CIPHER_BLOCKSIZE 8 ++#define MAX_CIPHER_BLOCKSIZE 128 ++ ++/* ++ Default align() method of the cipher plugin (look for description of this ++ method in plugin/plugin.h) ++ ++ 1) creates the aligning armored format of the input flow before encryption. ++ "armored" means that padding is filled by private data (for example, ++ pseudo-random sequence of bytes is not private data). ++ 2) returns length of appended padding ++ ++ [ flow | aligning_padding ] ++ ^ ++ | ++ @pad ++*/ ++static int align_stream_common(__u8 * pad, ++ int flow_size /* size of non-aligned flow */, ++ int blocksize /* cipher block size */) ++{ ++ int pad_size; ++ ++ assert("edward-01", pad != NULL); ++ assert("edward-02", flow_size != 0); ++ assert("edward-03", blocksize != 0 ++ || blocksize <= MAX_CIPHER_BLOCKSIZE); ++ ++ pad_size = blocksize - (flow_size % blocksize); ++ get_random_bytes(pad, pad_size); ++ return pad_size; ++} ++ ++/* This is used for all the cipher algorithms which do not inflate ++ block-aligned data */ ++static loff_t scale_common(struct inode *inode, size_t blocksize, ++ loff_t src_off /* offset to scale */ ) ++{ ++ return src_off; ++} ++ ++static void free_aes (struct crypto_tfm * tfm) ++{ ++#if REISER4_AES ++ crypto_free_tfm(tfm); ++#endif ++ return; ++} ++ ++static struct crypto_tfm * alloc_aes (void) ++{ ++#if REISER4_AES ++ return crypto_alloc_tfm ("aes", 0); ++#else ++ warning("edward-1417", "aes unsupported"); ++ return ERR_PTR(-EINVAL); ++#endif /* REISER4_AES */ ++} + +cipher_plugin cipher_plugins[LAST_CIPHER_ID] = { + [NONE_CIPHER_ID] = { @@ -28489,6 +29095,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.c linux-2.6.22/fs/re + .setkey = NULL, + .encrypt = NULL, + .decrypt = NULL ++ }, ++ [AES_CIPHER_ID] = { ++ .h = { ++ .type_id = REISER4_CIPHER_PLUGIN_TYPE, ++ .id = AES_CIPHER_ID, ++ .pops = NULL, ++ .label = "aes", ++ .desc = "aes cipher transform", ++ .linkage = {NULL, NULL} ++ }, ++ .alloc = alloc_aes, ++ .free = free_aes, ++ .scale = scale_common, ++ .align_stream = align_stream_common, ++ .setkey = NULL, ++ .encrypt = NULL, ++ .decrypt = NULL + } +}; + @@ -28502,10 +29125,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.c linux-2.6.22/fs/re + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.h linux-2.6.22/fs/reiser4/plugin/crypto/cipher.h ---- linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/crypto/cipher.h 2007-07-29 00:25:34.900702689 +0400 -@@ -0,0 +1,55 @@ +Index: linux-2.6.16/fs/reiser4/plugin/crypto/cipher.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/crypto/cipher.h +@@ -0,0 +1,67 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* This file contains definitions for the objects operated + by reiser4 key manager, which is something like keyring @@ -28516,28 +29140,40 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.h linux-2.6.22/fs/re + +#include + ++ ++/* Transform actions involved in ciphering process and ++ supported by reiser4 via appropriate transform plugins */ ++typedef enum { ++ CIPHER_TFM, /* cipher transform */ ++ DIGEST_TFM, /* digest transform */ ++ LAST_TFM ++} reiser4_tfm; ++ ++/* This represents a transform action in reiser4 */ ++typedef struct reiser4_tfma { ++ reiser4_plugin * plug; /* transform plugin */ ++ struct crypto_tfm * tfm; /* low-level info, operated by ++ linux crypto-api (see linux/crypto) */ ++} reiser4_tfma_t; ++ +/* key info imported from user space */ -+struct reiser4_crypto_data { ++typedef struct crypto_data { + int keysize; /* uninstantiated key size */ + __u8 * key; /* uninstantiated key */ + int keyid_size; /* size of passphrase */ + __u8 * keyid; /* passphrase */ -+}; ++} crypto_data_t; + +/* This object contains all needed infrastructure to implement + cipher transform. This is operated (allocating, inheriting, + validating, binding to host inode, etc..) by reiser4 key manager. + + This info can be allocated in two cases: -+ 1. importing a key from user space. ++ 1. importing a key from user space. + 2. reading inode from disk */ -+struct reiser4_crypto_info { -+ struct inode * host; -+ struct crypto_hash * digest; -+ struct crypto_blkcipher * cipher; -+#if 0 -+ cipher_key_plugin * kplug; /* key manager */ -+#endif ++typedef struct crypto_stat { ++ reiser4_tfma_t tfma[LAST_TFM]; ++// cipher_key_plugin * kplug; /* key manager */ + __u8 * keyid; /* key fingerprint, created by digest plugin, + using uninstantiated key and passphrase. + supposed to be stored in disk stat-data */ @@ -28547,7 +29183,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.h linux-2.6.22/fs/re + to be stored in disk stat-data */ + int keyload_count; /* number of the objects which has this + crypto-stat attached */ -+}; ++} crypto_stat_t; + +#endif /* __FS_REISER4_CRYPT_H__ */ + @@ -28561,9 +29197,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/cipher.h linux-2.6.22/fs/re + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/digest.c linux-2.6.22/fs/reiser4/plugin/crypto/digest.c ---- linux-2.6.22.orig/fs/reiser4/plugin/crypto/digest.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/crypto/digest.c 2007-07-29 00:25:34.900702689 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/crypto/digest.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/crypto/digest.c @@ -0,0 +1,58 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -28578,20 +29215,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/digest.c linux-2.6.22/fs/re + +extern digest_plugin digest_plugins[LAST_DIGEST_ID]; + -+static struct crypto_hash * alloc_sha256 (void) ++static struct crypto_tfm * alloc_sha256 (void) +{ +#if REISER4_SHA256 -+ return crypto_alloc_hash ("sha256", 0, CRYPTO_ALG_ASYNC); ++ return crypto_alloc_tfm ("sha256", 0); +#else + warning("edward-1418", "sha256 unsupported"); + return ERR_PTR(-EINVAL); +#endif +} + -+static void free_sha256 (struct crypto_hash * tfm) ++static void free_sha256 (struct crypto_tfm * tfm) +{ +#if REISER4_SHA256 -+ crypto_free_hash(tfm); ++ crypto_free_tfm(tfm); +#endif + return; +} @@ -28623,9 +29260,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/crypto/digest.c linux-2.6.22/fs/re + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/dir.h linux-2.6.22/fs/reiser4/plugin/dir/dir.h ---- linux-2.6.22.orig/fs/reiser4/plugin/dir/dir.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/dir/dir.h 2007-07-29 00:25:34.900702689 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/dir/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/dir/Makefile +@@ -0,0 +1,5 @@ ++obj-$(CONFIG_REISER4_FS) += dir_plugins.o ++ ++dir_plugins-objs := \ ++ hashed_dir.o \ ++ seekable_dir.o +Index: linux-2.6.16/fs/reiser4/plugin/dir/dir.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/dir/dir.h @@ -0,0 +1,36 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -28663,9 +29311,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/dir.h linux-2.6.22/fs/reiser4/ + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/hashed_dir.c linux-2.6.22/fs/reiser4/plugin/dir/hashed_dir.c ---- linux-2.6.22.orig/fs/reiser4/plugin/dir/hashed_dir.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/dir/hashed_dir.c 2007-07-29 00:25:34.900702689 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/dir/hashed_dir.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/dir/hashed_dir.c @@ -0,0 +1,81 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -28748,18 +29397,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/hashed_dir.c linux-2.6.22/fs/r + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/Makefile linux-2.6.22/fs/reiser4/plugin/dir/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/dir/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/dir/Makefile 2007-07-29 00:25:34.900702689 +0400 -@@ -0,0 +1,5 @@ -+obj-$(CONFIG_REISER4_FS) += dir_plugins.o -+ -+dir_plugins-objs := \ -+ hashed_dir.o \ -+ seekable_dir.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/seekable_dir.c linux-2.6.22/fs/reiser4/plugin/dir/seekable_dir.c ---- linux-2.6.22.orig/fs/reiser4/plugin/dir/seekable_dir.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/dir/seekable_dir.c 2007-07-29 00:25:34.904703724 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/dir/seekable_dir.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/dir/seekable_dir.c @@ -0,0 +1,46 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -28807,10 +29448,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir/seekable_dir.c linux-2.6.22/fs + set_key_offset(result, (__u64) 0); + return; +} -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/fs/reiser4/plugin/dir_plugin_common.c ---- linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/dir_plugin_common.c 2007-07-29 00:25:34.904703724 +0400 -@@ -0,0 +1,872 @@ +Index: linux-2.6.16/fs/reiser4/plugin/dir_plugin_common.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/dir_plugin_common.c +@@ -0,0 +1,864 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + reiser4/README */ + @@ -28820,9 +29462,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + +#include "../inode.h" + -+int reiser4_find_entry(struct inode *dir, struct dentry *name, ++int find_entry(struct inode *dir, struct dentry *name, + lock_handle *, znode_lock_mode, reiser4_dir_entry_desc *); -+int reiser4_lookup_name(struct inode *parent, struct dentry *dentry, reiser4_key * key); ++int lookup_name(struct inode *parent, struct dentry *dentry, reiser4_key * key); +void check_light_weight(struct inode *inode, struct inode *parent); + +/* this is common implementation of get_parent method of dir plugin @@ -28848,7 +29490,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + dotdot.d_name.len = 2; + dotdot.d_op = &get_super_private(s)->ops.dentry; + -+ result = reiser4_lookup_name(child, &dotdot, &key); ++ result = lookup_name(child, &dotdot, &key); + if (result != 0) + return ERR_PTR(result); + @@ -28901,7 +29543,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + +/* this is common implementation of build_readdir_key method of dir + plugin -+ see reiser4_readdir_common for more details ++ see readdir_common for more details +*/ +int build_readdir_key_common(struct file *dir /* directory being read */ , + reiser4_key * result /* where to store key */ ) @@ -28925,24 +29567,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + +} + -+void reiser4_adjust_dir_file(struct inode *, const struct dentry *, int offset, -+ int adj); ++void adjust_dir_file(struct inode *, const struct dentry *, int offset, ++ int adj); + +/* this is common implementation of add_entry method of dir plugin +*/ -+int reiser4_add_entry_common(struct inode *object, /* directory to add new name -+ * in */ -+ struct dentry *where, /* new name */ -+ reiser4_object_create_data * data, /* parameters of -+ * new object */ -+ reiser4_dir_entry_desc * entry /* parameters of -+ * new directory -+ * entry */) ++int add_entry_common(struct inode *object, /* directory to add new name ++ * in */ ++ struct dentry *where, /* new name */ ++ reiser4_object_create_data * data UNUSED_ARG, /* parameters ++ * of new ++ * object */ ++ reiser4_dir_entry_desc * entry /* parameters of new ++ * directory entry */ ) +{ + int result; + coord_t *coord; + lock_handle lh; -+ struct reiser4_dentry_fsdata *fsdata; ++ reiser4_dentry_fsdata *fsdata; + reiser4_block_nr reserve; + + assert("nikita-1114", object != NULL); @@ -28961,22 +29603,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + coord_clear_iplug(coord); + + /* check for this entry in a directory. This is plugin method. */ -+ result = reiser4_find_entry(object, where, &lh, ZNODE_WRITE_LOCK, -+ entry); ++ result = find_entry(object, where, &lh, ZNODE_WRITE_LOCK, entry); + if (likely(result == -ENOENT)) { + /* add new entry. Just pass control to the directory + item plugin. */ + assert("nikita-1709", inode_dir_item_plugin(object)); + assert("nikita-2230", coord->node == lh.node); -+ reiser4_seal_done(&fsdata->dec.entry_seal); ++ seal_done(&fsdata->dec.entry_seal); + result = + inode_dir_item_plugin(object)->s.dir.add_entry(object, + coord, &lh, + where, + entry); + if (result == 0) { -+ reiser4_adjust_dir_file(object, where, -+ fsdata->dec.pos + 1, +1); ++ adjust_dir_file(object, where, fsdata->dec.pos + 1, +1); + INODE_INC_FIELD(object, i_size); + } + } else if (result == 0) { @@ -29030,21 +29670,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +} + +/** -+ * reiser4_rem_entry_common - remove entry from a directory ++ * rem_entry_common - remove entry from a directory + * @dir: directory to remove entry from + * @where: name that is being removed + * @entry: description of entry being removed + * + * This is common implementation of rem_entry method of dir plugin. + */ -+int reiser4_rem_entry_common(struct inode *dir, -+ struct dentry *dentry, -+ reiser4_dir_entry_desc *entry) ++int rem_entry_common(struct inode *dir, ++ struct dentry *dentry, ++ reiser4_dir_entry_desc *entry) +{ + int result; + coord_t *coord; + lock_handle lh; -+ struct reiser4_dentry_fsdata *fsdata; ++ reiser4_dentry_fsdata *fsdata; + __u64 tograb; + + assert("nikita-1124", dir != NULL); @@ -29058,7 +29698,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + init_lh(&lh); + + /* check for this entry in a directory. This is plugin method. */ -+ result = reiser4_find_entry(dir, dentry, &lh, ZNODE_WRITE_LOCK, entry); ++ result = find_entry(dir, dentry, &lh, ZNODE_WRITE_LOCK, entry); + fsdata = reiser4_get_dentry_fsdata(dentry); + if (IS_ERR(fsdata)) { + done_lh(&lh); @@ -29076,8 +29716,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + /* remove entry. Just pass control to the directory item + plugin. */ + assert("vs-542", inode_dir_item_plugin(dir)); -+ reiser4_seal_done(&fsdata->dec.entry_seal); -+ reiser4_adjust_dir_file(dir, dentry, fsdata->dec.pos, -1); ++ seal_done(&fsdata->dec.entry_seal); ++ adjust_dir_file(dir, dentry, fsdata->dec.pos, -1); + result = + WITH_COORD(coord, + rem_entry(dir, dentry, entry, coord, &lh)); @@ -29108,14 +29748,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +/* this is common implementation of init method of dir plugin + create "." and ".." entries +*/ -+int reiser4_dir_init_common(struct inode *object, /* new directory */ -+ struct inode *parent, /* parent directory */ -+ reiser4_object_create_data * data /* info passed -+ * to us, this -+ * is filled by -+ * reiser4() -+ * syscall in -+ * particular */) ++int init_common(struct inode *object, /* new directory */ ++ struct inode *parent, /* parent directory */ ++ reiser4_object_create_data * data UNUSED_ARG /* info passed ++ * to us, this ++ * is filled by ++ * reiser4() ++ * syscall in ++ * particular */ ) +{ + reiser4_block_nr reserve; + @@ -29136,7 +29776,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +/* this is common implementation of done method of dir plugin + remove "." entry +*/ -+int reiser4_dir_done_common(struct inode *object /* object being deleted */ ) ++int done_common(struct inode *object /* object being deleted */ ) +{ + int result; + reiser4_block_nr reserve; @@ -29145,14 +29785,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + + assert("nikita-1449", object != NULL); + -+ if (reiser4_inode_get_flag(object, REISER4_NO_SD)) ++ if (inode_get_flag(object, REISER4_NO_SD)) + return 0; + + /* of course, this can be rewritten to sweep everything in one -+ reiser4_cut_tree(). */ ++ cut_tree(). */ + memset(&entry, 0, sizeof entry); + -+ /* FIXME: this done method is called from reiser4_delete_dir_common which ++ /* FIXME: this done method is called from delete_directory_common which + * reserved space already */ + reserve = inode_dir_plugin(object)->estimate.rem_entry(object); + if (reiser4_grab_space(reserve, BA_CAN_COMMIT | BA_RESERVED)) @@ -29162,7 +29802,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + entry.obj = goodby_dots.d_inode = object; + goodby_dots.d_name.name = "."; + goodby_dots.d_name.len = 1; -+ result = reiser4_rem_entry_common(object, &goodby_dots, &entry); ++ result = rem_entry_common(object, &goodby_dots, &entry); + reiser4_free_dentry_fsdata(&goodby_dots); + if (unlikely(result != 0 && result != -ENOMEM && result != -ENOENT)) + /* only worth a warning @@ -29177,8 +29817,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + +/* this is common implementation of attach method of dir plugin +*/ -+int reiser4_attach_common(struct inode *child UNUSED_ARG, -+ struct inode *parent UNUSED_ARG) ++int ++attach_common(struct inode *child UNUSED_ARG, struct inode *parent UNUSED_ARG) +{ + assert("nikita-2647", child != NULL); + assert("nikita-2648", parent != NULL); @@ -29189,14 +29829,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +/* this is common implementation of detach method of dir plugin + remove "..", decrease nlink on parent +*/ -+int reiser4_detach_common(struct inode *object, struct inode *parent) ++int detach_common(struct inode *object, struct inode *parent) +{ + int result; + struct dentry goodby_dots; + reiser4_dir_entry_desc entry; + + assert("nikita-2885", object != NULL); -+ assert("nikita-2886", !reiser4_inode_get_flag(object, REISER4_NO_SD)); ++ assert("nikita-2886", !inode_get_flag(object, REISER4_NO_SD)); + + memset(&entry, 0, sizeof entry); + @@ -29207,12 +29847,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + entry.obj = goodby_dots.d_inode = parent; + goodby_dots.d_name.name = ".."; + goodby_dots.d_name.len = 2; -+ result = reiser4_rem_entry_common(object, &goodby_dots, &entry); ++ result = rem_entry_common(object, &goodby_dots, &entry); + reiser4_free_dentry_fsdata(&goodby_dots); + if (result == 0) { + /* the dot should be the only entry remaining at this time... */ -+ assert("nikita-3400", -+ object->i_size == 1 && object->i_nlink <= 2); ++ assert("nikita-3400", object->i_size == 1 && ++ (object->i_nlink >= 0 && object->i_nlink <= 2)); +#if 0 + /* and, together with the only name directory can have, they + * provides for the last 2 remaining references. If we get @@ -29238,7 +29878,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +*/ +reiser4_block_nr estimate_add_entry_common(const struct inode * inode) +{ -+ return estimate_one_insert_into_item(reiser4_tree_by_inode(inode)); ++ return estimate_one_insert_into_item(tree_by_inode(inode)); +} + +/* this is common implementation of estimate.rem_entry method of dir @@ -29246,7 +29886,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +*/ +reiser4_block_nr estimate_rem_entry_common(const struct inode * inode) +{ -+ return estimate_one_item_removal(reiser4_tree_by_inode(inode)); ++ return estimate_one_item_removal(tree_by_inode(inode)); +} + +/* this is common implementation of estimate.unlink method of dir @@ -29273,18 +29913,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + */ +void check_light_weight(struct inode *inode, struct inode *parent) +{ -+ if (reiser4_inode_get_flag(inode, REISER4_LIGHT_WEIGHT)) { ++ if (inode_get_flag(inode, REISER4_LIGHT_WEIGHT)) { + inode->i_uid = parent->i_uid; + inode->i_gid = parent->i_gid; + /* clear light-weight flag. If inode would be read by any + other name, [ug]id wouldn't change. */ -+ reiser4_inode_clr_flag(inode, REISER4_LIGHT_WEIGHT); ++ inode_clr_flag(inode, REISER4_LIGHT_WEIGHT); + } +} + +/* looks for name specified in @dentry in directory @parent and if name is + found - key of object found entry points to is stored in @entry->key */ -+int reiser4_lookup_name(struct inode *parent, /* inode of directory to lookup for ++int lookup_name(struct inode *parent, /* inode of directory to lookup for + * name in */ + struct dentry *dentry, /* name to look for */ + reiser4_key * key /* place to store key */ ) @@ -29295,7 +29935,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + const char *name; + int len; + reiser4_dir_entry_desc entry; -+ struct reiser4_dentry_fsdata *fsdata; ++ reiser4_dentry_fsdata *fsdata; + + assert("nikita-1247", parent != NULL); + assert("nikita-1248", dentry != NULL); @@ -29319,8 +29959,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + init_lh(&lh); + + /* find entry in a directory. This is plugin method. */ -+ result = reiser4_find_entry(parent, dentry, &lh, ZNODE_READ_LOCK, -+ &entry); ++ result = find_entry(parent, dentry, &lh, ZNODE_READ_LOCK, &entry); + if (result == 0) { + /* entry was found, extract object key from it. */ + result = @@ -29333,7 +29972,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + +} + -+/* helper for reiser4_dir_init_common(): estimate number of blocks to reserve */ ++/* helper for init_common(): estimate number of blocks to reserve */ +static reiser4_block_nr +estimate_init(struct inode *parent, struct inode *object) +{ @@ -29354,10 +29993,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + return 0; +} + -+/* helper function for reiser4_dir_init_common(). Create "." and ".." */ -+static int create_dot_dotdot(struct inode *object /* object to create dot and -+ * dotdot for */ , -+ struct inode *parent /* parent of @object */) ++/* helper function for init_common(). Create "." and ".." */ ++static int create_dot_dotdot(struct inode *object /* object to create dot and ++ * dotdot for */ , ++ struct inode *parent /* parent of @object */ ) +{ + int result; + struct dentry dots_entry; @@ -29387,7 +30026,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + entry.obj = dots_entry.d_inode = object; + dots_entry.d_name.name = "."; + dots_entry.d_name.len = 1; -+ result = reiser4_add_entry_common(object, &dots_entry, NULL, &entry); ++ result = add_entry_common(object, &dots_entry, NULL, &entry); + reiser4_free_dentry_fsdata(&dots_entry); + + if (result == 0) { @@ -29396,7 +30035,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + entry.obj = dots_entry.d_inode = parent; + dots_entry.d_name.name = ".."; + dots_entry.d_name.len = 2; -+ result = reiser4_add_entry_common(object, ++ result = add_entry_common(object, + &dots_entry, NULL, &entry); + reiser4_free_dentry_fsdata(&dots_entry); + /* if creation of ".." failed, iput() will delete @@ -29408,7 +30047,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + * if we failed to bump i_nlink, try + * to remove ".." + */ -+ reiser4_detach_common(object, parent); ++ detach_common(object, parent); + } + } + } @@ -29467,7 +30106,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +/* + * argument package used by entry_actor to scan entries with identical keys. + */ -+struct entry_actor_args { ++typedef struct entry_actor_args { + /* name we are looking for */ + const char *name; + /* key of directory entry. entry_actor() scans through sequence of @@ -29491,17 +30130,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + lock_handle last_lh; + /* inode of directory */ + const struct inode *inode; -+}; ++} entry_actor_args; + -+/* Function called by reiser4_find_entry() to look for given name -+ in the directory. */ ++/* Function called by find_entry() to look for given name in the directory. */ +static int entry_actor(reiser4_tree * tree UNUSED_ARG /* tree being scanned */ , + coord_t * coord /* current coord */ , + lock_handle * lh /* current lock handle */ , + void *entry_actor_arg /* argument to scan */ ) +{ + reiser4_key unit_key; -+ struct entry_actor_args *args; ++ entry_actor_args *args; + + assert("nikita-1131", tree != NULL); + assert("nikita-1132", coord != NULL); @@ -29552,26 +30190,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f +/* Look for given @name within directory @dir. + + This is called during lookup, creation and removal of directory -+ entries and on reiser4_rename_common ++ entries and on rename_common + + First calculate key that directory entry for @name would have. Search + for this key in the tree. If such key is found, scan all items with + the same key, checking name in each directory entry along the way. +*/ -+int reiser4_find_entry(struct inode *dir, /* directory to scan */ -+ struct dentry *de, /* name to search for */ -+ lock_handle * lh, /* resulting lock handle */ -+ znode_lock_mode mode, /* required lock mode */ -+ reiser4_dir_entry_desc * entry /* parameters of found -+ directory entry */) ++int find_entry(struct inode *dir, /* directory to scan */ ++ struct dentry *de, /* name to search for */ ++ lock_handle * lh, /* resulting lock handle */ ++ znode_lock_mode mode, /* required lock mode */ ++ reiser4_dir_entry_desc * entry /* parameters of found directory ++ * entry */ ) +{ + const struct qstr *name; + seal_t *seal; + coord_t *coord; + int result; + __u32 flags; -+ struct de_location *dec; -+ struct reiser4_dentry_fsdata *fsdata; ++ de_location *dec; ++ reiser4_dentry_fsdata *fsdata; + + assert("nikita-1130", lh != NULL); + assert("nikita-1128", dir != NULL); @@ -29596,10 +30234,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + /* compose key of directory entry for @name */ + inode_dir_plugin(dir)->build_entry_key(dir, name, &entry->key); + -+ if (reiser4_seal_is_set(seal)) { ++ if (seal_is_set(seal)) { + /* check seal */ -+ result = reiser4_seal_validate(seal, coord, &entry->key, -+ lh, mode, ZNODE_LOCK_LOPRI); ++ result = seal_validate(seal, coord, &entry->key, ++ lh, mode, ZNODE_LOCK_LOPRI); + if (result == 0) { + /* key was found. Check that it is really item we are + looking for. */ @@ -29612,16 +30250,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + /* + * find place in the tree where directory item should be located. + */ -+ result = reiser4_object_lookup(dir, &entry->key, coord, lh, mode, -+ FIND_EXACT, LEAF_LEVEL, LEAF_LEVEL, -+ flags, NULL /*ra_info */ ); ++ result = object_lookup(dir, &entry->key, coord, lh, mode, ++ FIND_EXACT, LEAF_LEVEL, LEAF_LEVEL, flags, ++ NULL /*ra_info */ ); + if (result == CBK_COORD_FOUND) { -+ struct entry_actor_args arg; ++ entry_actor_args arg; + + /* fast path: no hash collisions */ + result = check_entry(dir, coord, name); + if (result == 0) { -+ reiser4_seal_init(seal, coord, &entry->key); ++ seal_init(seal, coord, &entry->key); + dec->pos = 0; + } else if (result > 0) { + /* Iterate through all units with the same keys. */ @@ -29638,10 +30276,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + coord_init_zero(&arg.last_coord); + init_lh(&arg.last_lh); + -+ result = reiser4_iterate_tree -+ (reiser4_tree_by_inode(dir), -+ coord, lh, -+ entry_actor, &arg, mode, 1); ++ result = iterate_tree(tree_by_inode(dir), coord, lh, ++ entry_actor, &arg, mode, 1); + /* if end of the tree or extent was reached during + scanning. */ + if (arg.not_found || (result == -E_NO_NEIGHBOR)) { @@ -29661,7 +30297,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + + done_lh(&arg.last_lh); + if (result == 0) -+ reiser4_seal_init(seal, coord, &entry->key); ++ seal_init(seal, coord, &entry->key); + + if (result == 0 || result == -ENOENT) { + assert("nikita-2580", arg.non_uniq > 0); @@ -29673,7 +30309,57 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + return result; +} + -+/* ++/* Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/disk_format/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/disk_format/Makefile +@@ -0,0 +1,5 @@ ++obj-$(CONFIG_REISER4_FS) += df_plugins.o ++ ++df_plugins-objs := \ ++ disk_format40.o \ ++ disk_format.o +Index: linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format.c +@@ -0,0 +1,37 @@ ++/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++#include "../../debug.h" ++#include "../plugin_header.h" ++#include "disk_format40.h" ++#include "disk_format.h" ++#include "../plugin.h" ++ ++/* initialization of disk layout plugins */ ++disk_format_plugin format_plugins[LAST_FORMAT_ID] = { ++ [FORMAT40_ID] = { ++ .h = { ++ .type_id = REISER4_FORMAT_PLUGIN_TYPE, ++ .id = FORMAT40_ID, ++ .pops = NULL, ++ .label = "reiser40", ++ .desc = "standard disk layout for reiser40", ++ .linkage = {NULL, NULL} ++ }, ++ .init_format = init_format_format40, ++ .root_dir_key = root_dir_key_format40, ++ .release = release_format40, ++ .log_super = log_super_format40, ++ .check_open = check_open_format40 ++ } ++}; ++ ++/* Make Linus happy. + Local variables: + c-indentation-style: "K&R" + mode-name: "LC" @@ -29683,10 +30369,43 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/dir_plugin_common.c linux-2.6.22/f + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format40.c ---- linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format40.c 2007-07-29 00:25:34.904703724 +0400 -@@ -0,0 +1,655 @@ +Index: linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format.h +@@ -0,0 +1,27 @@ ++/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++/* identifiers for disk layouts, they are also used as indexes in array of disk ++ plugins */ ++ ++#if !defined( __REISER4_DISK_FORMAT_H__ ) ++#define __REISER4_DISK_FORMAT_H__ ++ ++typedef enum { ++ /* standard reiser4 disk layout plugin id */ ++ FORMAT40_ID, ++ LAST_FORMAT_ID ++} disk_format_id; ++ ++/* __REISER4_DISK_FORMAT_H__ */ ++#endif ++ ++/* Make Linus happy. ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format40.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format40.c +@@ -0,0 +1,556 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "../../debug.h" @@ -29716,13 +30435,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + & tx record. */ +#define RELEASE_RESERVED 4 + -+/* The greatest supported format40 version number */ -+#define FORMAT40_VERSION PLUGIN_LIBRARY_VERSION -+ -+/* This flag indicates that backup should be updated -+ (the update is performed by fsck) */ -+#define FORMAT40_UPDATE_BACKUP (1 << 31) -+ +/* functions to access fields of format40_disk_super_block */ +static __u64 get_format40_block_count(const format40_disk_super_block * sb) +{ @@ -29764,28 +30476,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + return le64_to_cpu(get_unaligned(&sb->flags)); +} + -+static __u32 get_format40_version(const format40_disk_super_block * sb) -+{ -+ return le32_to_cpu(get_unaligned(&sb->version)) & -+ ~FORMAT40_UPDATE_BACKUP; -+} -+ -+static int update_backup_version(const format40_disk_super_block * sb) -+{ -+ return (le32_to_cpu(get_unaligned(&sb->version)) & -+ FORMAT40_UPDATE_BACKUP); -+} -+ -+static int update_disk_version(const format40_disk_super_block * sb) -+{ -+ return (get_format40_version(sb) < FORMAT40_VERSION); -+} -+ -+static int incomplete_compatibility(const format40_disk_super_block * sb) -+{ -+ return (get_format40_version(sb) > FORMAT40_VERSION); -+} -+ +static format40_super_info *get_sb_info(struct super_block *super) +{ + return &get_super_private(super)->u.format40; @@ -29862,12 +30552,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + jnode *sb_jnode; + int ret; + -+ sb_jnode = reiser4_alloc_io_head(&get_sb_info(s)->loc.super); ++ sb_jnode = alloc_io_head(&get_sb_info(s)->loc.super); + + ret = jload(sb_jnode); + + if (ret) { -+ reiser4_drop_io_head(sb_jnode); ++ drop_io_head(sb_jnode); + return ret; + } + @@ -29885,7 +30575,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + + if (sb_jnode) { + unpin_jnode_data(sb_jnode); -+ reiser4_drop_io_head(sb_jnode); ++ drop_io_head(sb_jnode); + } +} + @@ -29910,8 +30600,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- +{ + format40_disk_super_block *sb_copy; + -+ sb_copy = kmalloc(sizeof(format40_disk_super_block), -+ reiser4_ctx_gfp_mask_get()); ++ sb_copy = kmalloc(sizeof(format40_disk_super_block), get_gfp_mask()); + if (sb_copy == NULL) + return ERR_PTR(RETERR(-ENOMEM)); + memcpy(sb_copy, ((format40_disk_super_block *) super_bh->b_data), @@ -29964,10 +30653,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + brelse(super_bh); + *stage = FIND_A_SUPER; + -+ /* ok, we are sure that filesystem format is a format40 format */ -+ + /* map jnodes for journal control blocks (header, footer) to disk */ -+ result = reiser4_init_journal_info(super); ++ result = init_journal_info(super); + if (result) + return result; + *stage = INIT_JOURNAL_INFO; @@ -29983,11 +30670,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + + result = reiser4_status_query(NULL, NULL); + if (result == REISER4_STATUS_MOUNT_WARN) -+ notice("vpf-1363", "Warning: mounting %s with errors.", -+ super->s_id); -+ if (result == REISER4_STATUS_MOUNT_RO) -+ notice("vpf-1364", "Warning: mounting %s with fatal errors," -+ " forcing read-only mount.", super->s_id); ++ printk("Warning, mounting filesystem with errors\n"); ++ if (result == REISER4_STATUS_MOUNT_RO) { ++ printk ++ ("Warning, mounting filesystem with fatal errors, forcing read-only mount\n"); ++ /* FIXME: here we should actually enforce read-only mount, ++ * only it is unsupported yet. */ ++ } ++ + result = reiser4_journal_replay(super); + if (result) + return result; @@ -30001,18 +30691,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + /* allocate and make a copy of format40_disk_super_block */ + sb_copy = copy_sb(super_bh); + brelse(super_bh); -+ + if (IS_ERR(sb_copy)) + return PTR_ERR(sb_copy); -+ printk("reiser4: %s: found disk format 4.0.%u.\n", -+ super->s_id, -+ get_format40_version(sb_copy)); -+ if (incomplete_compatibility(sb_copy)) -+ printk("reiser4: Warning: The last completely supported " -+ "version of disk format40 is %u. Some objects of " -+ "the semantic tree can be unaccessible.\n", -+ FORMAT40_VERSION); -+ /* make sure that key format of kernel and filesystem match */ ++ ++ /* make sure that key format of kernel and filesyste match */ + result = check_key_format(sb_copy); + if (result) { + kfree(sb_copy); @@ -30033,11 +30715,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + height = get_format40_tree_height(sb_copy); + nplug = node_plugin_by_id(NODE40_ID); + ++ + /* initialize reiser4_super_info_data */ + sbinfo = get_super_private(super); + assert("", sbinfo->tree.super == super); + /* init reiser4_tree for the filesystem */ -+ result = reiser4_init_tree(&sbinfo->tree, &root_block, height, nplug); ++ result = init_tree(&sbinfo->tree, &root_block, height, nplug); + if (result) { + kfree(sb_copy); + return result; @@ -30054,14 +30737,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + /* number of blocks in filesystem and reserved space */ + reiser4_set_block_count(super, get_format40_block_count(sb_copy)); + sbinfo->blocks_free = get_format40_free_blocks(sb_copy); -+ sbinfo->version = get_format40_version(sb_copy); + kfree(sb_copy); + -+ if (update_backup_version(sb_copy)) -+ printk("reiser4: Warning: metadata backup is not updated. " -+ "Please run 'fsck.reiser4 --fix' on %s.\n", -+ super->s_id); -+ + sbinfo->fsuid = 0; + sbinfo->fs_flags |= (1 << REISER4_ADG); /* hard links for directories + * are not supported */ @@ -30099,8 +30776,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- +#endif + + /* init disk space allocator */ -+ result = sa_init_allocator(reiser4_get_space_allocator(super), -+ super, NULL); ++ result = sa_init_allocator(get_space_allocator(super), super, NULL); + if (result) + return result; + *stage = INIT_SA; @@ -30125,10 +30801,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + case INIT_JNODE: + done_super_jnode(s); + case INIT_SA: -+ sa_destroy_allocator(reiser4_get_space_allocator(s), s); ++ sa_destroy_allocator(get_space_allocator(s), s); + case JOURNAL_RECOVER: + case INIT_TREE: -+ reiser4_done_tree(&get_super_private(s)->tree); ++ done_tree(&get_super_private(s)->tree); + case INIT_OID: + case KEY_CHECK: + case READ_SUPER: @@ -30136,7 +30812,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + case INIT_STATUS: + reiser4_status_finish(); + case INIT_JOURNAL_INFO: -+ reiser4_done_journal_info(s); ++ done_journal_info(s); + case FIND_A_SUPER: + case CONSULT_DISKMAP: + case NONE_DONE: @@ -30155,31 +30831,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- +{ + format40_disk_super_block *super_data = + (format40_disk_super_block *) data; -+ + reiser4_super_info_data *sbinfo = get_super_private(s); + + assert("zam-591", data != NULL); + + put_unaligned(cpu_to_le64(reiser4_free_committed_blocks(s)), + &super_data->free_blocks); ++ put_unaligned(cpu_to_le64(sbinfo->tree.root_block), &super_data->root_block); + -+ put_unaligned(cpu_to_le64(sbinfo->tree.root_block), -+ &super_data->root_block); -+ -+ put_unaligned(cpu_to_le64(oid_next(s)), -+ &super_data->oid); -+ -+ put_unaligned(cpu_to_le64(oids_used(s)), -+ &super_data->file_count); -+ -+ put_unaligned(cpu_to_le16(sbinfo->tree.height), -+ &super_data->tree_height); ++ put_unaligned(cpu_to_le64(oid_next(s)), &super_data->oid); ++ put_unaligned(cpu_to_le64(oids_used(s)), &super_data->file_count); + -+ if (update_disk_version(super_data)) { -+ __u32 version = FORMAT40_VERSION | FORMAT40_UPDATE_BACKUP; -+ -+ put_unaligned(cpu_to_le32(version), &super_data->version); -+ } ++ put_unaligned(cpu_to_le16(sbinfo->tree.height), &super_data->tree_height); +} + +/* plugin->u.format.log_super @@ -30210,10 +30873,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + assert("zam-579", sbinfo != NULL); + + if (!rofs_super(s)) { -+ ret = reiser4_capture_super_block(s); ++ ret = capture_super_block(s); + if (ret != 0) -+ warning("vs-898", -+ "reiser4_capture_super_block failed: %d", ++ warning("vs-898", "capture_super_block failed: %d", + ret); + + ret = txnmgr_force_commit_all(s, 1); @@ -30224,13 +30886,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + } + + sa_destroy_allocator(&sbinfo->space_allocator, s); -+ reiser4_done_journal_info(s); ++ done_journal_info(s); + done_super_jnode(s); + + rcu_barrier(); -+ reiser4_done_tree(&sbinfo->tree); ++ done_tree(&sbinfo->tree); + /* call finish_rcu(), because some znode were "released" in -+ * reiser4_done_tree(). */ ++ * done_tree(). */ + rcu_barrier(); + + return 0; @@ -30280,7 +30942,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + /* Check the locality. */ + oid = reiser4_inode_data(object)->locality_id; + if (oid > max) { -+ warning("vpf-1361", "The object with the locality %llu " ++ warning("vpf-1360", "The object with the locality %llu " + "greater then the max used oid %llu found.", + (unsigned long long)oid, (unsigned long long)max); + @@ -30290,48 +30952,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + return 0; +} + -+/* plugin->u.format.version_update. -+ Perform all version update operations from the on-disk -+ format40_disk_super_block.version on disk to FORMAT40_VERSION. -+ */ -+int version_update_format40(struct super_block *super) { -+ txn_handle * trans; -+ lock_handle lh; -+ txn_atom *atom; -+ int ret; -+ -+ /* Nothing to do if RO mount or the on-disk version is not less. */ -+ if (super->s_flags & MS_RDONLY) -+ return 0; -+ -+ if (get_super_private(super)->version >= FORMAT40_VERSION) -+ return 0; -+ -+ printk("reiser4: Updating disk format to 4.0.%u. The reiser4 metadata " -+ "backup is left unchanged. Please run 'fsck.reiser4 --fix' " -+ "on %s to update it too.\n", FORMAT40_VERSION, super->s_id); -+ -+ /* Mark the uber znode dirty to call log_super on write_logs. */ -+ init_lh(&lh); -+ ret = get_uber_znode(reiser4_get_tree(super), ZNODE_WRITE_LOCK, -+ ZNODE_LOCK_HIPRI, &lh); -+ if (ret != 0) -+ return ret; -+ -+ znode_make_dirty(lh.node); -+ done_lh(&lh); -+ -+ /* Update the backup blocks. */ -+ -+ /* Force write_logs immediately. */ -+ trans = get_current_context()->trans; -+ atom = get_current_atom_locked(); -+ assert("vpf-1906", atom != NULL); -+ -+ spin_lock_txnh(trans); -+ return force_commit_atom(trans); -+} -+ +/* Make Linus happy. + Local variables: + c-indentation-style: "K&R" @@ -30342,10 +30962,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.c linux- + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.h linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format40.h ---- linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format40.h 2007-07-29 00:25:34.908704759 +0400 -@@ -0,0 +1,109 @@ +Index: linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format40.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/disk_format/disk_format40.h +@@ -0,0 +1,99 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* this file contains: @@ -30395,17 +31016,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.h linux- + /* 68 */ d16 tree_height; + /* height of filesystem tree */ + /* 70 */ d16 formatting_policy; -+ /* not used anymore */ + /* 72 */ d64 flags; -+ /* 80 */ d32 version; -+ /* on-disk format version number -+ initially assigned by mkfs as the greatest format40 -+ version number supported by reiser4progs and updated -+ in mount time in accordance with the greatest format40 -+ version number supported by kernel. -+ Is used by fsck to catch possible corruption and -+ for various compatibility issues */ -+ /* 84 */ char not_used[428]; ++ /* 72 */ char not_used[432]; +} format40_disk_super_block; + +/* format 40 specific part of reiser4_super_info_data */ @@ -30435,12 +31047,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.h linux- + +/* declarations of functions implementing methods of layout plugin for + format 40. The functions theirself are in disk_format40.c */ -+extern int init_format_format40(struct super_block *, void *data); -+extern const reiser4_key *root_dir_key_format40(const struct super_block *); -+extern int release_format40(struct super_block *s); -+extern jnode *log_super_format40(struct super_block *s); -+extern int check_open_format40(const struct inode *object); -+extern int version_update_format40(struct super_block *super); ++int init_format_format40(struct super_block *, void *data); ++const reiser4_key *root_dir_key_format40(const struct super_block *); ++int release_format40(struct super_block *s); ++jnode *log_super_format40(struct super_block *s); ++int check_open_format40(const struct inode *object); + +/* __DISK_FORMAT40_H__ */ +#endif @@ -30455,92 +31066,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format40.h linux- + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format.c linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format.c ---- linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format.c 2007-07-29 00:25:34.908704759 +0400 -@@ -0,0 +1,38 @@ -+/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+#include "../../debug.h" -+#include "../plugin_header.h" -+#include "disk_format40.h" -+#include "disk_format.h" -+#include "../plugin.h" -+ -+/* initialization of disk layout plugins */ -+disk_format_plugin format_plugins[LAST_FORMAT_ID] = { -+ [FORMAT40_ID] = { -+ .h = { -+ .type_id = REISER4_FORMAT_PLUGIN_TYPE, -+ .id = FORMAT40_ID, -+ .pops = NULL, -+ .label = "reiser40", -+ .desc = "standard disk layout for reiser40", -+ .linkage = {NULL, NULL} -+ }, -+ .init_format = init_format_format40, -+ .root_dir_key = root_dir_key_format40, -+ .release = release_format40, -+ .log_super = log_super_format40, -+ .check_open = check_open_format40, -+ .version_update = version_update_format40 -+ } -+}; -+ -+/* Make Linus happy. -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format.h linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format.h ---- linux-2.6.22.orig/fs/reiser4/plugin/disk_format/disk_format.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/disk_format/disk_format.h 2007-07-29 00:25:34.908704759 +0400 -@@ -0,0 +1,27 @@ -+/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+/* identifiers for disk layouts, they are also used as indexes in array of disk -+ plugins */ -+ -+#if !defined( __REISER4_DISK_FORMAT_H__ ) -+#define __REISER4_DISK_FORMAT_H__ -+ -+typedef enum { -+ /* standard reiser4 disk layout plugin id */ -+ FORMAT40_ID, -+ LAST_FORMAT_ID -+} disk_format_id; -+ -+/* __REISER4_DISK_FORMAT_H__ */ -+#endif -+ -+/* Make Linus happy. -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/disk_format/Makefile linux-2.6.22/fs/reiser4/plugin/disk_format/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/disk_format/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/disk_format/Makefile 2007-07-29 00:25:34.908704759 +0400 -@@ -0,0 +1,5 @@ -+obj-$(CONFIG_REISER4_FS) += df_plugins.o -+ -+df_plugins-objs := \ -+ disk_format40.o \ -+ disk_format.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.c linux-2.6.22/fs/reiser4/plugin/fibration.c ---- linux-2.6.22.orig/fs/reiser4/plugin/fibration.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/fibration.c 2007-07-29 00:25:34.908704759 +0400 -@@ -0,0 +1,175 @@ +Index: linux-2.6.16/fs/reiser4/plugin/fibration.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/fibration.c +@@ -0,0 +1,174 @@ +/* Copyright 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -30624,9 +31154,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.c linux-2.6.22/fs/reiser + return FIBRE_NO(0); +} + -+static int change_fibration(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_fibration(struct inode *inode, reiser4_plugin * plugin) +{ + int result; + @@ -30642,8 +31170,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.c linux-2.6.22/fs/reiser + if (inode_fibration_plugin(inode) == NULL || + inode_fibration_plugin(inode)->h.id != plugin->h.id) { + if (is_dir_empty(inode) == 0) -+ result = aset_set_unsafe(&reiser4_inode_data(inode)->pset, -+ PSET_FIBRATION, plugin); ++ result = ++ plugin_set_fibration(&reiser4_inode_data(inode)-> ++ pset, &plugin->fibration); + else + result = RETERR(-ENOTEMPTY); + @@ -30716,9 +31245,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.c linux-2.6.22/fs/reiser + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.h linux-2.6.22/fs/reiser4/plugin/fibration.h ---- linux-2.6.22.orig/fs/reiser4/plugin/fibration.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/fibration.h 2007-07-29 00:25:34.908704759 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/fibration.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/fibration.h @@ -0,0 +1,37 @@ +/* Copyright 2004 by Hans Reiser, licensing governed by reiser4/README */ + @@ -30757,21 +31287,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/fibration.h linux-2.6.22/fs/reiser + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/fs/reiser4/plugin/file/cryptcompress.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/cryptcompress.c 2007-07-29 00:25:34.916706830 +0400 -@@ -0,0 +1,3832 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by +Index: linux-2.6.16/fs/reiser4/plugin/file/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/Makefile +@@ -0,0 +1,7 @@ ++obj-$(CONFIG_REISER4_FS) += file_plugins.o ++ ++file_plugins-objs := \ ++ file.o \ ++ tail_conversion.o \ ++ symlink.o \ ++ cryptcompress.o +Index: linux-2.6.16/fs/reiser4/plugin/file/cryptcompress.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/cryptcompress.c +@@ -0,0 +1,3817 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + reiser4/README */ -+/* -+ * Written by Edward Shishkin. -+ * -+ * Implementations of inode/file/address_space operations -+ * specific for cryptcompress file plugin which manages -+ * regular files built of compressed and(or) encrypted bodies. -+ * See http://dev.namesys.com/CryptcompressPlugin for details. ++ ++/* This file contains implementations of inode/file/address_space/file plugin ++ * operations specific for cryptcompress file plugin which manages files with ++ * compressed and encrypted bodies. "Cryptcompress file" is built of items of ++ * CTAIL_ID (see http://www.namesys.com/cryptcompress_design.html for details). + */ + ++#include "../../page_cache.h" +#include "../../inode.h" +#include "../cluster.h" +#include "../object.h" @@ -30785,185 +31327,180 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +#include +#include + -+/* -+ Managing primary and secondary caches by Reiser4 -+ cryptcompress file plugin. Synchronization scheme. -+ -+ -+ +------------------+ -+ +------------------->| tfm stream | -+ | | (compressed data)| -+ flush | +------------------+ -+ +-----------------+ | -+ |(->)longterm lock| V -+--+ writepages() | | +-***-+ reiser4 +---+ -+ | | +--+ | *** | storage tree | | -+ | | | +-***-+ (primary cache)| | -+u | write() (secondary| cache) V / | \ | | -+s | ----> +----+ +----+ +----+ +----+ +-***** ******* **----+ ----> | d | -+e | | | |page cluster | | | **disk cluster** | | i | -+r | <---- +----+ +----+ +----+ +----+ +-***** **********----+ <---- | s | -+ | read() ^ ^ | | k | -+ | | (->)longterm lock| | page_io()| | -+ | | +------+ | | -+--+ readpages() | | +---+ -+ | V -+ | +------------------+ -+ +--------------------| tfm stream | -+ | (plain text) | -+ +------------------+ -+*/ -+ +/* get cryptcompress specific portion of inode */ -+struct cryptcompress_info *cryptcompress_inode_data(const struct inode *inode) ++cryptcompress_info_t *cryptcompress_inode_data(const struct inode *inode) +{ + return &reiser4_inode_data(inode)->file_plugin_data.cryptcompress_info; +} + +/* plugin->u.file.init_inode_data */ -+void init_inode_data_cryptcompress(struct inode *inode, -+ reiser4_object_create_data * crd, -+ int create) ++void ++init_inode_data_cryptcompress(struct inode *inode, ++ reiser4_object_create_data * crd, int create) +{ -+ struct cryptcompress_info *data; ++ cryptcompress_info_t *data; + + data = cryptcompress_inode_data(inode); + assert("edward-685", data != NULL); + + memset(data, 0, sizeof(*data)); + -+ mutex_init(&data->checkin_mutex); -+ data->trunc_index = ULONG_MAX; -+ turn_on_compression(data); -+ set_lattice_factor(data, MIN_LATTICE_FACTOR); ++ init_rwsem(&data->lock); ++ toggle_compression(data, 1); + init_inode_ordering(inode, crd, create); +} + ++#if REISER4_DEBUG ++int crc_inode_ok(struct inode *inode) ++{ ++ if (cluster_shift_ok(inode_cluster_shift(inode))) ++ return 1; ++ assert("edward-686", 0); ++ return 0; ++} ++#endif ++ ++static int check_cryptcompress(struct inode *inode) ++{ ++ int result = 0; ++ assert("edward-1307", inode_compression_plugin(inode) != NULL); ++ ++ if (inode_cluster_size(inode) < PAGE_CACHE_SIZE) { ++ warning("edward-1331", ++ "%s clusters are unsupported", ++ inode_cluster_plugin(inode)->h.label); ++ return RETERR(-EINVAL); ++ } ++ ++ /* FIXME-EDWARD: init? or check? */ ++ if (inode_compression_plugin(inode)->init) ++ result = inode_compression_plugin(inode)->init(); ++ return result; ++} ++ +/* The following is a part of reiser4 cipher key manager + which is called when opening/creating a cryptcompress file */ + +/* get/set cipher key info */ -+struct reiser4_crypto_info * inode_crypto_info (struct inode * inode) ++crypto_stat_t * inode_crypto_stat (struct inode * inode) +{ + assert("edward-90", inode != NULL); + assert("edward-91", reiser4_inode_data(inode) != NULL); + return cryptcompress_inode_data(inode)->crypt; +} + -+static void set_inode_crypto_info (struct inode * inode, -+ struct reiser4_crypto_info * info) ++static void set_inode_crypto_stat (struct inode * inode, crypto_stat_t * stat) +{ -+ cryptcompress_inode_data(inode)->crypt = info; ++ cryptcompress_inode_data(inode)->crypt = stat; +} + +/* allocate a cipher key info */ -+struct reiser4_crypto_info * reiser4_alloc_crypto_info (struct inode * inode) ++crypto_stat_t * alloc_crypto_stat (struct inode * inode) +{ -+ struct reiser4_crypto_info * info; ++ crypto_stat_t * info; + int fipsize; + -+ info = kmalloc(sizeof(*info), reiser4_ctx_gfp_mask_get()); ++ assert("edward-1421", 0); ++ info = kmalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return ERR_PTR(-ENOMEM); + memset(info, 0, sizeof (*info)); + fipsize = inode_digest_plugin(inode)->fipsize; -+ info->keyid = kmalloc(fipsize, reiser4_ctx_gfp_mask_get()); ++ info->keyid = kmalloc(fipsize, GFP_KERNEL); + if (!info->keyid) { + kfree(info); + return ERR_PTR(-ENOMEM); + } -+ info->host = inode; + return info; +} + +#if 0 +/* allocate/free low-level info for cipher and digest + transforms */ -+static int alloc_crypto_tfms(struct reiser4_crypto_info * info) ++static int ++alloc_crypto_tfms(plugin_set * pset, crypto_stat_t * info) +{ -+ struct crypto_blkcipher * ctfm = NULL; -+ struct crypto_hash * dtfm = NULL; -+ cipher_plugin * cplug = inode_cipher_plugin(info->host); -+ digest_plugin * dplug = inode_digest_plugin(info->host); ++ struct crypto_tfm * ret = NULL; ++ cipher_plugin * cplug = pset->cipher; ++ digest_plugin * dplug = pset->digest; ++ ++ assert("edward-1363", info != NULL); ++ assert("edward-414", cplug != NULL); ++ assert("edward-415", dplug != NULL); + + if (cplug->alloc) { -+ ctfm = cplug->alloc(); -+ if (IS_ERR(ctfm)) { ++ ret = cplug->alloc(); ++ if (ret == NULL) { + warning("edward-1364", + "Can not allocate info for %s\n", + cplug->h.desc); -+ return RETERR(PTR_ERR(ctfm)); ++ return RETERR(-EINVAL); + } + } -+ info_set_cipher(info, ctfm); ++ info_set_tfm(info, CIPHER_TFM, ret); + if (dplug->alloc) { -+ dtfm = dplug->alloc(); -+ if (IS_ERR(dtfm)) { ++ ret = dplug->alloc(); ++ if (ret == NULL) { + warning("edward-1365", + "Can not allocate info for %s\n", + dplug->h.desc); -+ goto unhappy_with_digest; ++ goto err; + } + } -+ info_set_digest(info, dtfm); ++ info_set_tfm(info, DIGEST_TFM, ret); + return 0; -+ unhappy_with_digest: ++ err: + if (cplug->free) { -+ cplug->free(ctfm); -+ info_set_cipher(info, NULL); ++ cplug->free(info->tfma[CIPHER_TFM].tfm); ++ info_set_tfm(info, CIPHER_TFM, NULL); + } -+ return RETERR(PTR_ERR(dtfm)); ++ return RETERR(-EINVAL); +} +#endif + +static void -+free_crypto_tfms(struct reiser4_crypto_info * info) ++free_crypto_tfms(crypto_stat_t * info) +{ + assert("edward-1366", info != NULL); -+ if (!info_get_cipher(info)) { -+ assert("edward-1601", !info_get_digest(info)); ++ if (!info_cipher_tfm(info)) + return; -+ } -+ inode_cipher_plugin(info->host)->free(info_get_cipher(info)); -+ info_set_cipher(info, NULL); -+ inode_digest_plugin(info->host)->free(info_get_digest(info)); -+ info_set_digest(info, NULL); ++ info_cipher_plugin(info)->free(info_cipher_tfm(info)); ++ info_set_tfm(info, CIPHER_TFM, NULL); ++ info_digest_plugin(info)->free(info_digest_tfm(info)); ++ info_set_tfm(info, DIGEST_TFM, NULL); + return; +} + +#if 0 +/* create a key fingerprint for disk stat-data */ -+static int create_keyid (struct reiser4_crypto_info * info, -+ struct reiser4_crypto_data * data) ++static int create_keyid (crypto_stat_t * info, crypto_data_t * data) +{ + int ret = -ENOMEM; + size_t blk, pad; + __u8 * dmem; + __u8 * cmem; -+ struct hash_desc ddesc; -+ struct blkcipher_desc cdesc; ++ struct crypto_tfm * dtfm; ++ struct crypto_tfm * ctfm; + struct scatterlist sg; + ++ assert("edward-1422", 0); + assert("edward-1367", info != NULL); + assert("edward-1368", info->keyid != NULL); + -+ ddesc.tfm = info_get_digest(info); -+ ddesc.flags = 0; -+ cdesc.tfm = info_get_cipher(info); -+ cdesc.flags = 0; ++ dtfm = info_digest_tfm(info); ++ ctfm = info_cipher_tfm(info); + -+ dmem = kmalloc((size_t)crypto_hash_digestsize(ddesc.tfm), -+ reiser4_ctx_gfp_mask_get()); ++ dmem = kmalloc((size_t)crypto_tfm_alg_digestsize(dtfm), ++ GFP_KERNEL); + if (!dmem) + goto exit1; + -+ blk = crypto_blkcipher_blocksize(cdesc.tfm); ++ blk = crypto_tfm_alg_blocksize(ctfm); + + pad = data->keyid_size % blk; + pad = (pad ? blk - pad : 0); + -+ cmem = kmalloc((size_t)data->keyid_size + pad, -+ reiser4_ctx_gfp_mask_get()); ++ cmem = kmalloc((size_t)data->keyid_size + pad, GFP_KERNEL); + if (!cmem) + goto exit2; + memcpy(cmem, data->keyid, data->keyid_size); @@ -30973,20 +31510,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + sg.offset = offset_in_page(cmem); + sg.length = data->keyid_size + pad; + -+ ret = crypto_blkcipher_encrypt(&cdesc, &sg, &sg, -+ data->keyid_size + pad); ++ ret = crypto_cipher_encrypt(ctfm, &sg, &sg, data->keyid_size + pad); + if (ret) { + warning("edward-1369", -+ "encryption failed flags=%x\n", cdesc.flags); ++ "encryption failed flags=%x\n", ctfm->crt_flags); + goto exit3; + } -+ ret = crypto_hash_digest(&ddesc, &sg, sg.length, dmem); -+ if (ret) { -+ warning("edward-1602", -+ "digest failed flags=%x\n", ddesc.flags); -+ goto exit3; -+ } -+ memcpy(info->keyid, dmem, inode_digest_plugin(info->host)->fipsize); ++ crypto_digest_init (dtfm); ++ crypto_digest_update (dtfm, &sg, 1); ++ crypto_digest_final (dtfm, dmem); ++ memcpy(info->keyid, dmem, info_digest_plugin(info)->fipsize); + exit3: + kfree(cmem); + exit2: @@ -30996,7 +31529,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} +#endif + -+static void destroy_keyid(struct reiser4_crypto_info * info) ++static void destroy_keyid(crypto_stat_t * info) +{ + assert("edward-1370", info != NULL); + assert("edward-1371", info->keyid != NULL); @@ -31004,9 +31537,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return; +} + -+static void __free_crypto_info (struct inode * inode) ++static void free_crypto_stat (crypto_stat_t * info) +{ -+ struct reiser4_crypto_info * info = inode_crypto_info(inode); + assert("edward-1372", info != NULL); + + free_crypto_tfms(info); @@ -31015,7 +31547,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +#if 0 -+static void instantiate_crypto_info(struct reiser4_crypto_info * info) ++static void instantiate_crypto_stat(crypto_stat_t * info) +{ + assert("edward-1373", info != NULL); + assert("edward-1374", info->inst == 0); @@ -31023,13 +31555,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} +#endif + -+static void uninstantiate_crypto_info(struct reiser4_crypto_info * info) ++static void uninstantiate_crypto_stat(crypto_stat_t * info) +{ + assert("edward-1375", info != NULL); + info->inst = 0; +} + -+static int is_crypto_info_instantiated(struct reiser4_crypto_info * info) ++static int crypto_stat_instantiated(crypto_stat_t * info) +{ + return info->inst; +} @@ -31037,14 +31569,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +static int inode_has_cipher_key(struct inode * inode) +{ + assert("edward-1376", inode != NULL); -+ return inode_crypto_info(inode) && -+ is_crypto_info_instantiated(inode_crypto_info(inode)); ++ return inode_crypto_stat(inode) && ++ crypto_stat_instantiated(inode_crypto_stat(inode)); +} + -+static void free_crypto_info (struct inode * inode) ++static void inode_free_crypto_stat (struct inode * inode) +{ -+ uninstantiate_crypto_info(inode_crypto_info(inode)); -+ __free_crypto_info(inode); ++ uninstantiate_crypto_stat(inode_crypto_stat(inode)); ++ free_crypto_stat(inode_crypto_stat(inode)); +} + +static int need_cipher(struct inode * inode) @@ -31053,15 +31585,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + cipher_plugin_by_id(NONE_CIPHER_ID); +} + -+/* Parse @data which contains a (uninstantiated) cipher key imported -+ from user space, create a low-level cipher info and attach it to -+ the @object. If success, then info contains an instantiated key */ ++/* Create a crypto-stat and attach result to the @object. ++ If success is returned, then low-level cipher info contains ++ an instantiated key */ +#if 0 -+struct reiser4_crypto_info * create_crypto_info(struct inode * object, -+ struct reiser4_crypto_data * data) ++crypto_stat_t * ++create_crypto_stat(struct inode * object, ++ crypto_data_t * data /* this contains a (uninstantiated) ++ cipher key imported from user ++ space */) +{ + int ret; -+ struct reiser4_crypto_info * info; ++ crypto_stat_t * info; + + assert("edward-1377", data != NULL); + assert("edward-1378", need_cipher(object)); @@ -31070,74 +31605,78 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + file_plugin_by_id(DIRECTORY_FILE_PLUGIN_ID)) + return ERR_PTR(-EINVAL); + -+ info = reiser4_alloc_crypto_info(object); ++ info = alloc_crypto_stat(object); + if (IS_ERR(info)) + return info; -+ ret = alloc_crypto_tfms(info); ++ ret = alloc_crypto_tfms(reiser4_inode_data(object)->pset, info); + if (ret) + goto err; ++ /* Someone can change plugins of the host (for example if ++ the host is a directory), so we keep the original ones ++ in the crypto-stat. */ ++ info_set_cipher_plugin(info, inode_cipher_plugin(object)); ++ info_set_digest_plugin(info, inode_digest_plugin(object)); + /* instantiating a key */ -+ ret = crypto_blkcipher_setkey(info_get_cipher(info), -+ data->key, -+ data->keysize); ++ ret = crypto_cipher_setkey(info_cipher_tfm(info), ++ data->key, ++ data->keysize); + if (ret) { + warning("edward-1379", -+ "setkey failed flags=%x", -+ crypto_blkcipher_get_flags(info_get_cipher(info))); ++ "setkey failed flags=%x\n", ++ info_cipher_tfm(info)->crt_flags); + goto err; + } + info->keysize = data->keysize; + ret = create_keyid(info, data); + if (ret) + goto err; -+ instantiate_crypto_info(info); ++ instantiate_crypto_stat(info); + return info; + err: -+ __free_crypto_info(object); ++ free_crypto_stat(info); + return ERR_PTR(ret); +} +#endif + -+/* increment/decrement a load counter when ++/* increment/decrement a load counter when + attaching/detaching the crypto-stat to any object */ -+static void load_crypto_info(struct reiser4_crypto_info * info) ++static void load_crypto_stat(crypto_stat_t * info) +{ + assert("edward-1380", info != NULL); + inc_keyload_count(info); +} + -+static void unload_crypto_info(struct inode * inode) ++static void unload_crypto_stat(struct inode * inode) +{ -+ struct reiser4_crypto_info * info = inode_crypto_info(inode); ++ crypto_stat_t * info = inode_crypto_stat(inode); + assert("edward-1381", info->keyload_count > 0); + -+ dec_keyload_count(inode_crypto_info(inode)); ++ dec_keyload_count(inode_crypto_stat(inode)); + if (info->keyload_count == 0) + /* final release */ -+ free_crypto_info(inode); ++ inode_free_crypto_stat(inode); +} + +/* attach/detach an existing crypto-stat */ -+void reiser4_attach_crypto_info(struct inode * inode, -+ struct reiser4_crypto_info * info) ++void attach_crypto_stat(struct inode * inode, crypto_stat_t * info) +{ + assert("edward-1382", inode != NULL); + assert("edward-1383", info != NULL); -+ assert("edward-1384", inode_crypto_info(inode) == NULL); ++ assert("edward-1384", inode_crypto_stat(inode) == NULL); + -+ set_inode_crypto_info(inode, info); -+ load_crypto_info(info); ++ set_inode_crypto_stat(inode, info); ++ load_crypto_stat(info); +} + +/* returns true, if crypto stat can be attached to the @host */ +#if REISER4_DEBUG -+static int host_allows_crypto_info(struct inode * host) ++static int host_allows_crypto_stat(struct inode * host) +{ + int ret; + file_plugin * fplug = inode_file_plugin(host); + + switch (fplug->h.id) { -+ case CRYPTCOMPRESS_FILE_PLUGIN_ID: ++ case CRC_FILE_PLUGIN_ID: + ret = 1; + break; + default: @@ -31147,43 +31686,39 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} +#endif /* REISER4_DEBUG */ + -+static void reiser4_detach_crypto_info(struct inode * inode) ++void detach_crypto_stat(struct inode * inode) +{ + assert("edward-1385", inode != NULL); -+ assert("edward-1386", host_allows_crypto_info(inode)); ++ assert("edward-1386", host_allows_crypto_stat(inode)); + -+ if (inode_crypto_info(inode)) -+ unload_crypto_info(inode); -+ set_inode_crypto_info(inode, NULL); ++ if (inode_crypto_stat(inode)) ++ unload_crypto_stat(inode); ++ set_inode_crypto_stat(inode, NULL); +} + +#if 0 + +/* compare fingerprints of @child and @parent */ -+static int keyid_eq(struct reiser4_crypto_info * child, -+ struct reiser4_crypto_info * parent) ++static int keyid_eq(crypto_stat_t * child, crypto_stat_t * parent) +{ -+ return !memcmp(child->keyid, -+ parent->keyid, -+ info_digest_plugin(parent)->fipsize); ++ return !memcmp(child->keyid, parent->keyid, info_digest_plugin(parent)->fipsize); +} + +/* check if a crypto-stat (which is bound to @parent) can be inherited */ -+int can_inherit_crypto_cryptcompress(struct inode *child, struct inode *parent) ++int can_inherit_crypto_crc(struct inode *child, struct inode *parent) +{ + if (!need_cipher(child)) + return 0; + /* the child is created */ -+ if (!inode_crypto_info(child)) ++ if (!inode_crypto_stat(child)) + return 1; + /* the child is looked up */ -+ if (!inode_crypto_info(parent)) ++ if (!inode_crypto_stat(parent)) + return 0; + return (inode_cipher_plugin(child) == inode_cipher_plugin(parent) && + inode_digest_plugin(child) == inode_digest_plugin(parent) && -+ inode_crypto_info(child)->keysize == -+ inode_crypto_info(parent)->keysize && -+ keyid_eq(inode_crypto_info(child), inode_crypto_info(parent))); ++ inode_crypto_stat(child)->keysize == inode_crypto_stat(parent)->keysize && ++ keyid_eq(inode_crypto_stat(child), inode_crypto_stat(parent))); +} +#endif + @@ -31191,7 +31726,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +static int inode_set_crypto(struct inode * object) +{ + reiser4_inode * info; -+ if (!inode_crypto_info(object)) { ++ if (!inode_crypto_stat(object)) { + if (need_cipher(object)) + return RETERR(-EINVAL); + /* the file is not to be encrypted */ @@ -31199,42 +31734,63 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + } + info = reiser4_inode_data(object); + info->extmask |= (1 << CRYPTO_STAT); ++ info->plugin_mask |= (1 << PSET_CIPHER) | (1 << PSET_DIGEST); + return 0; +} + -+static int inode_init_compression(struct inode * object) ++static int ++inode_set_compression(struct inode * object) +{ + int result = 0; -+ assert("edward-1461", object != NULL); -+ if (inode_compression_plugin(object)->init) -+ result = inode_compression_plugin(object)->init(); -+ return result; ++ compression_plugin * cplug; ++ reiser4_inode * info = reiser4_inode_data(object); ++ ++ cplug = inode_compression_plugin(object); ++ ++ if (cplug->init != NULL) { ++ result = cplug->init(); ++ if (result) ++ return result; ++ } ++ info->plugin_mask |= (1 << PSET_COMPRESSION); ++ ++ return 0; ++} ++ ++static void ++inode_set_compression_mode(struct inode * object) ++{ ++ reiser4_inode * info = reiser4_inode_data(object); ++ ++ info->plugin_mask |= (1 << PSET_COMPRESSION_MODE); ++ return; +} + -+static int inode_check_cluster(struct inode * object) ++static int inode_set_cluster(struct inode *object) +{ ++ reiser4_inode *info; ++ cluster_plugin *cplug; ++ + assert("edward-696", object != NULL); + -+ if (unlikely(inode_cluster_size(object) < PAGE_CACHE_SIZE)) { -+ warning("edward-1320", "Can not support '%s' " -+ "logical clusters (less then page size)", -+ inode_cluster_plugin(object)->h.label); -+ return RETERR(-EINVAL); -+ } -+ if (unlikely(inode_cluster_shift(object)) >= BITS_PER_BYTE*sizeof(int)){ -+ warning("edward-1463", "Can not support '%s' " -+ "logical clusters (too big for transform)", -+ inode_cluster_plugin(object)->h.label); ++ info = reiser4_inode_data(object); ++ cplug = inode_cluster_plugin(object); ++ ++ if (cplug->shift < PAGE_CACHE_SHIFT) { ++ warning("edward-1320", ++ "Can not support %p clusters (less then page size)", ++ cplug->h.label); + return RETERR(-EINVAL); + } ++ info->plugin_mask |= (1 << PSET_CLUSTER); + return 0; +} + +/* ->destroy_inode() method of the cryptcompress plugin */ +void destroy_inode_cryptcompress(struct inode * inode) +{ -+ assert("edward-1464", INODE_PGCOUNT(inode) == 0); -+ reiser4_detach_crypto_info(inode); ++ assert("edward-23", cryptcompress_inode_data(inode)->pgcount == 0); ++ detach_crypto_stat(inode); + return; +} + @@ -31245,8 +31801,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +. attach compression info if specified +. attach cluster info +*/ -+int create_cryptcompress(struct inode *object, struct inode *parent, -+ reiser4_object_create_data * data) ++int ++create_cryptcompress(struct inode *object, struct inode *parent, ++ reiser4_object_create_data * data) +{ + int result; + reiser4_inode *info; @@ -31254,8 +31811,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-23", object != NULL); + assert("edward-24", parent != NULL); + assert("edward-30", data != NULL); -+ assert("edward-26", reiser4_inode_get_flag(object, REISER4_NO_SD)); -+ assert("edward-27", data->id == CRYPTCOMPRESS_FILE_PLUGIN_ID); ++ assert("edward-26", inode_get_flag(object, REISER4_NO_SD)); ++ assert("edward-27", data->id == CRC_FILE_PLUGIN_ID); + + info = reiser4_inode_data(object); + @@ -31269,27 +31826,30 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result) + goto error; + /* set compression */ -+ result = inode_init_compression(object); ++ result = inode_set_compression(object); + if (result) + goto error; -+ /* set cluster */ -+ result = inode_check_cluster(object); ++ inode_set_compression_mode(object); ++ ++ /* set cluster info */ ++ result = inode_set_cluster(object); + if (result) + goto error; ++ /* set plugin mask */ ++ info->extmask |= (1 << PLUGIN_STAT); + + /* save everything in disk stat-data */ + result = write_sd_by_inode_common(object); + if (!result) + return 0; + error: -+ reiser4_detach_crypto_info(object); ++ detach_crypto_stat(object); + return result; +} + -+/* ->open_object() method of the cryptcompress plugin */ -+int open_object_cryptcompress(struct inode * inode, struct file * file) ++/* ->open() method of the cryptcompress plugin */ ++int open_cryptcompress(struct inode * inode, struct file * file) +{ -+ int result; + struct inode * parent; + + assert("edward-1394", inode != NULL); @@ -31300,13 +31860,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-1399", file->f_dentry->d_parent->d_inode != NULL); + assert("edward-698", + inode_file_plugin(inode) == -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); -+ result = inode_check_cluster(inode); -+ if (result) -+ return result; -+ result = inode_init_compression(inode); -+ if (result) -+ return result; ++ file_plugin_by_id(CRC_FILE_PLUGIN_ID)); ++ + if (!need_cipher(inode)) + /* the file is not to be ciphered */ + return 0; @@ -31321,9 +31876,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +cipher_blocksize(struct inode * inode) +{ + assert("edward-758", need_cipher(inode)); -+ assert("edward-1400", inode_crypto_info(inode) != NULL); -+ return crypto_blkcipher_blocksize -+ (info_get_cipher(inode_crypto_info(inode))); ++ assert("edward-1400", inode_crypto_stat(inode) != NULL); ++ return crypto_tfm_alg_blocksize ++ (info_cipher_tfm(inode_crypto_stat(inode))); +} + +/* returns offset translated by scale factor of the crypto-algorithm */ @@ -31333,8 +31888,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-97", inode != NULL); + + if (!need_cipher(inode) || -+ src_off == get_key_offset(reiser4_min_key()) || -+ src_off == get_key_offset(reiser4_max_key())) ++ src_off == get_key_offset(min_key()) || ++ src_off == get_key_offset(max_key())) + return src_off; + + return inode_cipher_plugin(inode)->scale(inode, @@ -31350,84 +31905,100 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return inode_scaled_offset(inode, inode_cluster_size(inode)); +} + ++static int new_cluster(reiser4_cluster_t * clust, struct inode *inode) ++{ ++ return (clust_to_off(clust->index, inode) >= inode->i_size); ++} ++ +/* set number of cluster pages */ -+static void set_cluster_nrpages(struct cluster_handle * clust, -+ struct inode *inode) ++static void set_cluster_nrpages(reiser4_cluster_t * clust, struct inode *inode) +{ -+ struct reiser4_slide * win; ++ reiser4_slide_t *win; + + assert("edward-180", clust != NULL); + assert("edward-1040", inode != NULL); + -+ clust->old_nrpages = size_in_pages(lbytes(clust->index, inode)); + win = clust->win; + if (!win) { -+ clust->nr_pages = size_in_pages(lbytes(clust->index, inode)); ++ /* NOTE-EDWARD: i_size should be protected */ ++ clust->nr_pages = ++ count_to_nrpages(fsize_to_count(clust, inode)); + return; + } -+ assert("edward-1176", clust->op != LC_INVAL); ++ assert("edward-1176", clust->op != PCL_UNKNOWN); + assert("edward-1064", win->off + win->count + win->delta != 0); + + if (win->stat == HOLE_WINDOW && + win->off == 0 && win->count == inode_cluster_size(inode)) { -+ /* special case: writing a "fake" logical cluster */ ++ /* special case: we start write hole from fake cluster */ + clust->nr_pages = 0; + return; + } -+ clust->nr_pages = size_in_pages(max(win->off + win->count + win->delta, -+ lbytes(clust->index, inode))); ++ clust->nr_pages = ++ count_to_nrpages(max_count(win->off + win->count + win->delta, ++ fsize_to_count(clust, inode))); + return; +} + -+/* plugin->key_by_inode() -+ build key of a disk cluster */ -+int key_by_inode_cryptcompress(struct inode *inode, loff_t off, -+ reiser4_key * key) ++/* ->key_by_inode() method of the cryptcompress plugin */ ++/* see plugin/plugin.h for details */ ++int ++key_by_inode_cryptcompress(struct inode *inode, loff_t off, reiser4_key * key) +{ ++ loff_t clust_off; ++ + assert("edward-64", inode != 0); ++ // assert("edward-112", ergo(off != get_key_offset(max_key()), !off_to_cloff(off, inode))); ++ /* don't come here with other offsets */ + -+ if (likely(off != get_key_offset(reiser4_max_key()))) -+ off = off_to_clust_to_off(off, inode); -+ if (inode_crypto_info(inode)) -+ off = inode_scaled_offset(inode, off); ++ clust_off = ++ (off == ++ get_key_offset(max_key())? get_key_offset(max_key()) : ++ off_to_clust_to_off(off, inode)); + + key_by_inode_and_offset_common(inode, 0, key); -+ set_key_offset(key, (__u64)off); ++ set_key_offset(key, ++ (__u64) (!inode_crypto_stat(inode) ? clust_off : ++ inode_scaled_offset(inode, clust_off))); + return 0; +} + -+/* plugin->flow_by_inode() */ -+/* flow is used to read/write disk clusters */ -+int flow_by_inode_cryptcompress(struct inode *inode, const char __user * buf, -+ int user, /* 1: @buf is of user space, -+ 0: kernel space */ -+ loff_t size, /* @buf size */ -+ loff_t off, /* offset to start io from */ -+ rw_op op, /* READ or WRITE */ -+ flow_t * f /* resulting flow */) ++/* plugin->flow_by_inode */ ++int ++flow_by_inode_cryptcompress(struct inode *inode /* file to build flow for */ , ++ const char __user *buf /* user level buffer */ , ++ int user /* 1 if @buf is of user space, 0 - if it is ++ kernel space */ , ++ loff_t size /* buffer size */ , ++ loff_t off /* offset to start io from */ , ++ rw_op op /* READ or WRITE */ , ++ flow_t * f /* resulting flow */ ) +{ + assert("edward-436", f != NULL); + assert("edward-149", inode != NULL); + assert("edward-150", inode_file_plugin(inode) != NULL); -+ assert("edward-1465", user == 0); /* we use flow to read/write -+ disk clusters located in -+ kernel space */ ++ assert("edward-151", ++ inode_file_plugin(inode)->key_by_inode == ++ key_by_inode_cryptcompress); ++ + f->length = size; + memcpy(&f->data, &buf, sizeof(buf)); + f->user = user; + f->op = op; + ++ if (op == WRITE_OP && user == 1) ++ return 0; + return key_by_inode_cryptcompress(inode, off, &f->key); +} + +static int -+cryptcompress_hint_validate(hint_t * hint, const reiser4_key * key, -+ znode_lock_mode lock_mode) ++crc_hint_validate(hint_t * hint, const reiser4_key * key, ++ znode_lock_mode lock_mode) +{ + coord_t *coord; + + assert("edward-704", hint != NULL); -+ assert("edward-1089", !hint_is_valid(hint)); ++ assert("edward-1089", !hint->ext_coord.valid); + assert("edward-706", hint->lh.owner == NULL); + + coord = &hint->ext_coord.coord; @@ -31440,27 +32011,27 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + /* hint is set for different key */ + return RETERR(-E_REPEAT); + -+ assert("edward-707", reiser4_schedulable()); ++ assert("edward-707", schedulable()); + -+ return reiser4_seal_validate(&hint->seal, &hint->ext_coord.coord, -+ key, &hint->lh, lock_mode, -+ ZNODE_LOCK_LOPRI); ++ return seal_validate(&hint->seal, &hint->ext_coord.coord, ++ key, &hint->lh, lock_mode, ZNODE_LOCK_LOPRI); +} + +/* reserve disk space when writing a logical cluster */ -+static int reserve4cluster(struct inode *inode, struct cluster_handle *clust) ++static int reserve4cluster(struct inode *inode, reiser4_cluster_t *clust) +{ + int result = 0; + -+ assert("edward-965", reiser4_schedulable()); ++ assert("edward-965", schedulable()); + assert("edward-439", inode != NULL); + assert("edward-440", clust != NULL); + assert("edward-441", clust->pages != NULL); ++ assert("edward-1261", get_current_context()->grabbed_blocks == 0); + + if (clust->nr_pages == 0) { + assert("edward-1152", clust->win != NULL); + assert("edward-1153", clust->win->stat == HOLE_WINDOW); -+ /* don't reserve disk space for fake logical cluster */ ++ /* don't reserve space for fake disk clusteer */ + return 0; + } + assert("edward-442", jprivate(clust->pages[0]) != NULL); @@ -31478,22 +32049,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + clust->reserved_unprepped = estimate_insert_cluster(inode); +#endif + /* there can be space grabbed by txnmgr_force_commit_all */ ++ all_grabbed2free(); + return 0; +} + +/* free reserved disk space if writing a logical cluster fails */ -+static void free_reserved4cluster(struct inode *inode, -+ struct cluster_handle *ch, int count) ++static void ++free_reserved4cluster(struct inode *inode, reiser4_cluster_t * clust, int count) +{ -+ assert("edward-967", ch->reserved == 1); ++ assert("edward-967", clust->reserved == 1); + + cluster_reserved2free(count); -+ ch->reserved = 0; ++ clust->reserved = 0; +} + +/* The core search procedure of the cryptcompress plugin. + If returned value is not cbk_errored, then current znode is locked */ -+static int find_cluster_item(hint_t * hint, ++static int find_cluster_item(hint_t * hint, + const reiser4_key * key, /* key of the item we are + looking for */ + znode_lock_mode lock_mode /* which lock */ , @@ -31501,21 +32073,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +{ + int result; + reiser4_key ikey; -+ int went_right = 0; + coord_t *coord = &hint->ext_coord.coord; + coord_t orig = *coord; + + assert("edward-152", hint != NULL); + -+ if (!hint_is_valid(hint)) { -+ result = cryptcompress_hint_validate(hint, key, lock_mode); ++ if (hint->ext_coord.valid == 0) { ++ result = crc_hint_validate(hint, key, lock_mode); + if (result == -E_REPEAT) + goto traverse_tree; + else if (result) { + assert("edward-1216", 0); + return result; + } -+ hint_set_valid(hint); ++ hint->ext_coord.valid = 1; + } + assert("edward-709", znode_is_any_locked(coord->node)); + @@ -31531,7 +32102,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result) + return result; + assert("edward-1218", equal_to_ldk(coord->node, key)); -+ went_right = 1; + } else { + coord->item_pos++; + coord->unit_pos = 0; @@ -31550,12 +32120,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + zrelse(coord->node); + if (!keyeq(key, &ikey)) + goto not_found; -+ /* Ok, item is found, update node counts */ -+ if (went_right) -+ dclust_inc_extension_ncount(hint); + return CBK_COORD_FOUND; + -+ not_found: ++ not_found: + assert("edward-1220", coord->item_pos > 0); + //coord->item_pos--; + /* roll back */ @@ -31563,21 +32130,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + ON_DEBUG(coord_update_v(coord)); + return CBK_COORD_NOTFOUND; + -+ traverse_tree: ++ traverse_tree: + assert("edward-713", hint->lh.owner == NULL); -+ assert("edward-714", reiser4_schedulable()); ++ assert("edward-714", schedulable()); + -+ reiser4_unset_hint(hint); -+ dclust_init_extension(hint); ++ unset_hint(hint); + coord_init_zero(coord); + result = coord_by_key(current_tree, key, coord, &hint->lh, + lock_mode, bias, LEAF_LEVEL, LEAF_LEVEL, + CBK_UNIQUE | flags, ra_info); + if (cbk_errored(result)) + return result; -+ if(result == CBK_COORD_FOUND) -+ dclust_inc_extension_ncount(hint); -+ hint_set_valid(hint); ++ hint->ext_coord.valid = 1; + return result; +} + @@ -31586,10 +32150,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + create/cut some overhead. If this returns true, then @oh + contains the size of this overhead. + */ -+static int need_cut_or_align(struct inode * inode, -+ struct cluster_handle * ch, rw_op rw, int * oh) ++static int ++need_cut_or_align(struct inode * inode, reiser4_cluster_t * clust, ++ rw_op rw, int * oh) +{ -+ struct tfm_cluster * tc = &ch->tc; ++ tfm_cluster_t * tc = &clust->tc; + switch (rw) { + case WRITE_OP: /* estimate align */ + *oh = tc->len % cipher_blocksize(inode); @@ -31597,7 +32162,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return 1; + break; + case READ_OP: /* estimate cut */ -+ *oh = *(tfm_output_data(ch) + tc->len - 1); ++ *oh = *(tfm_output_data(clust) + tc->len - 1); + break; + default: + impossible("edward-1401", "bad option"); @@ -31606,28 +32171,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* create/cut an overhead of transformed/plain stream */ -+static void align_or_cut_overhead(struct inode * inode, -+ struct cluster_handle * ch, rw_op rw) ++static void ++align_or_cut_overhead(struct inode * inode, reiser4_cluster_t * clust, rw_op rw) +{ + int oh; + cipher_plugin * cplug = inode_cipher_plugin(inode); + + assert("edward-1402", need_cipher(inode)); + -+ if (!need_cut_or_align(inode, ch, rw, &oh)) ++ if (!need_cut_or_align(inode, clust, rw, &oh)) + return; + switch (rw) { + case WRITE_OP: /* do align */ -+ ch->tc.len += -+ cplug->align_stream(tfm_input_data(ch) + -+ ch->tc.len, ch->tc.len, ++ clust->tc.len += ++ cplug->align_stream(tfm_input_data(clust) + ++ clust->tc.len, clust->tc.len, + cipher_blocksize(inode)); -+ *(tfm_input_data(ch) + ch->tc.len - 1) = ++ *(tfm_input_data(clust) + clust->tc.len - 1) = + cipher_blocksize(inode) - oh; + break; + case READ_OP: /* do cut */ + assert("edward-1403", oh <= cipher_blocksize(inode)); -+ ch->tc.len -= oh; ++ clust->tc.len -= oh; + break; + default: + impossible("edward-1404", "bad option"); @@ -31635,7 +32200,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return; +} + -+static unsigned max_cipher_overhead(struct inode * inode) ++/* the following two functions are to evaluate results ++ of compression transform */ ++static unsigned ++max_cipher_overhead(struct inode * inode) +{ + if (!need_cipher(inode) || !inode_cipher_plugin(inode)->align_stream) + return 0; @@ -31658,7 +32226,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + If this returns false, then compressor won't be called for + the cluster of index @index. +*/ -+static int should_compress(struct tfm_cluster * tc, cloff_t index, ++static int should_compress(tfm_cluster_t * tc, cloff_t index, + struct inode *inode) +{ + compression_plugin *cplug = inode_compression_plugin(inode); @@ -31680,17 +32248,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + +/* Evaluating results of compression transform. + Returns true, if we need to accept this results */ -+static int save_compressed(int size_before, int size_after, struct inode *inode) ++static int ++save_compressed(int size_before, int size_after, struct inode * inode) +{ + return (size_after + deflate_overhead(inode) + + max_cipher_overhead(inode) < size_before); +} + +/* Guess result of the evaluation above */ -+static int need_inflate(struct cluster_handle * ch, struct inode * inode, -+ int encrypted /* is cluster encrypted */ ) ++static int ++need_inflate(reiser4_cluster_t * clust, struct inode *inode, ++ int encrypted /* is cluster encrypted */ ) +{ -+ struct tfm_cluster * tc = &ch->tc; ++ tfm_cluster_t *tc = &clust->tc; + + assert("edward-142", tc != 0); + assert("edward-143", inode != NULL); @@ -31719,7 +32289,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + 1 <= overhead <= cipher_blksize +*/ +/* Append a checksum at the end of a transformed stream */ -+static void dc_set_checksum(compression_plugin * cplug, struct tfm_cluster * tc) ++static void dc_set_checksum(compression_plugin * cplug, tfm_cluster_t * tc) +{ + __u32 checksum; + @@ -31735,7 +32305,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + +/* Check a disk cluster checksum. + Returns 0 if checksum is correct, otherwise returns 1 */ -+static int dc_check_checksum(compression_plugin * cplug, struct tfm_cluster * tc) ++static int dc_check_checksum(compression_plugin * cplug, tfm_cluster_t * tc) +{ + assert("edward-1312", tc != NULL); + assert("edward-1313", tc->len > (int)DC_CHECKSUM_SIZE); @@ -31762,7 +32332,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* get input/output stream for some transform action */ -+int grab_tfm_stream(struct inode * inode, struct tfm_cluster * tc, ++int grab_tfm_stream(struct inode * inode, tfm_cluster_t * tc, + tfm_stream_id id) +{ + size_t size = inode_scaled_cluster_size(inode); @@ -31770,12 +32340,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-901", tc != NULL); + assert("edward-1027", inode_compression_plugin(inode) != NULL); + -+ if (cluster_get_tfm_act(tc) == TFMA_WRITE) ++ if (tc->act == TFM_WRITE_ACT) + size += deflate_overrun(inode, inode_cluster_size(inode)); + -+ if (!get_tfm_stream(tc, id) && id == INPUT_STREAM) ++ if (!tfm_stream(tc, id) && id == INPUT_STREAM) + alternate_streams(tc); -+ if (!get_tfm_stream(tc, id)) ++ if (!tfm_stream(tc, id)) + return alloc_tfm_stream(tc, size, id); + + assert("edward-902", tfm_stream_is_set(tc, id)); @@ -31786,17 +32356,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* Common deflate manager */ -+int reiser4_deflate_cluster(struct cluster_handle * clust, struct inode * inode) ++int deflate_cluster(reiser4_cluster_t * clust, struct inode * inode) +{ + int result = 0; + int compressed = 0; + int encrypted = 0; -+ struct tfm_cluster * tc = &clust->tc; ++ tfm_cluster_t * tc = &clust->tc; + compression_plugin * coplug; + + assert("edward-401", inode != NULL); + assert("edward-903", tfm_stream_is_set(tc, INPUT_STREAM)); -+ assert("edward-1348", cluster_get_tfm_act(tc) == TFMA_WRITE); ++ assert("edward-1348", tc->act == TFM_WRITE_ACT); + assert("edward-498", !tfm_cluster_is_uptodate(tc)); + + coplug = inode_compression_plugin(inode); @@ -31845,9 +32415,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + } + else { + /* bad result, discard */ -+#if 0 ++#if REISER4_DEBUG + if (cluster_is_complete(clust, inode)) -+ warning("edward-1496", ++ warning("edward-1338", + "incompressible cluster %lu (inode %llu)", + clust->index, + (unsigned long long)get_inode_oid(inode)); @@ -31866,13 +32436,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + cipher: + if (need_cipher(inode)) { + cipher_plugin * ciplug; -+ struct blkcipher_desc desc; ++ struct crypto_tfm * tfm; + struct scatterlist src; + struct scatterlist dst; + + ciplug = inode_cipher_plugin(inode); -+ desc.tfm = info_get_cipher(inode_crypto_info(inode)); -+ desc.flags = 0; ++ tfm = info_cipher_tfm(inode_crypto_stat(inode)); + if (compressed) + alternate_streams(tc); + result = grab_tfm_stream(inode, tc, OUTPUT_STREAM); @@ -31888,10 +32457,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + dst.offset = offset_in_page(tfm_output_data(clust)); + dst.length = tc->len; + -+ result = crypto_blkcipher_encrypt(&desc, &dst, &src, tc->len); ++ result = crypto_cipher_encrypt(tfm, &dst, &src, tc->len); + if (result) { + warning("edward-1405", -+ "encryption failed flags=%x\n", desc.flags); ++ "encryption failed flags=%x\n", tfm->crt_flags); + return result; + } + encrypted = 1; @@ -31904,17 +32473,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* Common inflate manager. */ -+int reiser4_inflate_cluster(struct cluster_handle * clust, struct inode * inode) ++int inflate_cluster(reiser4_cluster_t * clust, struct inode * inode) +{ + int result = 0; + int transformed = 0; -+ struct tfm_cluster * tc = &clust->tc; ++ tfm_cluster_t * tc = &clust->tc; + compression_plugin * coplug; + + assert("edward-905", inode != NULL); + assert("edward-1178", clust->dstat == PREP_DISK_CLUSTER); + assert("edward-906", tfm_stream_is_set(&clust->tc, INPUT_STREAM)); -+ assert("edward-1349", tc->act == TFMA_READ); ++ assert("edward-1349", tc->act == TFM_READ_ACT); + assert("edward-907", !tfm_cluster_is_uptodate(tc)); + + /* Handle a checksum (if any) */ @@ -31922,23 +32491,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (need_inflate(clust, inode, need_cipher(inode)) && + coplug->checksum != NULL) { + result = dc_check_checksum(coplug, tc); -+ if (unlikely(result)) { -+ warning("edward-1460", -+ "Inode %llu: disk cluster %lu looks corrupted", -+ (unsigned long long)get_inode_oid(inode), -+ clust->index); ++ if (result) + return RETERR(-EIO); -+ } + } + if (need_cipher(inode)) { + cipher_plugin * ciplug; -+ struct blkcipher_desc desc; ++ struct crypto_tfm * tfm; + struct scatterlist src; + struct scatterlist dst; + + ciplug = inode_cipher_plugin(inode); -+ desc.tfm = info_get_cipher(inode_crypto_info(inode)); -+ desc.flags = 0; ++ tfm = info_cipher_tfm(inode_crypto_stat(inode)); + result = grab_tfm_stream(inode, tc, OUTPUT_STREAM); + if (result) + return result; @@ -31952,12 +32515,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + dst.offset = offset_in_page(tfm_output_data(clust)); + dst.length = tc->len; + -+ result = crypto_blkcipher_decrypt(&desc, &dst, &src, tc->len); -+ if (result) { -+ warning("edward-1600", "decrypt failed flags=%x\n", -+ desc.flags); ++ result = crypto_cipher_decrypt(tfm, &dst, &src, tc->len); ++ if (result) + return result; -+ } + align_or_cut_overhead(inode, clust, READ_OP); + transformed = 1; + } @@ -31990,7 +32550,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +int readpage_cryptcompress(struct file *file, struct page *page) +{ + reiser4_context *ctx; -+ struct cluster_handle clust; ++ reiser4_cluster_t clust; + item_plugin *iplug; + int result; + @@ -31998,10 +32558,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("vs-976", !PageUptodate(page)); + assert("edward-89", page->mapping && page->mapping->host); + -+ ctx = reiser4_init_context(page->mapping->host->i_sb); -+ if (IS_ERR(ctx)) { -+ unlock_page(page); ++ ctx = init_context(page->mapping->host->i_sb); ++ if (IS_ERR(ctx)) + return PTR_ERR(ctx); ++ result = check_cryptcompress(page->mapping->host); ++ if (result) { ++ unlock_page(page); ++ reiser4_exit_context(ctx); ++ return result; + } + assert("edward-113", + ergo(file != NULL, @@ -32009,7 +32573,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + if (PageUptodate(page)) { + warning("edward-1338", "page is already uptodate\n"); -+ unlock_page(page); + reiser4_exit_context(ctx); + return 0; + } @@ -32023,34 +32586,35 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return -EINVAL; + } + result = iplug->s.file.readpage(&clust, page); -+ ++ if (result) ++ unlock_page(page); ++ assert("edward-64", ++ ergo(result == 0, (PageLocked(page) || PageUptodate(page)))); + put_cluster_handle(&clust); -+ reiser4_txn_restart(ctx); + reiser4_exit_context(ctx); + return result; +} + -+/* number of pages to check in */ -+static int get_new_nrpages(struct cluster_handle * clust) ++/* how much pages will be captured */ ++static int cluster_nrpages_to_capture(reiser4_cluster_t * clust) +{ + switch (clust->op) { -+ case LC_APPOV: ++ case PCL_APPEND: + return clust->nr_pages; -+ case LC_TRUNC: ++ case PCL_TRUNCATE: + assert("edward-1179", clust->win != NULL); -+ return size_in_pages(clust->win->off + clust->win->count); ++ return count_to_nrpages(clust->win->off + clust->win->count); + default: + impossible("edward-1180", "bad page cluster option"); + return 0; + } +} + -+static void set_cluster_pages_dirty(struct cluster_handle * clust, -+ struct inode * inode) ++static void set_cluster_pages_dirty(reiser4_cluster_t * clust) +{ + int i; + struct page *pg; -+ int nrpages = get_new_nrpages(clust); ++ int nrpages = cluster_nrpages_to_capture(clust); + + for (i = 0; i < nrpages; i++) { + @@ -32058,23 +32622,179 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-968", pg != NULL); + lock_page(pg); + assert("edward-1065", PageUptodate(pg)); -+ reiser4_set_page_dirty_internal(pg); ++ set_page_dirty_internal(pg); + unlock_page(pg); + mark_page_accessed(pg); + } +} + -+/* Grab a page cluster for read/write operations. -+ Attach a jnode for write operations (when preparing for modifications, which -+ are supposed to be committed). ++static void clear_cluster_pages_dirty(reiser4_cluster_t * clust) ++{ ++ int i; ++ assert("edward-1275", clust != NULL); ++ ++ for (i = 0; i < clust->nr_pages; i++) { ++ assert("edward-1276", clust->pages[i] != NULL); ++ ++ lock_page(clust->pages[i]); ++ if (PageDirty(clust->pages[i])) { ++ assert("edward-1277", PageUptodate(clust->pages[i])); ++ clear_page_dirty_for_io(clust->pages[i]); ++ } ++#if REISER4_DEBUG ++ else ++ /* Race between flush and write: ++ some pages became clean when write() (or another ++ process which modifies data) capture the cluster. */ ++ warning("edward-985", "Page of index %lu (inode %llu)" ++ " is not dirty\n", clust->pages[i]->index, ++ (unsigned long long)get_inode_oid(clust-> ++ pages[i]-> ++ mapping-> ++ host)); ++#endif ++ unlock_page(clust->pages[i]); ++ } ++} ++ ++/* update i_size by window */ ++static void inode_set_new_size(reiser4_cluster_t * clust, struct inode *inode) ++{ ++ loff_t size; ++ reiser4_slide_t *win; ++ ++ assert("edward-1181", clust != NULL); ++ assert("edward-1182", inode != NULL); ++ ++ win = clust->win; ++ assert("edward-1183", win != NULL); ++ ++ size = clust_to_off(clust->index, inode) + win->off; ++ ++ switch (clust->op) { ++ case PCL_APPEND: ++ if (size + win->count <= inode->i_size) ++ /* overwrite only */ ++ return; ++ size += win->count; ++ break; ++ case PCL_TRUNCATE: ++ break; ++ default: ++ impossible("edward-1184", "bad page cluster option"); ++ break; ++ } ++ inode_check_scale_nolock(inode, inode->i_size, size); ++ inode->i_size = size; ++ return; ++} ++ ++/* Check in page cluster modifications. ++ . Make jnode dirty, if it wasn't; ++ . Reserve space for a disk cluster update by flush algorithm, if needed; ++ . Clean up old references (if any). ++ . Put pages (grabbed in this thread) which will be truncated ++*/ ++static void ++make_cluster_jnode_dirty_locked(reiser4_cluster_t * clust, jnode * node, ++ loff_t * old_isize, struct inode *inode) ++{ ++ int i; ++ int old_nrpages; ++ int new_nrpages = cluster_nrpages_to_capture(clust); ++ ++ assert("edward-973", new_nrpages > 0); ++ assert("edward-221", node != NULL); ++ assert("edward-971", clust->reserved == 1); ++ assert_spin_locked(&(node->guard)); ++ assert("edward-972", node->page_count < cluster_nrpages(inode)); ++ assert("edward-1263", ++ clust->reserved_prepped == estimate_update_cluster(inode)); ++ assert("edward-1264", clust->reserved_unprepped == 0); + -+ We allocate only one jnode per page cluster; this jnode is binded to the -+ first page of this cluster, so we have an extra-reference that will be put -+ as soon as jnode is evicted from memory), other references will be cleaned -+ up in flush time (assume that check in page cluster was successful). ++ if (JF_ISSET(node, JNODE_DIRTY)) { ++ /* someone has modified this cluster, but ++ the modifications are not committed yet */ ++ old_nrpages = ++ count_to_nrpages(cnt_to_clcnt(*old_isize, ++ clust->index, inode)); ++ /* free space which is already reserved */ ++ free_reserved4cluster(inode, clust, ++ estimate_update_cluster(inode)); ++ /* put old references */ ++ for (i = 0; i < old_nrpages; i++) { ++ assert("edward-975", clust->pages[i]); ++ assert("edward-1185", PageUptodate(clust->pages[i])); ++ ++ page_cache_release(clust->pages[i]); ++#if REISER4_DEBUG ++ cryptcompress_inode_data(inode)->pgcount --; ++#endif ++ } ++ } else { ++ /* no captured pages */ ++ assert("edward-1043", node->page_count == 0); ++ jnode_make_dirty_locked(node); ++ clust->reserved = 0; ++ } ++ /* put pages that will be truncated (if any) */ ++ for (i = new_nrpages; i < clust->nr_pages; i++) { ++ assert("edward-1433", clust->pages[i]); ++ assert("edward-1434", PageUptodate(clust->pages[i])); ++ page_cache_release(clust->pages[i]); ++#if REISER4_DEBUG ++ cryptcompress_inode_data(inode)->pgcount --; ++#endif ++ } ++#if REISER4_DEBUG ++ clust->reserved_prepped -= estimate_update_cluster(inode); ++ node->page_count = new_nrpages - 1; ++#endif ++ return; ++} ++ ++/* This function spawns a transaction and ++ is called by any thread as a final step in page cluster modification. ++*/ ++static int try_capture_cluster(reiser4_cluster_t * clust, struct inode *inode) ++{ ++ int result = 0; ++ loff_t old_size; ++ jnode *node; ++ ++ assert("edward-1029", clust != NULL); ++ assert("edward-1030", clust->reserved == 1); ++ assert("edward-1031", clust->nr_pages != 0); ++ assert("edward-1032", clust->pages != NULL); ++ assert("edward-1033", clust->pages[0] != NULL); ++ ++ node = jprivate(clust->pages[0]); ++ ++ assert("edward-1035", node != NULL); ++ ++ spin_lock_jnode(node); ++ old_size = inode->i_size; ++ if (clust->win) ++ inode_set_new_size(clust, inode); ++ ++ result = try_capture(node, ZNODE_WRITE_LOCK, 0); ++ if (result) ++ goto exit; ++ make_cluster_jnode_dirty_locked(clust, node, &old_size, inode); ++ exit: ++ assert("edward-1034", !result); ++ spin_unlock_jnode(node); ++ jput(node); ++ return result; ++} ++ ++/* Collect unlocked cluster pages for any modifications and attach a jnode. ++ We allocate only one jnode per cluster, this jnode is binded to the first ++ page of this cluster, so we have an extra-reference that will exist with ++ this jnode, other references will be cleaned up in flush time. +*/ -+int grab_page_cluster(struct inode * inode, -+ struct cluster_handle * clust, rw_op rw) ++static int ++grab_cluster_pages_jnode(struct inode *inode, reiser4_cluster_t * clust) +{ + int i; + int result = 0; @@ -32082,9 +32802,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + assert("edward-182", clust != NULL); + assert("edward-183", clust->pages != NULL); -+ assert("edward-1466", clust->node == NULL); -+ assert("edward-1428", inode != NULL); -+ assert("edward-1429", inode->i_mapping != NULL); + assert("edward-184", clust->nr_pages <= cluster_nrpages(inode)); + + if (clust->nr_pages == 0) @@ -32095,14 +32812,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-1044", clust->pages[i] == NULL); + + clust->pages[i] = -+ find_or_create_page(inode->i_mapping, -+ clust_to_pg(clust->index, inode) + i, -+ reiser4_ctx_gfp_mask_get()); ++ grab_cache_page(inode->i_mapping, ++ clust_to_pg(clust->index, inode) + i); + if (!clust->pages[i]) { + result = RETERR(-ENOMEM); + break; + } -+ if (i == 0 && rw == WRITE_OP) { ++ if (i == 0) { + node = jnode_of_page(clust->pages[i]); + if (IS_ERR(node)) { + result = PTR_ERR(node); @@ -32110,90 +32826,117 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + break; + } + JF_SET(node, JNODE_CLUSTER_PAGE); -+ assert("edward-920", jprivate(clust->pages[0])); ++ unlock_page(clust->pages[i]); ++ assert("edward-919", node); ++ continue; + } -+ INODE_PGCOUNT_INC(inode); + unlock_page(clust->pages[i]); + } -+ if (unlikely(result)) { -+ while (i) { -+ put_cluster_page(clust->pages[--i]); -+ INODE_PGCOUNT_DEC(inode); -+ } ++ if (result) { ++ while (i) ++ page_cache_release(clust->pages[--i]); + if (node && !IS_ERR(node)) + jput(node); + return result; + } -+ clust->node = node; ++ assert("edward-920", jprivate(clust->pages[0])); ++#if REISER4_DEBUG ++ cryptcompress_inode_data(inode)->pgcount += clust->nr_pages; ++#endif + return 0; +} + -+static void truncate_page_cluster_range(struct inode * inode, -+ struct page ** pages, -+ cloff_t index, -+ int from, int count, -+ int even_cows) ++/* Collect unlocked cluster pages only for read (not to modify) */ ++static int grab_cluster_pages(struct inode *inode, reiser4_cluster_t * clust) +{ -+ assert("edward-1467", count > 0); -+ reiser4_invalidate_pages(inode->i_mapping, -+ clust_to_pg(index, inode) + from, -+ count, even_cows); ++ int i; ++ int result = 0; ++ ++ assert("edward-1428", inode != NULL); ++ assert("edward-1429", inode->i_mapping != NULL); ++ assert("edward-787", clust != NULL); ++ assert("edward-788", clust->pages != NULL); ++ assert("edward-789", clust->nr_pages != 0); ++ assert("edward-790", clust->nr_pages <= cluster_nrpages(inode)); ++ ++ for (i = 0; i < clust->nr_pages; i++) { ++ clust->pages[i] = ++ grab_cache_page(inode->i_mapping, ++ clust_to_pg(clust->index, inode) + i); ++ if (!clust->pages[i]) { ++ result = RETERR(-ENOMEM); ++ break; ++ } ++ unlock_page(clust->pages[i]); ++ } ++ if (result) ++ while (i) ++ page_cache_release(clust->pages[--i]); ++ return result; +} + -+/* Put @count pages starting from @from offset */ -+void __put_page_cluster(int from, int count, -+ struct page ** pages, struct inode * inode) ++/* @node might be attached by reiser4_writepage(), not by ++ cryptcompress plugin code, but emergency flush should ++ understand that pages of cryptcompress files are not ++ flushable. ++*/ ++int jnode_of_cluster(const jnode * node, struct page * page) ++{ ++ assert("edward-1339", node != NULL); ++ assert("edward-1340", page != NULL); ++ assert("edward-1341", page->mapping != NULL); ++ assert("edward-1342", page->mapping->host != NULL); ++ assert("edward-1343", ++ ergo(jnode_is_unformatted(node), ++ get_inode_oid(page->mapping->host) == ++ node->key.j.objectid)); ++ if (inode_file_plugin(page->mapping->host) == ++ file_plugin_by_id(CRC_FILE_PLUGIN_ID)) { ++#if REISER4_DEBUG ++ if (!jnode_is_cluster_page(node)) ++ warning("edward-1345", ++ "inode %llu: cluster page of index %lu became private", ++ (unsigned long long)get_inode_oid(page->mapping->host), ++ page->index); ++#endif ++ return 1; ++ } ++ return 0; ++} ++ ++/* put cluster pages */ ++void release_cluster_pages(reiser4_cluster_t * clust) +{ + int i; -+ assert("edward-1468", pages != NULL); -+ assert("edward-1469", inode != NULL); -+ assert("edward-1470", from >= 0 && count >= 0); + -+ for (i = 0; i < count; i++) { -+ assert("edward-1471", pages[from + i] != NULL); -+ assert("edward-1472", -+ pages[from + i]->index == pages[from]->index + i); ++ assert("edward-447", clust != NULL); ++ for (i = 0; i < clust->nr_pages; i++) { ++ ++ assert("edward-449", clust->pages[i] != NULL); + -+ put_cluster_page(pages[from + i]); -+ INODE_PGCOUNT_DEC(inode); ++ page_cache_release(clust->pages[i]); + } +} + -+/* -+ * This is dual to grab_page_cluster, -+ * however if @rw == WRITE_OP, then we call this function -+ * only if something is failed before checkin page cluster. -+ */ -+void put_page_cluster(struct cluster_handle * clust, -+ struct inode * inode, rw_op rw) ++/* this is called when something is failed */ ++static void release_cluster_pages_and_jnode(reiser4_cluster_t * clust) +{ ++ jnode *node; ++ + assert("edward-445", clust != NULL); + assert("edward-922", clust->pages != NULL); -+ assert("edward-446", -+ ergo(clust->nr_pages != 0, clust->pages[0] != NULL)); ++ assert("edward-446", clust->pages[0] != NULL); + -+ __put_page_cluster(0, clust->nr_pages, clust->pages, inode); -+ if (rw == WRITE_OP) { -+ if (unlikely(clust->node)) { -+ assert("edward-447", -+ clust->node == jprivate(clust->pages[0])); -+ jput(clust->node); -+ clust->node = NULL; -+ } -+ } -+} ++ node = jprivate(clust->pages[0]); + -+#if REISER4_DEBUG -+int cryptcompress_inode_ok(struct inode *inode) -+{ -+ if (!(reiser4_inode_data(inode)->plugin_mask & (1 << PSET_FILE))) -+ return 0; -+ if (!cluster_shift_ok(inode_cluster_shift(inode))) -+ return 0; -+ return 1; ++ assert("edward-447", node != NULL); ++ ++ release_cluster_pages(clust); ++ jput(node); +} + -+static int window_ok(struct reiser4_slide * win, struct inode *inode) ++#if REISER4_DEBUG ++static int window_ok(reiser4_slide_t * win, struct inode *inode) +{ + assert("edward-1115", win != NULL); + assert("edward-1116", ergo(win->delta, win->stat == HOLE_WINDOW)); @@ -32202,7 +32945,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + (win->off + win->count + win->delta <= inode_cluster_size(inode)); +} + -+static int cluster_ok(struct cluster_handle * clust, struct inode *inode) ++static int cluster_ok(reiser4_cluster_t * clust, struct inode *inode) +{ + assert("edward-279", clust != NULL); + @@ -32210,58 +32953,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return 0; + return (clust->win ? window_ok(clust->win, inode) : 1); +} -+#if 0 -+static int pages_truncate_ok(struct inode *inode, pgoff_t start) -+{ -+ int found; -+ struct page * page; -+ -+ found = find_get_pages(inode->i_mapping, start, 1, &page); -+ if (found) -+ put_cluster_page(page); -+ return !found; -+} -+#else -+#define pages_truncate_ok(inode, start) 1 -+#endif -+ -+static int jnode_truncate_ok(struct inode *inode, cloff_t index) -+{ -+ jnode *node; -+ node = jlookup(current_tree, get_inode_oid(inode), -+ clust_to_pg(index, inode)); -+ if (likely(!node)) -+ return 1; -+ jput(node); -+ return 0; -+} -+ -+static int find_fake_appended(struct inode *inode, cloff_t * index); -+ -+static int body_truncate_ok(struct inode *inode, cloff_t aidx) -+{ -+ int result; -+ cloff_t raidx; -+ -+ result = find_fake_appended(inode, &raidx); -+ return !result && (aidx == raidx); -+} +#endif + +/* guess next window stat */ -+static inline window_stat next_window_stat(struct reiser4_slide * win) ++static inline window_stat next_window_stat(reiser4_slide_t * win) +{ + assert("edward-1130", win != NULL); + return ((win->stat == HOLE_WINDOW && win->delta == 0) ? + HOLE_WINDOW : DATA_WINDOW); +} + -+/* guess and set next cluster index and window params */ -+static void move_update_window(struct inode * inode, -+ struct cluster_handle * clust, -+ loff_t file_off, loff_t to_file) ++/* guess next cluster index and window params */ ++static void ++update_cluster(struct inode *inode, reiser4_cluster_t * clust, loff_t file_off, ++ loff_t to_file) +{ -+ struct reiser4_slide * win; ++ reiser4_slide_t *win; + + assert("edward-185", clust != NULL); + assert("edward-438", clust->pages != NULL); @@ -32273,27 +32980,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + switch (win->stat) { + case DATA_WINDOW: -+ /* increment */ ++ /* increment window position */ + clust->index++; + win->stat = DATA_WINDOW; + win->off = 0; -+ win->count = min((loff_t)inode_cluster_size(inode), to_file); ++ win->count = min_count(inode_cluster_size(inode), to_file); + break; + case HOLE_WINDOW: + switch (next_window_stat(win)) { + case HOLE_WINDOW: -+ /* skip */ ++ /* set window to fit the offset we start write from */ + clust->index = off_to_clust(file_off, inode); + win->stat = HOLE_WINDOW; + win->off = 0; + win->count = off_to_cloff(file_off, inode); -+ win->delta = min((loff_t)(inode_cluster_size(inode) - -+ win->count), to_file); ++ win->delta = ++ min_count(inode_cluster_size(inode) - win->count, ++ to_file); + break; + case DATA_WINDOW: -+ /* stay */ ++ /* do not move the window, just change its state, ++ off+count+delta=inv */ + win->stat = DATA_WINDOW; -+ /* off+count+delta=inv */ + win->off = win->off + win->count; + win->count = win->delta; + win->delta = 0; @@ -32312,402 +33020,127 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +{ + int result = 0; + -+ assert("edward-978", reiser4_schedulable()); ++ assert("edward-978", schedulable()); ++ assert("edward-1265", get_current_context()->grabbed_blocks == 0); + -+ result = reiser4_grab_space_force(/* one for stat data update */ -+ estimate_update_common(inode), -+ BA_CAN_COMMIT); ++ result = reiser4_grab_space_force( /* one for stat data update */ ++ estimate_update_common(inode), ++ BA_CAN_COMMIT); ++ assert("edward-979", !result); + if (result) + return result; + inode->i_ctime = inode->i_mtime = CURRENT_TIME; + result = reiser4_update_sd(inode); + ++ all_grabbed2free(); + return result; +} + ++ ++/* NOTE-Edward: this is too similar to reiser4/txnmgr.c:uncapture_jnode() */ +static void uncapture_cluster_jnode(jnode * node) +{ + txn_atom *atom; + + assert_spin_locked(&(node->guard)); + ++ /*jnode_make_clean(node); */ + atom = jnode_get_atom(node); + if (atom == NULL) { + assert("jmacd-7111", !JF_ISSET(node, JNODE_DIRTY)); + spin_unlock_jnode(node); + return; + } -+ reiser4_uncapture_block(node); ++ ++ uncapture_block(node); + spin_unlock_atom(atom); + jput(node); +} + -+static void put_found_pages(struct page **pages, int nr) ++void forget_cluster_pages(struct page **pages, int nr) +{ + int i; + for (i = 0; i < nr; i++) { -+ assert("edward-1045", pages[i] != NULL); -+ put_cluster_page(pages[i]); -+ } -+} -+ -+/* Lifecycle of a logical cluster in the system. -+ * -+ * -+ * Logical cluster of a cryptcompress file is represented in the system by -+ * . page cluster (in memory, primary cache, contains plain text); -+ * . disk cluster (in memory, secondary cache, contains transformed text). -+ * Primary cache is to reduce number of transform operations (compression, -+ * encryption), i.e. to implement transform-caching strategy. -+ * Secondary cache is to reduce number of I/O operations, i.e. for usual -+ * write-caching strategy. Page cluster is a set of pages, i.e. mapping of -+ * a logical cluster to the primary cache. Disk cluster is a set of items -+ * of the same type defined by some reiser4 item plugin id. -+ * -+ * 1. Performing modifications -+ * -+ * Every modification of a cryptcompress file is considered as a set of -+ * operations performed on file's logical clusters. Every such "atomic" -+ * modification is truncate, append and(or) overwrite some bytes of a -+ * logical cluster performed in the primary cache with the following -+ * synchronization with the secondary cache (in flush time). Disk clusters, -+ * which live in the secondary cache, are supposed to be synchronized with -+ * disk. The mechanism of synchronization of primary and secondary caches -+ * includes so-called checkin/checkout technique described below. -+ * -+ * 2. Submitting modifications -+ * -+ * Each page cluster has associated jnode (a special in-memory header to -+ * keep a track of transactions in reiser4), which is attached to its first -+ * page when grabbing page cluster for modifications (see grab_page_cluster). -+ * Submitting modifications (see checkin_logical_cluster) is going per logical -+ * cluster and includes: -+ * . checkin_cluster_size; -+ * . checkin_page_cluster. -+ * checkin_cluster_size() is resolved to file size update (which completely -+ * defines new size of logical cluster (number of file's bytes in a logical -+ * cluster). -+ * checkin_page_cluster() captures jnode of a page cluster and installs -+ * jnode's dirty flag (if needed) to indicate that modifications are -+ * successfully checked in. -+ * -+ * 3. Checking out modifications -+ * -+ * Is going per logical cluster in flush time (see checkout_logical_cluster). -+ * This is the time of synchronizing primary and secondary caches. -+ * checkout_logical_cluster() includes: -+ * . checkout_page_cluster (retrieving checked in pages). -+ * . uncapture jnode (including clear dirty flag and unlock) -+ * -+ * 4. Committing modifications -+ * -+ * Proceeding a synchronization of primary and secondary caches. When checking -+ * out page cluster (the phase above) pages are locked/flushed/unlocked -+ * one-by-one in ascending order of their indexes to contiguous stream, which -+ * is supposed to be transformed (compressed, encrypted), chopped up into items -+ * and committed to disk as a disk cluster. -+ * -+ * 5. Managing page references -+ * -+ * Every checked in page have a special additional "control" reference, -+ * which is dropped at checkout. We need this to avoid unexpected evicting -+ * pages from memory before checkout. Control references are managed so -+ * they are not accumulated with every checkin: -+ * -+ * 0 -+ * checkin -> 1 -+ * 0 -> checkout -+ * checkin -> 1 -+ * checkin -> 1 -+ * checkin -> 1 -+ * 0 -> checkout -+ * ... -+ * -+ * Every page cluster has its own unique "cluster lock". Update/drop -+ * references are serialized via this lock. Number of checked in cluster -+ * pages is calculated by i_size under cluster lock. File size is updated -+ * at every checkin action also under cluster lock (except cases of -+ * appending/truncating fake logical clusters). -+ * -+ * Proof of correctness: -+ * -+ * Since we update file size under cluster lock, in the case of non-fake -+ * logical cluster with its lock held we do have expected number of checked -+ * in pages. On the other hand, append/truncate of fake logical clusters -+ * doesn't change number of checked in pages of any cluster. -+ * -+ * NOTE-EDWARD: As cluster lock we use guard (spinlock_t) of its jnode. -+ * Currently, I don't see any reason to create a special lock for those -+ * needs. -+ */ -+ -+static inline void lock_cluster(jnode * node) -+{ -+ spin_lock_jnode(node); -+} -+ -+static inline void unlock_cluster(jnode * node) -+{ -+ spin_unlock_jnode(node); -+} -+ -+static inline void unlock_cluster_uncapture(jnode * node) -+{ -+ uncapture_cluster_jnode(node); -+} -+ -+/* Set new file size by window. Cluster lock is required. */ -+static void checkin_file_size(struct cluster_handle * clust, -+ struct inode * inode) -+{ -+ loff_t new_size; -+ struct reiser4_slide * win; + -+ assert("edward-1181", clust != NULL); -+ assert("edward-1182", inode != NULL); -+ assert("edward-1473", clust->pages != NULL); -+ assert("edward-1474", clust->pages[0] != NULL); -+ assert("edward-1475", jprivate(clust->pages[0]) != NULL); -+ assert_spin_locked(&(jprivate(clust->pages[0])->guard)); -+ -+ -+ win = clust->win; -+ assert("edward-1183", win != NULL); -+ -+ new_size = clust_to_off(clust->index, inode) + win->off; -+ -+ switch (clust->op) { -+ case LC_APPOV: -+ if (new_size + win->count <= i_size_read(inode)) -+ /* overwrite only */ -+ return; -+ new_size += win->count; -+ break; -+ case LC_TRUNC: -+ break; -+ default: -+ impossible("edward-1184", "bad page cluster option"); -+ break; ++ assert("edward-1045", pages[i] != NULL); ++ page_cache_release(pages[i]); + } -+ inode_check_scale_nolock(inode, i_size_read(inode), new_size); -+ i_size_write(inode, new_size); -+ return; +} + -+static inline void checkin_cluster_size(struct cluster_handle * clust, -+ struct inode * inode) ++/* Check out last modifications we are about to commit, ++ and prepare input stream for transform operations. ++*/ ++int ++flush_cluster_pages(reiser4_cluster_t * clust, jnode * node, ++ struct inode *inode) +{ -+ if (clust->win) -+ checkin_file_size(clust, inode); -+} ++ int result = 0; ++ int i; ++ int nr_pages = 0; ++ tfm_cluster_t *tc = &clust->tc; + -+static int checkin_page_cluster(struct cluster_handle * clust, -+ struct inode * inode) -+{ -+ int result; -+ jnode * node; -+ int old_nrpages = clust->old_nrpages; -+ int new_nrpages = get_new_nrpages(clust); ++ assert("edward-980", node != NULL); ++ assert("edward-236", inode != NULL); ++ assert("edward-237", clust != NULL); ++ assert("edward-240", !clust->win); ++ assert("edward-241", schedulable()); ++ assert("edward-718", crc_inode_ok(inode)); + -+ node = clust->node; ++ result = grab_tfm_stream(inode, tc, INPUT_STREAM); ++ if (result) { ++ warning("edward-1430", ++ "alloc stream failed with ret=%d", result); ++ return result; ++ } ++ spin_lock_jnode(node); ++ assert("edward-1435", JF_ISSET(node, JNODE_DIRTY)); + -+ assert("edward-221", node != NULL); -+ assert("edward-971", clust->reserved == 1); -+ assert("edward-1263", -+ clust->reserved_prepped == estimate_update_cluster(inode)); -+ assert("edward-1264", clust->reserved_unprepped == 0); ++ /* Check out a size of logical cluster and ++ set a number of cluster pages to commit. */ ++ tc->len = tc->lsize = fsize_to_count(clust, inode); ++ clust->nr_pages = count_to_nrpages(tc->len); + -+ if (JF_ISSET(node, JNODE_DIRTY)) { -+ /* -+ * page cluster was checked in, but not yet -+ * checked out, so release related resources -+ */ -+ free_reserved4cluster(inode, clust, -+ estimate_update_cluster(inode)); -+ __put_page_cluster(0, clust->old_nrpages, -+ clust->pages, inode); -+ } else { -+ result = capture_cluster_jnode(node); -+ if (unlikely(result)) { -+ unlock_cluster(node); -+ return result; -+ } -+ jnode_make_dirty_locked(node); -+ clust->reserved = 0; -+ } -+ unlock_cluster(node); -+ -+ if (new_nrpages < old_nrpages) { -+ /* truncate >= 1 complete pages */ -+ __put_page_cluster(new_nrpages, -+ old_nrpages - new_nrpages, -+ clust->pages, inode); -+ truncate_page_cluster_range(inode, -+ clust->pages, clust->index, -+ new_nrpages, -+ old_nrpages - new_nrpages, -+ 0); -+ } ++ assert("edward-983", clust->nr_pages == node->page_count + 1); +#if REISER4_DEBUG -+ clust->reserved_prepped -= estimate_update_cluster(inode); ++ node->page_count = 0; +#endif -+ return 0; -+} -+ -+/* Submit modifications of a logical cluster */ -+static int checkin_logical_cluster(struct cluster_handle * clust, -+ struct inode *inode) -+{ -+ int result = 0; -+ jnode * node; -+ -+ node = clust->node; -+ -+ assert("edward-1035", node != NULL); -+ assert("edward-1029", clust != NULL); -+ assert("edward-1030", clust->reserved == 1); -+ assert("edward-1031", clust->nr_pages != 0); -+ assert("edward-1032", clust->pages != NULL); -+ assert("edward-1033", clust->pages[0] != NULL); -+ assert("edward-1446", jnode_is_cluster_page(node)); -+ assert("edward-1476", node == jprivate(clust->pages[0])); -+ -+ lock_cluster(node); -+ checkin_cluster_size(clust, inode); -+ /* this will unlock cluster */ -+ result = checkin_page_cluster(clust, inode); -+ jput(node); -+ clust->node = NULL; -+ return result; -+} -+ -+/* -+ * Retrieve size of logical cluster that was checked in at -+ * the latest modifying session (cluster lock is required) -+ */ -+static inline void checkout_cluster_size(struct cluster_handle * clust, -+ struct inode * inode) -+{ -+ struct tfm_cluster *tc = &clust->tc; -+ -+ tc->len = lbytes(clust->index, inode); -+ assert("edward-1478", tc->len != 0); -+} -+ -+/* -+ * Retrieve a page cluster with the latest submitted modifications -+ * and flush its pages to previously allocated contiguous stream. -+ */ -+static void checkout_page_cluster(struct cluster_handle * clust, -+ jnode * node, struct inode * inode) -+{ -+ int i; -+ int found; -+ int to_put; -+ struct tfm_cluster *tc = &clust->tc; -+ -+ /* find and put checked in pages: cluster is locked, -+ * so we must get expected number (to_put) of pages -+ */ -+ to_put = size_in_pages(lbytes(clust->index, inode)); -+ found = find_get_pages(inode->i_mapping, -+ clust_to_pg(clust->index, inode), -+ to_put, clust->pages); -+ BUG_ON(found != to_put); ++ cluster_reserved2grabbed(estimate_update_cluster(inode)); ++ uncapture_cluster_jnode(node); + -+ __put_page_cluster(0, to_put, clust->pages, inode); -+ unlock_cluster_uncapture(node); ++ assert("edward-1224", schedulable()); ++ /* Check out cluster pages to commit */ ++ nr_pages = ++ find_get_pages(inode->i_mapping, clust_to_pg(clust->index, inode), ++ clust->nr_pages, clust->pages); + -+ /* Flush found pages. -+ * -+ * Note, that we don't disable modifications while flushing, -+ * moreover, some found pages can be truncated, as we have -+ * released cluster lock. -+ */ -+ for (i = 0; i < found; i++) { -+ int in_page; -+ char * data; -+ assert("edward-1479", -+ clust->pages[i]->index == clust->pages[0]->index + i); ++ assert("edward-1280", nr_pages == clust->nr_pages); ++ /* Construct input stream from the checked out pages */ ++ for (i = 0; i < clust->nr_pages; i++) { ++ char *data; + ++ assert("edward-242", clust->pages[i] != NULL); ++ assert("edward-1436", clust->pages[i]->index == ++ clust_to_pg(clust->index, inode) + i); ++ assert("edward-1437", PageUptodate(clust->pages[i])); ++ /* flush the page into the input stream */ + lock_page(clust->pages[i]); -+ if (!PageUptodate(clust->pages[i])) { -+ /* page was truncated */ -+ assert("edward-1480", -+ i_size_read(inode) <= page_offset(clust->pages[i])); -+ assert("edward-1481", -+ clust->pages[i]->mapping != inode->i_mapping); -+ unlock_page(clust->pages[i]); -+ break; -+ } -+ /* Update the number of bytes in the logical cluster, -+ * as it could be partially truncated. Note, that only -+ * partial truncate is possible (complete truncate can -+ * not go here, as it is performed via ->kill_hook() -+ * called by cut_file_items(), and the last one must -+ * wait for znode locked with parent coord). -+ */ -+ checkout_cluster_size(clust, inode); ++ data = kmap(clust->pages[i]); + -+ /* this can be zero, as new file size is -+ checked in before truncating pages */ -+ in_page = __mbp(tc->len, i); ++ assert("edward-986", cnt_to_pgcnt(tc->len, i) != 0); + -+ data = kmap(clust->pages[i]); + memcpy(tfm_stream_data(tc, INPUT_STREAM) + pg_to_off(i), -+ data, in_page); ++ data, cnt_to_pgcnt(tc->len, i)); + kunmap(clust->pages[i]); -+ -+ if (PageDirty(clust->pages[i])) -+ cancel_dirty_page(clust->pages[i], PAGE_CACHE_SIZE); -+ + unlock_page(clust->pages[i]); -+ -+ if (in_page < PAGE_CACHE_SIZE) -+ /* end of the file */ -+ break; + } -+ put_found_pages(clust->pages, found); /* find_get_pages */ -+ tc->lsize = tc->len; -+ return; -+} -+ -+/* Check out modifications of a logical cluster */ -+int checkout_logical_cluster(struct cluster_handle * clust, -+ jnode * node, struct inode *inode) -+{ -+ int result; -+ struct tfm_cluster *tc = &clust->tc; -+ -+ assert("edward-980", node != NULL); -+ assert("edward-236", inode != NULL); -+ assert("edward-237", clust != NULL); -+ assert("edward-240", !clust->win); -+ assert("edward-241", reiser4_schedulable()); -+ assert("edward-718", cryptcompress_inode_ok(inode)); -+ -+ result = grab_tfm_stream(inode, tc, INPUT_STREAM); -+ if (result) { -+ warning("edward-1430", "alloc stream failed with ret=%d", -+ result); -+ return RETERR(-E_REPEAT); -+ } -+ lock_cluster(node); -+ -+ if (unlikely(!JF_ISSET(node, JNODE_DIRTY))) { -+ /* race with another flush */ -+ warning("edward-982", -+ "checking out logical cluster %lu of inode %llu: " -+ "jnode is not dirty", clust->index, -+ (unsigned long long)get_inode_oid(inode)); -+ unlock_cluster(node); -+ return RETERR(-E_REPEAT); -+ } -+ cluster_reserved2grabbed(estimate_update_cluster(inode)); -+ -+ /* this will unlock cluster */ -+ checkout_page_cluster(clust, node, inode); -+ return 0; ++ clear_cluster_pages_dirty(clust); ++ release_cluster_pages(clust); ++#if REISER4_DEBUG ++ cryptcompress_inode_data(inode)->pgcount -= clust->nr_pages; ++#endif ++ /* put pages that were found here */ ++ release_cluster_pages(clust); ++ return result; +} + +/* set hint for the cluster of the index @index */ @@ -32715,31 +33148,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + cloff_t index, znode_lock_mode mode) +{ + reiser4_key key; -+ assert("edward-722", cryptcompress_inode_ok(inode)); ++ assert("edward-722", crc_inode_ok(inode)); + assert("edward-723", + inode_file_plugin(inode) == -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); ++ file_plugin_by_id(CRC_FILE_PLUGIN_ID)); + + inode_file_plugin(inode)->key_by_inode(inode, + clust_to_off(index, inode), + &key); + -+ reiser4_seal_init(&hint->seal, &hint->ext_coord.coord, &key); ++ seal_init(&hint->seal, &hint->ext_coord.coord, &key); + hint->offset = get_key_offset(&key); + hint->mode = mode; +} + -+void invalidate_hint_cluster(struct cluster_handle * clust) ++void invalidate_hint_cluster(reiser4_cluster_t * clust) +{ + assert("edward-1291", clust != NULL); + assert("edward-1292", clust->hint != NULL); + + done_lh(&clust->hint->lh); -+ hint_clr_valid(clust->hint); ++ clust->hint->ext_coord.valid = 0; +} + -+void put_hint_cluster(struct cluster_handle * clust, struct inode *inode, -+ znode_lock_mode mode) ++void put_hint_cluster(reiser4_cluster_t * clust, struct inode *inode, ++ znode_lock_mode mode) +{ + assert("edward-1286", clust != NULL); + assert("edward-1287", clust->hint != NULL); @@ -32748,45 +33181,45 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + invalidate_hint_cluster(clust); +} + -+static int balance_dirty_page_cluster(struct cluster_handle * clust, -+ struct inode *inode, loff_t off, -+ loff_t to_file) ++static int ++balance_dirty_page_cluster(reiser4_cluster_t * clust, struct inode *inode, ++ loff_t off, loff_t to_file) +{ + int result; -+ struct cryptcompress_info * info; + + assert("edward-724", inode != NULL); -+ assert("edward-725", cryptcompress_inode_ok(inode)); ++ assert("edward-725", crc_inode_ok(inode)); ++ assert("edward-1272", get_current_context()->grabbed_blocks == 0); + + /* set next window params */ -+ move_update_window(inode, clust, off, to_file); ++ update_cluster(inode, clust, off, to_file); + + result = update_sd_cryptcompress(inode); ++ assert("edward-988", !result); + if (result) + return result; + assert("edward-726", clust->hint->lh.owner == NULL); -+ info = cryptcompress_inode_data(inode); + -+ mutex_unlock(&info->checkin_mutex); + reiser4_throttle_write(inode); -+ mutex_lock(&info->checkin_mutex); ++ all_grabbed2free(); + return 0; +} + -+/* set zeroes to the page cluster, proceed it, and maybe, try to capture -+ its pages */ -+static int write_hole(struct inode *inode, struct cluster_handle * clust, -+ loff_t file_off, loff_t to_file) ++/* set zeroes to the cluster, update it, and maybe, try to capture its pages */ ++static int ++write_hole(struct inode *inode, reiser4_cluster_t * clust, loff_t file_off, ++ loff_t to_file) +{ ++ char *data; + int result = 0; + unsigned cl_off, cl_count = 0; + unsigned to_pg, pg_off; -+ struct reiser4_slide * win; ++ reiser4_slide_t *win; + + assert("edward-190", clust != NULL); + assert("edward-1069", clust->win != NULL); + assert("edward-191", inode != NULL); -+ assert("edward-727", cryptcompress_inode_ok(inode)); ++ assert("edward-727", crc_inode_ok(inode)); + assert("edward-1171", clust->dstat != INVAL_DISK_CLUSTER); + assert("edward-1154", + ergo(clust->dstat != FAKE_DISK_CLUSTER, clust->reserved == 1)); @@ -32798,13 +33231,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-192", cluster_ok(clust, inode)); + + if (win->off == 0 && win->count == inode_cluster_size(inode)) { -+ /* This part of the hole will be represented by "fake" -+ * logical cluster, i.e. which doesn't have appropriate -+ * disk cluster until someone modify this logical cluster -+ * and make it dirty. -+ * So go forward here.. -+ */ -+ move_update_window(inode, clust, file_off, to_file); ++ /* the hole will be represented by fake disk cluster */ ++ update_cluster(inode, clust, file_off, to_file); + return 0; + } + cl_count = win->count; /* number of zeroes to write */ @@ -32817,12 +33245,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + assert("edward-284", page != NULL); + -+ to_pg = min((typeof(pg_off))PAGE_CACHE_SIZE - pg_off, cl_count); ++ to_pg = min_count(PAGE_CACHE_SIZE - pg_off, cl_count); + lock_page(page); -+ zero_user_page(page, pg_off, to_pg, KM_USER0); ++ data = kmap_atomic(page, KM_USER0); ++ memset(data + pg_off, 0, to_pg); ++ flush_dcache_page(page); ++ kunmap_atomic(data, KM_USER0); + SetPageUptodate(page); -+ reiser4_set_page_dirty_internal(page); -+ mark_page_accessed(page); + unlock_page(page); + + cl_off += to_pg; @@ -32830,88 +33259,92 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + pg_off = 0; + } + if (!win->delta) { -+ /* only zeroes in this window, try to capture -+ */ -+ result = checkin_logical_cluster(clust, inode); ++ /* only zeroes, try to capture */ ++ ++ set_cluster_pages_dirty(clust); ++ result = try_capture_cluster(clust, inode); + if (result) + return result; + put_hint_cluster(clust, inode, ZNODE_WRITE_LOCK); + result = + balance_dirty_page_cluster(clust, inode, file_off, to_file); + } else -+ move_update_window(inode, clust, file_off, to_file); ++ update_cluster(inode, clust, file_off, to_file); + return result; +} + +/* -+ The main disk search procedure for cryptcompress plugin, which -+ . scans all items of disk cluster with the lock mode @mode -+ . maybe reads each one (if @read) -+ . maybe makes its znode dirty (if write lock mode was specified) ++ The main disk search procedure for cryptcompress plugins, which ++ . scans all items of disk cluster ++ . maybe reads each one (if @read != 0) ++ . maybe makes its znode dirty (if @write != 0) + + NOTE-EDWARD: Callers should handle the case when disk cluster + is incomplete (-EIO) +*/ -+int find_disk_cluster(struct cluster_handle * clust, -+ struct inode *inode, int read, znode_lock_mode mode) ++int ++find_cluster(reiser4_cluster_t * clust, ++ struct inode *inode, int read, int write) +{ + flow_t f; + hint_t *hint; + int result = 0; -+ int was_grabbed; ++ unsigned long cl_idx; + ra_info_t ra_info; + file_plugin *fplug; + item_plugin *iplug; -+ struct tfm_cluster *tc; -+ struct cryptcompress_info * info; ++ tfm_cluster_t *tc; ++ int was_grabbed; + + assert("edward-138", clust != NULL); + assert("edward-728", clust->hint != NULL); -+ assert("edward-226", reiser4_schedulable()); ++ assert("edward-225", read || write); ++ assert("edward-226", schedulable()); + assert("edward-137", inode != NULL); -+ assert("edward-729", cryptcompress_inode_ok(inode)); ++ assert("edward-729", crc_inode_ok(inode)); + + hint = clust->hint; ++ cl_idx = clust->index; + fplug = inode_file_plugin(inode); + was_grabbed = get_current_context()->grabbed_blocks; -+ info = cryptcompress_inode_data(inode); + tc = &clust->tc; + + assert("edward-462", !tfm_cluster_is_uptodate(tc)); + assert("edward-461", ergo(read, tfm_stream_is_set(tc, INPUT_STREAM))); + -+ dclust_init_extension(hint); -+ + /* set key of the first disk cluster item */ + fplug->flow_by_inode(inode, + (read ? (char __user *)tfm_stream_data(tc, INPUT_STREAM) : NULL), + 0 /* kernel space */ , + inode_scaled_cluster_size(inode), -+ clust_to_off(clust->index, inode), READ_OP, &f); -+ if (mode == ZNODE_WRITE_LOCK) { ++ clust_to_off(cl_idx, inode), READ_OP, &f); ++ if (write) { + /* reserve for flush to make dirty all the leaf nodes + which contain disk cluster */ + result = + reiser4_grab_space_force(estimate_dirty_cluster(inode), + BA_CAN_COMMIT); ++ assert("edward-990", !result); + if (result) + goto out; + } + + ra_info.key_to_stop = f.key; -+ set_key_offset(&ra_info.key_to_stop, get_key_offset(reiser4_max_key())); ++ set_key_offset(&ra_info.key_to_stop, get_key_offset(max_key())); + + while (f.length) { -+ result = find_cluster_item(hint, &f.key, mode, -+ NULL, FIND_EXACT, -+ (mode == ZNODE_WRITE_LOCK ? -+ CBK_FOR_INSERT : 0)); ++ result = find_cluster_item(hint, ++ &f.key, ++ (write ? ZNODE_WRITE_LOCK : ++ ZNODE_READ_LOCK), NULL, FIND_EXACT, ++ (write ? CBK_FOR_INSERT : 0)); + switch (result) { + case CBK_COORD_NOTFOUND: + result = 0; + if (inode_scaled_offset -+ (inode, clust_to_off(clust->index, inode)) == -+ get_key_offset(&f.key)) { ++ (inode, ++ clust_to_off(cl_idx, ++ inode)) == get_key_offset(&f.key)) { + /* first item not found, this is treated + as disk cluster is absent */ + clust->dstat = FAKE_DISK_CLUSTER; @@ -32941,16 +33374,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + zrelse(hint->ext_coord.coord.node); + goto out; + } -+ if (mode == ZNODE_WRITE_LOCK) { -+ /* Don't make dirty more nodes then it was -+ estimated (see comments before -+ estimate_dirty_cluster). Missed nodes will be -+ read up in flush time if they are evicted from -+ memory */ -+ if (dclust_get_extension_ncount(hint) <= -+ estimate_dirty_cluster(inode)) -+ znode_make_dirty(hint->ext_coord.coord.node); -+ ++ if (write) { ++ znode_make_dirty(hint->ext_coord.coord.node); + znode_set_convertible(hint->ext_coord.coord. + node); + } @@ -32965,18 +33390,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + /* NOTE-EDWARD: Callers should handle the case + when disk cluster is incomplete (-EIO) */ + tc->len = inode_scaled_cluster_size(inode) - f.length; -+ tc->lsize = lbytes(clust->index, inode); ++ tc->lsize = fsize_to_count(clust, inode); + assert("edward-1196", tc->len > 0); + assert("edward-1406", tc->lsize > 0); + -+ if (hint_is_unprepped_dclust(clust->hint)) { ++ if (hint_is_unprepped_dclust(clust->hint)) + clust->dstat = UNPR_DISK_CLUSTER; -+ } else if (clust->index == info->trunc_index) { -+ clust->dstat = TRNC_DISK_CLUSTER; -+ } else { ++ else + clust->dstat = PREP_DISK_CLUSTER; -+ dclust_set_extension_dsize(clust->hint, tc->len); -+ } + out: + assert("edward-1339", + get_current_context()->grabbed_blocks >= was_grabbed); @@ -32986,17 +33407,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return result; +} + -+int get_disk_cluster_locked(struct cluster_handle * clust, struct inode *inode, -+ znode_lock_mode lock_mode) ++int ++get_disk_cluster_locked(reiser4_cluster_t * clust, struct inode *inode, ++ znode_lock_mode lock_mode) +{ + reiser4_key key; + ra_info_t ra_info; + -+ assert("edward-730", reiser4_schedulable()); ++ assert("edward-730", schedulable()); + assert("edward-731", clust != NULL); + assert("edward-732", inode != NULL); + -+ if (hint_is_valid(clust->hint)) { ++ if (clust->hint->ext_coord.valid) { + assert("edward-1293", clust->dstat != INVAL_DISK_CLUSTER); + assert("edward-1294", + znode_is_write_locked(clust->hint->lh.node)); @@ -33008,7 +33430,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + key_by_inode_cryptcompress(inode, clust_to_off(clust->index, inode), + &key); + ra_info.key_to_stop = key; -+ set_key_offset(&ra_info.key_to_stop, get_key_offset(reiser4_max_key())); ++ set_key_offset(&ra_info.key_to_stop, get_key_offset(max_key())); + + return find_cluster_item(clust->hint, &key, lock_mode, NULL, FIND_EXACT, + CBK_FOR_INSERT); @@ -33020,17 +33442,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + . find and set disk cluster state + . make disk cluster dirty if its state is not FAKE_DISK_CLUSTER. +*/ -+static int read_some_cluster_pages(struct inode * inode, -+ struct cluster_handle * clust) ++static int ++read_some_cluster_pages(struct inode *inode, reiser4_cluster_t * clust) +{ + int i; + int result = 0; + item_plugin *iplug; -+ struct reiser4_slide * win = clust->win; -+ znode_lock_mode mode = ZNODE_WRITE_LOCK; ++ reiser4_slide_t *win = clust->win; + + iplug = item_plugin_by_id(CTAIL_ID); + ++ assert("edward-733", get_current_context()->grabbed_blocks == 0); + assert("edward-924", !tfm_cluster_is_uptodate(&clust->tc)); + +#if REISER4_DEBUG @@ -33038,18 +33460,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + /* start write hole from fake disk cluster */ + assert("edward-1117", win != NULL); + assert("edward-1118", win->stat == HOLE_WINDOW); -+ assert("edward-1119", new_logical_cluster(clust, inode)); ++ assert("edward-1119", new_cluster(clust, inode)); + } +#endif -+ if (new_logical_cluster(clust, inode)) { ++ if (new_cluster(clust, inode)) { + /* + new page cluster is about to be written, nothing to read, + */ -+ assert("edward-734", reiser4_schedulable()); ++ assert("edward-734", schedulable()); + assert("edward-735", clust->hint->lh.owner == NULL); + + if (clust->nr_pages) { + int off; ++ char *data; + struct page * pg; + assert("edward-1419", clust->pages != NULL); + pg = clust->pages[clust->nr_pages - 1]; @@ -33057,8 +33480,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + off = off_to_pgoff(win->off+win->count+win->delta); + if (off) { + lock_page(pg); -+ zero_user_page(pg, off, PAGE_CACHE_SIZE - off, -+ KM_USER0); ++ data = kmap_atomic(pg, KM_USER0); ++ memset(data + off, 0, PAGE_CACHE_SIZE - off); ++ flush_dcache_page(pg); ++ kunmap_atomic(data, KM_USER0); + unlock_page(pg); + } + } @@ -33085,7 +33510,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + unlock_page(pg); + + if (win && -+ i >= size_in_pages(win->off) && ++ i >= count_to_nrpages(win->off) && + i < off_to_pg(win->off + win->count + win->delta)) + /* page will be completely overwritten */ + continue; @@ -33094,48 +33519,60 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + /* the last page is + partially modified, + not uptodate .. */ -+ (size_in_pages(i_size_read(inode)) <= pg->index)) { ++ (count_to_nrpages(inode->i_size) <= pg->index)) { + /* .. and appended, + so set zeroes to the rest */ ++ char *data; + int offset; + lock_page(pg); ++ data = kmap_atomic(pg, KM_USER0); ++ + assert("edward-1260", -+ size_in_pages(win->off + win->count + -+ win->delta) - 1 == i); ++ count_to_nrpages(win->off + win->count + ++ win->delta) - 1 == i); + + offset = + off_to_pgoff(win->off + win->count + win->delta); -+ zero_user_page(pg, offset, PAGE_CACHE_SIZE - offset, -+ KM_USER0); ++ memset(data + offset, 0, PAGE_CACHE_SIZE - offset); ++ flush_dcache_page(pg); ++ kunmap_atomic(data, KM_USER0); + unlock_page(pg); + /* still not uptodate */ + break; + } ++ if (!tfm_cluster_is_uptodate(&clust->tc)) { ++ result = ctail_read_disk_cluster(clust, inode, 1); ++ assert("edward-992", !result); ++ if (result) ++ goto out; ++ assert("edward-925", ++ tfm_cluster_is_uptodate(&clust->tc)); ++ } + lock_page(pg); -+ result = do_readpage_ctail(inode, clust, pg, mode); -+ -+ assert("edward-1526", ergo(!result, PageUptodate(pg))); ++ result = do_readpage_ctail(inode, clust, pg); + unlock_page(pg); ++ assert("edward-993", !result); + if (result) { -+ warning("edward-219", "do_readpage_ctail failed"); ++ impossible("edward-219", ++ "do_readpage_ctail returned crap"); + goto out; + } + } + if (!tfm_cluster_is_uptodate(&clust->tc)) { + /* disk cluster unclaimed, but we need to make its znodes dirty -+ * to make flush update convert its content -+ */ -+ result = find_disk_cluster(clust, inode, -+ 0 /* do not read items */, -+ mode); ++ to make flush update convert its content */ ++ result = ++ find_cluster(clust, inode, 0 /* do not read */ , ++ 1 /* write */ ); ++ assert("edward-994", !result); + } + out: + tfm_cluster_clr_uptodate(&clust->tc); + return result; +} + -+static int should_create_unprepped_cluster(struct cluster_handle * clust, -+ struct inode * inode) ++static int ++should_create_unprepped_cluster(reiser4_cluster_t * clust, struct inode *inode) +{ + assert("edward-737", clust != NULL); + @@ -33146,8 +33583,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + case FAKE_DISK_CLUSTER: + if (clust->win && + clust->win->stat == HOLE_WINDOW && clust->nr_pages == 0) { -+ assert("edward-1172", -+ new_logical_cluster(clust, inode)); ++ assert("edward-1172", new_cluster(clust, inode)); + return 0; + } + return 1; @@ -33157,171 +33593,182 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + } +} + -+static int cryptcompress_make_unprepped_cluster(struct cluster_handle * clust, -+ struct inode *inode) ++static int ++crc_make_unprepped_cluster(reiser4_cluster_t * clust, struct inode *inode) +{ + int result; + -+ assert("edward-1123", reiser4_schedulable()); ++ assert("edward-1123", schedulable()); + assert("edward-737", clust != NULL); + assert("edward-738", inode != NULL); -+ assert("edward-739", cryptcompress_inode_ok(inode)); ++ assert("edward-739", crc_inode_ok(inode)); + assert("edward-1053", clust->hint != NULL); ++ assert("edward-1266", get_current_context()->grabbed_blocks == 0); + -+ if (!should_create_unprepped_cluster(clust, inode)) { -+ if (clust->reserved) { -+ cluster_reserved2free(estimate_insert_cluster(inode)); ++ if (clust->reserved) { ++ cluster_reserved2grabbed(estimate_insert_cluster(inode)); +#if REISER4_DEBUG -+ assert("edward-1267", -+ clust->reserved_unprepped == -+ estimate_insert_cluster(inode)); -+ clust->reserved_unprepped -= -+ estimate_insert_cluster(inode); ++ assert("edward-1267", ++ clust->reserved_unprepped == ++ estimate_insert_cluster(inode)); ++ clust->reserved_unprepped -= estimate_insert_cluster(inode); +#endif -+ } ++ } ++ if (!should_create_unprepped_cluster(clust, inode)) { ++ all_grabbed2free(); + return 0; ++ } else { ++ assert("edward-1268", clust->reserved == 1); + } -+ assert("edward-1268", clust->reserved); -+ cluster_reserved2grabbed(estimate_insert_cluster(inode)); -+#if REISER4_DEBUG -+ assert("edward-1441", -+ clust->reserved_unprepped == estimate_insert_cluster(inode)); -+ clust->reserved_unprepped -= estimate_insert_cluster(inode); -+#endif + result = ctail_insert_unprepped_cluster(clust, inode); ++ all_grabbed2free(); + if (result) + return result; + -+ inode_add_bytes(inode, inode_cluster_size(inode)); -+ -+ assert("edward-743", cryptcompress_inode_ok(inode)); ++ assert("edward-743", crc_inode_ok(inode)); ++ assert("edward-1269", get_current_context()->grabbed_blocks == 0); + assert("edward-744", znode_is_write_locked(clust->hint->lh.node)); + + clust->dstat = UNPR_DISK_CLUSTER; + return 0; +} + -+/* . Grab page cluster for read, write, setattr, etc. operations; -+ * . Truncate its complete pages, if needed; -+ */ -+int prepare_page_cluster(struct inode * inode, struct cluster_handle * clust, -+ rw_op rw) ++#if REISER4_DEBUG ++static int jnode_truncate_ok(struct inode *inode, cloff_t index) ++{ ++ jnode *node; ++ node = ++ jlookup(current_tree, get_inode_oid(inode), ++ clust_to_pg(index, inode)); ++ if (likely(!node)) ++ return 1; ++ /* someone got this jnode */ ++ warning("edward-1315", "jnode %p is untruncated\n", node); ++ jput(node); ++ return (atomic_read(&node->x_count)); ++} ++#endif ++ ++/* Collect unlocked cluster pages and jnode (the last is in the ++ case when the page cluster will be modified and captured) */ ++int ++prepare_page_cluster(struct inode *inode, reiser4_cluster_t * clust, ++ int capture) +{ + assert("edward-177", inode != NULL); -+ assert("edward-741", cryptcompress_inode_ok(inode)); ++ assert("edward-741", crc_inode_ok(inode)); + assert("edward-740", clust->pages != NULL); + + set_cluster_nrpages(clust, inode); + reset_cluster_pgset(clust, cluster_nrpages(inode)); -+ return grab_page_cluster(inode, clust, rw); ++ return (capture ? ++ grab_cluster_pages_jnode(inode, clust) : ++ grab_cluster_pages(inode, clust)); +} + -+/* Truncate complete page cluster of index @index. -+ * This is called by ->kill_hook() method of item -+ * plugin when deleting a disk cluster of such index. -+ */ -+void truncate_complete_page_cluster(struct inode *inode, cloff_t index, -+ int even_cows) ++/* Truncate all pages of the cluster of index @index. ++ This is called by ->kill_hook() method of item plugin */ ++void truncate_page_cluster(struct inode *inode, cloff_t index) +{ -+ int found; ++ int i; ++ int found = 0; + int nr_pages; + jnode *node; + struct page *pages[MAX_CLUSTER_NRPAGES]; + -+ node = jlookup(current_tree, get_inode_oid(inode), -+ clust_to_pg(index, inode)); -+ nr_pages = size_in_pages(lbytes(index, inode)); -+ assert("edward-1483", nr_pages != 0); -+ if (!node) -+ goto truncate; -+ found = find_get_pages(inode->i_mapping, -+ clust_to_pg(index, inode), -+ cluster_nrpages(inode), pages); -+ if (!found) { -+ assert("edward-1484", jnode_truncate_ok(inode, index)); ++ node = ++ jlookup(current_tree, get_inode_oid(inode), ++ clust_to_pg(index, inode)); ++ /* jnode is absent, just drop pages which can not ++ acquire jnode because of exclusive access */ ++ if (!node) { ++ truncate_inode_pages_range(inode->i_mapping, ++ clust_to_off(index, inode), ++ clust_to_off(index, ++ inode) + ++ inode_cluster_size(inode) - 1); + return; + } -+ lock_cluster(node); ++ /* jnode is present and may be dirty */ ++ nr_pages = count_to_nrpages(cnt_to_clcnt(inode->i_size, index, inode)); + -+ if (reiser4_inode_get_flag(inode, REISER4_FILE_CONV_IN_PROGRESS) -+ && index == 0) -+ /* converting to unix_file is in progress */ -+ JF_CLR(node, JNODE_CLUSTER_PAGE); ++ found = find_get_pages(inode->i_mapping, clust_to_pg(index, inode), ++ nr_pages, pages); ++ spin_lock_jnode(node); + if (JF_ISSET(node, JNODE_DIRTY)) { -+ /* -+ * @nr_pages were checked in, but not yet checked out - -+ * we need to release them. (also there can be pages -+ * attached to page cache by read(), etc. - don't take -+ * them into account). -+ */ -+ assert("edward-1198", found >= nr_pages); -+ ++ /* someone has done modifications which are not ++ yet committed, so we need to release some resources */ ++ + /* free disk space grabbed for disk cluster converting */ + cluster_reserved2grabbed(estimate_update_cluster(inode)); + grabbed2free(get_current_context(), + get_current_super_private(), + estimate_update_cluster(inode)); -+ __put_page_cluster(0, nr_pages, pages, inode); + -+ /* This will clear dirty bit, uncapture and unlock jnode */ -+ unlock_cluster_uncapture(node); ++ assert("edward-1198", found == nr_pages); ++ assert("edward-1199", node->page_count + 1 == nr_pages); ++#if REISER4_DEBUG ++ node->page_count = 0; ++#endif ++ /* This will clear dirty bit */ ++ uncapture_cluster_jnode(node); ++ ++ /* put pages grabbed for last uncommitted modifications */ ++ for (i = 0; i < nr_pages; i++) { ++ assert("edward-1200", PageUptodate(pages[i])); ++ page_cache_release(pages[i]); ++#if REISER4_DEBUG ++ cryptcompress_inode_data(inode)->pgcount --; ++#endif ++ } + } else -+ unlock_cluster(node); -+ jput(node); /* jlookup */ -+ put_found_pages(pages, found); /* find_get_pages */ -+ truncate: -+ if (reiser4_inode_get_flag(inode, REISER4_FILE_CONV_IN_PROGRESS) && -+ index == 0) -+ return; -+ truncate_page_cluster_range(inode, pages, index, 0, -+ cluster_nrpages(inode), -+ even_cows); -+ assert("edward-1201", -+ ergo(!reiser4_inode_get_flag(inode, -+ REISER4_FILE_CONV_IN_PROGRESS), -+ jnode_truncate_ok(inode, index))); ++ spin_unlock_jnode(node); ++ /* FIXME-EDWARD: Use truncate_complete_page in the loop above instead */ ++ ++ jput(node); ++ /* put pages found here */ ++ forget_cluster_pages(pages, found); ++ truncate_inode_pages_range(inode->i_mapping, ++ clust_to_off(index, inode), ++ clust_to_off(index, ++ inode) + ++ inode_cluster_size(inode) - 1); ++ assert("edward-1201", jnode_truncate_ok(inode, index)); + return; +} + -+/* -+ * Set cluster handle @clust of a logical cluster before -+ * modifications which are supposed to be committed. -+ * -+ * . grab cluster pages; -+ * . reserve disk space; -+ * . maybe read pages from disk and set the disk cluster dirty; -+ * . maybe write hole and check in (partially zeroed) logical cluster; -+ * . create 'unprepped' disk cluster for new or fake logical one. -+ */ -+static int prepare_logical_cluster(struct inode *inode, -+ loff_t file_off, /* write position -+ in the file */ -+ loff_t to_file, /* bytes of users data -+ to write to the file */ -+ struct cluster_handle * clust, -+ logical_cluster_op op) ++/* Prepare cluster handle before(after) modifications ++ which are supposed to be committed. ++ ++ . grab cluster pages; ++ . reserve disk space; ++ . maybe read pages from disk and set the disk cluster dirty; ++ . maybe write hole; ++ . maybe create 'unprepped' disk cluster if the last one is fake ++ (i.e. is not represenred by any items) ++*/ ++ ++static int ++prepare_cluster(struct inode *inode, ++ loff_t file_off /* write position in the file */ , ++ loff_t to_file, /* bytes of users data to write to the file */ ++ reiser4_cluster_t * clust, page_cluster_op op) +{ + int result = 0; -+ struct reiser4_slide * win = clust->win; ++ reiser4_slide_t *win = clust->win; + ++ assert("edward-1273", get_current_context()->grabbed_blocks == 0); + reset_cluster_params(clust); -+ cluster_set_tfm_act(&clust->tc, TFMA_READ); +#if REISER4_DEBUG + clust->ctx = get_current_context(); +#endif -+ assert("edward-1190", op != LC_INVAL); ++ assert("edward-1190", op != PCL_UNKNOWN); + + clust->op = op; + -+ result = prepare_page_cluster(inode, clust, WRITE_OP); ++ result = prepare_page_cluster(inode, clust, 1); + if (result) + return result; -+ assert("edward-1447", -+ ergo(clust->nr_pages != 0, jprivate(clust->pages[0]))); -+ assert("edward-1448", -+ ergo(clust->nr_pages != 0, -+ jnode_is_cluster_page(jprivate(clust->pages[0])))); -+ + result = reserve4cluster(inode, clust); + if (result) + goto err1; @@ -33335,7 +33782,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + } + assert("edward-1124", clust->dstat != INVAL_DISK_CLUSTER); + -+ result = cryptcompress_make_unprepped_cluster(clust, inode); ++ result = crc_make_unprepped_cluster(clust, inode); + if (result) + goto err2; + if (win && win->stat == HOLE_WINDOW) { @@ -33344,19 +33791,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + goto err2; + } + return 0; -+ err2: ++ err2: + free_reserved4cluster(inode, clust, + estimate_update_cluster(inode)); -+ err1: -+ put_page_cluster(clust, inode, WRITE_OP); ++ err1: ++ release_cluster_pages_and_jnode(clust); + assert("edward-1125", result == -ENOSPC); + return result; +} + +/* set window by two offsets */ -+static void set_window(struct cluster_handle * clust, -+ struct reiser4_slide * win, struct inode *inode, -+ loff_t o1, loff_t o2) ++static void ++set_window(reiser4_cluster_t * clust, reiser4_slide_t * win, ++ struct inode *inode, loff_t o1, loff_t o2) +{ + assert("edward-295", clust != NULL); + assert("edward-296", inode != NULL); @@ -33366,17 +33813,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + clust->index = off_to_clust(o1, inode); + + win->off = off_to_cloff(o1, inode); -+ win->count = min((loff_t)(inode_cluster_size(inode) - win->off), -+ o2 - o1); ++ win->count = min_count(inode_cluster_size(inode) - win->off, o2 - o1); + win->delta = 0; + + clust->win = win; +} + -+static int set_cluster_by_window(struct inode *inode, -+ struct cluster_handle * clust, -+ struct reiser4_slide * win, size_t length, -+ loff_t file_off) ++static int ++set_cluster_by_window(struct inode *inode, reiser4_cluster_t * clust, ++ reiser4_slide_t * win, flow_t * f, loff_t file_off) +{ + int result; + @@ -33388,7 +33833,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result) + return result; + -+ if (file_off > i_size_read(inode)) { ++ if (file_off > inode->i_size) { + /* Uhmm, hole in cryptcompress file... */ + loff_t hole_size; + hole_size = file_off - inode->i_size; @@ -33397,35 +33842,35 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + win->stat = HOLE_WINDOW; + if (win->off + hole_size < inode_cluster_size(inode)) + /* there is also user's data to append to the hole */ -+ win->delta = min(inode_cluster_size(inode) - -+ (win->off + win->count), length); ++ win->delta = ++ min_count(inode_cluster_size(inode) - ++ (win->off + win->count), f->length); + return 0; + } -+ set_window(clust, win, inode, file_off, file_off + length); ++ set_window(clust, win, inode, file_off, file_off + f->length); + win->stat = DATA_WINDOW; + return 0; +} + -+int set_cluster_by_page(struct cluster_handle * clust, struct page * page, ++int set_cluster_by_page(reiser4_cluster_t * clust, struct page * page, + int count) +{ + int result = 0; -+ int (*setting_actor)(struct cluster_handle * clust, int count); ++ int (*setting_actor)(reiser4_cluster_t * clust, int count); + + assert("edward-1358", clust != NULL); + assert("edward-1359", page != NULL); + assert("edward-1360", page->mapping != NULL); + assert("edward-1361", page->mapping->host != NULL); + -+ setting_actor = -+ (clust->pages ? reset_cluster_pgset : alloc_cluster_pgset); ++ setting_actor = (clust->pages ? reset_cluster_pgset : alloc_cluster_pgset); + result = setting_actor(clust, count); + clust->index = pg_to_clust(page->index, page->mapping->host); + return result; +} + +/* reset all the params that not get updated */ -+void reset_cluster_params(struct cluster_handle * clust) ++void reset_cluster_params(reiser4_cluster_t * clust) +{ + assert("edward-197", clust != NULL); + @@ -33434,24 +33879,34 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + clust->tc.len = 0; +} + -+static loff_t do_write_cryptcompress(struct file *file, struct inode *inode, -+ const char __user *buf, size_t to_write, -+ loff_t pos, int *conv_occured) ++/* Core write procedure of cryptcompress plugin, which slices user's ++ flow into logical clusters, maps the last ones to the appropriate ++ page clusters, and tries to capture them. ++ If @buf != NULL, returns number of successfully written bytes, ++ otherwise returns error ++*/ ++static loff_t ++write_cryptcompress_flow(struct file *file, struct inode *inode, ++ const char __user *buf, size_t count, loff_t pos) +{ + int i; ++ flow_t f; + hint_t *hint; + int result = 0; -+ size_t count; -+ struct reiser4_slide win; -+ struct cluster_handle clust; -+ struct cryptcompress_info * info; ++ size_t to_write = 0; ++ loff_t file_off; ++ reiser4_slide_t win; ++ reiser4_cluster_t clust; + -+ assert("edward-161", reiser4_schedulable()); -+ assert("edward-748", cryptcompress_inode_ok(inode)); ++ assert("edward-161", schedulable()); ++ assert("edward-748", crc_inode_ok(inode)); + assert("edward-159", current_blocksize == PAGE_CACHE_SIZE); + assert("edward-1274", get_current_context()->grabbed_blocks == 0); + -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ result = check_cryptcompress(inode); ++ if (result) ++ return result; ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) + return RETERR(-ENOMEM); + @@ -33460,75 +33915,69 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + kfree(hint); + return result; + } -+ count = to_write; + ++ result = ++ flow_by_inode_cryptcompress(inode, buf, 1 /* user space */ , ++ count, pos, WRITE_OP, &f); ++ if (result) ++ goto out; ++ to_write = f.length; ++ ++ /* current write position in file */ ++ file_off = pos; + reiser4_slide_init(&win); + cluster_init_read(&clust, &win); + clust.hint = hint; -+ info = cryptcompress_inode_data(inode); -+ -+ mutex_lock(&info->checkin_mutex); + -+ result = set_cluster_by_window(inode, &clust, &win, to_write, pos); ++ result = set_cluster_by_window(inode, &clust, &win, &f, file_off); + if (result) + goto out; + + if (next_window_stat(&win) == HOLE_WINDOW) { -+ /* write hole in this iteration -+ separated from the loop below */ -+ result = write_conversion_hook(file, inode, -+ pos, -+ &clust, -+ NULL); -+ if (result) -+ goto out; -+ result = prepare_logical_cluster(inode, pos, count, &clust, -+ LC_APPOV); ++ result = ++ prepare_cluster(inode, file_off, f.length, &clust, ++ PCL_APPEND); + if (result) + goto out; + } + do { -+ const char __user * src; -+ unsigned page_off, to_page; ++ char *src; ++ unsigned page_off, page_count; + -+ assert("edward-750", reiser4_schedulable()); ++ assert("edward-750", schedulable()); + -+ result = write_conversion_hook(file, inode, -+ pos + to_write - count, -+ &clust, -+ conv_occured); -+ if (result || *conv_occured) -+ goto out; -+ result = prepare_logical_cluster(inode, pos, count, &clust, -+ LC_APPOV); ++ result = ++ prepare_cluster(inode, file_off, f.length, &clust, ++ PCL_APPEND); + if (result) + goto out; + -+ assert("edward-751", cryptcompress_inode_ok(inode)); ++ assert("edward-751", crc_inode_ok(inode)); + assert("edward-204", win.stat == DATA_WINDOW); -+ assert("edward-1288", hint_is_valid(clust.hint)); ++ assert("edward-1288", clust.hint->ext_coord.valid); + assert("edward-752", + znode_is_write_locked(hint->ext_coord.coord.node)); ++ + put_hint_cluster(&clust, inode, ZNODE_WRITE_LOCK); + + /* set write position in page */ + page_off = off_to_pgoff(win.off); + + /* copy user's data to cluster pages */ -+ for (i = off_to_pg(win.off), src = buf; -+ i < size_in_pages(win.off + win.count); -+ i++, src += to_page) { -+ to_page = __mbp(win.off + win.count, i) - page_off; ++ for (i = off_to_pg(win.off), src = f.data; ++ i < count_to_nrpages(win.off + win.count); ++ i++, src += page_count) { ++ page_count = ++ cnt_to_pgcnt(win.off + win.count, i) - page_off; ++ + assert("edward-1039", -+ page_off + to_page <= PAGE_CACHE_SIZE); ++ page_off + page_count <= PAGE_CACHE_SIZE); + assert("edward-287", clust.pages[i] != NULL); + -+ fault_in_pages_readable(src, to_page); -+ + lock_page(clust.pages[i]); + result = + __copy_from_user((char *)kmap(clust.pages[i]) + -+ page_off, src, to_page); ++ page_off, (char __user *)src, page_count); + kunmap(clust.pages[i]); + if (unlikely(result)) { + unlock_page(clust.pages[i]); @@ -33536,41 +33985,45 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + goto err2; + } + SetPageUptodate(clust.pages[i]); -+ reiser4_set_page_dirty_internal(clust.pages[i]); -+ flush_dcache_page(clust.pages[i]); -+ mark_page_accessed(clust.pages[i]); + unlock_page(clust.pages[i]); + page_off = 0; + } -+ assert("edward-753", cryptcompress_inode_ok(inode)); ++ assert("edward-753", crc_inode_ok(inode)); + -+ result = checkin_logical_cluster(&clust, inode); ++ set_cluster_pages_dirty(&clust); ++ ++ result = try_capture_cluster(&clust, inode); + if (result) + goto err2; + -+ buf += win.count; -+ count -= win.count; ++ assert("edward-998", f.user == 1); ++ ++ move_flow_forward(&f, win.count); + -+ result = balance_dirty_page_cluster(&clust, inode, 0, count); ++ /* disk cluster may be already clean at this point */ ++ ++ /* . update cluster ++ . set hint for new offset ++ . unlock znode ++ . update inode ++ . balance dirty pages ++ */ ++ result = balance_dirty_page_cluster(&clust, inode, 0, f.length); + if (result) + goto err1; + assert("edward-755", hint->lh.owner == NULL); + reset_cluster_params(&clust); + continue; -+ err2: -+ put_page_cluster(&clust, inode, WRITE_OP); -+ err1: ++ err2: ++ release_cluster_pages_and_jnode(&clust); ++ err1: + if (clust.reserved) + free_reserved4cluster(inode, + &clust, + estimate_update_cluster(inode)); + break; -+ } while (count); -+ out: -+ /* -+ * NOTE: at this point file may have -+ * another (unix-file) plugin installed -+ */ ++ } while (f.length); ++ out: + done_lh(&hint->lh); + if (result == -EEXIST) + warning("edward-1407", "write returns EEXIST!\n"); @@ -33578,21 +34031,56 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + put_cluster_handle(&clust); + save_file_hint(file, hint); + kfree(hint); -+ /* -+ * don't release cryptcompress-specific -+ * checkin_mutex, if conversion occured -+ */ -+ if (*conv_occured == 0) -+ mutex_unlock(&info->checkin_mutex); + if (buf) { + /* if nothing were written - there must be an error */ -+ assert("edward-195", ergo((to_write == count), -+ (result < 0 || *conv_occured))); -+ return (to_write - count) ? (to_write - count) : result; ++ assert("edward-195", ergo((to_write == f.length), result < 0)); ++ return (to_write - f.length) ? (to_write - f.length) : result; + } + return result; +} + ++static ssize_t write_crc_file(struct file *file, /* file to write to */ ++ struct inode *inode, /* inode */ ++ const char __user *buf, /* address of user-space buffer */ ++ size_t count, /* number of bytes to write */ ++ loff_t * off /* position to write which */ ) ++{ ++ ++ int result; ++ loff_t pos; ++ ssize_t written; ++ cryptcompress_info_t *info = cryptcompress_inode_data(inode); ++ ++ assert("edward-196", crc_inode_ok(inode)); ++ ++ result = generic_write_checks(file, off, &count, 0); ++ if (unlikely(result != 0)) ++ return result; ++ ++ if (unlikely(count == 0)) ++ return 0; ++ ++ down_write(&info->lock); ++ LOCK_CNT_INC(inode_sem_w); ++ ++ pos = *off; ++ written = ++ write_cryptcompress_flow(file, inode, buf, count, pos); ++ ++ up_write(&info->lock); ++ LOCK_CNT_DEC(inode_sem_w); ++ ++ if (written < 0) { ++ if (written == -EEXIST) ++ printk("write_crc_file returns EEXIST!\n"); ++ return written; ++ } ++ /* update position in a file */ ++ *off = pos + written; ++ /* return number of written bytes */ ++ return written; ++} ++ +/** + * write_cryptcompress - write of struct file_operations + * @file: file to write to @@ -33604,45 +34092,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + * cryptcompress plugin. + */ +ssize_t write_cryptcompress(struct file *file, const char __user *buf, -+ size_t count, loff_t *off, int *conv) ++ size_t count, loff_t *off) +{ + ssize_t result; + struct inode *inode; + reiser4_context *ctx; -+ loff_t pos = *off; -+ struct cryptcompress_info *info; -+ -+ assert("edward-1449", *conv == 0); + + inode = file->f_dentry->d_inode; -+ assert("edward-196", cryptcompress_inode_ok(inode)); -+ -+ info = cryptcompress_inode_data(inode); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + -+ mutex_lock(&inode->i_mutex); -+ -+ result = generic_write_checks(file, &pos, &count, 0); -+ if (unlikely(result != 0)) -+ goto out; -+ if (unlikely(count == 0)) -+ goto out; -+ result = remove_suid(file->f_dentry); -+ if (unlikely(result != 0)) -+ goto out; -+ /* remove_suid might create a transaction */ -+ reiser4_txn_restart(ctx); ++ mutex_lock(&inode->i_mutex); + -+ result = do_write_cryptcompress(file, inode, buf, count, pos, conv); ++ result = write_crc_file(file, inode, buf, count, off); + -+ if (result < 0) -+ goto out; -+ /* update position in a file */ -+ *off = pos + result; -+ out: + mutex_unlock(&inode->i_mutex); + + context_set_commit_async(ctx); @@ -33650,26 +34115,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return result; +} + -+int readpages_cryptcompress(struct file *file, struct address_space *mapping, -+ struct list_head *pages, unsigned nr_pages) ++static void ++readpages_crc(struct address_space *mapping, struct list_head *pages, ++ void *data) +{ -+ reiser4_context * ctx; -+ int ret; ++ file_plugin *fplug; ++ item_plugin *iplug; + -+ ctx = reiser4_init_context(mapping->host->i_sb); -+ if (IS_ERR(ctx)) { -+ ret = PTR_ERR(ctx); -+ goto err; -+ } -+ /* cryptcompress file can be built of ctail items only */ -+ ret = readpages_ctail(file, mapping, pages); -+ reiser4_txn_restart(ctx); -+ reiser4_exit_context(ctx); -+ if (ret) { -+err: -+ put_pages_list(pages); -+ } -+ return ret; ++ assert("edward-1112", mapping != NULL); ++ assert("edward-1113", mapping->host != NULL); ++ ++ fplug = inode_file_plugin(mapping->host); ++ assert("edward-1114", fplug == file_plugin_by_id(CRC_FILE_PLUGIN_ID)); ++ iplug = item_plugin_by_id(CTAIL_ID); ++ ++ iplug->s.file.readpages(data, mapping, pages); ++ ++ return; +} + +static reiser4_block_nr cryptcompress_estimate_read(struct inode *inode) @@ -33697,25 +34159,38 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + ssize_t result; + struct inode *inode; + reiser4_context *ctx; -+ struct cryptcompress_info *info; ++ reiser4_file_fsdata *fsdata; ++ cryptcompress_info_t *info; + reiser4_block_nr needed; + + inode = file->f_dentry->d_inode; -+ assert("edward-1194", !reiser4_inode_get_flag(inode, REISER4_NO_SD)); ++ assert("edward-1194", !inode_get_flag(inode, REISER4_NO_SD)); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + info = cryptcompress_inode_data(inode); + needed = cryptcompress_estimate_read(inode); + ++ /* FIXME-EDWARD: ++ Grab space for sd_update so find_cluster will be happy */ + result = reiser4_grab_space(needed, BA_CAN_COMMIT); + if (result != 0) { + reiser4_exit_context(ctx); + return result; + } -+ result = do_sync_read(file, buf, size, off); ++ fsdata = reiser4_get_file_fsdata(file); ++ fsdata->ra2.data = file; ++ fsdata->ra2.readpages = readpages_crc; ++ ++ down_read(&info->lock); ++ LOCK_CNT_INC(inode_sem_r); ++ ++ result = generic_file_read(file, buf, size, off); ++ ++ up_read(&info->lock); ++ LOCK_CNT_DEC(inode_sem_r); + + context_set_commit_async(ctx); + reiser4_exit_context(ctx); @@ -33723,15 +34198,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return result; +} + -+/* Look for a disk cluster and keep lookup result in @found. -+ * If @index > 0, then find disk cluster of the index (@index - 1); -+ * If @index == 0, then find the rightmost disk cluster. -+ * Keep incremented index of the found disk cluster in @found. -+ * @found == 0 means that disk cluster was not found (in the last -+ * case (@index == 0) it means that file doesn't have disk clusters). -+ */ -+static int lookup_disk_cluster(struct inode *inode, cloff_t * found, -+ cloff_t index) ++/* If @index > 0, find real disk cluster of the index (@index - 1), ++ If @index == 0 find the real disk cluster of the object of maximal index. ++ Keep incremented index of the result in @found. ++ It succes was returned: ++ (@index == 0 && @found == 0) means that the object doesn't have real disk ++ clusters. ++ (@index != 0 && @found == 0) means that disk cluster of (@index -1) doesn't ++ exist. ++*/ ++static int ++find_real_disk_cluster(struct inode *inode, cloff_t * found, cloff_t index) +{ + int result; + reiser4_key key; @@ -33743,9 +34220,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + item_plugin *iplug; + + assert("edward-1131", inode != NULL); -+ assert("edward-95", cryptcompress_inode_ok(inode)); ++ assert("edward-95", crc_inode_ok(inode)); + -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) + return RETERR(-ENOMEM); + hint_init_zero(hint); @@ -33754,7 +34231,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + bias = (index ? FIND_EXACT : FIND_MAX_NOT_MORE_THAN); + offset = + (index ? clust_to_off(index, inode) - -+ 1 : get_key_offset(reiser4_max_key())); ++ 1 : get_key_offset(max_key())); + + key_by_inode_cryptcompress(inode, offset, &key); + @@ -33800,8 +34277,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + +static int find_fake_appended(struct inode *inode, cloff_t * index) +{ -+ return lookup_disk_cluster(inode, index, -+ 0 /* find last real one */ ); ++ return find_real_disk_cluster(inode, index, ++ 0 /* find last real one */ ); +} + +/* Set left coord when unit is not found after node_lookup() @@ -33823,11 +34300,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +#define CRC_CUT_TREE_MIN_ITERATIONS 64 -+int cut_tree_worker_cryptcompress(tap_t * tap, const reiser4_key * from_key, -+ const reiser4_key * to_key, -+ reiser4_key * smallest_removed, -+ struct inode *object, int truncate, -+ int *progress) ++int ++cut_tree_worker_cryptcompress(tap_t * tap, const reiser4_key * from_key, ++ const reiser4_key * to_key, ++ reiser4_key * smallest_removed, ++ struct inode *object, int truncate, int *progress) +{ + lock_handle next_node_lock; + coord_t left_coord; @@ -33854,7 +34331,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result != 0 && result != -E_NO_NEIGHBOR) + break; + /* FIXME-EDWARD: Check can we delete the node as a whole. */ -+ result = reiser4_tap_load(tap); ++ result = tap_load(tap); + if (result) + return result; + @@ -33895,7 +34372,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + } + + /* cut data from one node */ -+ *smallest_removed = *reiser4_min_key(); ++ *smallest_removed = *min_key(); + result = kill_node_content(&left_coord, + tap->coord, + from_key, @@ -33903,7 +34380,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + smallest_removed, + next_node_lock.node, + object, truncate); -+ reiser4_tap_relse(tap); ++#if REISER4_DEBUG ++ /*node_check(node, ~0U); */ ++#endif ++ tap_relse(tap); + + if (result) + break; @@ -33919,7 +34399,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (next_node_lock.node == NULL) + break; + -+ result = reiser4_tap_move(tap, &next_node_lock); ++ result = tap_move(tap, &next_node_lock); + done_lh(&next_node_lock); + if (result) + break; @@ -33936,29 +34416,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return result; +} + -+/* Append or expand hole in two steps: -+ * 1) set zeroes to the rightmost page of the rightmost non-fake -+ * logical cluster; -+ * 2) expand hole via fake logical clusters (just increase i_size) -+ */ -+static int cryptcompress_append_hole(struct inode *inode /* with old size */, -+ loff_t new_size) ++/* Append or expand hole in two steps (exclusive access should be aquired!) ++ 1) write zeroes to the current real cluster, ++ 2) expand hole via fake clusters (just increase i_size) */ ++static int ++cryptcompress_append_hole(struct inode *inode /*contains old i_size */ , ++ loff_t new_size) +{ + int result = 0; + hint_t *hint; + lock_handle *lh; + loff_t hole_size; + int nr_zeroes; -+ struct reiser4_slide win; -+ struct cluster_handle clust; ++ reiser4_slide_t win; ++ reiser4_cluster_t clust; + + assert("edward-1133", inode->i_size < new_size); -+ assert("edward-1134", reiser4_schedulable()); -+ assert("edward-1135", cryptcompress_inode_ok(inode)); ++ assert("edward-1134", schedulable()); ++ assert("edward-1135", crc_inode_ok(inode)); + assert("edward-1136", current_blocksize == PAGE_CACHE_SIZE); + assert("edward-1333", off_to_cloff(inode->i_size, inode) != 0); + -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) + return RETERR(-ENOMEM); + hint_init_zero(hint); @@ -33972,9 +34451,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result) + goto out; + if (off_to_cloff(inode->i_size, inode) == 0) -+ goto append_fake; ++ goto fake_append; + hole_size = new_size - inode->i_size; -+ nr_zeroes = ++ nr_zeroes = + inode_cluster_size(inode) - off_to_cloff(inode->i_size, inode); + if (hole_size < nr_zeroes) + nr_zeroes = hole_size; @@ -33985,7 +34464,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-1137", + clust.index == off_to_clust(inode->i_size, inode)); + -+ result = prepare_logical_cluster(inode, 0, 0, &clust, LC_APPOV); ++ result = prepare_cluster(inode, 0, 0, &clust, PCL_APPEND); + + assert("edward-1271", !result || result == -ENOSPC); + if (result) @@ -33998,32 +34477,73 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (hole_size == nr_zeroes) + /* nothing to append anymore */ + goto out; -+ append_fake: -+ INODE_SET_SIZE(inode, new_size); -+ out: ++ fake_append: ++ INODE_SET_FIELD(inode, i_size, new_size); ++ out: + done_lh(lh); + kfree(hint); + put_cluster_handle(&clust); + return result; +} + ++#if REISER4_DEBUG ++static int ++pages_truncate_ok(struct inode *inode, loff_t old_size, pgoff_t start) ++{ ++ struct pagevec pvec; ++ int i; ++ int count; ++ int rest; ++ ++ rest = count_to_nrpages(old_size) - start; ++ ++ pagevec_init(&pvec, 0); ++ count = min_count(pagevec_space(&pvec), rest); ++ ++ while (rest) { ++ count = min_count(pagevec_space(&pvec), rest); ++ pvec.nr = find_get_pages(inode->i_mapping, start, ++ count, pvec.pages); ++ for (i = 0; i < pagevec_count(&pvec); i++) { ++ if (PageUptodate(pvec.pages[i])) { ++ warning("edward-1205", ++ "truncated page of index %lu is uptodate", ++ pvec.pages[i]->index); ++ return 0; ++ } ++ } ++ start += count; ++ rest -= count; ++ pagevec_release(&pvec); ++ } ++ return 1; ++} ++ ++static int body_truncate_ok(struct inode *inode, cloff_t aidx) ++{ ++ int result; ++ cloff_t raidx; ++ ++ result = find_fake_appended(inode, &raidx); ++ return !result && (aidx == raidx); ++} ++#endif ++ +static int +update_cryptcompress_size(struct inode *inode, reiser4_key * key, int update_sd) +{ + return (get_key_offset(key) & ((loff_t) (inode_cluster_size(inode)) - 1) -+ ? 0 : reiser4_update_file_size(inode, key, update_sd)); ++ ? 0 : update_file_size(inode, key, update_sd)); +} + -+/* Prune cryptcompress file in two steps: -+ * 1) cut all nominated logical clusters except the leftmost one which -+ * is to be partially truncated. Note, that there can be "holes" -+ * represented by fake logical clusters. -+ * 2) set zeroes and capture leftmost partially truncated logical -+ * cluster, if it is not fake; otherwise prune fake logical cluster -+ * (just decrease i_size). -+ */ -+static int prune_cryptcompress(struct inode *inode, loff_t new_size, -+ int update_sd, cloff_t aidx) ++/* prune cryptcompress file in two steps (exclusive access should be acquired!) ++ 1) cut all disk clusters but the last one partially truncated, ++ 2) set zeroes and capture last partially truncated page cluster if the last ++ one exists, otherwise truncate via prune fake cluster (just decrease i_size) ++*/ ++static int ++prune_cryptcompress(struct inode *inode, loff_t new_size, int update_sd, ++ cloff_t aidx) +{ + int result = 0; + unsigned nr_zeroes; @@ -34033,17 +34553,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + hint_t *hint; + lock_handle *lh; -+ struct reiser4_slide win; -+ struct cluster_handle clust; ++ reiser4_slide_t win; ++ reiser4_cluster_t clust; + + assert("edward-1140", inode->i_size >= new_size); -+ assert("edward-1141", reiser4_schedulable()); -+ assert("edward-1142", cryptcompress_inode_ok(inode)); ++ assert("edward-1141", schedulable()); ++ assert("edward-1142", crc_inode_ok(inode)); + assert("edward-1143", current_blocksize == PAGE_CACHE_SIZE); + -+ old_size = inode->i_size; -+ -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) + return RETERR(-ENOMEM); + hint_init_zero(hint); @@ -34053,55 +34571,42 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + cluster_init_read(&clust, &win); + clust.hint = hint; + -+ /* calculate index of the rightmost logical cluster -+ that will be completely truncated */ -+ ridx = size_in_lc(new_size, inode); ++ /* rightmost completely truncated cluster */ ++ ridx = count_to_nrclust(new_size, inode); + -+ /* truncate all disk clusters starting from @ridx */ + assert("edward-1174", ridx <= aidx); + old_size = inode->i_size; + if (ridx != aidx) { -+ struct cryptcompress_info * info; -+ info = cryptcompress_inode_data(inode); + result = cut_file_items(inode, + clust_to_off(ridx, inode), + update_sd, + clust_to_off(aidx, inode), + update_cryptcompress_size); -+ info->trunc_index = ULONG_MAX; + if (result) + goto out; + } -+ /* -+ * there can be pages of fake logical clusters, truncate them -+ */ -+ truncate_inode_pages(inode->i_mapping, clust_to_off(ridx, inode)); -+ assert("edward-1524", -+ pages_truncate_ok(inode, clust_to_pg(ridx, inode))); -+ /* -+ * now perform partial truncate of last logical cluster -+ */ + if (!off_to_cloff(new_size, inode)) { -+ /* no partial truncate is needed */ ++ /* no partially truncated clusters */ + assert("edward-1145", inode->i_size == new_size); -+ goto truncate_fake; ++ goto finish; + } + assert("edward-1146", new_size < inode->i_size); + + to_prune = inode->i_size - new_size; + -+ /* check if the last logical cluster is fake */ -+ result = lookup_disk_cluster(inode, &aidx, ridx); ++ /* partial truncate of leftmost cluster, ++ first check if it is fake */ ++ result = find_real_disk_cluster(inode, &aidx, ridx); + if (result) + goto out; + if (!aidx) + /* yup, this is fake one */ -+ goto truncate_fake; ++ goto finish; + + assert("edward-1148", aidx == ridx); + -+ /* do partial truncate of the last page cluster, -+ and try to capture this one */ ++ /* do partial truncate of the leftmost page cluster, ++ then try to capture this one */ + result = alloc_cluster_pgset(&clust, cluster_nrpages(inode)); + if (result) + goto out; @@ -34112,7 +34617,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + assert("edward-1149", clust.index == ridx - 1); + -+ result = prepare_logical_cluster(inode, 0, 0, &clust, LC_TRUNC); ++ result = prepare_cluster(inode, 0, 0, &clust, PCL_TRUNCATE); + if (result) + goto out; + assert("edward-1151", @@ -34121,19 +34626,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + + assert("edward-1191", inode->i_size == new_size); + assert("edward-1206", body_truncate_ok(inode, ridx)); -+ truncate_fake: ++ finish: + /* drop all the pages that don't have jnodes (i.e. pages + which can not be truncated by cut_file_items() because + of holes represented by fake disk clusters) including + the pages of partially truncated cluster which was -+ released by prepare_logical_cluster() */ -+ INODE_SET_SIZE(inode, new_size); ++ released by prepare_cluster() */ + truncate_inode_pages(inode->i_mapping, new_size); -+ out: ++ INODE_SET_FIELD(inode, i_size, new_size); ++ out: + assert("edward-1334", !result || result == -ENOSPC); -+ assert("edward-1497", -+ pages_truncate_ok(inode, size_in_pages(new_size))); -+ ++ assert("edward-1209", ++ pages_truncate_ok(inode, old_size, count_to_nrpages(new_size))); + done_lh(lh); + kfree(hint); + put_cluster_handle(&clust); @@ -34141,10 +34645,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* Prepare cryptcompress file for truncate: -+ * prune or append rightmost fake logical clusters (if any) -+ */ -+static int start_truncate_fake(struct inode *inode, cloff_t aidx, -+ loff_t new_size, int update_sd) ++ prune or append rightmost fake logical clusters (if any) ++*/ ++static int ++start_truncate_fake(struct inode *inode, cloff_t aidx, loff_t new_size, ++ int update_sd) +{ + int result = 0; + int bytes; @@ -34155,17 +34660,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + /* no fake bytes */ + return 0; + bytes = new_size - inode->i_size; -+ INODE_SET_SIZE(inode, inode->i_size + bytes); ++ INODE_SET_FIELD(inode, i_size, inode->i_size + bytes); + } else { + /* prune */ + if (inode->i_size <= clust_to_off(aidx, inode)) + /* no fake bytes */ + return 0; -+ bytes = inode->i_size - -+ max(new_size, clust_to_off(aidx, inode)); ++ bytes = ++ inode->i_size - max_count(new_size, ++ clust_to_off(aidx, inode)); + if (!bytes) + return 0; -+ INODE_SET_SIZE(inode, inode->i_size - bytes); ++ INODE_SET_FIELD(inode, i_size, inode->i_size - bytes); + /* In the case of fake prune we need to drop page cluster. + There are only 2 cases for partially truncated page: + 1. If is is dirty, therefore it is anonymous @@ -34183,7 +34689,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +} + +/* This is called in setattr_cryptcompress when it is used to truncate, -+ * and in delete_cryptcompress */ ++ and in delete_cryptcompress */ +static int cryptcompress_truncate(struct inode *inode, /* old size */ + loff_t new_size, /* new size */ + int update_sd) @@ -34203,19 +34709,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (inode->i_size == new_size) + /* nothing to truncate anymore */ + return 0; -+ result = (inode->i_size < new_size ? -+ cryptcompress_append_hole(inode, new_size) : -+ prune_cryptcompress(inode, new_size, update_sd, aidx)); -+ if (!result && update_sd) -+ result = update_sd_cryptcompress(inode); -+ return result; ++ return (inode->i_size < new_size ? ++ cryptcompress_append_hole(inode, new_size) : ++ prune_cryptcompress(inode, new_size, update_sd, aidx)); ++} ++ ++static void clear_moved_tag_cluster(struct address_space * mapping, ++ reiser4_cluster_t * clust) ++{ ++ int i; ++ void * ret; ++ read_lock_irq(&mapping->tree_lock); ++ for (i = 0; i < clust->nr_pages; i++) { ++ assert("edward-1438", clust->pages[i] != NULL); ++ ret = radix_tree_tag_clear(&mapping->page_tree, ++ clust->pages[i]->index, ++ PAGECACHE_TAG_REISER4_MOVED); ++ assert("edward-1439", ret == clust->pages[i]); ++ } ++ read_unlock_irq(&mapping->tree_lock); +} + +/* Capture an anonymous pager cluster. (Page cluser is -+ * anonymous if it contains at least one anonymous page -+ */ -+static int capture_anon_page_cluster(struct cluster_handle * clust, -+ struct inode * inode) ++ anonymous if it contains at least one anonymous page */ ++static int ++capture_page_cluster(reiser4_cluster_t * clust, struct inode *inode) +{ + int result; + @@ -34223,72 +34741,48 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + assert("edward-1074", inode != NULL); + assert("edward-1075", clust->dstat == INVAL_DISK_CLUSTER); + -+ result = prepare_logical_cluster(inode, 0, 0, clust, LC_APPOV); ++ result = prepare_cluster(inode, 0, 0, clust, PCL_APPEND); + if (result) + return result; -+ set_cluster_pages_dirty(clust, inode); -+ result = checkin_logical_cluster(clust, inode); ++ set_cluster_pages_dirty(clust); ++ clear_moved_tag_cluster(inode->i_mapping, clust); ++ ++ result = try_capture_cluster(clust, inode); + put_hint_cluster(clust, inode, ZNODE_WRITE_LOCK); -+ if (unlikely(result)) -+ put_page_cluster(clust, inode, WRITE_OP); ++ if (unlikely(result)) { ++ /* set cleared tag back, so it will be ++ possible to capture it again later */ ++ read_lock_irq(&inode->i_mapping->tree_lock); ++ radix_tree_tag_set(&inode->i_mapping->page_tree, ++ clust_to_pg(clust->index, inode), ++ PAGECACHE_TAG_REISER4_MOVED); ++ read_unlock_irq(&inode->i_mapping->tree_lock); ++ ++ release_cluster_pages_and_jnode(clust); ++ } + return result; +} + -+/* Starting from @index find tagged pages of the same page cluster. -+ * Clear the tag for each of them. Return number of found pages. -+ */ -+static int find_anon_page_cluster(struct address_space * mapping, -+ pgoff_t * index, struct page ** pages) -+{ -+ int i = 0; -+ int found; -+ write_lock_irq(&mapping->tree_lock); -+ do { -+ /* looking for one page */ -+ found = radix_tree_gang_lookup_tag(&mapping->page_tree, -+ (void **)&pages[i], -+ *index, 1, -+ PAGECACHE_TAG_REISER4_MOVED); -+ if (!found) -+ break; -+ if (!same_page_cluster(pages[0], pages[i])) -+ break; -+ -+ /* found */ -+ page_cache_get(pages[i]); -+ *index = pages[i]->index + 1; -+ -+ radix_tree_tag_clear(&mapping->page_tree, -+ pages[i]->index, -+ PAGECACHE_TAG_REISER4_MOVED); -+ if (last_page_in_cluster(pages[i++])) -+ break; -+ } while (1); -+ write_unlock_irq(&mapping->tree_lock); -+ return i; -+} -+ -+#define MAX_PAGES_TO_CAPTURE (1024) ++#define MAX_CLUSTERS_TO_CAPTURE(inode) (1024 >> cluster_nrpages_shift(inode)) + -+/* Capture anonymous page clusters */ -+static int capture_anon_pages(struct address_space * mapping, pgoff_t * index, -+ int to_capture) ++/* read lock should be acquired */ ++static int ++capture_anonymous_clusters(struct address_space *mapping, pgoff_t * index, ++ int to_capture) +{ -+ int count = 0; -+ int found = 0; + int result = 0; ++ int found; ++ int progress = 0; ++ struct page *page = NULL; + hint_t *hint; + lock_handle *lh; -+ struct inode * inode; -+ struct cluster_handle clust; -+ struct page * pages[MAX_CLUSTER_NRPAGES]; ++ reiser4_cluster_t clust; + + assert("edward-1127", mapping != NULL); + assert("edward-1128", mapping->host != NULL); -+ assert("edward-1440", mapping->host->i_mapping == mapping); ++ assert("edward-1440", mapping->host->i_mapping == mapping); + -+ inode = mapping->host; -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) + return RETERR(-ENOMEM); + hint_init_zero(hint); @@ -34297,35 +34791,41 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + cluster_init_read(&clust, NULL); + clust.hint = hint; + -+ result = alloc_cluster_pgset(&clust, cluster_nrpages(inode)); ++ result = alloc_cluster_pgset(&clust, cluster_nrpages(mapping->host)); + if (result) + goto out; + + while (to_capture > 0) { -+ found = find_anon_page_cluster(mapping, index, pages); ++ found = ++ find_get_pages_tag(mapping, index, ++ PAGECACHE_TAG_REISER4_MOVED, 1, &page); + if (!found) { + *index = (pgoff_t) - 1; + break; + } -+ move_cluster_forward(&clust, inode, pages[0]->index); -+ result = capture_anon_page_cluster(&clust, inode); ++ assert("edward-1109", page != NULL); + -+ put_found_pages(pages, found); /* find_anon_page_cluster */ ++ move_cluster_forward(&clust, mapping->host, page->index, ++ &progress); ++ result = capture_page_cluster(&clust, mapping->host); ++ page_cache_release(page); + if (result) + break; -+ to_capture -= clust.nr_pages; -+ count += clust.nr_pages; ++ to_capture--; + } + if (result) { + warning("edward-1077", -+ "Capture failed (inode %llu, result=%i, captured=%d)\n", -+ (unsigned long long)get_inode_oid(inode), result, count); ++ "Cannot capture anon pages: result=%i (captured=%d)\n", ++ result, ++ ((__u32) MAX_CLUSTERS_TO_CAPTURE(mapping->host)) - ++ to_capture); + } else { -+ assert("edward-1078", ergo(found > 0, count > 0)); ++ /* something had to be found */ ++ assert("edward-1078", ++ to_capture <= MAX_CLUSTERS_TO_CAPTURE(mapping->host)); + if (to_capture <= 0) + /* there may be left more pages */ -+ __mark_inode_dirty(inode, I_DIRTY_PAGES); -+ result = count; ++ __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); + } + out: + done_lh(lh); @@ -34334,90 +34834,91 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return result; +} + -+/* Returns true if inode's mapping has dirty pages -+ which do not belong to any atom */ -+static int cryptcompress_inode_has_anon_pages(struct inode *inode) ++/* Check mapping for existence of not captured dirty pages. ++ This returns !0 if either page tree contains pages tagged ++ PAGECACHE_TAG_REISER4_MOVED */ ++static int crc_inode_has_anon_pages(struct inode *inode) +{ -+ int result; -+ read_lock_irq(&inode->i_mapping->tree_lock); -+ result = radix_tree_tagged(&inode->i_mapping->page_tree, -+ PAGECACHE_TAG_REISER4_MOVED); -+ read_unlock_irq(&inode->i_mapping->tree_lock); -+ return result; ++ return mapping_tagged(inode->i_mapping, PAGECACHE_TAG_REISER4_MOVED); +} + -+/* This is implementation of vfs's writepages method of struct ++/* this is implementation of vfs's writepages method of struct + address_space_operations */ -+int writepages_cryptcompress(struct address_space *mapping, -+ struct writeback_control *wbc) ++int ++writepages_cryptcompress(struct address_space *mapping, ++ struct writeback_control *wbc) +{ -+ int result = 0; -+ long to_capture; ++ int result; ++ int to_capture; + pgoff_t nrpages; + pgoff_t index = 0; ++ cryptcompress_info_t *info; + struct inode *inode; -+ struct cryptcompress_info *info; + + inode = mapping->host; -+ if (!cryptcompress_inode_has_anon_pages(inode)) ++ if (!crc_inode_has_anon_pages(inode)) { ++ result = 0; + goto end; ++ } ++ + info = cryptcompress_inode_data(inode); -+ nrpages = size_in_pages(i_size_read(inode)); ++ nrpages = count_to_nrpages(i_size_read(inode)); + + if (wbc->sync_mode != WB_SYNC_ALL) -+ to_capture = min(wbc->nr_to_write, (long)MAX_PAGES_TO_CAPTURE); ++ to_capture = ++ min_count(wbc->nr_to_write, MAX_CLUSTERS_TO_CAPTURE(inode)); + else -+ to_capture = MAX_PAGES_TO_CAPTURE; ++ to_capture = MAX_CLUSTERS_TO_CAPTURE(inode); + do { + reiser4_context *ctx; + -+ ctx = reiser4_init_context(inode->i_sb); ++ if (is_in_reiser4_context()) { ++ /* FIXME-EDWARD: REMOVEME */ ++ all_grabbed2free(); ++ ++ /* It can be in the context of write system call from ++ balance_dirty_pages() */ ++ if (down_read_trylock(&info->lock) == 0) { ++ result = RETERR(-EBUSY); ++ break; ++ } ++ } else ++ down_read(&info->lock); ++ ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) { + result = PTR_ERR(ctx); + break; + } -+ /* avoid recursive calls to ->sync_inodes */ + ctx->nobalance = 1; + + assert("edward-1079", + lock_stack_isclean(get_current_lock_stack())); + -+ reiser4_txn_restart_current(); ++ LOCK_CNT_INC(inode_sem_r); + -+ if (get_current_context()->entd) { -+ if (mutex_trylock(&info->checkin_mutex) == 0) { -+ /* the mutex might be occupied by -+ entd caller */ -+ result = RETERR(-EBUSY); -+ reiser4_exit_context(ctx); -+ break; -+ } -+ } else -+ mutex_lock(&info->checkin_mutex); ++ result = ++ capture_anonymous_clusters(inode->i_mapping, &index, ++ to_capture); + -+ result = capture_anon_pages(inode->i_mapping, &index, -+ to_capture); -+ mutex_unlock(&info->checkin_mutex); ++ up_read(&info->lock); + -+ if (result < 0) { -+ reiser4_exit_context(ctx); -+ break; -+ } -+ wbc->nr_to_write -= result; -+ if (wbc->sync_mode != WB_SYNC_ALL) { ++ LOCK_CNT_DEC(inode_sem_r); ++ ++ if (result != 0 || wbc->sync_mode != WB_SYNC_ALL) { + reiser4_exit_context(ctx); + break; + } + result = txnmgr_force_commit_all(inode->i_sb, 0); + reiser4_exit_context(ctx); -+ } while (result >= 0 && index < nrpages); ++ } while (result == 0 && index < nrpages); + -+ end: ++ end: + if (is_in_reiser4_context()) { + if (get_current_context()->nr_captured >= CAPTURE_APAGE_BURST) { -+ /* there are already pages to flush, flush them out, -+ do not delay until end of reiser4_sync_inodes */ -+ reiser4_writeout(inode->i_sb, wbc); ++ /* there are already pages to flush, flush them out, do ++ not delay until end of reiser4_sync_inodes */ ++ writeout(inode->i_sb, wbc); + get_current_context()->nr_captured = 0; + } + } @@ -34427,104 +34928,104 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ +/* plugin->u.file.mmap */ +int mmap_cryptcompress(struct file *file, struct vm_area_struct *vma) +{ -+ int result; -+ struct inode *inode; -+ reiser4_context *ctx; -+ -+ inode = file->f_dentry->d_inode; -+ ctx = reiser4_init_context(inode->i_sb); -+ if (IS_ERR(ctx)) -+ return PTR_ERR(ctx); -+ /* -+ * generic_file_mmap will do update_atime. Grab space for stat data -+ * update. -+ */ -+ result = reiser4_grab_space_force -+ (inode_file_plugin(inode)->estimate.update(inode), -+ BA_CAN_COMMIT); -+ if (result) { -+ reiser4_exit_context(ctx); -+ return result; -+ } -+ result = generic_file_mmap(file, vma); -+ reiser4_exit_context(ctx); -+ return result; ++ //return -ENOSYS; ++ return generic_file_mmap(file, vma); +} + +/* plugin->u.file.release */ +/* plugin->u.file.get_block */ + +/* this is implementation of delete method of file plugin for -+ * cryptcompress objects -+ */ -+int delete_object_cryptcompress(struct inode *inode) ++ cryptcompress objects */ ++int delete_cryptcompress(struct inode *inode) +{ + int result; -+ struct cryptcompress_info * info; + + assert("edward-429", inode->i_nlink == 0); + -+ reiser4_txn_restart_current(); -+ info = cryptcompress_inode_data(inode); -+ -+ mutex_lock(&info->checkin_mutex); -+ result = cryptcompress_truncate(inode, 0, 0); -+ mutex_unlock(&info->checkin_mutex); -+ -+ if (result) { -+ warning("edward-430", -+ "cannot truncate cryptcompress file %lli: %i", -+ (unsigned long long)get_inode_oid(inode), -+ result); ++ if (inode->i_size) { ++ result = cryptcompress_truncate(inode, 0, 0); ++ if (result) { ++ warning("edward-430", ++ "cannot truncate cryptcompress file %lli: %i", ++ (unsigned long long)get_inode_oid(inode), ++ result); ++ return result; ++ } + } -+ truncate_inode_pages(inode->i_mapping, 0); -+ assert("edward-1487", pages_truncate_ok(inode, 0)); + /* and remove stat data */ -+ return reiser4_delete_object_common(inode); ++ return delete_object_common(inode); +} + +/* plugin->u.file.setattr method -+ This implements actual truncate (see comments in reiser4/page_cache.c) */ -+int setattr_cryptcompress(struct dentry *dentry, struct iattr *attr) ++ see plugin.h for description */ ++int setattr_cryptcompress(struct dentry *dentry, /* Object to change attributes */ ++ struct iattr *attr /* change description */ ) +{ + int result; + struct inode *inode; -+ struct cryptcompress_info * info; + + inode = dentry->d_inode; -+ info = cryptcompress_inode_data(inode); -+ ++ result = check_cryptcompress(inode); ++ if (result) ++ return result; + if (attr->ia_valid & ATTR_SIZE) { -+ if (i_size_read(inode) != attr->ia_size) { ++ /* EDWARD-FIXME-HANS: VS-FIXME-HANS: ++ Q: this case occurs when? truncate? ++ A: yes ++ ++ Q: If so, why isn't this code in truncate itself instead of here? ++ ++ A: because vfs calls fs's truncate after it has called truncate_inode_pages to get rid of pages ++ corresponding to part of file being truncated. In reiser4 it may cause existence of unallocated ++ extents which do not have jnodes. Flush code does not expect that. Solution of this problem is ++ straightforward. As vfs's truncate is implemented using setattr operation (common implementaion of ++ which calls truncate_inode_pages and fs's truncate in case when size of file changes) - it seems ++ reasonable to have reiser4_setattr which will take care of removing pages, jnodes and extents ++ simultaneously in case of truncate. ++ Q: do you think implementing truncate using setattr is ugly, ++ and vfs needs improving, or is there some sense in which this is a good design? ++ ++ A: VS-FIXME-HANS: ++ */ ++ ++ /* truncate does reservation itself and requires exclusive access obtained */ ++ if (inode->i_size != attr->ia_size) { + reiser4_context *ctx; + loff_t old_size; ++ cryptcompress_info_t *info = ++ cryptcompress_inode_data(inode); + -+ ctx = reiser4_init_context(dentry->d_inode->i_sb); ++ ctx = init_context(dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + -+ old_size = i_size_read(inode); -+ inode_check_scale(inode, old_size, attr->ia_size); ++ down_write(&info->lock); ++ LOCK_CNT_INC(inode_sem_w); + -+ mutex_lock(&info->checkin_mutex); -+ result = cryptcompress_truncate(inode, -+ attr->ia_size, -+ 1/* update sd */); -+ mutex_unlock(&info->checkin_mutex); ++ inode_check_scale(inode, inode->i_size, attr->ia_size); ++ ++ old_size = inode->i_size; ++ ++ result = ++ cryptcompress_truncate(inode, attr->ia_size, ++ 1 /* update stat data */ ); + if (result) { -+ warning("edward-1192", -+ "truncate_cryptcompress failed: oid %lli, " -+ "old size %lld, new size %lld, retval %d", -+ (unsigned long long) -+ get_inode_oid(inode), old_size, -+ attr->ia_size, result); ++ warning("edward-1192", ++ "truncate_cryptcompress failed: oid %lli, " ++ "old size %lld, new size %lld, retval %d", ++ (unsigned long long) ++ get_inode_oid(inode), old_size, ++ attr->ia_size, result); + } ++ up_write(&info->lock); ++ LOCK_CNT_DEC(inode_sem_w); + context_set_commit_async(ctx); + reiser4_exit_context(ctx); + } else + result = 0; + } else -+ result = reiser4_setattr_common(dentry, attr); ++ result = setattr_common(dentry, attr); + return result; +} + @@ -34536,10 +35037,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + reiser4_context *ctx; + ssize_t result; + struct inode *inode; -+ struct cryptcompress_info *info; ++ cryptcompress_info_t *info; + + inode = file->f_dentry->d_inode; -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + /* @@ -34551,8 +35052,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + if (result) + goto exit; + info = cryptcompress_inode_data(inode); -+ ++ down_read(&info->lock); + result = generic_file_sendfile(file, ppos, count, actor, target); ++ up_read(&info->lock); + exit: + reiser4_exit_context(ctx); + return result; @@ -34565,7 +35067,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + */ +int release_cryptcompress(struct inode *inode, struct file *file) +{ -+ reiser4_context *ctx = reiser4_init_context(inode->i_sb); ++ reiser4_context *ctx = init_context(inode->i_sb); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); @@ -34574,14 +35076,40 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + return 0; +} + -+#if 0 -+int prepare_write_cryptcompress(struct file *file, struct page *page, -+ unsigned from, unsigned to) ++static int ++save_len_cryptcompress_plugin(struct inode *inode, reiser4_plugin * plugin) +{ -+ return prepare_write_common(file, page, from, to); ++ assert("edward-457", inode != NULL); ++ assert("edward-458", plugin != NULL); ++ assert("edward-459", plugin->h.id == CRC_FILE_PLUGIN_ID); ++ return 0; +} -+#endif /* 0 */ + ++static int ++load_cryptcompress_plugin(struct inode *inode, reiser4_plugin * plugin, ++ char **area, int *len) ++{ ++ assert("edward-455", inode != NULL); ++ assert("edward-456", (reiser4_inode_data(inode)->pset != NULL)); ++ ++ plugin_set_file(&reiser4_inode_data(inode)->pset, ++ file_plugin_by_id(CRC_FILE_PLUGIN_ID)); ++ return 0; ++} ++ ++static int change_cryptcompress(struct inode *inode, reiser4_plugin * plugin) ++{ ++ /* cannot change object plugin of already existing object */ ++ return RETERR(-EINVAL); ++} ++ ++struct reiser4_plugin_ops cryptcompress_plugin_ops = { ++ .load = load_cryptcompress_plugin, ++ .save_len = save_len_cryptcompress_plugin, ++ .save = NULL, ++ .alignment = 8, ++ .change = change_cryptcompress ++}; + +/* + Local variables: @@ -34593,40 +35121,38 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.c linux-2.6.22/ + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/fs/reiser4/plugin/file/cryptcompress.h ---- linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/cryptcompress.h 2007-07-29 00:26:21.804839975 +0400 -@@ -0,0 +1,607 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file/cryptcompress.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/cryptcompress.h +@@ -0,0 +1,551 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* See http://www.namesys.com/cryptcompress_design.html */ + +#if !defined( __FS_REISER4_CRYPTCOMPRESS_H__ ) +#define __FS_REISER4_CRYPTCOMPRESS_H__ + -+#include "../../page_cache.h" +#include "../compress/compress.h" +#include "../crypto/cipher.h" + +#include ++#include + ++#define MIN_CLUSTER_SIZE PAGE_CACHE_SIZE +#define MIN_CLUSTER_SHIFT PAGE_CACHE_SHIFT +#define MAX_CLUSTER_SHIFT 16 +#define MAX_CLUSTER_NRPAGES (1U << MAX_CLUSTER_SHIFT >> PAGE_CACHE_SHIFT) +#define DC_CHECKSUM_SIZE 4 + -+#define MIN_LATTICE_FACTOR 1 -+#define MAX_LATTICE_FACTOR 32 ++static inline loff_t min_count(loff_t a, loff_t b) ++{ ++ return (a < b ? a : b); ++} + -+/* this mask contains all non-standard plugins that might -+ be present in reiser4-specific part of inode managed by -+ cryptcompress file plugin */ -+#define cryptcompress_mask \ -+ ((1 << PSET_FILE) | \ -+ (1 << PSET_CLUSTER) | \ -+ (1 << PSET_CIPHER) | \ -+ (1 << PSET_DIGEST) | \ -+ (1 << PSET_COMPRESSION) | \ -+ (1 << PSET_COMPRESSION_MODE)) ++static inline loff_t max_count(loff_t a, loff_t b) ++{ ++ return (a > b ? a : b); ++} + +#if REISER4_DEBUG +static inline int cluster_shift_ok(int shift) @@ -34635,35 +35161,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ +} +#endif + -+#if REISER4_DEBUG -+#define INODE_PGCOUNT(inode) \ -+({ \ -+ assert("edward-1530", inode_file_plugin(inode) == \ -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); \ -+ atomic_read(&cryptcompress_inode_data(inode)->pgcount); \ -+ }) -+#define INODE_PGCOUNT_INC(inode) \ -+do { \ -+ assert("edward-1531", inode_file_plugin(inode) == \ -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); \ -+ atomic_inc(&cryptcompress_inode_data(inode)->pgcount); \ -+} while (0) -+#define INODE_PGCOUNT_DEC(inode) \ -+do { \ -+ if (inode_file_plugin(inode) == \ -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)) \ -+ atomic_dec(&cryptcompress_inode_data(inode)->pgcount); \ -+} while (0) -+#else -+#define INODE_PGCOUNT(inode) (0) -+#define INODE_PGCOUNT_INC(inode) -+#define INODE_PGCOUNT_DEC(inode) -+#endif /* REISER4_DEBUG */ -+ -+struct tfm_stream { ++typedef struct tfm_stream { + __u8 *data; + size_t size; -+}; ++} tfm_stream_t; + +typedef enum { + INPUT_STREAM, @@ -34671,40 +35172,40 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + LAST_STREAM +} tfm_stream_id; + -+typedef struct tfm_stream * tfm_unit[LAST_STREAM]; ++typedef tfm_stream_t *tfm_unit[LAST_STREAM]; + -+static inline __u8 *ts_data(struct tfm_stream * stm) ++static inline __u8 *ts_data(tfm_stream_t * stm) +{ + assert("edward-928", stm != NULL); + return stm->data; +} + -+static inline size_t ts_size(struct tfm_stream * stm) ++static inline size_t ts_size(tfm_stream_t * stm) +{ + assert("edward-929", stm != NULL); + return stm->size; +} + -+static inline void set_ts_size(struct tfm_stream * stm, size_t size) ++static inline void set_ts_size(tfm_stream_t * stm, size_t size) +{ + assert("edward-930", stm != NULL); + + stm->size = size; +} + -+static inline int alloc_ts(struct tfm_stream ** stm) ++static inline int alloc_ts(tfm_stream_t ** stm) +{ + assert("edward-931", stm); + assert("edward-932", *stm == NULL); + -+ *stm = kmalloc(sizeof **stm, reiser4_ctx_gfp_mask_get()); ++ *stm = kmalloc(sizeof **stm, GFP_KERNEL); + if (*stm == NULL) + return -ENOMEM; + memset(*stm, 0, sizeof **stm); + return 0; +} + -+static inline void free_ts(struct tfm_stream * stm) ++static inline void free_ts(tfm_stream_t * stm) +{ + assert("edward-933", !ts_data(stm)); + assert("edward-934", !ts_size(stm)); @@ -34712,20 +35213,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + kfree(stm); +} + -+static inline int alloc_ts_data(struct tfm_stream * stm, size_t size) ++static inline int alloc_ts_data(tfm_stream_t * stm, size_t size) +{ + assert("edward-935", !ts_data(stm)); + assert("edward-936", !ts_size(stm)); + assert("edward-937", size != 0); + -+ stm->data = reiser4_vmalloc(size); ++ stm->data = vmalloc(size); + if (!stm->data) + return -ENOMEM; + set_ts_size(stm, size); + return 0; +} + -+static inline void free_ts_data(struct tfm_stream * stm) ++static inline void free_ts_data(tfm_stream_t * stm) +{ + assert("edward-938", equi(ts_data(stm), ts_size(stm))); + @@ -34739,40 +35240,42 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + CRC_APPEND_ITEM = 1, + CRC_OVERWRITE_ITEM = 2, + CRC_CUT_ITEM = 3 -+} cryptcompress_write_mode_t; ++} crc_write_mode_t; + +typedef enum { -+ LC_INVAL = 0, /* invalid value */ -+ LC_APPOV = 1, /* append and/or overwrite */ -+ LC_TRUNC = 2 /* truncate */ -+} logical_cluster_op; -+ -+/* Transform cluster. -+ * Intermediate state between page cluster and disk cluster -+ * Is used for data transform (compression/encryption) -+ */ -+struct tfm_cluster { -+ coa_set coa; /* compression algorithms info */ -+ tfm_unit tun; /* plain and transformed streams */ ++ PCL_UNKNOWN = 0, /* invalid option */ ++ PCL_APPEND = 1, /* append and/or overwrite */ ++ PCL_TRUNCATE = 2 /* truncate */ ++} page_cluster_op; ++ ++/* Reiser4 file write/read transforms page cluster into disk cluster (and back) ++ using crypto/compression transforms implemented by reiser4 transform plugins. ++ Before each transform we allocate a pair of streams (tfm_unit) and assemble ++ page cluster into the input one. After transform we split output stream into ++ a set of items (disk cluster). ++*/ ++typedef struct tfm_cluster { ++ coa_set coa; ++ tfm_unit tun; + tfm_action act; + int uptodate; -+ int lsize; /* number of bytes in logical cluster */ ++ int lsize; /* size of the logical cluster */ + int len; /* length of the transform stream */ -+}; ++} tfm_cluster_t; + -+static inline coa_t get_coa(struct tfm_cluster * tc, reiser4_compression_id id, -+ tfm_action act) ++static inline coa_t get_coa(tfm_cluster_t * tc, reiser4_compression_id id, tfm_action act) +{ + return tc->coa[id][act]; +} + -+static inline void set_coa(struct tfm_cluster * tc, reiser4_compression_id id, -+ tfm_action act, coa_t coa) ++static inline void ++set_coa(tfm_cluster_t * tc, reiser4_compression_id id, tfm_action act, coa_t coa) +{ + tc->coa[id][act] = coa; +} + -+static inline int alloc_coa(struct tfm_cluster * tc, compression_plugin * cplug) ++static inline int ++alloc_coa(tfm_cluster_t * tc, compression_plugin * cplug) +{ + coa_t coa; + @@ -34784,13 +35287,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ +} + +static inline int -+grab_coa(struct tfm_cluster * tc, compression_plugin * cplug) ++grab_coa(tfm_cluster_t * tc, compression_plugin * cplug) +{ + return (cplug->alloc && !get_coa(tc, cplug->h.id, tc->act) ? + alloc_coa(tc, cplug) : 0); +} + -+static inline void free_coa_set(struct tfm_cluster * tc) ++static inline void free_coa_set(tfm_cluster_t * tc) +{ + tfm_action j; + reiser4_compression_id i; @@ -34798,7 +35301,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + + assert("edward-810", tc != NULL); + -+ for (j = 0; j < TFMA_LAST; j++) ++ for (j = 0; j < LAST_TFM; j++) + for (i = 0; i < LAST_COMPRESSION_ID; i++) { + if (!get_coa(tc, i, j)) + continue; @@ -34810,65 +35313,64 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + return; +} + -+static inline struct tfm_stream * get_tfm_stream(struct tfm_cluster * tc, -+ tfm_stream_id id) ++static inline tfm_stream_t *tfm_stream(tfm_cluster_t * tc, tfm_stream_id id) +{ + return tc->tun[id]; +} + -+static inline void set_tfm_stream(struct tfm_cluster * tc, -+ tfm_stream_id id, struct tfm_stream * ts) ++static inline void ++set_tfm_stream(tfm_cluster_t * tc, tfm_stream_id id, tfm_stream_t * ts) +{ + tc->tun[id] = ts; +} + -+static inline __u8 *tfm_stream_data(struct tfm_cluster * tc, tfm_stream_id id) ++static inline __u8 *tfm_stream_data(tfm_cluster_t * tc, tfm_stream_id id) +{ -+ return ts_data(get_tfm_stream(tc, id)); ++ return ts_data(tfm_stream(tc, id)); +} + -+static inline void set_tfm_stream_data(struct tfm_cluster * tc, -+ tfm_stream_id id, __u8 * data) ++static inline void ++set_tfm_stream_data(tfm_cluster_t * tc, tfm_stream_id id, __u8 * data) +{ -+ get_tfm_stream(tc, id)->data = data; ++ tfm_stream(tc, id)->data = data; +} + -+static inline size_t tfm_stream_size(struct tfm_cluster * tc, tfm_stream_id id) ++static inline size_t tfm_stream_size(tfm_cluster_t * tc, tfm_stream_id id) +{ -+ return ts_size(get_tfm_stream(tc, id)); ++ return ts_size(tfm_stream(tc, id)); +} + +static inline void -+set_tfm_stream_size(struct tfm_cluster * tc, tfm_stream_id id, size_t size) ++set_tfm_stream_size(tfm_cluster_t * tc, tfm_stream_id id, size_t size) +{ -+ get_tfm_stream(tc, id)->size = size; ++ tfm_stream(tc, id)->size = size; +} + +static inline int -+alloc_tfm_stream(struct tfm_cluster * tc, size_t size, tfm_stream_id id) ++alloc_tfm_stream(tfm_cluster_t * tc, size_t size, tfm_stream_id id) +{ + assert("edward-939", tc != NULL); -+ assert("edward-940", !get_tfm_stream(tc, id)); ++ assert("edward-940", !tfm_stream(tc, id)); + -+ tc->tun[id] = kzalloc(sizeof(struct tfm_stream), -+ reiser4_ctx_gfp_mask_get()); ++ tc->tun[id] = kmalloc(sizeof(tfm_stream_t), GFP_KERNEL); + if (!tc->tun[id]) + return -ENOMEM; -+ return alloc_ts_data(get_tfm_stream(tc, id), size); ++ memset(tfm_stream(tc, id), 0, sizeof(tfm_stream_t)); ++ return alloc_ts_data(tfm_stream(tc, id), size); +} + +static inline int -+realloc_tfm_stream(struct tfm_cluster * tc, size_t size, tfm_stream_id id) ++realloc_tfm_stream(tfm_cluster_t * tc, size_t size, tfm_stream_id id) +{ + assert("edward-941", tfm_stream_size(tc, id) < size); -+ free_ts_data(get_tfm_stream(tc, id)); -+ return alloc_ts_data(get_tfm_stream(tc, id), size); ++ free_ts_data(tfm_stream(tc, id)); ++ return alloc_ts_data(tfm_stream(tc, id), size); +} + -+static inline void free_tfm_stream(struct tfm_cluster * tc, tfm_stream_id id) ++static inline void free_tfm_stream(tfm_cluster_t * tc, tfm_stream_id id) +{ -+ free_ts_data(get_tfm_stream(tc, id)); -+ free_ts(get_tfm_stream(tc, id)); ++ free_ts_data(tfm_stream(tc, id)); ++ free_ts(tfm_stream(tc, id)); + set_tfm_stream(tc, id, 0); +} + @@ -34877,31 +35379,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + return (cplug->overrun != NULL ? cplug->overrun(ilen) : 0); +} + -+static inline void free_tfm_unit(struct tfm_cluster * tc) ++static inline void free_tfm_unit(tfm_cluster_t * tc) +{ + tfm_stream_id id; + for (id = 0; id < LAST_STREAM; id++) { -+ if (!get_tfm_stream(tc, id)) ++ if (!tfm_stream(tc, id)) + continue; + free_tfm_stream(tc, id); + } +} + -+static inline void put_tfm_cluster(struct tfm_cluster * tc) ++static inline void put_tfm_cluster(tfm_cluster_t * tc) +{ + assert("edward-942", tc != NULL); + free_coa_set(tc); + free_tfm_unit(tc); +} + -+static inline int tfm_cluster_is_uptodate(struct tfm_cluster * tc) ++static inline int tfm_cluster_is_uptodate(tfm_cluster_t * tc) +{ + assert("edward-943", tc != NULL); + assert("edward-944", tc->uptodate == 0 || tc->uptodate == 1); + return (tc->uptodate == 1); +} + -+static inline void tfm_cluster_set_uptodate(struct tfm_cluster * tc) ++static inline void tfm_cluster_set_uptodate(tfm_cluster_t * tc) +{ + assert("edward-945", tc != NULL); + assert("edward-946", tc->uptodate == 0 || tc->uptodate == 1); @@ -34909,7 +35411,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + return; +} + -+static inline void tfm_cluster_clr_uptodate(struct tfm_cluster * tc) ++static inline void tfm_cluster_clr_uptodate(tfm_cluster_t * tc) +{ + assert("edward-947", tc != NULL); + assert("edward-948", tc->uptodate == 0 || tc->uptodate == 1); @@ -34917,13 +35419,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + return; +} + -+static inline int tfm_stream_is_set(struct tfm_cluster * tc, tfm_stream_id id) ++static inline int tfm_stream_is_set(tfm_cluster_t * tc, tfm_stream_id id) +{ -+ return (get_tfm_stream(tc, id) && ++ return (tfm_stream(tc, id) && + tfm_stream_data(tc, id) && tfm_stream_size(tc, id)); +} + -+static inline int tfm_cluster_is_set(struct tfm_cluster * tc) ++static inline int tfm_cluster_is_set(tfm_cluster_t * tc) +{ + int i; + for (i = 0; i < LAST_STREAM; i++) @@ -34932,130 +35434,108 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + return 1; +} + -+static inline void alternate_streams(struct tfm_cluster * tc) ++static inline void alternate_streams(tfm_cluster_t * tc) +{ -+ struct tfm_stream *tmp = get_tfm_stream(tc, INPUT_STREAM); ++ tfm_stream_t *tmp = tfm_stream(tc, INPUT_STREAM); + -+ set_tfm_stream(tc, INPUT_STREAM, get_tfm_stream(tc, OUTPUT_STREAM)); ++ set_tfm_stream(tc, INPUT_STREAM, tfm_stream(tc, OUTPUT_STREAM)); + set_tfm_stream(tc, OUTPUT_STREAM, tmp); +} + -+/* Set of states to indicate a kind of data -+ * that will be written to the window */ ++/* a kind of data that we can write to the window */ +typedef enum { -+ DATA_WINDOW, /* user's data */ -+ HOLE_WINDOW /* zeroes (such kind of data can be written -+ * if we start to write from offset > i_size) */ ++ DATA_WINDOW, /* the data we copy form user space */ ++ HOLE_WINDOW /* zeroes if we write hole */ +} window_stat; + -+/* Window (of logical cluster size) discretely sliding along a file. -+ * Is used to locate hole region in a logical cluster to be properly -+ * represented on disk. -+ * We split a write to cryptcompress file into writes to its logical -+ * clusters. Before writing to a logical cluster we set a window, i.e. -+ * calculate values of the following fields: -+ */ -+struct reiser4_slide { -+ unsigned off; /* offset to write from */ -+ unsigned count; /* number of bytes to write */ ++/* Sliding window of cluster size which should be set to the approprite position ++ (defined by cluster index) in a file before page cluster modification by ++ file_write. Then we translate file size, offset to write from, number of ++ bytes to write, etc.. to the following configuration needed to estimate ++ number of pages to read before write, etc... ++*/ ++typedef struct reiser4_slide { ++ unsigned off; /* offset we start to write/truncate from */ ++ unsigned count; /* number of bytes (zeroes) to write/truncate */ + unsigned delta; /* number of bytes to append to the hole */ -+ window_stat stat; /* what kind of data will be written starting -+ from @off */ -+}; ++ window_stat stat; /* a kind of data to write to the window */ ++} reiser4_slide_t; + -+/* Possible states of a disk cluster */ ++/* The following is a set of possible disk cluster states */ +typedef enum { + INVAL_DISK_CLUSTER, /* unknown state */ + PREP_DISK_CLUSTER, /* disk cluster got converted by flush -+ * at least 1 time */ ++ at least 1 time */ + UNPR_DISK_CLUSTER, /* disk cluster just created and should be -+ * converted by flush */ -+ FAKE_DISK_CLUSTER, /* disk cluster doesn't exist neither in memory -+ * nor on disk */ -+ TRNC_DISK_CLUSTER /* disk cluster is partially truncated */ ++ converted by flush */ ++ FAKE_DISK_CLUSTER /* disk cluster doesn't exist neither in memory ++ nor on disk */ +} disk_cluster_stat; + -+/* The following structure represents various stages of the same logical -+ * cluster of index @index: -+ * . fixed slide -+ * . page cluster (stage in primary cache) -+ * . transform cluster (transition stage) -+ * . disk cluster (stage in secondary cache) -+ * This structure is used in transition and synchronizing operations, e.g. -+ * transform cluster is a transition state when synchronizing page cluster -+ * and disk cluster. -+ * FIXME: Encapsulate page cluster, disk cluster. -+ */ -+struct cluster_handle { -+ cloff_t index; /* offset in a file (unit is a cluster size) */ -+ int index_valid; /* for validating the index above, if needed */ -+ struct file *file; /* host file */ -+ -+ /* logical cluster */ -+ struct reiser4_slide *win; /* sliding window to locate holes */ -+ logical_cluster_op op; /* logical cluster operation (truncate or -+ append/overwrite) */ -+ /* transform cluster */ -+ struct tfm_cluster tc; /* contains all needed info to synchronize -+ page cluster and disk cluster) */ -+ /* page cluster */ -+ int nr_pages; /* number of pages of current checkin action */ -+ int old_nrpages; /* number of pages of last checkin action */ -+ struct page **pages; /* attached pages */ -+ jnode * node; /* jnode for capture */ -+ -+ /* disk cluster */ -+ hint_t *hint; /* current position in the tree */ -+ disk_cluster_stat dstat; /* state of the current disk cluster */ -+ int reserved; /* is space for disk cluster reserved */ ++/* ++ While implementing all transforms (from page to disk cluster, and back) ++ reiser4 cluster manager fills the following structure incapsulating pointers ++ to all the clusters for the same index including the sliding window above ++*/ ++typedef struct reiser4_cluster { ++ tfm_cluster_t tc; /* transform cluster */ ++ int nr_pages; /* number of pages */ ++ struct page **pages; /* page cluster */ ++ page_cluster_op op; /* page cluster operation */ ++ struct file *file; ++ hint_t *hint; /* disk cluster item for traversal */ ++ disk_cluster_stat dstat; /* state of the current disk cluster */ ++ cloff_t index; /* offset in the units of cluster size */ ++ reiser4_slide_t *win; /* sliding window of cluster size */ ++ int reserved; /* this indicates that space for disk ++ cluster modification is reserved */ +#if REISER4_DEBUG + reiser4_context *ctx; + int reserved_prepped; + int reserved_unprepped; +#endif + -+}; ++} reiser4_cluster_t; + -+static inline __u8 * tfm_input_data (struct cluster_handle * clust) ++static inline __u8 * tfm_input_data (reiser4_cluster_t * clust) +{ + return tfm_stream_data(&clust->tc, INPUT_STREAM); +} + -+static inline __u8 * tfm_output_data (struct cluster_handle * clust) ++static inline __u8 * tfm_output_data (reiser4_cluster_t * clust) +{ + return tfm_stream_data(&clust->tc, OUTPUT_STREAM); +} + -+static inline int reset_cluster_pgset(struct cluster_handle * clust, -+ int nrpages) ++static inline int reset_cluster_pgset(reiser4_cluster_t * clust, int nrpages) +{ + assert("edward-1057", clust->pages != NULL); + memset(clust->pages, 0, sizeof(*clust->pages) * nrpages); + return 0; +} + -+static inline int alloc_cluster_pgset(struct cluster_handle * clust, -+ int nrpages) ++static inline int alloc_cluster_pgset(reiser4_cluster_t * clust, int nrpages) +{ + assert("edward-949", clust != NULL); + assert("edward-1362", clust->pages == NULL); + assert("edward-950", nrpages != 0 && nrpages <= MAX_CLUSTER_NRPAGES); + -+ clust->pages = kzalloc(sizeof(*clust->pages) * nrpages, -+ reiser4_ctx_gfp_mask_get()); ++ clust->pages = ++ kmalloc(sizeof(*clust->pages) * nrpages, GFP_KERNEL); + if (!clust->pages) + return RETERR(-ENOMEM); ++ reset_cluster_pgset(clust, nrpages); + return 0; +} + -+static inline void free_cluster_pgset(struct cluster_handle * clust) ++static inline void free_cluster_pgset(reiser4_cluster_t * clust) +{ + assert("edward-951", clust->pages != NULL); + kfree(clust->pages); + clust->pages = NULL; +} + -+static inline void put_cluster_handle(struct cluster_handle * clust) ++static inline void put_cluster_handle(reiser4_cluster_t * clust) +{ + assert("edward-435", clust != NULL); + @@ -35065,134 +35545,127 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + memset(clust, 0, sizeof *clust); +} + -+static inline void inc_keyload_count(struct reiser4_crypto_info * data) ++static inline void inc_keyload_count(crypto_stat_t * data) +{ + assert("edward-1410", data != NULL); + data->keyload_count++; +} + -+static inline void dec_keyload_count(struct reiser4_crypto_info * data) ++static inline void dec_keyload_count(crypto_stat_t * data) +{ + assert("edward-1411", data != NULL); + assert("edward-1412", data->keyload_count > 0); + data->keyload_count--; +} + -+static inline int capture_cluster_jnode(jnode * node) -+{ -+ return reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); -+} -+ +/* cryptcompress specific part of reiser4_inode */ -+struct cryptcompress_info { -+ struct mutex checkin_mutex; /* This is to serialize -+ * checkin_logical_cluster operations */ -+ cloff_t trunc_index; /* Index of the leftmost truncated disk -+ * cluster (to resolve races with read) */ -+ struct reiser4_crypto_info *crypt; -+ /* -+ * the following 2 fields are controlled by compression mode plugin -+ */ -+ int compress_toggle; /* Current status of compressibility */ -+ int lattice_factor; /* Factor of dynamic lattice. FIXME: Have -+ * a compression_toggle to keep the factor -+ */ ++typedef struct cryptcompress_info { ++ struct rw_semaphore lock; ++ crypto_stat_t *crypt; ++ int compress_toggle; /* current status of compressibility ++ is set by compression mode plugin */ +#if REISER4_DEBUG -+ atomic_t pgcount; /* number of grabbed pages */ ++ int pgcount; /* number of captured pages */ +#endif -+}; ++} cryptcompress_info_t; + -+static inline void set_compression_toggle (struct cryptcompress_info * info, int val) ++ ++static inline void toggle_compression (cryptcompress_info_t * info, int val) +{ + info->compress_toggle = val; +} + -+static inline int get_compression_toggle (struct cryptcompress_info * info) ++static inline int compression_is_on (cryptcompress_info_t * info) +{ + return info->compress_toggle; +} + -+static inline int compression_is_on(struct cryptcompress_info * info) ++cryptcompress_info_t *cryptcompress_inode_data(const struct inode *); ++int equal_to_rdk(znode *, const reiser4_key *); ++int goto_right_neighbor(coord_t *, lock_handle *); ++int load_file_hint(struct file *, hint_t *); ++void save_file_hint(struct file *, const hint_t *); ++void hint_init_zero(hint_t *); ++int crc_inode_ok(struct inode *inode); ++int jnode_of_cluster(const jnode * node, struct page * page); ++extern int ctail_read_disk_cluster (reiser4_cluster_t *, struct inode *, int); ++extern int do_readpage_ctail(struct inode *, reiser4_cluster_t *, ++ struct page * page); ++extern int ctail_insert_unprepped_cluster(reiser4_cluster_t * clust, ++ struct inode * inode); ++int bind_cryptcompress(struct inode *child, struct inode *parent); ++void destroy_inode_cryptcompress(struct inode * inode); ++crypto_stat_t * inode_crypto_stat (struct inode * inode); ++void inherit_crypto_stat_common(struct inode * parent, struct inode * object, ++ int (*can_inherit)(struct inode * child, ++ struct inode * parent)); ++void attach_crypto_stat(struct inode * inode, crypto_stat_t * info); ++void detach_crypto_stat(struct inode * inode); ++void change_crypto_stat(struct inode * inode, crypto_stat_t * new); ++crypto_stat_t * alloc_crypto_stat (struct inode * inode); ++ ++ ++static inline reiser4_tfma_t * ++info_get_tfma (crypto_stat_t * info, reiser4_tfm id) +{ -+ return get_compression_toggle(info) == 1; ++ return &info->tfma[id]; +} + -+static inline void turn_on_compression(struct cryptcompress_info * info) ++static inline struct crypto_tfm * ++info_get_tfm (crypto_stat_t * info, reiser4_tfm id) +{ -+ set_compression_toggle(info, 1); ++ return info_get_tfma(info, id)->tfm; +} + -+static inline void turn_off_compression(struct cryptcompress_info * info) ++static inline void ++info_set_tfm (crypto_stat_t * info, reiser4_tfm id, struct crypto_tfm * tfm) +{ -+ set_compression_toggle(info, 0); ++ info_get_tfma(info, id)->tfm = tfm; +} + -+static inline void set_lattice_factor(struct cryptcompress_info * info, int val) ++static inline struct crypto_tfm * ++info_cipher_tfm (crypto_stat_t * info) +{ -+ info->lattice_factor = val; ++ return info_get_tfm(info, CIPHER_TFM); +} + -+static inline int get_lattice_factor(struct cryptcompress_info * info) ++static inline struct crypto_tfm * ++info_digest_tfm (crypto_stat_t * info) +{ -+ return info->lattice_factor; ++ return info_get_tfm(info, DIGEST_TFM); +} + -+struct cryptcompress_info *cryptcompress_inode_data(const struct inode *); -+int equal_to_rdk(znode *, const reiser4_key *); -+int goto_right_neighbor(coord_t *, lock_handle *); -+int cryptcompress_inode_ok(struct inode *inode); -+int coord_is_unprepped_ctail(const coord_t * coord); -+extern int ctail_read_disk_cluster (struct cluster_handle *, struct inode *, -+ struct page *, znode_lock_mode mode); -+extern int do_readpage_ctail(struct inode *, struct cluster_handle *, -+ struct page * page, znode_lock_mode mode); -+extern int ctail_insert_unprepped_cluster(struct cluster_handle * clust, -+ struct inode * inode); -+extern int readpages_cryptcompress(struct file*, struct address_space*, -+ struct list_head*, unsigned); -+int bind_cryptcompress(struct inode *child, struct inode *parent); -+void destroy_inode_cryptcompress(struct inode * inode); -+int grab_page_cluster(struct inode *inode, struct cluster_handle * clust, -+ rw_op rw); -+int write_conversion_hook(struct file *file, struct inode * inode, loff_t pos, -+ struct cluster_handle * clust, int * progress); -+struct reiser4_crypto_info * inode_crypto_info(struct inode * inode); -+void inherit_crypto_info_common(struct inode * parent, struct inode * object, -+ int (*can_inherit)(struct inode * child, -+ struct inode * parent)); -+void reiser4_attach_crypto_info(struct inode * inode, -+ struct reiser4_crypto_info * info); -+void change_crypto_info(struct inode * inode, struct reiser4_crypto_info * new); -+struct reiser4_crypto_info * reiser4_alloc_crypto_info (struct inode * inode); -+ -+static inline struct crypto_blkcipher * info_get_cipher(struct reiser4_crypto_info * info) ++static inline cipher_plugin * ++info_cipher_plugin (crypto_stat_t * info) +{ -+ return info->cipher; ++ return &info_get_tfma(info, CIPHER_TFM)->plug->cipher; +} + -+static inline void info_set_cipher(struct reiser4_crypto_info * info, -+ struct crypto_blkcipher * tfm) ++static inline digest_plugin * ++info_digest_plugin (crypto_stat_t * info) +{ -+ info->cipher = tfm; ++ return &info_get_tfma(info, DIGEST_TFM)->plug->digest; +} + -+static inline struct crypto_hash * info_get_digest(struct reiser4_crypto_info * info) ++static inline void ++info_set_plugin(crypto_stat_t * info, reiser4_tfm id, reiser4_plugin * plugin) +{ -+ return info->digest; ++ info_get_tfma(info, id)->plug = plugin; +} + -+static inline void info_set_digest(struct reiser4_crypto_info * info, -+ struct crypto_hash * tfm) ++static inline void ++info_set_cipher_plugin(crypto_stat_t * info, cipher_plugin * cplug) +{ -+ info->digest = tfm; ++ info_set_plugin(info, CIPHER_TFM, cipher_plugin_to_plugin(cplug)); +} + -+static inline void put_cluster_page(struct page * page) ++static inline void ++info_set_digest_plugin(crypto_stat_t * info, digest_plugin * plug) +{ -+ page_cache_release(page); ++ info_set_plugin(info, DIGEST_TFM, digest_plugin_to_plugin(plug)); +} + -+#endif /* __FS_REISER4_CRYPTCOMPRESS_H__ */ ++#endif /* __FS_REISER4_CRYPTCOMPRESS_H__ */ + +/* Make Linus happy. + Local variables: @@ -35204,10 +35677,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/cryptcompress.h linux-2.6.22/ + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser4/plugin/file/file.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/file.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/file.c 2007-07-29 00:25:34.924708901 +0400 -@@ -0,0 +1,2817 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file/file.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/file.c +@@ -0,0 +1,2712 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -35226,7 +35700,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +#include "../../page_cache.h" +#include "../../ioctl.h" +#include "../object.h" -+#include "../cluster.h" +#include "../../safe_link.h" + +#include @@ -35235,28 +35708,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + +static int unpack(struct file *file, struct inode *inode, int forever); -+static void drop_access(struct unix_file_info *); -+static int hint_validate(hint_t * hint, const reiser4_key * key, int check_key, -+ znode_lock_mode lock_mode); -+ -+/* Get exclusive access and make sure that file is not partially -+ * converted (It may happen that another process is doing tail -+ * conversion. If so, wait until it completes) -+ */ -+static inline void get_exclusive_access_careful(struct unix_file_info * uf_info, -+ struct inode *inode) -+{ -+ do { -+ get_exclusive_access(uf_info); -+ if (!reiser4_inode_get_flag(inode, REISER4_PART_IN_CONV)) -+ break; -+ drop_exclusive_access(uf_info); -+ schedule(); -+ } while (1); -+} + +/* get unix file plugin specific portion of inode */ -+struct unix_file_info *unix_file_inode_data(const struct inode *inode) ++unix_file_info_t *unix_file_inode_data(const struct inode *inode) +{ + return &reiser4_inode_data(inode)->file_plugin_data.unix_file_info; +} @@ -35333,7 +35787,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + uf_coord->valid = 0; +} + -+static void validate_extended_coord(uf_coord_t *uf_coord, loff_t offset) ++void validate_extended_coord(uf_coord_t *uf_coord, loff_t offset) +{ + assert("vs-1333", uf_coord->valid == 0); + @@ -35395,7 +35849,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * This is to be used by find_file_item and in find_file_state to + * determine real state of file + */ -+static void set_file_state(struct unix_file_info *uf_info, int cbk_result, ++static void set_file_state(unix_file_info_t *uf_info, int cbk_result, + tree_level level) +{ + if (cbk_errored(cbk_result)) @@ -35405,6 +35859,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + assert("vs-1164", level == LEAF_LEVEL || level == TWIG_LEVEL); + + if (uf_info->container == UF_CONTAINER_UNKNOWN) { ++ /* ++ * container is unknown, therefore conversion can not be in ++ * progress ++ */ ++ assert("", !inode_get_flag(unix_file_info_to_inode(uf_info), ++ REISER4_PART_IN_CONV)); + if (cbk_result == CBK_COORD_NOTFOUND) + uf_info->container = UF_CONTAINER_EMPTY; + else if (level == LEAF_LEVEL) @@ -35416,8 +35876,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * file state is known, check whether it is set correctly if + * file is not being tail converted + */ -+ if (!reiser4_inode_get_flag(unix_file_info_to_inode(uf_info), -+ REISER4_PART_IN_CONV)) { ++ if (!inode_get_flag(unix_file_info_to_inode(uf_info), ++ REISER4_PART_IN_CONV)) { + assert("vs-1162", + ergo(level == LEAF_LEVEL && + cbk_result == CBK_COORD_FOUND, @@ -35434,12 +35894,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + const reiser4_key *key, znode_lock_mode lock_mode, + struct inode *inode) +{ -+ return reiser4_object_lookup(inode, key, coord, lh, lock_mode, -+ FIND_MAX_NOT_MORE_THAN, -+ TWIG_LEVEL, LEAF_LEVEL, -+ (lock_mode == ZNODE_READ_LOCK) ? CBK_UNIQUE : -+ (CBK_UNIQUE | CBK_FOR_INSERT), -+ NULL /* ra_info */ ); ++ return object_lookup(inode, key, coord, lh, lock_mode, ++ FIND_MAX_NOT_MORE_THAN, ++ TWIG_LEVEL, LEAF_LEVEL, ++ (lock_mode == ZNODE_READ_LOCK) ? CBK_UNIQUE : ++ (CBK_UNIQUE | CBK_FOR_INSERT), ++ NULL /* ra_info */ ); +} + +/** @@ -35461,7 +35921,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + coord_t *coord; + lock_handle *lh; + -+ assert("nikita-3030", reiser4_schedulable()); ++ assert("nikita-3030", schedulable()); + assert("vs-1707", hint != NULL); + assert("vs-47", inode != NULL); + @@ -35488,7 +35948,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + set_file_state(unix_file_inode_data(inode), CBK_COORD_FOUND, + znode_get_level(coord->node)); -+ ++ + return CBK_COORD_FOUND; + } + @@ -35512,7 +35972,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + hint->ext_coord.lh = &hint->lh; +} + -+static int find_file_state(struct inode *inode, struct unix_file_info *uf_info) ++static int find_file_state(struct inode *inode, unix_file_info_t *uf_info) +{ + int result; + reiser4_key key; @@ -35534,7 +35994,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = 0; + assert("vs-1074", + ergo(result == 0, uf_info->container != UF_CONTAINER_UNKNOWN)); -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + return result; +} + @@ -35565,12 +36025,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + BA_CAN_COMMIT); +} + -+int reiser4_update_file_size(struct inode *inode, reiser4_key * key, -+ int update_sd) ++int update_file_size(struct inode *inode, reiser4_key * key, int update_sd) +{ + int result = 0; + -+ INODE_SET_SIZE(inode, get_key_offset(key)); ++ INODE_SET_FIELD(inode, i_size, get_key_offset(key)); + if (update_sd) { + inode->i_ctime = inode->i_mtime = CURRENT_TIME; + result = reiser4_update_sd(inode); @@ -35593,20 +36052,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + assert("vs-1248", + fplug == file_plugin_by_id(UNIX_FILE_PLUGIN_ID) || -+ fplug == file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); ++ fplug == file_plugin_by_id(CRC_FILE_PLUGIN_ID)); + + fplug->key_by_inode(inode, new_size, &from_key); + to_key = from_key; -+ set_key_offset(&to_key, cur_size - 1 /*get_key_offset(reiser4_max_key()) */ ); ++ set_key_offset(&to_key, cur_size - 1 /*get_key_offset(max_key()) */ ); + /* this loop normally runs just once */ + while (1) { -+ result = reserve_cut_iteration(reiser4_tree_by_inode(inode)); ++ result = reserve_cut_iteration(tree_by_inode(inode)); + if (result) + break; + -+ result = reiser4_cut_tree_object(current_tree, &from_key, &to_key, -+ &smallest_removed, inode, 1, -+ &progress); ++ result = cut_tree_object(current_tree, &from_key, &to_key, ++ &smallest_removed, inode, 1, ++ &progress); + if (result == -E_REPEAT) { + /* -E_REPEAT is a signal to interrupt a long file truncation process */ + if (progress) { @@ -35617,13 +36076,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + break; + } + -+ /* the below does up(sbinfo->delete_mutex). Do not get folled */ ++ /* the below does up(sbinfo->delete_sema). Do not get folled */ + reiser4_release_reserved(inode->i_sb); + -+ /* reiser4_cut_tree_object() was interrupted probably because ++ /* cut_tree_object() was interrupted probably because + * current atom requires commit, we have to release + * transaction handle to allow atom commit. */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + continue; + } + if (result @@ -35637,7 +36096,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + break; + } + -+ /* the below does up(sbinfo->delete_mutex). Do not get folled */ ++ /* the below does up(sbinfo->delete_sema). Do not get folled */ + reiser4_release_reserved(inode->i_sb); + + return result; @@ -35645,6 +36104,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + +int find_or_create_extent(struct page *page); + ++static int filler(void *vp, struct page *page) ++{ ++ return readpage_unix_file_nolock(vp, page); ++} ++ +/* part of truncate_file_body: it is called when truncate is used to make file + shorter */ +static int shorten_file(struct inode *inode, loff_t new_size) @@ -35653,16 +36117,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + struct page *page; + int padd_from; + unsigned long index; -+ struct unix_file_info *uf_info; ++ char *kaddr; ++ unix_file_info_t *uf_info; + + /* + * all items of ordinary reiser4 file are grouped together. That is why -+ * we can use reiser4_cut_tree. Plan B files (for instance) can not be ++ * we can use cut_tree. Plan B files (for instance) can not be + * truncated that simply + */ + result = cut_file_items(inode, new_size, 1 /*update_sd */ , -+ get_key_offset(reiser4_max_key()), -+ reiser4_update_file_size); ++ get_key_offset(max_key()), update_file_size); + if (result) + return result; + @@ -35688,7 +36152,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + /* file is truncated to page boundary */ + return 0; + -+ result = reserve_partial_page(reiser4_tree_by_inode(inode)); ++ result = reserve_partial_page(tree_by_inode(inode)); + if (result) { + reiser4_release_reserved(inode->i_sb); + return result; @@ -35696,10 +36160,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + /* last page is partially truncated - zero its content */ + index = (inode->i_size >> PAGE_CACHE_SHIFT); -+ page = read_mapping_page(inode->i_mapping, index, NULL); ++ page = read_cache_page(inode->i_mapping, index, filler, NULL); + if (IS_ERR(page)) { + /* -+ * the below does up(sbinfo->delete_mutex). Do not get ++ * the below does up(sbinfo->delete_sema). Do not get + * confused + */ + reiser4_release_reserved(inode->i_sb); @@ -35713,7 +36177,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (!PageUptodate(page)) { + page_cache_release(page); + /* -+ * the below does up(sbinfo->delete_mutex). Do not get ++ * the below does up(sbinfo->delete_sema). Do not get + * confused + */ + reiser4_release_reserved(inode->i_sb); @@ -35733,7 +36197,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (result) { + page_cache_release(page); + /* -+ * the below does up(sbinfo->delete_mutex). Do not get ++ * the below does up(sbinfo->delete_sema). Do not get + * confused + */ + reiser4_release_reserved(inode->i_sb); @@ -35742,10 +36206,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + lock_page(page); + assert("vs-1066", PageLocked(page)); -+ zero_user_page(page, padd_from, PAGE_CACHE_SIZE - padd_from, KM_USER0); ++ kaddr = kmap_atomic(page, KM_USER0); ++ memset(kaddr + padd_from, 0, PAGE_CACHE_SIZE - padd_from); ++ flush_dcache_page(page); ++ kunmap_atomic(kaddr, KM_USER0); + unlock_page(page); + page_cache_release(page); -+ /* the below does up(sbinfo->delete_mutex). Do not get confused */ ++ /* the below does up(sbinfo->delete_sema). Do not get confused */ + reiser4_release_reserved(inode->i_sb); + return 0; +} @@ -35758,7 +36225,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * Calls formatting plugin to see whether file of size @new_size has to be + * stored in unformatted nodes or in tail items. 0 is returned for later case. + */ -+static int should_have_notail(const struct unix_file_info *uf_info, loff_t new_size) ++static int should_have_notail(const unix_file_info_t *uf_info, loff_t new_size) +{ + if (!uf_info->tplug) + return 1; @@ -35784,7 +36251,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + /* expanding truncate */ + struct dentry dentry; + struct file file; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + dentry.d_inode = inode; + file.f_dentry = &dentry; @@ -35795,7 +36262,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = find_file_state(inode, uf_info); + if (result) + return result; -+ ++ + if (should_have_notail(uf_info, new_size)) { + /* + * file of size @new_size has to be built of @@ -35808,8 +36275,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * - wait until it completes + */ + while (1) { -+ if (reiser4_inode_get_flag(inode, -+ REISER4_PART_IN_CONV)) { ++ if (inode_get_flag(inode, REISER4_PART_IN_CONV)) { + drop_exclusive_access(uf_info); + schedule(); + get_exclusive_access(uf_info); @@ -35817,27 +36283,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + } + break; + } -+ ++ + if (uf_info->container == UF_CONTAINER_TAILS) { + result = tail2extent(uf_info); + if (result) + return result; + } + } -+ result = reiser4_write_extent(&file, NULL, 0, -+ &new_size); ++ result = write_extent(&file, NULL, 0, &new_size); + if (result) + return result; + uf_info->container = UF_CONTAINER_EXTENTS; + } else { + if (uf_info->container == UF_CONTAINER_EXTENTS) { -+ result = reiser4_write_extent(&file, NULL, 0, -+ &new_size); ++ result = write_extent(&file, NULL, 0, &new_size); + if (result) + return result; + } else { -+ result = reiser4_write_tail(&file, NULL, 0, -+ &new_size); ++ result = write_tail(&file, NULL, 0, &new_size); + if (result) + return result; + uf_info->container = UF_CONTAINER_TAILS; @@ -35877,7 +36340,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + return PTR_ERR(fsdata); + + spin_lock_inode(file->f_dentry->d_inode); -+ if (reiser4_seal_is_set(&fsdata->reg.hint.seal)) { ++ if (seal_is_set(&fsdata->reg.hint.seal)) { + *hint = fsdata->reg.hint; + init_lh(&hint->lh); + hint->ext_coord.lh = &hint->lh; @@ -35913,7 +36376,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + assert("edward-1337", hint != NULL); + -+ if (!file || !reiser4_seal_is_set(&hint->seal)) ++ if (!file || !seal_is_set(&hint->seal)) + return; + fsdata = reiser4_get_file_fsdata(file); + assert("vs-965", !IS_ERR(fsdata)); @@ -35926,23 +36389,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + return; +} + -+void reiser4_unset_hint(hint_t * hint) ++void unset_hint(hint_t * hint) +{ + assert("vs-1315", hint); + hint->ext_coord.valid = 0; -+ reiser4_seal_done(&hint->seal); ++ seal_done(&hint->seal); + done_lh(&hint->lh); +} + -+/* coord must be set properly. So, that reiser4_set_hint -+ has nothing to do */ -+void reiser4_set_hint(hint_t * hint, const reiser4_key * key, -+ znode_lock_mode mode) ++/* coord must be set properly. So, that set_hint has nothing to do */ ++void set_hint(hint_t * hint, const reiser4_key * key, znode_lock_mode mode) +{ + ON_DEBUG(coord_t * coord = &hint->ext_coord.coord); + assert("vs-1207", WITH_DATA(coord->node, check_coord(coord, key))); + -+ reiser4_seal_init(&hint->seal, &hint->ext_coord.coord, key); ++ seal_init(&hint->seal, &hint->ext_coord.coord, key); + hint->offset = get_key_offset(key); + hint->mode = mode; + done_lh(&hint->lh); @@ -35950,7 +36411,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + +int hint_is_set(const hint_t * hint) +{ -+ return reiser4_seal_is_set(&hint->seal); ++ return seal_is_set(&hint->seal); +} + +#if REISER4_DEBUG @@ -35964,7 +36425,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +} +#endif + -+static int ++int +hint_validate(hint_t * hint, const reiser4_key * key, int check_key, + znode_lock_mode lock_mode) +{ @@ -35979,14 +36440,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + return RETERR(-E_REPEAT); + + assert("vs-31", hint->ext_coord.lh == &hint->lh); -+ return reiser4_seal_validate(&hint->seal, &hint->ext_coord.coord, key, -+ hint->ext_coord.lh, lock_mode, -+ ZNODE_LOCK_LOPRI); ++ return seal_validate(&hint->seal, &hint->ext_coord.coord, key, ++ hint->ext_coord.lh, lock_mode, ZNODE_LOCK_LOPRI); +} + ++int xversion; ++ +/** -+ * find_or_create_extent - -+ * @page: ++ * find_or_create_extent - ++ * @page: + * + * + */ @@ -36005,35 +36467,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + lock_page(page); + node = jnode_of_page(page); -+ if (IS_ERR(node)) { -+ unlock_page(page); -+ return PTR_ERR(node); -+ } -+ JF_SET(node, JNODE_WRITE_PREPARED); + unlock_page(page); ++ if (IS_ERR(node)) ++ return PTR_ERR(node); + + if (node->blocknr == 0) { + plugged_hole = 0; -+ result = reiser4_update_extent(inode, node, page_offset(page), -+ &plugged_hole); ++ result = update_extent(inode, node, ++ (loff_t)page->index << PAGE_CACHE_SHIFT, ++ &plugged_hole); + if (result) { -+ JF_CLR(node, JNODE_WRITE_PREPARED); + jput(node); -+ warning("", "reiser4_update_extent failed: %d", result); ++ warning("", "update_extent failed: %d", result); + return result; + } + if (plugged_hole) + reiser4_update_sd(inode); + } else { + spin_lock_jnode(node); -+ result = reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); ++ result = try_capture(node, ZNODE_WRITE_LOCK, 0); + BUG_ON(result != 0); + jnode_make_dirty_locked(node); + spin_unlock_jnode(node); + } + + BUG_ON(node->atom == NULL); -+ JF_CLR(node, JNODE_WRITE_PREPARED); + jput(node); + + if (get_current_context()->entd) { @@ -36082,15 +36540,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + unix_file_inode_data(inode)->container == UF_CONTAINER_EXTENTS); + /* page belongs to file */ + assert("vs-1393", -+ inode->i_size > page_offset(page)); ++ inode->i_size > ((loff_t) page->index << PAGE_CACHE_SHIFT)); + + /* page capture may require extent creation (if it does not exist yet) + and stat data's update (number of blocks changes on extent + creation) */ + grab_space_enable(); -+ result = reiser4_grab_space(2 * estimate_one_insert_into_item -+ (reiser4_tree_by_inode(inode)), -+ BA_CAN_COMMIT); ++ result = ++ reiser4_grab_space(2 * ++ estimate_one_insert_into_item(tree_by_inode ++ (inode)), ++ BA_CAN_COMMIT); + if (likely(!result)) + result = find_or_create_extent(page); + @@ -36116,7 +36576,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + SetPageUptodate(page); + + inode = page->mapping->host; -+ ctx = reiser4_init_context(page->mapping->host->i_sb); ++ ctx = init_context(page->mapping->host->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + page_cache_get(page); @@ -36235,7 +36695,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + for (i = 0; i < pagevec_count(&pvec); i++) { + /* + * tag PAGECACHE_TAG_REISER4_MOVED will be cleared by -+ * reiser4_set_page_dirty_internal which is called when jnode is ++ * set_page_dirty_internal which is called when jnode is + * captured + */ + result = capture_anonymous_page(pvec.pages[i]); @@ -36322,7 +36782,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + } else + atom = NULL; + unlock_page(page); -+ result = reiser4_sync_atom(atom); ++ result = sync_atom(atom); + } while (result == -E_REPEAT); + /* + * ZAM-FIXME-HANS: document the logic of this loop, is it just to @@ -36379,7 +36839,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +static int commit_file_atoms(struct inode *inode) +{ + int result; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + uf_info = unix_file_inode_data(inode); + @@ -36398,7 +36858,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + switch (uf_info->container) { + case UF_CONTAINER_EXTENTS: + /* find_file_state might open join an atom */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + result = + /* + * when we are called by @@ -36438,7 +36898,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * commit current transaction: there can be captured nodes from + * find_file_state() and finish_conversion(). + */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + return result; +} + @@ -36455,7 +36915,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + struct writeback_control *wbc) +{ + int result; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + pgoff_t pindex, jindex, nr_pages; + long to_capture; + struct inode *inode; @@ -36465,10 +36925,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = 0; + goto end; + } -+ jindex = pindex = wbc->range_start >> PAGE_CACHE_SHIFT; ++ jindex = pindex = wbc->start >> PAGE_CACHE_SHIFT; + result = 0; -+ nr_pages = size_in_pages(i_size_read(inode)); -+ ++ nr_pages = ++ (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + uf_info = unix_file_inode_data(inode); + + do { @@ -36479,7 +36939,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + else + to_capture = CAPTURE_APAGE_BURST; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) { + result = PTR_ERR(ctx); + break; @@ -36490,7 +36950,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + assert("", LOCK_CNT_NIL(inode_sem_w)); + assert("", LOCK_CNT_NIL(inode_sem_r)); + -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + + /* we have to get nonexclusive access to the file */ + if (get_current_context()->entd) { @@ -36579,7 +37039,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * there are already pages to flush, flush them out, do + * not delay until end of reiser4_sync_inodes + */ -+ reiser4_writeout(inode->i_sb, wbc); ++ writeout(inode->i_sb, wbc); + get_current_context()->nr_captured = 0; + } + } @@ -36604,7 +37064,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + txn_atom *atom; + reiser4_block_nr reserve; + -+ ctx = reiser4_init_context(dentry->d_inode->i_sb); ++ ctx = init_context(dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -36630,7 +37090,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * Compose a key and search for item containing information about @page + * data. If item is found - its readpage method is called. + */ -+int readpage_unix_file(struct file *file, struct page *page) ++int readpage_unix_file_nolock(struct file *file, struct page *page) +{ + reiser4_context *ctx; + int result; @@ -36645,20 +37105,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + assert("vs-976", !PageUptodate(page)); + assert("vs-1061", page->mapping && page->mapping->host); + -+ if (page->mapping->host->i_size <= page_offset(page)) { ++ if ((page->mapping->host->i_size <= ++ ((loff_t) page->index << PAGE_CACHE_SHIFT))) { + /* page is out of file already */ + unlock_page(page); + return -EINVAL; + } + + inode = page->mapping->host; -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) { + unlock_page(page); + return PTR_ERR(ctx); + } + -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ hint = kmalloc(sizeof(*hint), get_gfp_mask()); + if (hint == NULL) { + unlock_page(page); + reiser4_exit_context(ctx); @@ -36675,7 +37136,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + lh = &hint->lh; + + /* get key of first byte of the page */ -+ key_by_inode_and_offset_common(inode, page_offset(page), &key); ++ key_by_inode_and_offset_common(inode, ++ (loff_t) page->index << PAGE_CACHE_SHIFT, ++ &key); + + /* look for file metadata corresponding to first byte of page */ + page_cache_get(page); @@ -36692,7 +37155,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + done_lh(lh); + kfree(hint); + unlock_page(page); -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return -EINVAL; + } @@ -36705,7 +37168,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + done_lh(lh); + kfree(hint); + unlock_page(page); -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return result; + } @@ -36718,7 +37181,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + done_lh(lh); + kfree(hint); + unlock_page(page); -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return 0; + } @@ -36729,12 +37192,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + done_lh(lh); + kfree(hint); + unlock_page(page); -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return result; + } + -+ validate_extended_coord(&hint->ext_coord, page_offset(page)); ++ validate_extended_coord(&hint->ext_coord, ++ (loff_t) page->index << PAGE_CACHE_SHIFT); + + if (!coord_is_existing_unit(coord)) { + /* this indicates corruption */ @@ -36747,7 +37211,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + done_lh(lh); + kfree(hint); + unlock_page(page); -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return RETERR(-EIO); + } @@ -36765,11 +37229,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (!result) { + set_key_offset(&key, + (loff_t) (page->index + 1) << PAGE_CACHE_SHIFT); -+ /* FIXME should call reiser4_set_hint() */ -+ reiser4_unset_hint(hint); ++ /* FIXME should call set_hint() */ ++ unset_hint(hint); + } else { + unlock_page(page); -+ reiser4_unset_hint(hint); ++ unset_hint(hint); + } + assert("vs-979", + ergo(result == 0, (PageLocked(page) || PageUptodate(page)))); @@ -36786,126 +37250,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * not be done when atom is not NULL because reiser4_writepage can not + * kick entd and have to eflush + */ -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + reiser4_exit_context(ctx); + return result; +} + -+struct uf_readpages_context { -+ lock_handle lh; -+ coord_t coord; -+}; -+ -+/* A callback function for readpages_unix_file/read_cache_pages. -+ * If the file is build of tails, then return error (-ENOENT). -+ * -+ * @data -- a pointer to reiser4_readpages_context object, -+ * to save the twig lock and the coord between -+ * read_cache_page iterations. -+ * @page -- page to start read. -+ */ -+static int uf_readpages_filler(void * data, struct page * page) -+{ -+ struct uf_readpages_context *rc = data; -+ jnode * node; -+ int ret = 0; -+ reiser4_extent *ext; -+ __u64 ext_index; -+ int cbk_done = 0; -+ struct address_space * mapping = page->mapping; -+ -+ if (PageUptodate(page)) { -+ unlock_page(page); -+ return 0; -+ } -+ page_cache_get(page); -+ -+ if (rc->lh.node == 0) { -+ /* no twig lock - have to do tree search. */ -+ reiser4_key key; -+ repeat: -+ unlock_page(page); -+ key_by_inode_and_offset_common( -+ mapping->host, page_offset(page), &key); -+ ret = coord_by_key( -+ &get_super_private(mapping->host->i_sb)->tree, -+ &key, &rc->coord, &rc->lh, -+ ZNODE_READ_LOCK, FIND_EXACT, -+ TWIG_LEVEL, TWIG_LEVEL, CBK_UNIQUE, NULL); -+ if (unlikely(ret)) -+ goto exit; -+ lock_page(page); -+ cbk_done = 1; -+ } -+ ret = zload(rc->coord.node); -+ if (unlikely(ret)) -+ goto unlock; -+ if (!coord_is_existing_item(&rc->coord) || -+ !item_is_extent(&rc->coord)) { -+ zrelse(rc->coord.node); -+ ret = RETERR(-EIO); -+ goto unlock; -+ } -+ ext = extent_by_coord(&rc->coord); -+ ext_index = extent_unit_index(&rc->coord); -+ if (page->index < ext_index || -+ page->index >= ext_index + extent_get_width(ext)) { -+ /* the page index doesn't belong to the extent unit -+ which the coord points to - release the lock and -+ repeat with tree search. */ -+ zrelse(rc->coord.node); -+ done_lh(&rc->lh); -+ /* we can be here after a CBK call only in case of -+ corruption of the tree or the tree lookup algorithm bug. */ -+ if (unlikely(cbk_done)) { -+ ret = RETERR(-EIO); -+ goto unlock; -+ } -+ goto repeat; -+ } -+ node = jnode_of_page(page); -+ if (unlikely(IS_ERR(node))) { -+ zrelse(rc->coord.node); -+ ret = PTR_ERR(node); -+ goto unlock; -+ } -+ ret = reiser4_do_readpage_extent(ext, page->index - ext_index, page); -+ jput(node); -+ zrelse(rc->coord.node); -+ if (likely(!ret)) -+ goto exit; -+ unlock: -+ unlock_page(page); -+ exit: -+ page_cache_release(page); -+ return ret; -+} -+ +/** -+ * readpages_unix_file - called by the readahead code, starts reading for each -+ * page of given list of pages ++ * readpage_unix_file - readpage of struct address_space_operations ++ * @file: file @page belongs to ++ * @page: page to read ++ * ++ * Get non exclusive access to a file to avoid races with truncate. If page is ++ * out of file - return error. Call readpage_unix_file_nolock to do the rest. + */ -+int readpages_unix_file( -+ struct file *file, struct address_space *mapping, -+ struct list_head *pages, unsigned nr_pages) ++int readpage_unix_file(struct file *file, struct page *page) +{ -+ reiser4_context *ctx; -+ struct uf_readpages_context rc; -+ int ret; -+ -+ ctx = reiser4_init_context(mapping->host->i_sb); -+ if (IS_ERR(ctx)) { -+ put_pages_list(pages); -+ return PTR_ERR(ctx); -+ } -+ init_lh(&rc.lh); -+ ret = read_cache_pages(mapping, pages, uf_readpages_filler, &rc); -+ done_lh(&rc.lh); -+ context_set_commit_async(ctx); -+ /* close the transaction to protect further page allocation from deadlocks */ -+ reiser4_txn_restart(ctx); -+ reiser4_exit_context(ctx); -+ return ret; ++ return readpage_unix_file_nolock(file, page); +} + +static reiser4_block_nr unix_file_estimate_read(struct inode *inode, @@ -36920,10 +37280,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +} + +/* this is called with nonexclusive access obtained, file's container can not change */ -+static ssize_t read_file(hint_t *hint, struct file *file, /* file to read from to */ -+ char __user *buf, /* address of user-space buffer */ -+ size_t count, /* number of bytes to read */ -+ loff_t *off) ++static size_t read_file(hint_t * hint, struct file *file, /* file to read from to */ ++ char __user *buf, /* address of user-space buffer */ ++ size_t count, /* number of bytes to read */ ++ loff_t * off) +{ + int result; + struct inode *inode; @@ -36986,8 +37346,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + return (count - flow.length) ? (count - flow.length) : result; +} + -+static ssize_t read_unix_file_container_tails(struct file*, char __user*, size_t, loff_t*); -+ +/** + * read_unix_file - read of struct file_operations + * @file: file to read from @@ -37002,9 +37360,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + loff_t *off) +{ + reiser4_context *ctx; -+ ssize_t result; ++ int result; + struct inode *inode; -+ struct unix_file_info *uf_info; ++ hint_t *hint; ++ unix_file_info_t *uf_info; ++ size_t count, read, left; ++ reiser4_block_nr needed; ++ loff_t size; + + if (unlikely(read_amount == 0)) + return 0; @@ -37012,62 +37374,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + assert("umka-072", file != NULL); + assert("umka-074", off != NULL); + inode = file->f_dentry->d_inode; -+ assert("vs-972", !reiser4_inode_get_flag(inode, REISER4_NO_SD)); ++ assert("vs-972", !inode_get_flag(inode, REISER4_NO_SD)); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); -+ uf_info = unix_file_inode_data(inode); -+ if (uf_info->container == UF_CONTAINER_UNKNOWN) { -+ get_exclusive_access(uf_info); -+ result = find_file_state(inode, uf_info); -+ if (unlikely(result != 0)) -+ goto out; -+ } else -+ get_nonexclusive_access(uf_info); -+ result = reiser4_grab_space_force(unix_file_estimate_read(inode, read_amount), -+ BA_CAN_COMMIT); -+ if (unlikely(result != 0)) -+ goto out; -+ if (uf_info->container == UF_CONTAINER_EXTENTS){ -+ result = do_sync_read(file, buf, read_amount, off); -+ } else if (uf_info->container == UF_CONTAINER_TAILS || -+ reiser4_inode_get_flag(inode, REISER4_PART_IN_CONV) || -+ reiser4_inode_get_flag(inode, REISER4_PART_MIXED)) { -+ result = read_unix_file_container_tails(file, buf, read_amount, off); -+ } else { -+ assert("zam-1085", uf_info->container == UF_CONTAINER_EMPTY); -+ result = 0; -+ } -+out: -+ drop_access(uf_info); -+ context_set_commit_async(ctx); -+ reiser4_exit_context(ctx); -+ return result; -+} + -+static ssize_t read_unix_file_container_tails( -+ struct file *file, char __user *buf, size_t read_amount, loff_t *off) -+{ -+ int result; -+ struct inode *inode; -+ hint_t *hint; -+ struct unix_file_info *uf_info; -+ size_t count, read, left; -+ loff_t size; -+ -+ assert("umka-072", file != NULL); -+ assert("umka-074", off != NULL); -+ inode = file->f_dentry->d_inode; -+ assert("vs-972", !reiser4_inode_get_flag(inode, REISER4_NO_SD)); -+ -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); -+ if (hint == NULL) ++ hint = kmalloc(sizeof(*hint), get_gfp_mask()); ++ if (hint == NULL) { ++ context_set_commit_async(ctx); ++ reiser4_exit_context(ctx); + return RETERR(-ENOMEM); ++ } + + result = load_file_hint(file, hint); + if (result) { + kfree(hint); ++ context_set_commit_async(ctx); ++ reiser4_exit_context(ctx); + return result; + } + @@ -37075,21 +37399,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + count = 0; + uf_info = unix_file_inode_data(inode); + while (left > 0) { -+ reiser4_txn_restart_current(); ++ txn_restart_current(); ++ ++ get_nonexclusive_access(uf_info); ++ + size = i_size_read(inode); -+ if (*off >= size) ++ if (*off >= size) { + /* position to read from is past the end of file */ ++ drop_nonexclusive_access(uf_info); + break; ++ } + if (*off + left > size) + left = size - *off; ++ + /* faultin user page */ -+ result = fault_in_pages_writeable(buf, left > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : left); -+ if (result) -+ return RETERR(-EFAULT); ++ if(fault_in_pages_writeable(buf, left > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : left)) { ++ drop_nonexclusive_access(uf_info); ++ result = RETERR(-EFAULT); ++ break; ++ } + + read = read_file(hint, file, buf, + left > PAGE_CACHE_SIZE ? PAGE_CACHE_SIZE : left, + off); ++ ++ drop_nonexclusive_access(uf_info); ++ + if (read < 0) { + result = read; + break; @@ -37102,11 +37437,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + /* total number of read bytes */ + count += read; + } -+ done_lh(&hint->lh); + save_file_hint(file, hint); ++ done_lh(&hint->lh); + kfree(hint); -+ if (count) -+ file_accessed(file); ++ ++ if (count) { ++ /* ++ * something was read. Grab space for stat data update and ++ * update atime ++ */ ++ needed = unix_file_estimate_read(inode, read_amount); ++ result = reiser4_grab_space_force(needed, BA_CAN_COMMIT); ++ if (result == 0) ++ file_accessed(file); ++ else ++ warning("", "failed to grab space for atime update"); ++ } ++ ++ context_set_commit_async(ctx); ++ reiser4_exit_context(ctx); ++ + /* return number of read bytes or error code if nothing is read */ + return count ? count : result; +} @@ -37143,17 +37493,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + reiser4_context *ctx; + int result; + struct inode *inode; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + reiser4_block_nr needed; + + inode = file->f_dentry->d_inode; -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + uf_info = unix_file_inode_data(inode); + -+ get_exclusive_access_careful(uf_info, inode); ++ down(&uf_info->write); ++ get_exclusive_access(uf_info); + + if (!IS_RDONLY(inode) && (vma->vm_flags & (VM_MAYWRITE | VM_SHARED))) { + /* @@ -37164,6 +37515,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = find_file_state(inode, uf_info); + if (result != 0) { + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + reiser4_exit_context(ctx); + return result; + } @@ -37179,6 +37531,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = check_pages_unix_file(file, inode); + if (result) { + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + reiser4_exit_context(ctx); + return result; + } @@ -37193,6 +37546,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = reiser4_grab_space_force(needed, BA_CAN_COMMIT); + if (result) { + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + reiser4_exit_context(ctx); + return result; + } @@ -37200,10 +37554,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = generic_file_mmap(file, vma); + if (result == 0) { + /* mark file as having mapping. */ -+ reiser4_inode_set_flag(inode, REISER4_HAS_MMAP); ++ inode_set_flag(inode, REISER4_HAS_MMAP); + } + + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + reiser4_exit_context(ctx); + return result; +} @@ -37255,23 +37610,36 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +{ + int result; + reiser4_context *ctx; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + if (IS_RDONLY(inode)) + return 0; + -+ if (!reiser4_inode_get_flag(inode, REISER4_PART_MIXED)) ++ if (!inode_get_flag(inode, REISER4_PART_MIXED)) + return 0; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + uf_info = unix_file_inode_data(inode); ++ get_exclusive_access(uf_info); + -+ get_exclusive_access_careful(uf_info, inode); ++ /* ++ * it may happen that another process is doing tail conversion. Wait ++ * until it completes ++ */ ++ while (1) { ++ if (inode_get_flag(inode, REISER4_PART_IN_CONV)) { ++ drop_exclusive_access(uf_info); ++ schedule(); ++ get_exclusive_access(uf_info); ++ continue; ++ } ++ break; ++ } + -+ if (!reiser4_inode_get_flag(inode, REISER4_PART_MIXED)) { ++ if (!inode_get_flag(inode, REISER4_PART_MIXED)) { + /* + * other process completed the conversion + */ @@ -37302,9 +37670,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = -EIO; + + assert("vs-1712", -+ ergo(result == 0, -+ (!reiser4_inode_get_flag(inode, REISER4_PART_MIXED) && -+ !reiser4_inode_get_flag(inode, REISER4_PART_IN_CONV)))); ++ ergo(result == 0, (!inode_get_flag(inode, REISER4_PART_MIXED) && ++ !inode_get_flag(inode, REISER4_PART_IN_CONV)))); + drop_exclusive_access(uf_info); + reiser4_exit_context(ctx); + return result; @@ -37314,7 +37681,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +#define EA_OBTAINED 1 +#define NEA_OBTAINED 2 + -+static void drop_access(struct unix_file_info *uf_info) ++static void drop_access(unix_file_info_t *uf_info) +{ + if (uf_info->exclusive_use) + drop_exclusive_access(uf_info); @@ -37325,6 +37692,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +#define debug_wuf(format, ...) printk("%s: %d: %s: " format "\n", \ + __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__) + ++void balance_dirty_pages(struct address_space *mapping); ++ +/** + * write_unix_file - write of struct file_operations + * @file: file to write to @@ -37341,7 +37710,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + int result; + reiser4_context *ctx; + struct inode *inode; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + ssize_t written; + int try_free_space; + int to_write = PAGE_CACHE_SIZE * WRITE_GRANULARITY; @@ -37352,14 +37721,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + loff_t new_size; + + inode = file->f_dentry->d_inode; -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + mutex_lock(&inode->i_mutex); + -+ assert("vs-947", !reiser4_inode_get_flag(inode, REISER4_NO_SD)); -+ assert("vs-9471", (!reiser4_inode_get_flag(inode, REISER4_PART_MIXED))); ++ assert("vs-947", !inode_get_flag(inode, REISER4_NO_SD)); ++ assert("vs-9471", (!inode_get_flag(inode, REISER4_PART_MIXED))); + + /* check amount of bytes to write and writing position */ + result = generic_write_checks(file, pos, &count, 0); @@ -37377,8 +37746,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + reiser4_exit_context(ctx); + return result; + } -+ /* remove_suid might create a transaction */ -+ reiser4_txn_restart(ctx); + + uf_info = unix_file_inode_data(inode); + @@ -37426,13 +37793,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + /* either EA or NEA is obtained. Choose item write method */ + if (uf_info->container == UF_CONTAINER_EXTENTS) { + /* file is built of extent items */ -+ write_op = reiser4_write_extent; ++ write_op = write_extent; + } else if (uf_info->container == UF_CONTAINER_EMPTY) { + /* file is empty */ + if (should_have_notail(uf_info, new_size)) -+ write_op = reiser4_write_extent; ++ write_op = write_extent; + else -+ write_op = reiser4_write_tail; ++ write_op = write_tail; + } else { + /* file is built of tail items */ + if (should_have_notail(uf_info, new_size)) { @@ -37447,15 +37814,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * process - wait until it completes + */ + while (1) { -+ if (reiser4_inode_get_flag(inode, -+ REISER4_PART_IN_CONV)) { ++ if (inode_get_flag(inode, REISER4_PART_IN_CONV)) { + drop_exclusive_access(uf_info); + schedule(); + get_exclusive_access(uf_info); + continue; + } + break; -+ } ++ } + if (uf_info->container == UF_CONTAINER_TAILS) { + result = tail2extent(uf_info); + if (result) @@ -37466,7 +37832,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + ea = NEITHER_OBTAINED; + continue; + } -+ write_op = reiser4_write_tail; ++ write_op = write_tail; + } + + written = write_op(file, buf, to_write, pos); @@ -37484,14 +37850,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + /* something is written. */ + if (uf_info->container == UF_CONTAINER_EMPTY) { + assert("", ea == EA_OBTAINED); -+ uf_info->container = -+ (write_op == reiser4_write_extent) ? ++ uf_info->container = (write_op == write_extent) ? + UF_CONTAINER_EXTENTS : UF_CONTAINER_TAILS; + } else { + assert("", ergo(uf_info->container == UF_CONTAINER_EXTENTS, -+ write_op == reiser4_write_extent)); ++ write_op == write_extent)); + assert("", ergo(uf_info->container == UF_CONTAINER_TAILS, -+ write_op == reiser4_write_tail)); ++ write_op == write_tail)); + } + if (*pos + written > inode->i_size) + INODE_SET_FIELD(inode, i_size, *pos + written); @@ -37507,14 +37872,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + } + drop_access(uf_info); + ea = NEITHER_OBTAINED; -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + current->journal_info = NULL; + /* + * tell VM how many pages were dirtied. Maybe number of pages + * which were dirty already should not be counted + */ -+ balance_dirty_pages_ratelimited_nr(inode->i_mapping, -+ (written + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE); ++ balance_dirty_pages(inode->i_mapping); + current->journal_info = ctx; + + left -= written; @@ -37525,7 +37889,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + mutex_unlock(&inode->i_mutex); + + if (result == 0 && ((file->f_flags & O_SYNC) || IS_SYNC(inode))) { -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + grab_space_enable(); + result = sync_unix_file(file, file->f_dentry, + 0 /* data and stat data */ ); @@ -37558,13 +37922,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +int release_unix_file(struct inode *inode, struct file *file) +{ + reiser4_context *ctx; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + int result; + int in_reiser4; + + in_reiser4 = is_in_reiser4_context(); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -37572,7 +37936,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (in_reiser4 == 0) { + uf_info = unix_file_inode_data(inode); + -+ get_exclusive_access_careful(uf_info, inode); ++ down(&uf_info->write); ++ get_exclusive_access(uf_info); + if (atomic_read(&file->f_dentry->d_count) == 1 && + uf_info->container == UF_CONTAINER_EXTENTS && + !should_have_notail(uf_info, inode->i_size) && @@ -37587,6 +37952,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + } + } + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + } else { + /* + we are within reiser4 context already. How latter is @@ -37610,7 +37976,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + #15 0xc01131e5 in do_page_fault () + #16 0xc0104935 in error_code () + #17 0xc025c0c6 in __copy_to_user_ll () -+ #18 0xc01d496f in reiser4_read_tail () ++ #18 0xc01d496f in read_tail () + #19 0xc01e4def in read_unix_file () + #20 0xc01c3504 in reiser4_read () + #21 0xc014bd4f in vfs_read () @@ -37632,14 +37998,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + state = reiser4_inode_data(inode); + tplug = formatting_plugin_by_id(NEVER_TAILS_FORMATTING_ID); -+ force_plugin_pset(inode, PSET_FORMATTING, (reiser4_plugin *)tplug); ++ plugin_set_formatting(&state->pset, tplug); ++ inode_set_plugin(inode, ++ formatting_plugin_to_plugin(tplug), PSET_FORMATTING); +} + +/* if file is built of tails - convert it to extents */ +static int unpack(struct file *filp, struct inode *inode, int forever) +{ + int result = 0; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + uf_info = unix_file_inode_data(inode); + assert("vs-1628", ea_obtained(uf_info)); @@ -37655,8 +38023,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * completes + */ + while (1) { -+ if (reiser4_inode_get_flag(inode, -+ REISER4_PART_IN_CONV)) { ++ if (inode_get_flag(inode, REISER4_PART_IN_CONV)) { + drop_exclusive_access(uf_info); + schedule(); + get_exclusive_access(uf_info); @@ -37673,15 +38040,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (forever) { + /* safe new formatting plugin in stat data */ + __u64 tograb; -+ ++ + set_file_notail(inode); -+ ++ + grab_space_enable(); + tograb = inode_file_plugin(inode)->estimate.update(inode); + result = reiser4_grab_space(tograb, BA_CAN_COMMIT); + result = reiser4_update_sd(inode); + } -+ ++ + return result; +} + @@ -37695,7 +38062,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + reiser4_context *ctx; + int result; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -37730,7 +38097,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + inode = mapping->host; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + key_by_inode_and_offset_common(inode, @@ -37803,7 +38170,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + plugin->u.file.create_blank_sd = NULL */ +/* plugin->u.file.delete */ +/* -+ plugin->u.file.add_link = reiser4_add_link_common ++ plugin->u.file.add_link = add_link_common + plugin->u.file.rem_link = NULL */ + +/* plugin->u.file.owns_item @@ -37818,8 +38185,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + result = owns_item_common(inode, coord); + if (!result) + return 0; -+ if (!plugin_of_group(item_plugin_by_coord(coord), -+ UNIX_FILE_METADATA_ITEM_TYPE)) ++ if (item_type_by_coord(coord) != UNIX_FILE_METADATA_ITEM_TYPE) + return 0; + assert("vs-547", + item_id_by_coord(coord) == EXTENT_POINTER_ID || @@ -37837,7 +38203,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + inode_check_scale(inode, inode->i_size, attr->ia_size); + + old_size = inode->i_size; -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + + result = safe_link_grab(tree, BA_CAN_COMMIT); + if (result == 0) @@ -37872,22 +38238,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + + if (attr->ia_valid & ATTR_SIZE) { + reiser4_context *ctx; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + /* truncate does reservation itself and requires exclusive + access obtained */ -+ ctx = reiser4_init_context(dentry->d_inode->i_sb); ++ ctx = init_context(dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + uf_info = unix_file_inode_data(dentry->d_inode); -+ get_exclusive_access_careful(uf_info, dentry->d_inode); ++ down(&uf_info->write); ++ get_exclusive_access(uf_info); + result = setattr_truncate(dentry->d_inode, attr); + drop_exclusive_access(uf_info); ++ up(&uf_info->write); + context_set_commit_async(ctx); + reiser4_exit_context(ctx); + } else -+ result = reiser4_setattr_common(dentry, attr); ++ result = setattr_common(dentry, attr); + + return result; +} @@ -37897,11 +38265,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser +init_inode_data_unix_file(struct inode *inode, + reiser4_object_create_data * crd, int create) +{ -+ struct unix_file_info *data; ++ unix_file_info_t *data; + + data = unix_file_inode_data(inode); + data->container = create ? UF_CONTAINER_EMPTY : UF_CONTAINER_UNKNOWN; + init_rwsem(&data->latch); ++ sema_init(&data->write, 1); + data->tplug = inode_formatting_plugin(inode); + data->exclusive_use = 0; + @@ -37920,10 +38289,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + */ +int delete_object_unix_file(struct inode *inode) +{ -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + int result; + -+ if (reiser4_inode_get_flag(inode, REISER4_NO_SD)) ++ if (inode_get_flag(inode, REISER4_NO_SD)) + return 0; + + /* truncate file bogy first */ @@ -37937,7 +38306,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + get_inode_oid(inode), result); + + /* remove stat data and safe link */ -+ return reiser4_delete_object_common(inode); ++ return delete_object_common(inode); +} + +/** @@ -37958,10 +38327,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + reiser4_context *ctx; + ssize_t result; + struct inode *inode; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + inode = file->f_dentry->d_inode; -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -37974,7 +38343,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + if (result) + goto error; + mutex_lock(&inode->i_mutex); -+ reiser4_inode_set_flag(inode, REISER4_HAS_MMAP); ++ inode_set_flag(inode, REISER4_HAS_MMAP); + mutex_unlock(&inode->i_mutex); + + uf_info = unix_file_inode_data(inode); @@ -37991,10 +38360,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + unsigned from, unsigned to) +{ + reiser4_context *ctx; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + int ret; + -+ ctx = reiser4_init_context(file->f_dentry->d_inode->i_sb); ++ ctx = init_context(file->f_dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -38025,629 +38394,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.c linux-2.6.22/fs/reiser + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file_conversion.c linux-2.6.22/fs/reiser4/plugin/file/file_conversion.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/file_conversion.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/file_conversion.c 2007-07-29 00:25:34.928709936 +0400 -@@ -0,0 +1,609 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, -+ licensing governed by reiser4/README */ -+ -+/* This file contains hooks that converts (*) cryptcompress files to unix-files, -+ and a set of protected (**) methods of a cryptcompress file plugin to perform -+ such conversion. -+ -+(*) -+ The conversion is performed for incompressible files to reduce cpu and memory -+ usage. If first logical cluster (64K by default) of a file is incompressible, -+ then we make a desicion, that the whole file is incompressible. -+ The conversion can be enabled via installing a special compression mode -+ plugin (CONVX_COMPRESSION_MODE_ID, see plugin/compress/compress_mode.c for -+ details). -+ -+(**) -+ The protection means serialization of critical sections (readers and writers -+ of @pset->file) -+*/ -+ -+#include "../../inode.h" -+#include "../cluster.h" -+#include "file.h" -+ -+#define conversion_enabled(inode) \ -+ (inode_compression_mode_plugin(inode) == \ -+ compression_mode_plugin_by_id(CONVX_COMPRESSION_MODE_ID)) -+ -+ -+/* Located sections (readers and writers of @pset->file) are not -+ permanently critical: cryptcompress file can be converted only -+ if the conversion is enabled (see the macrio above). And we don't -+ convert unix files at all. -+ The following helper macro is a sanity check to decide if we -+ need to protect a located section. -+*/ -+#define should_protect(inode) \ -+ (inode_file_plugin(inode) == \ -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID) && \ -+ conversion_enabled(inode)) -+ -+/* All protected methods have prefix "prot" in their names. -+ It is convenient to construct them by usual (unprotected) ones -+ using the following common macros: -+*/ -+ -+/* Macro for passive protection. -+ method_cryptcompress contains only readers */ -+#define PROT_PASSIVE(type, method, args) \ -+({ \ -+ type _result; \ -+ struct rw_semaphore * guard = \ -+ &reiser4_inode_data(inode)->conv_sem; \ -+ \ -+ if (should_protect(inode)) { \ -+ down_read(guard); \ -+ if (!should_protect(inode)) \ -+ up_read(guard); \ -+ } \ -+ if (inode_file_plugin(inode) == \ -+ file_plugin_by_id(UNIX_FILE_PLUGIN_ID)) \ -+ _result = method ## _unix_file args; \ -+ else \ -+ _result = method ## _cryptcompress args; \ -+ if (should_protect(inode)) \ -+ up_read(guard); \ -+ _result; \ -+}) -+ -+#define PROT_PASSIVE_VOID(method, args) \ -+({ \ -+ struct rw_semaphore * guard = \ -+ &reiser4_inode_data(inode)->conv_sem; \ -+ \ -+ if (should_protect(inode)) { \ -+ down_read(guard); \ -+ if (!should_protect(inode)) \ -+ up_read(guard); \ -+ } \ -+ if (inode_file_plugin(inode) == \ -+ file_plugin_by_id(UNIX_FILE_PLUGIN_ID)) \ -+ method ## _unix_file args; \ -+ else \ -+ method ## _cryptcompress args; \ -+ if (should_protect(inode)) \ -+ up_read(guard); \ -+}) -+ -+/* Macro for active protection. -+ active_expr contains readers and writers; after its -+ evaluation conversion should be disabled */ -+#define PROT_ACTIVE(type, method, args, active_expr) \ -+({ \ -+ type _result = 0; \ -+ struct rw_semaphore * guard = \ -+ &reiser4_inode_data(inode)->conv_sem; \ -+ reiser4_context * ctx = reiser4_init_context(inode->i_sb); \ -+ if (IS_ERR(ctx)) \ -+ return PTR_ERR(ctx); \ -+ \ -+ if (should_protect(inode)) { \ -+ down_write(guard); \ -+ if (should_protect(inode)) \ -+ _result = active_expr; \ -+ up_write(guard); \ -+ } \ -+ if (_result == 0) { \ -+ if (inode_file_plugin(inode) == \ -+ file_plugin_by_id(UNIX_FILE_PLUGIN_ID)) \ -+ _result = method ## _unix_file args; \ -+ else \ -+ _result = method ## _cryptcompress args; \ -+ } \ -+ reiser4_exit_context(ctx); \ -+ _result; \ -+}) -+ -+/* Pass management to the unix-file plugin with "notail" policy */ -+static int __cryptcompress2unixfile(struct file *file, struct inode * inode) -+{ -+ int result; -+ reiser4_inode *info; -+ struct unix_file_info * uf; -+ info = reiser4_inode_data(inode); -+ -+ result = aset_set_unsafe(&info->pset, -+ PSET_FILE, -+ (reiser4_plugin *) -+ file_plugin_by_id(UNIX_FILE_PLUGIN_ID)); -+ if (result) -+ return result; -+ result = aset_set_unsafe(&info->pset, -+ PSET_FORMATTING, -+ (reiser4_plugin *) -+ formatting_plugin_by_id(NEVER_TAILS_FORMATTING_ID)); -+ if (result) -+ return result; -+ /* get rid of non-standard plugins */ -+ info->plugin_mask &= ~cryptcompress_mask; -+ /* get rid of plugin stat-data extension */ -+ info->extmask &= ~(1 << PLUGIN_STAT); -+ -+ reiser4_inode_clr_flag(inode, REISER4_SDLEN_KNOWN); -+ -+ /* FIXME use init_inode_data_unix_file() instead, -+ but aviod init_inode_ordering() */ -+ /* Init unix-file specific part of inode */ -+ uf = unix_file_inode_data(inode); -+ uf->container = UF_CONTAINER_UNKNOWN; -+ init_rwsem(&uf->latch); -+ uf->tplug = inode_formatting_plugin(inode); -+ uf->exclusive_use = 0; -+#if REISER4_DEBUG -+ uf->ea_owner = NULL; -+ atomic_set(&uf->nr_neas, 0); -+#endif -+ inode->i_op = -+ &file_plugin_by_id(UNIX_FILE_PLUGIN_ID)->inode_ops; -+ inode->i_fop = -+ &file_plugin_by_id(UNIX_FILE_PLUGIN_ID)->file_ops; -+ inode->i_mapping->a_ops = -+ &file_plugin_by_id(UNIX_FILE_PLUGIN_ID)->as_ops; -+ file->f_op = inode->i_fop; -+ return 0; -+} -+ -+#if REISER4_DEBUG -+static int disabled_conversion_inode_ok(struct inode * inode) -+{ -+ __u64 extmask = reiser4_inode_data(inode)->extmask; -+ __u16 plugin_mask = reiser4_inode_data(inode)->plugin_mask; -+ -+ return ((extmask & (1 << LIGHT_WEIGHT_STAT)) && -+ (extmask & (1 << UNIX_STAT)) && -+ (extmask & (1 << LARGE_TIMES_STAT)) && -+ (extmask & (1 << PLUGIN_STAT)) && -+ (plugin_mask & (1 << PSET_COMPRESSION_MODE))); -+} -+#endif -+ -+/* Assign another mode that will control -+ compression at flush time only */ -+static int disable_conversion_no_update_sd(struct inode * inode) -+{ -+ int result; -+ result = -+ force_plugin_pset(inode, -+ PSET_COMPRESSION_MODE, -+ (reiser4_plugin *)compression_mode_plugin_by_id -+ (LATTD_COMPRESSION_MODE_ID)); -+ assert("edward-1500", -+ ergo(!result, disabled_conversion_inode_ok(inode))); -+ return result; -+} -+ -+/* Disable future attempts to check/convert. This function is called by -+ conversion hooks. */ -+static int disable_conversion(struct inode * inode) -+{ -+ return disable_conversion_no_update_sd(inode); -+} -+ -+static int check_position(struct inode * inode, -+ loff_t pos /* position in the file to write from */, -+ struct cluster_handle * clust, -+ int * check_compress) -+{ -+ assert("edward-1505", conversion_enabled(inode)); -+ /* -+ * if file size is more then cluster size, then compressible -+ * status must be figured out (i.e. compression was disabled, -+ * or file plugin was converted to unix_file) -+ */ -+ assert("edward-1506", inode->i_size <= inode_cluster_size(inode)); -+ -+ if (pos > inode->i_size) -+ /* first logical cluster will contain a (partial) hole */ -+ return disable_conversion(inode); -+ if (pos < inode_cluster_size(inode)) -+ /* writing to the first logical cluster */ -+ return 0; -+ /* -+ * here we have: -+ * cluster_size <= pos <= i_size <= cluster_size, -+ * and, hence, pos == i_size == cluster_size -+ */ -+ assert("edward-1498", -+ pos == inode->i_size && -+ pos == inode_cluster_size(inode)); -+ -+ *check_compress = 1; -+ return 0; -+} -+ -+static void start_check_compressibility(struct inode * inode, -+ struct cluster_handle * clust, -+ hint_t * hint) -+{ -+ assert("edward-1507", clust->index == 1); -+ assert("edward-1508", !tfm_cluster_is_uptodate(&clust->tc)); -+ assert("edward-1509", cluster_get_tfm_act(&clust->tc) == TFMA_READ); -+ -+ hint_init_zero(hint); -+ clust->hint = hint; -+ clust->index --; -+ clust->nr_pages = size_in_pages(lbytes(clust->index, inode)); -+ -+ /* first logical cluster (of index #0) must be complete */ -+ assert("edward-1510", lbytes(clust->index, inode) == -+ inode_cluster_size(inode)); -+} -+ -+static void finish_check_compressibility(struct inode * inode, -+ struct cluster_handle * clust, -+ hint_t * hint) -+{ -+ reiser4_unset_hint(clust->hint); -+ clust->hint = hint; -+ clust->index ++; -+} -+ -+#if REISER4_DEBUG -+static int prepped_dclust_ok(hint_t * hint) -+{ -+ reiser4_key key; -+ coord_t * coord = &hint->ext_coord.coord; -+ -+ item_key_by_coord(coord, &key); -+ return (item_id_by_coord(coord) == CTAIL_ID && -+ !coord_is_unprepped_ctail(coord) && -+ (get_key_offset(&key) + nr_units_ctail(coord) == -+ dclust_get_extension_dsize(hint))); -+} -+#endif -+ -+#define fifty_persent(size) (size >> 1) -+/* evaluation of data compressibility */ -+#define data_is_compressible(osize, isize) \ -+ (osize < fifty_persent(isize)) -+ -+/* This is called only once per file life. -+ Read first logical cluster (of index #0) and estimate its compressibility. -+ Save estimation result in @compressible */ -+static int read_check_compressibility(struct inode * inode, -+ struct cluster_handle * clust, -+ int * compressible) -+{ -+ int i; -+ int result; -+ __u32 dst_len; -+ hint_t tmp_hint; -+ hint_t * cur_hint = clust->hint; -+ -+ start_check_compressibility(inode, clust, &tmp_hint); -+ -+ reset_cluster_pgset(clust, cluster_nrpages(inode)); -+ result = grab_page_cluster(inode, clust, READ_OP); -+ if (result) -+ return result; -+ /* Read page cluster here */ -+ for (i = 0; i < clust->nr_pages; i++) { -+ struct page *page = clust->pages[i]; -+ lock_page(page); -+ result = do_readpage_ctail(inode, clust, page, -+ ZNODE_READ_LOCK); -+ unlock_page(page); -+ if (result) -+ goto error; -+ } -+ tfm_cluster_clr_uptodate(&clust->tc); -+ -+ cluster_set_tfm_act(&clust->tc, TFMA_WRITE); -+ -+ if (hint_is_valid(&tmp_hint) && !hint_is_unprepped_dclust(&tmp_hint)) { -+ /* lenght of compressed data is known, no need to compress */ -+ assert("edward-1511", -+ znode_is_any_locked(tmp_hint.lh.node)); -+ assert("edward-1512", -+ WITH_DATA(tmp_hint.ext_coord.coord.node, -+ prepped_dclust_ok(&tmp_hint))); -+ dst_len = dclust_get_extension_dsize(&tmp_hint); -+ } -+ else { -+ struct tfm_cluster * tc = &clust->tc; -+ compression_plugin * cplug = inode_compression_plugin(inode); -+ result = grab_tfm_stream(inode, tc, INPUT_STREAM); -+ if (result) -+ goto error; -+ for (i = 0; i < clust->nr_pages; i++) { -+ char *data; -+ lock_page(clust->pages[i]); -+ BUG_ON(!PageUptodate(clust->pages[i])); -+ data = kmap(clust->pages[i]); -+ memcpy(tfm_stream_data(tc, INPUT_STREAM) + pg_to_off(i), -+ data, PAGE_CACHE_SIZE); -+ kunmap(clust->pages[i]); -+ unlock_page(clust->pages[i]); -+ } -+ result = grab_tfm_stream(inode, tc, OUTPUT_STREAM); -+ if (result) -+ goto error; -+ result = grab_coa(tc, cplug); -+ if (result) -+ goto error; -+ tc->len = tc->lsize = lbytes(clust->index, inode); -+ assert("edward-1513", tc->len == inode_cluster_size(inode)); -+ dst_len = tfm_stream_size(tc, OUTPUT_STREAM); -+ cplug->compress(get_coa(tc, cplug->h.id, tc->act), -+ tfm_input_data(clust), tc->len, -+ tfm_output_data(clust), &dst_len); -+ assert("edward-1514", -+ dst_len <= tfm_stream_size(tc, OUTPUT_STREAM)); -+ } -+ finish_check_compressibility(inode, clust, cur_hint); -+ *compressible = data_is_compressible(dst_len, -+ inode_cluster_size(inode)); -+ return 0; -+ error: -+ put_page_cluster(clust, inode, READ_OP); -+ return result; -+} -+ -+/* Cut disk cluster of index @idx */ -+static int cut_disk_cluster(struct inode * inode, cloff_t idx) -+{ -+ reiser4_key from, to; -+ assert("edward-1515", inode_file_plugin(inode) == -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); -+ key_by_inode_cryptcompress(inode, clust_to_off(idx, inode), &from); -+ to = from; -+ set_key_offset(&to, -+ get_key_offset(&from) + inode_cluster_size(inode) - 1); -+ return reiser4_cut_tree(reiser4_tree_by_inode(inode), -+ &from, &to, inode, 0); -+} -+ -+static int reserve_cryptcompress2unixfile(struct inode *inode) -+{ -+ reiser4_block_nr unformatted_nodes; -+ reiser4_tree *tree; -+ -+ tree = reiser4_tree_by_inode(inode); -+ -+ /* number of unformatted nodes which will be created */ -+ unformatted_nodes = cluster_nrpages(inode); /* N */ -+ -+ /* -+ * space required for one iteration of extent->tail conversion: -+ * -+ * 1. kill ctail items -+ * -+ * 2. insert N unformatted nodes -+ * -+ * 3. insert N (worst-case single-block -+ * extents) extent units. -+ * -+ * 4. drilling to the leaf level by coord_by_key() -+ * -+ * 5. possible update of stat-data -+ * -+ */ -+ grab_space_enable(); -+ return reiser4_grab_space -+ (2 * tree->height + -+ unformatted_nodes + -+ unformatted_nodes * estimate_one_insert_into_item(tree) + -+ 1 + estimate_one_insert_item(tree) + -+ inode_file_plugin(inode)->estimate.update(inode), -+ BA_CAN_COMMIT); -+} -+ -+/* clear flag that indicated conversion and update -+ stat-data with new (unix-file - specific) info */ -+static int complete_file_conversion(struct inode *inode) -+{ -+ int result; -+ -+ grab_space_enable(); -+ result = -+ reiser4_grab_space(inode_file_plugin(inode)->estimate.update(inode), -+ BA_CAN_COMMIT); -+ if (result == 0) { -+ reiser4_inode_clr_flag(inode, REISER4_FILE_CONV_IN_PROGRESS); -+ result = reiser4_update_sd(inode); -+ } -+ if (result) -+ warning("edward-1452", -+ "Converting %llu to unix-file: update sd failed (%i)", -+ (unsigned long long)get_inode_oid(inode), result); -+ return 0; -+} -+ -+ -+/* do conversion */ -+static int cryptcompress2unixfile(struct file * file, struct inode * inode, -+ struct cluster_handle * clust) -+{ -+ int i; -+ int result = 0; -+ struct cryptcompress_info *cr_info; -+ struct unix_file_info *uf_info; -+ -+ assert("edward-1516", clust->pages[0]->index == 0); -+ assert("edward-1517", clust->hint != NULL); -+ -+ /* release all cryptcompress-specific recources */ -+ cr_info = cryptcompress_inode_data(inode); -+ result = reserve_cryptcompress2unixfile(inode); -+ if (result) -+ goto out; -+ reiser4_inode_set_flag(inode, REISER4_FILE_CONV_IN_PROGRESS); -+ reiser4_unset_hint(clust->hint); -+ result = cut_disk_cluster(inode, 0); -+ if (result) -+ goto out; -+ /* captured jnode of cluster and assotiated resources (pages, -+ reserved disk space) were released by ->kill_hook() method -+ of the item plugin */ -+ -+ result = __cryptcompress2unixfile(file, inode); -+ if (result) -+ goto out; -+ /* At this point file is managed by unix file plugin */ -+ -+ uf_info = unix_file_inode_data(inode); -+ -+ assert("edward-1518", -+ ergo(jprivate(clust->pages[0]), -+ !jnode_is_cluster_page(jprivate(clust->pages[0])))); -+ for(i = 0; i < clust->nr_pages; i++) { -+ assert("edward-1519", clust->pages[i]); -+ assert("edward-1520", PageUptodate(clust->pages[i])); -+ -+ result = find_or_create_extent(clust->pages[i]); -+ if (result) -+ break; -+ } -+ if (!result) { -+ uf_info->container = UF_CONTAINER_EXTENTS; -+ complete_file_conversion(inode); -+ } -+ out: -+ all_grabbed2free(); -+ if (result) -+ warning("edward-1453", "Failed to convert file %llu: ret=%i", -+ (unsigned long long)get_inode_oid(inode), result); -+ return result; -+} -+ -+/* Check, then perform or disable conversion if needed */ -+int write_conversion_hook(struct file * file, struct inode * inode, loff_t pos, -+ struct cluster_handle * clust, int * progress) -+{ -+ int result; -+ int check_compress = 0; -+ int compressible = 0; -+ -+ if (!conversion_enabled(inode)) -+ return 0; -+ result = check_position(inode, pos, clust, &check_compress); -+ if (result || !check_compress) -+ return result; -+ result = read_check_compressibility(inode, clust, &compressible); -+ if (result) -+ return result; -+ -+ /* At this point page cluster is grabbed and uptodate */ -+ if (!compressible) { -+ result = cryptcompress2unixfile(file, inode, clust); -+ if (result == 0) -+ *progress = 1; -+ } -+ else -+ result = disable_conversion(inode); -+ -+ reiser4_txn_restart_current(); -+ put_page_cluster(clust, inode, READ_OP); -+ return result; -+} -+ -+static int setattr_conversion_hook(struct inode * inode, struct iattr *attr) -+{ -+ return (attr->ia_valid & ATTR_SIZE ? disable_conversion(inode) : 0); -+} -+ -+/* Protected methods of cryptcompress file plugin constructed -+ by the macros above */ -+ -+/* Wrappers with active protection for: -+ . write_cryptcompress; -+ . setattr_cryptcompress; -+*/ -+ -+ssize_t prot_write_cryptcompress(struct file *file, const char __user *buf, -+ size_t count, loff_t *off) -+{ -+ int prot = 0; -+ int conv = 0; -+ ssize_t written_cr = 0; -+ ssize_t written_uf = 0; -+ struct inode * inode = file->f_dentry->d_inode; -+ struct rw_semaphore * guard = &reiser4_inode_data(inode)->conv_sem; -+ -+ if (should_protect(inode)) { -+ prot = 1; -+ down_write(guard); -+ } -+ written_cr = write_cryptcompress(file, buf, count, off, &conv); -+ if (prot) -+ up_write(guard); -+ if (written_cr < 0) -+ return written_cr; -+ if (conv) -+ written_uf = write_unix_file(file, buf + written_cr, -+ count - written_cr, off); -+ return written_cr + (written_uf < 0 ? 0 : written_uf); -+} -+ -+int prot_setattr_cryptcompress(struct dentry *dentry, struct iattr *attr) -+{ -+ struct inode * inode = dentry->d_inode; -+ return PROT_ACTIVE(int, setattr, (dentry, attr), -+ setattr_conversion_hook(inode, attr)); -+} -+ -+/* Wrappers with passive protection for: -+ . read_cryptcomperess; -+ . mmap_cryptcompress; -+ . release_cryptcompress; -+ . sendfile_cryptcompress; -+ . delete_object_cryptcompress. -+*/ -+ssize_t prot_read_cryptcompress(struct file * file, char __user * buf, -+ size_t size, loff_t * off) -+{ -+ struct inode * inode = file->f_dentry->d_inode; -+ return PROT_PASSIVE(ssize_t, read, (file, buf, size, off)); -+} -+ -+int prot_mmap_cryptcompress(struct file *file, struct vm_area_struct *vma) -+{ -+ struct inode *inode = file->f_dentry->d_inode; -+ return PROT_PASSIVE(int, mmap, (file, vma)); -+} -+ -+int prot_release_cryptcompress(struct inode *inode, struct file *file) -+{ -+ return PROT_PASSIVE(int, release, (inode, file)); -+} -+ -+ssize_t prot_sendfile_cryptcompress(struct file *file, loff_t *ppos, -+ size_t count, read_actor_t actor, -+ void *target) -+{ -+ struct inode * inode = file->f_dentry->d_inode; -+ return PROT_PASSIVE(ssize_t, sendfile, -+ (file, ppos, count, actor, target)); -+} -+ -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 80 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser4/plugin/file/file.h ---- linux-2.6.22.orig/fs/reiser4/plugin/file/file.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/file.h 2007-07-29 00:25:34.928709936 +0400 -@@ -0,0 +1,272 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file/file.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/file.h +@@ -0,0 +1,257 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + -+/* this file contains declarations of methods implementing -+ file plugins (UNIX_FILE_PLUGIN_ID, CRYPTCOMPRESS_FILE_PLUGIN_ID -+ and SYMLINK_FILE_PLUGIN_ID) */ ++/* this file contains declarations of methods implementing file plugins ++ (UNIX_FILE_PLUGIN_ID, SYMLINK_FILE_PLUGIN_ID and CRC_FILE_PLUGIN_ID) */ + +#if !defined( __REISER4_FILE_H__ ) +#define __REISER4_FILE_H__ @@ -38673,7 +38429,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + +/* address space operations */ +int readpage_unix_file(struct file *, struct page *); -+int readpages_unix_file(struct file*, struct address_space*, struct list_head*, unsigned); ++int readpage_unix_file_nolock(struct file *, struct page *); +int writepages_unix_file(struct address_space *, struct writeback_control *); +int prepare_write_unix_file(struct file *, struct page *, unsigned from, + unsigned to); @@ -38712,7 +38468,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser +struct inode; + +/* unix file plugin specific part of reiser4 inode */ -+struct unix_file_info { ++typedef struct unix_file_info { + /* + * this read-write lock protects file containerization change. Accesses + * which do not change file containerization (see file_container_t) @@ -38722,6 +38478,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + * take write-lock. + */ + struct rw_semaphore latch; ++ /* ++ * this semaphore is used to serialize writes instead of inode->i_mutex, ++ * because write_unix_file uses get_user_pages which is to be used ++ * under mm->mmap_sem and because it is required to take mm->mmap_sem ++ * before inode->i_mutex, so inode->i_mutex would have to be unlocked ++ * before calling to get_user_pages which is unacceptable ++ */ ++ struct semaphore write; + /* this enum specifies which items are used to build the file */ + file_container_t container; + /* @@ -38737,23 +38501,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + atomic_t nr_neas; + void *last_reader; +#endif -+}; ++} unix_file_info_t; + +struct unix_file_info *unix_file_inode_data(const struct inode *inode); -+void get_exclusive_access(struct unix_file_info *); -+void drop_exclusive_access(struct unix_file_info *); -+void get_nonexclusive_access(struct unix_file_info *); -+void drop_nonexclusive_access(struct unix_file_info *); -+int try_to_get_nonexclusive_access(struct unix_file_info *); ++void get_exclusive_access(unix_file_info_t *); ++void drop_exclusive_access(unix_file_info_t *); ++void get_nonexclusive_access(unix_file_info_t *); ++void drop_nonexclusive_access(unix_file_info_t *); ++int try_to_get_nonexclusive_access(unix_file_info_t *); +int find_file_item(hint_t *, const reiser4_key *, znode_lock_mode, + struct inode *); +int find_file_item_nohint(coord_t *, lock_handle *, + const reiser4_key *, znode_lock_mode, + struct inode *); + ++void validate_extended_coord(uf_coord_t *, loff_t offset); +int load_file_hint(struct file *, hint_t *); +void save_file_hint(struct file *, const hint_t *); + ++ +#include "../item/extent.h" +#include "../item/tail.h" +#include "../item/ctail.h" @@ -38763,9 +38529,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + lock_handle *lh; + int valid; + union { -+ struct extent_coord_extension extent; -+ struct tail_coord_extension tail; -+ struct ctail_coord_extension ctail; ++ extent_coord_extension_t extent; ++ tail_coord_extension_t tail; ++ ctail_coord_extension_t ctail; + } extension; +}; + @@ -38788,36 +38554,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + lock_handle lh; +}; + -+static inline int hint_is_valid(hint_t * hint) -+{ -+ return hint->ext_coord.valid; -+} -+ -+static inline void hint_set_valid(hint_t * hint) -+{ -+ hint->ext_coord.valid = 1; -+} -+ -+static inline void hint_clr_valid(hint_t * hint) -+{ -+ hint->ext_coord.valid = 0; -+} -+ -+int load_file_hint(struct file *, hint_t *); -+void save_file_hint(struct file *, const hint_t *); -+void hint_init_zero(hint_t *); -+void reiser4_set_hint(hint_t *, const reiser4_key *, znode_lock_mode); ++void set_hint(hint_t *, const reiser4_key *, znode_lock_mode); +int hint_is_set(const hint_t *); -+void reiser4_unset_hint(hint_t *); ++void unset_hint(hint_t *); ++int hint_validate(hint_t *, const reiser4_key *, int check_key, ++ znode_lock_mode); ++void hint_init_zero(hint_t *); + -+int reiser4_update_file_size(struct inode *, reiser4_key *, int update_sd); ++int update_file_size(struct inode *, reiser4_key *, int update_sd); +int cut_file_items(struct inode *, loff_t new_size, int update_sd, + loff_t cur_size, int (*update_actor) (struct inode *, + reiser4_key *, int)); ++ ++ +#if REISER4_DEBUG + +/* return 1 is exclusive access is obtained, 0 - otherwise */ -+static inline int ea_obtained(struct unix_file_info * uf_info) ++static inline int ea_obtained(unix_file_info_t * uf_info) +{ + int ret; + @@ -38830,48 +38583,38 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser +#endif + +/* declarations of functions implementing SYMLINK_FILE_PLUGIN_ID file plugin */ -+int reiser4_create_symlink(struct inode *symlink, struct inode *dir, -+ reiser4_object_create_data *); ++int create_symlink(struct inode *symlink, struct inode *dir, ++ reiser4_object_create_data *); +void destroy_inode_symlink(struct inode *); + -+/* declarations of functions implementing CRYPTCOMPRESS_FILE_PLUGIN_ID -+ file plugin */ ++/* declarations of functions implementing CRC_FILE_PLUGIN_ID file plugin */ + +/* inode operations */ +int setattr_cryptcompress(struct dentry *, struct iattr *); -+int prot_setattr_cryptcompress(struct dentry *, struct iattr *); + +/* file operations */ +ssize_t read_cryptcompress(struct file *, char __user *buf, size_t read_amount, + loff_t * off); -+ssize_t prot_read_cryptcompress(struct file *, char __user *buf, -+ size_t read_amount, loff_t * off); -+ +ssize_t write_cryptcompress(struct file *, const char __user *buf, size_t write_amount, -+ loff_t * off, int * conv); -+ssize_t prot_write_cryptcompress(struct file *, const char __user *buf, size_t write_amount, -+ loff_t * off); ++ loff_t * off); +int mmap_cryptcompress(struct file *, struct vm_area_struct *); -+int prot_mmap_cryptcompress(struct file *, struct vm_area_struct *); +ssize_t sendfile_cryptcompress(struct file *file, loff_t *ppos, size_t count, + read_actor_t actor, void *target); -+ssize_t prot_sendfile_cryptcompress(struct file *file, loff_t *ppos, size_t count, -+ read_actor_t actor, void *target); -+ +int release_cryptcompress(struct inode *, struct file *); -+int prot_release_cryptcompress(struct inode *, struct file *); + +/* address space operations */ +extern int readpage_cryptcompress(struct file *, struct page *); +extern int writepages_cryptcompress(struct address_space *, + struct writeback_control *); ++ ++ +/* file plugin operations */ +int flow_by_inode_cryptcompress(struct inode *, const char __user *buf, + int user, loff_t, loff_t, rw_op, flow_t *); +int key_by_inode_cryptcompress(struct inode *, loff_t off, reiser4_key *); +int create_cryptcompress(struct inode *, struct inode *, + reiser4_object_create_data *); -+int delete_object_cryptcompress(struct inode *); ++int delete_cryptcompress(struct inode *); +void init_inode_data_cryptcompress(struct inode *, reiser4_object_create_data *, + int create); +int cut_tree_worker_cryptcompress(tap_t *, const reiser4_key * from_key, @@ -38880,22 +38623,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + struct inode *object, int truncate, + int *progress); +void destroy_inode_cryptcompress(struct inode *); -+int open_object_cryptcompress(struct inode * inode, struct file * file); + +extern reiser4_plugin_ops cryptcompress_plugin_ops; + +#define WRITE_GRANULARITY 32 + -+int tail2extent(struct unix_file_info *); -+int extent2tail(struct unix_file_info *); ++ ++int tail2extent(unix_file_info_t *); ++int extent2tail(unix_file_info_t *); + +int goto_right_neighbor(coord_t *, lock_handle *); +int find_or_create_extent(struct page *); +int equal_to_ldk(znode *, const reiser4_key *); + -+void init_uf_coord(uf_coord_t *uf_coord, lock_handle *lh); + -+static inline int cbk_errored(int cbk_result) ++extern inline int cbk_errored(int cbk_result) +{ + return (cbk_result != CBK_COORD_NOTFOUND + && cbk_result != CBK_COORD_FOUND); @@ -38914,20 +38656,508 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/file.h linux-2.6.22/fs/reiser + * scroll-step: 1 + * End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/Makefile linux-2.6.22/fs/reiser4/plugin/file/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/file/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/Makefile 2007-07-29 00:25:34.928709936 +0400 -@@ -0,0 +1,7 @@ -+obj-$(CONFIG_REISER4_FS) += file_plugins.o +Index: linux-2.6.16/fs/reiser4/plugin/file/invert.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/invert.c +@@ -0,0 +1,493 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + -+file_plugins-objs := \ -+ file.o \ -+ tail_conversion.o \ -+ symlink.o \ -+ cryptcompress.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symfile.c linux-2.6.22/fs/reiser4/plugin/file/symfile.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/symfile.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/symfile.c 2007-07-29 00:25:34.928709936 +0400 ++/* Suppose you want to conveniently read and write a large variety of small files conveniently within a single emacs ++ buffer, without having a separate buffer for each 8 byte or so file. Inverts are the way to do that. An invert ++ provides you with the contents of a set of subfiles plus its own contents. It is a file which inherits other files ++ when you read it, and allows you to write to it and through it to the files that it inherits from. In order for it ++ to know which subfiles each part of your write should go into, there must be delimiters indicating that. It tries to ++ make that easy for you by providing those delimiters in what you read from it. ++ ++ When you read it, an invert performs an inverted assignment. Instead of taking an assignment command and writing a ++ bunch of files, it takes a bunch of files and composes an assignment command for you to read from it that if executed ++ would create those files. But which files? Well, that must be specified in the body of the invert using a special ++ syntax, and that specification is called the invert of the assignment. ++ ++ When written to, an invert performs the assignment command that is written ++ to it, and modifies its own body to contain the invert of that ++ assignment. ++ ++ In other words, writing to an invert file what you have read from it ++ is the identity operation. ++ ++ Malformed assignments cause write errors. Partial writes are not ++ supported in v4.0, but will be. ++ ++ Example: ++ ++ If an invert contains: ++ ++ /filenameA/<>+"(some text stored in the invert)+/filenameB/<> ++ ++====================== ++Each element in this definition should be an invert, and all files ++should be called recursively - too. This is bad. If one of the ++included files in not a regular or invert file, then we can't read ++main file. ++ ++I think to make it is possible easier: ++ ++internal structure of invert file should be like symlink file. But ++read and write method should be explitely indicated in i/o operation.. ++ ++By default we read and write (if probably) as symlink and if we ++specify ..invert at reading time that too we can specify it at write time. ++ ++example: ++/my_invert_file/..invert<- ( (/filenameA<-"(The contents of filenameA))+"(some text stored in the invert)+(/filenameB<-"(The contents of filenameB) ) ) ++will create /my_invert_file as invert, and will creat /filenameA and /filenameB with specified body. ++ ++read of /my_invert_file/..invert will be ++/filenameA<-"(The contents of filenameA)+"(some text stored in the invert)+/filenameB<-"(The contents of filenameB) ++ ++but read of /my_invert_file/ will be ++The contents of filenameAsome text stored in the invertThe contents of filenameB ++ ++we also can creat this file as ++/my_invert_file/<-/filenameA+"(some text stored in the invert)+/filenameB ++will create /my_invert_file , and use existing files /filenameA and /filenameB. ++ ++and when we will read it will be as previously invert file. ++ ++This is correct? ++ ++ vv ++DEMIDOV-FIXME-HANS: ++ ++Maybe you are right, but then you must disable writes to /my_invert_file/ and only allow writes to /my_invert_file/..invert ++ ++Do you agree? Discuss it on reiserfs-list.... ++ ++-Hans ++======================= ++ ++ Then a read will return: ++ ++ /filenameA<-"(The contents of filenameA)+"(some text stored in the invert)+/filenameB<-"(The contents of filenameB) ++ ++ and a write of the line above to the invert will set the contents of ++ the invert and filenameA and filenameB to their original values. ++ ++ Note that the contents of an invert have no influence on the effect ++ of a write unless the write is a partial write (and a write of a ++ shorter file without using truncate first is a partial write). ++ ++ truncate() has no effect on filenameA and filenameB, it merely ++ resets the value of the invert. ++ ++ Writes to subfiles via the invert are implemented by preceding them ++ with truncates. ++ ++ Parse failures cause write failures. ++ ++ Questions to ponder: should the invert be acted on prior to file ++ close when writing to an open filedescriptor? ++ ++ Example: ++ ++ If an invert contains: ++ ++ "(This text and a pair of quotes are all that is here.) ++ ++Then a read will return: ++ ++ "(This text and a pair of quotes are all that is here.) ++ ++*/ ++ ++/* OPEN method places a struct file in memory associated with invert body ++ and returns something like file descriptor to the user for the future access ++ to the invert file. ++ During opening we parse the body of invert and get a list of the 'entryes' ++ (that describes all its subfiles) and place pointer on the first struct in ++ reiserfs-specific part of invert inode (arbitrary decision). ++ ++ Each subfile is described by the struct inv_entry that has a pointer @sd on ++ in-core based stat-data and a pointer on struct file @f (if we find that the ++ subfile uses more then one unformated node (arbitrary decision), we load ++ struct file in memory, otherwise we load base stat-data (and maybe 1-2 bytes ++ of some other information we need) ++ ++ Since READ and WRITE methods for inverts were formulated in assignment ++ language, they don't contain arguments 'size' and 'offset' that make sense ++ only in ordinary read/write methods. ++ ++ READ method is a combination of two methods: ++ 1) ordinary read method (with offset=0, lenght = @f->...->i_size) for entries ++ with @f != 0, this method uses pointer on struct file as an argument ++ 2) read method for inode-less files with @sd != 0, this method uses ++ in-core based stat-data instead struct file as an argument. ++ in the first case we don't use pagecache, just copy data that we got after ++ cbk() into userspace. ++ ++ WRITE method for invert files is more complex. ++ Besides declared WRITE-interface in assignment languageb above we need ++ to have an opportunity to edit unwrapped body of invert file with some ++ text editor, it means we need GENERIC WRITE METHOD for invert file: ++ ++ my_invert_file/..invert <- "string" ++ ++ this method parses "string" and looks for correct subfile signatures, also ++ the parsing process splits this "string" on the set of flows in accordance ++ with the set of subfiles specified by this signarure. ++ The found list of signatures #S is compared with the opened one #I of invert ++ file. If it doesn't have this one (#I==0, it will be so for instance if we ++ have just create this invert file) the write method assignes found signature ++ (#I=#S;) to the invert file. Then if #I==#S, generic write method splits ++ itself to the some write methods for ordinary or light-weight, or call itself ++ recursively for invert files with corresponding flows. ++ I am not sure, but the list of signatures looks like what mr.Demidov means ++ by 'delimiters'. ++ ++ The cases when #S<#I (#I<#S) (in the sense of set-theory) are also available ++ and cause delete (create new) subfiles (arbitrary decision - it may looks ++ too complex, but this interface will be the completest). The order of entries ++ of list #S (#I) and inherited order on #I (#S) must coincide. ++ The other parsing results give malformed signature that aborts READ method ++ and releases all resources. ++ ++ Format of subfile (entry) signature: ++ ++ "START_MAGIC"<>(TYPE="...",LOOKUP_ARG="...")SUBFILE_BODY"END_MAGIC" ++ ++ Legend: ++ ++ START_MAGIC - keyword indicates the start of subfile signature; ++ ++ <> indicates the start of 'subfile metadata', that is the pair ++ (TYPE="...",LOOKUP_ARG="...") in parenthesis separated by comma. ++ ++ TYPE - the string "type" indicates the start of one of the three words: ++ - ORDINARY_FILE, ++ - LIGHT_WEIGHT_FILE, ++ - INVERT_FILE; ++ ++ LOOKUP_ARG - lookup argument depends on previous type: ++ */ ++ ++ /************************************************************/ ++ /* TYPE * LOOKUP ARGUMENT */ ++ /************************************************************/ ++ /* LIGH_WEIGHT_FILE * stat-data key */ ++ /************************************************************/ ++ /* ORDINARY_FILE * filename */ ++ /************************************************************/ ++ /* INVERT_FILE * filename */ ++ /************************************************************/ ++ ++ /* where: ++ *stat-data key - the string contains stat data key of this subfile, it will be ++ passed to fast-access lookup method for light-weight files; ++ *filename - pathname of this subfile, iyt well be passed to VFS lookup methods ++ for ordinary and invert files; ++ ++ SUBFILE_BODY - data of this subfile (it will go to the flow) ++ END_MAGIC - the keyword indicates the end of subfile signature. ++ ++ The other simbols inside the signature interpreted as 'unformatted content', ++ which is available with VFS's read_link() (arbitraruy decision). ++ ++ NOTE: Parse method for a body of invert file uses mentioned signatures _without_ ++ subfile bodies. ++ ++ Now the only unclear thing is WRITE in regular light-weight subfile A that we ++ can describe only in assignment language: ++ ++ A <- "some_string" ++ ++ I guess we don't want to change stat-data and body items of file A ++ if this file exist, and size(A) != size("some_string") because this operation is ++ expencive, so we only do the partial write if size(A) > size("some_string") ++ and do truncate of the "some_string", and then do A <- "truncated string", if ++ size(A) < size("some_string"). This decision is also arbitrary.. ++ */ ++ ++/* here is infrastructure for formated flows */ ++ ++#define SUBFILE_HEADER_MAGIC 0x19196605 ++#define FLOW_HEADER_MAGIC 0x01194304 ++ ++#include "../plugin.h" ++#include "../../debug.h" ++#include "../../forward.h" ++#include "../object.h" ++#include "../item/item.h" ++#include "../item/static_stat.h" ++#include "../../dformat.h" ++#include "../znode.h" ++#include "../inode.h" ++ ++#include ++#include /* for struct file */ ++#include /* for struct list_head */ ++ ++typedef enum { ++ LIGHT_WEIGHT_FILE, ++ ORDINARY_FILE, ++ INVERT_FILE ++} inv_entry_type; ++ ++typedef struct flow_header { ++ d32 fl_magic; ++ d16 fl_nr; /* number of subfiles in the flow */ ++}; ++ ++typedef struct subfile_header { ++ d32 sh_magic; /* subfile magic */ ++ d16 sh_type; /* type of subfile: light-weight, ordinary, invert */ ++ d16 sh_arg_len; /* lenght of lookup argument (filename, key) */ ++ d32 sh_body_len; /* lenght of subfile body */ ++}; ++ ++/* functions to get/set fields of flow header */ ++ ++static void fl_set_magic(flow_header * fh, __u32 value) ++{ ++ cputod32(value, &fh->fh_magic); ++} ++ ++static __u32 fl_get_magic(flow_header * fh) ++{ ++ return d32tocpu(&fh->fh_magic); ++} ++static void fl_set_number(flow_header * fh, __u16 value) ++{ ++ cputod16(value, &fh->fh_nr); ++} ++static unsigned fl_get_number(flow_header * fh) ++{ ++ return d16tocpu(&fh->fh_nr); ++} ++ ++/* functions to get/set fields of subfile header */ ++ ++static void sh_set_magic(subfile_header * sh, __u32 value) ++{ ++ cputod32(value, &sh->sh_magic); ++} ++ ++static __u32 sh_get_magic(subfile_header * sh) ++{ ++ return d32tocpu(&sh->sh_magic); ++} ++static void sh_set_type(subfile_header * sh, __u16 value) ++{ ++ cputod16(value, &sh->sh_magic); ++} ++static unsigned sh_get_type(subfile_header * sh) ++{ ++ return d16tocpu(&sh->sh_magic); ++} ++static void sh_set_arg_len(subfile_header * sh, __u16 value) ++{ ++ cputod16(value, &sh->sh_arg_len); ++} ++static unsigned sh_get_arg_len(subfile_header * sh) ++{ ++ return d16tocpu(&sh->sh_arg_len); ++} ++static void sh_set_body_len(subfile_header * sh, __u32 value) ++{ ++ cputod32(value, &sh->sh_body_len); ++} ++ ++static __u32 sh_get_body_len(subfile_header * sh) ++{ ++ return d32tocpu(&sh->sh_body_len); ++} ++ ++/* in-core minimal stat-data, light-weight analog of inode */ ++ ++struct incore_sd_base { ++ umode_t isd_mode; ++ nlink_t isd_nlink; ++ loff_t isd_size; ++ char *isd_data; /* 'subflow' to write */ ++}; ++ ++/* open invert create a list of invert entries, ++ every entry is represented by structure inv_entry */ ++ ++struct inv_entry { ++ struct list_head *ie_list; ++ struct file *ie_file; /* this is NULL if the file doesn't ++ have unformated nodes */ ++ struct incore_sd_base *ie_sd; /* inode-less analog of struct file */ ++}; ++ ++/* allocate and init invert entry */ ++ ++static struct inv_entry *allocate_inv_entry(void) ++{ ++ struct inv_entry *inv_entry; ++ ++ inv_entry = reiser4_kmalloc(sizeof(struct inv_entry), GFP_KERNEL); ++ if (!inv_entry) ++ return ERR_PTR(RETERR(-ENOMEM)); ++ inv_entry->ie_file = NULL; ++ inv_entry->ie_sd = NULL; ++ INIT_LIST_HEAD(&inv_entry->ie_list); ++ return inv_entry; ++} ++ ++static int put_inv_entry(struct inv_entry *ientry) ++{ ++ int result = 0; ++ ++ assert("edward-96", ientry != NULL); ++ assert("edward-97", ientry->ie_list != NULL); ++ ++ list_del(ientry->ie_list); ++ if (ientry->ie_sd != NULL) { ++ kfree(ientry->ie_sd); ++ kfree(ientry); ++ } ++ if (ientry->ie_file != NULL) ++ result = filp_close(ientry->file, NULL); ++ return result; ++} ++ ++static int allocate_incore_sd_base(struct inv_entry *inv_entry) ++{ ++ struct incore_sd_base *isd_base assert("edward-98", inv_entry != NULL); ++ assert("edward-99", inv_entry->ie_inode = NULL); ++ assert("edward-100", inv_entry->ie_sd = NULL); ++ ++ isd_base = reiser4_kmalloc(sizeof(struct incore_sd_base), GFP_KERNEL); ++ if (!isd_base) ++ return RETERR(-ENOMEM); ++ inv_entry->ie_sd = isd_base; ++ return 0; ++} ++ ++/* this can be installed as ->init_inv_entry () method of ++ item_plugins[ STATIC_STAT_DATA_IT ] (fs/reiser4/plugin/item/item.c). ++ Copies data from on-disk stat-data format into light-weight analog of inode . ++ Doesn't hanlde stat-data extensions. */ ++ ++static void sd_base_load(struct inv_entry *inv_entry, char *sd) ++{ ++ reiser4_stat_data_base *sd_base; ++ ++ assert("edward-101", inv_entry != NULL); ++ assert("edward-101", inv_entry->ie_sd != NULL); ++ assert("edward-102", sd != NULL); ++ ++ sd_base = (reiser4_stat_data_base *) sd; ++ inv_entry->incore_sd_base->isd_mode = d16tocpu(&sd_base->mode); ++ inv_entry->incore_sd_base->isd_nlink = d32tocpu(&sd_base->nlink); ++ inv_entry->incore_sd_base->isd_size = d64tocpu(&sd_base->size); ++ inv_entry->incore_sd_base->isd_data = NULL; ++} ++ ++/* initialise incore stat-data */ ++ ++static void init_incore_sd_base(struct inv_entry *inv_entry, coord_t * coord) ++{ ++ reiser4_plugin *plugin = item_plugin_by_coord(coord); ++ void *body = item_body_by_coord(coord); ++ ++ assert("edward-103", inv_entry != NULL); ++ assert("edward-104", plugin != NULL); ++ assert("edward-105", body != NULL); ++ ++ sd_base_load(inv_entry, body); ++} ++ ++/* takes a key or filename and allocates new invert_entry, ++ init and adds it into the list, ++ we use lookup_sd_by_key() for light-weight files and VFS lookup by filename */ ++ ++int get_inv_entry(struct inode *invert_inode, /* inode of invert's body */ ++ inv_entry_type type, /* LIGHT-WEIGHT or ORDINARY */ ++ const reiser4_key * key, /* key of invert entry stat-data */ ++ char *filename, /* filename of the file to be opened */ ++ int flags, int mode) ++{ ++ int result; ++ struct inv_entry *ientry; ++ ++ assert("edward-107", invert_inode != NULL); ++ ++ ientry = allocate_inv_entry(); ++ if (IS_ERR(ientry)) ++ return (PTR_ERR(ientry)); ++ ++ if (type == LIGHT_WEIGHT_FILE) { ++ coord_t coord; ++ lock_handle lh; ++ ++ assert("edward-108", key != NULL); ++ ++ init_coord(&coord); ++ init_lh(&lh); ++ result = ++ lookup_sd_by_key(tree_by_inode(invert_inode), ++ ZNODE_READ_LOCK, &coord, &lh, key); ++ if (result == 0) ++ init_incore_sd_base(ientry, coord); ++ ++ done_lh(&lh); ++ done_coord(&coord); ++ return (result); ++ } else { ++ struct file *file = filp_open(filename, flags, mode); ++ /* FIXME_EDWARD here we need to check if we ++ did't follow to any mount point */ ++ ++ assert("edward-108", filename != NULL); ++ ++ if (IS_ERR(file)) ++ return (PTR_ERR(file)); ++ ientry->ie_file = file; ++ return 0; ++ } ++} ++ ++/* takes inode of invert, reads the body of this invert, parses it, ++ opens all invert entries and return pointer on the first inv_entry */ ++ ++struct inv_entry *open_invert(struct file *invert_file) ++{ ++ ++} ++ ++ssize_t subfile_read(struct *invert_entry, flow * f) ++{ ++ ++} ++ ++ssize_t subfile_write(struct *invert_entry, flow * f) ++{ ++ ++} ++ ++ssize_t invert_read(struct *file, flow * f) ++{ ++ ++} ++ ++ssize_t invert_write(struct *file, flow * f) ++{ ++ ++} ++ ++/* Make Linus happy. ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/file/symfile.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/symfile.c @@ -0,0 +1,87 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -39016,10 +39246,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symfile.c linux-2.6.22/fs/rei + sophisticated symfile syntax that we are not planning to write for + version 4.0. +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c linux-2.6.22/fs/reiser4/plugin/file/symlink.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/symlink.c 2007-07-29 00:25:34.928709936 +0400 -@@ -0,0 +1,95 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file/symlink.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/symlink.c +@@ -0,0 +1,92 @@ +/* Copyright 2002, 2003, 2005 by Hans Reiser, licensing governed by reiser4/README */ + +#include "../../inode.h" @@ -39035,25 +39266,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c linux-2.6.22/fs/rei + */ + +/** -+ * reiser4_create_symlink - create_object of file plugin for SYMLINK_FILE_PLUGIN_ID ++ * create_symlink - create_object of file plugin for SYMLINK_FILE_PLUGIN_ID + * @symlink: inode of symlink object + * @dir: inode of parent directory + * @info: parameters of new object + * + * Inserts stat data with symlink extension where into the tree. + */ -+int reiser4_create_symlink(struct inode *symlink, -+ struct inode *dir UNUSED_ARG, -+ reiser4_object_create_data *data /* info passed to us -+ * this is filled by -+ * reiser4() syscall -+ * in particular */) ++int create_symlink(struct inode *symlink, ++ struct inode *dir UNUSED_ARG, ++ reiser4_object_create_data *data /* info passed to us, ++ * this is filled by ++ * reiser4() syscall ++ * in particular */ ) +{ + int result; + + assert("nikita-680", symlink != NULL); + assert("nikita-681", S_ISLNK(symlink->i_mode)); -+ assert("nikita-685", reiser4_inode_get_flag(symlink, REISER4_NO_SD)); ++ assert("nikita-685", inode_get_flag(symlink, REISER4_NO_SD)); + assert("nikita-682", dir != NULL); + assert("nikita-684", data != NULL); + assert("nikita-686", data->id == SYMLINK_FILE_PLUGIN_ID); @@ -39064,8 +39295,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c linux-2.6.22/fs/rei + */ + reiser4_inode_data(symlink)->extmask |= (1 << SYMLINK_STAT); + -+ assert("vs-838", symlink->i_private == NULL); -+ symlink->i_private = (void *)data->name; ++ assert("vs-838", symlink->u.generic_ip == NULL); ++ symlink->u.generic_ip = (void *)data->name; + + assert("vs-843", symlink->i_size == 0); + INODE_SET_FIELD(symlink, i_size, strlen(data->name)); @@ -39073,15 +39304,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c linux-2.6.22/fs/rei + /* insert stat data appended with data->name */ + result = inode_file_plugin(symlink)->write_sd_by_inode(symlink); + if (result) { -+ /* FIXME-VS: Make sure that symlink->i_private is not attached ++ /* FIXME-VS: Make sure that symlink->u.generic_ip is not attached + to kmalloced data */ + INODE_SET_FIELD(symlink, i_size, 0); + } else { -+ assert("vs-849", symlink->i_private -+ && reiser4_inode_get_flag(symlink, -+ REISER4_GENERIC_PTR_USED)); ++ assert("vs-849", symlink->u.generic_ip ++ && inode_get_flag(symlink, REISER4_GENERIC_PTR_USED)); + assert("vs-850", -+ !memcmp((char *)symlink->i_private, data->name, ++ !memcmp((char *)symlink->u.generic_ip, data->name, + (size_t) symlink->i_size + 1)); + } + return result; @@ -39096,29 +39326,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/symlink.c linux-2.6.22/fs/rei + inode_file_plugin(inode) == + file_plugin_by_id(SYMLINK_FILE_PLUGIN_ID)); + assert("edward-800", !is_bad_inode(inode) && is_inode_loaded(inode)); -+ assert("edward-801", reiser4_inode_get_flag(inode, -+ REISER4_GENERIC_PTR_USED)); ++ assert("edward-801", inode_get_flag(inode, REISER4_GENERIC_PTR_USED)); + assert("vs-839", S_ISLNK(inode->i_mode)); + -+ kfree(inode->i_private); -+ inode->i_private = NULL; -+ reiser4_inode_clr_flag(inode, REISER4_GENERIC_PTR_USED); ++ kfree(inode->u.generic_ip); ++ inode->u.generic_ip = NULL; ++ inode_clr_flag(inode, REISER4_GENERIC_PTR_USED); +} + -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 80 -+ scroll-step: 1 -+ End: ++/* Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.22/fs/reiser4/plugin/file/tail_conversion.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file/tail_conversion.c 2007-07-29 00:25:34.932710971 +0400 -@@ -0,0 +1,729 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file/tail_conversion.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file/tail_conversion.c +@@ -0,0 +1,728 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "../../inode.h" @@ -39134,9 +39363,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + tail2extent and extent2tail */ + +/* exclusive access to a file is acquired when file state changes: tail2extent, empty2tail, extent2tail, etc */ -+void get_exclusive_access(struct unix_file_info * uf_info) ++void get_exclusive_access(unix_file_info_t * uf_info) +{ -+ assert("nikita-3028", reiser4_schedulable()); ++ assert("nikita-3028", schedulable()); + assert("nikita-3047", LOCK_CNT_NIL(inode_sem_w)); + assert("nikita-3048", LOCK_CNT_NIL(inode_sem_r)); + /* @@ -39145,7 +39374,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * thread that captured some block (hence preventing atom from being + * committed) and waits on rw-semaphore. + */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + LOCK_CNT_INC(inode_sem_w); + down_write(&uf_info->latch); + uf_info->exclusive_use = 1; @@ -39154,7 +39383,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + ON_DEBUG(uf_info->ea_owner = current); +} + -+void drop_exclusive_access(struct unix_file_info * uf_info) ++void drop_exclusive_access(unix_file_info_t * uf_info) +{ + assert("vs-1714", uf_info->ea_owner == current); + assert("vs-1715", atomic_read(&uf_info->nr_neas) == 0); @@ -39164,7 +39393,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + assert("nikita-3049", LOCK_CNT_NIL(inode_sem_r)); + assert("nikita-3049", LOCK_CNT_GTZ(inode_sem_w)); + LOCK_CNT_DEC(inode_sem_w); -+ reiser4_txn_restart_current(); ++ txn_restart_current(); +} + +/** @@ -39174,7 +39403,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * This is called when nonexclisive access is obtained on file. All it does is + * for debugging purposes. + */ -+static void nea_grabbed(struct unix_file_info *uf_info) ++static void nea_grabbed(unix_file_info_t *uf_info) +{ +#if REISER4_DEBUG + LOCK_CNT_INC(inode_sem_r); @@ -39190,9 +39419,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * + * Nonexclusive access is obtained on a file before read, write, readpage. + */ -+void get_nonexclusive_access(struct unix_file_info *uf_info) ++void get_nonexclusive_access(unix_file_info_t *uf_info) +{ -+ assert("nikita-3029", reiser4_schedulable()); ++ assert("nikita-3029", schedulable()); + assert("nikita-3361", get_current_context()->trans->atom == NULL); + + down_read(&uf_info->latch); @@ -39205,7 +39434,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * + * Non-blocking version of nonexclusive access obtaining. + */ -+int try_to_get_nonexclusive_access(struct unix_file_info *uf_info) ++int try_to_get_nonexclusive_access(unix_file_info_t *uf_info) +{ + int result; + @@ -39215,7 +39444,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + return result; +} + -+void drop_nonexclusive_access(struct unix_file_info * uf_info) ++void drop_nonexclusive_access(unix_file_info_t * uf_info) +{ + assert("vs-1718", uf_info->ea_owner == NULL); + assert("vs-1719", atomic_read(&uf_info->nr_neas) > 0); @@ -39224,7 +39453,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + up_read(&uf_info->latch); + + LOCK_CNT_DEC(inode_sem_r); -+ reiser4_txn_restart_current(); ++ txn_restart_current(); +} + +/* part of tail2extent. Cut all items covering @count bytes starting from @@ -39244,8 +39473,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + set_key_offset(&to, (__u64) (offset + count - 1)); + + /* cut everything between those keys */ -+ return reiser4_cut_tree(reiser4_tree_by_inode(inode), &from, &to, -+ inode, 0); ++ return cut_tree(tree_by_inode(inode), &from, &to, inode, 0); +} + +static void release_all_pages(struct page **pages, unsigned nr_pages) @@ -39280,7 +39508,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + assert("vs-596", pages[0]); + + /* cut copied items */ -+ result = cut_formatting_items(inode, page_offset(pages[0]), count); ++ result = ++ cut_formatting_items(inode, ++ (loff_t) pages[0]->index << PAGE_CACHE_SHIFT, ++ count); + if (result) + return result; + @@ -39311,7 +39542,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + reiser4_block_nr unformatted_nodes; + reiser4_tree *tree; + -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + + /* number of unformatted nodes which will be created */ + unformatted_nodes = TAIL2EXTENT_PAGE_NUM; @@ -39350,7 +39581,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + reiser4_grab_space(inode_file_plugin(inode)->estimate.update(inode), + BA_CAN_COMMIT); + if (result == 0) { -+ reiser4_inode_clr_flag(inode, REISER4_PART_MIXED); ++ inode_clr_flag(inode, REISER4_PART_MIXED); + result = reiser4_update_sd(inode); + } + if (result) @@ -39373,7 +39604,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + int result; + lock_handle lh; + coord_t coord; -+ struct unix_file_info *ufo; ++ unix_file_info_t *ufo; + int found; + reiser4_key key; + @@ -39415,7 +39646,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * + * + */ -+int tail2extent(struct unix_file_info *uf_info) ++int tail2extent(unix_file_info_t *uf_info) +{ + int result; + reiser4_key key; /* key of next byte to be moved to page */ @@ -39437,12 +39668,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + inode = unix_file_info_to_inode(uf_info); + assert("nikita-3412", !IS_RDONLY(inode)); + assert("vs-1649", uf_info->container != UF_CONTAINER_EXTENTS); -+ assert("", !reiser4_inode_get_flag(inode, REISER4_PART_IN_CONV)); ++ assert("", !inode_get_flag(inode, REISER4_PART_IN_CONV)); + + offset = 0; + first_iteration = 1; + result = 0; -+ if (reiser4_inode_get_flag(inode, REISER4_PART_MIXED)) { ++ if (inode_get_flag(inode, REISER4_PART_MIXED)) { + /* + * file is marked on disk as there was a conversion which did + * not complete due to either crash or some error. Find which @@ -39460,7 +39691,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + first_iteration = 0; + } + -+ reiser4_inode_set_flag(inode, REISER4_PART_IN_CONV); ++ inode_set_flag(inode, REISER4_PART_IN_CONV); + + /* get key of first byte of a file */ + inode_file_plugin(inode)->key_by_inode(inode, offset, &key); @@ -39472,7 +39703,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + if (result != 0) + goto out; + if (first_iteration) { -+ reiser4_inode_set_flag(inode, REISER4_PART_MIXED); ++ inode_set_flag(inode, REISER4_PART_MIXED); + reiser4_update_sd(inode); + first_iteration = 0; + } @@ -39480,7 +39711,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + for (i = 0; i < sizeof_array(pages) && done == 0; i++) { + assert("vs-598", + (get_key_offset(&key) & ~PAGE_CACHE_MASK) == 0); -+ page = alloc_page(reiser4_ctx_gfp_mask_get()); ++ page = alloc_page(get_gfp_mask()); + if (!page) { + result = RETERR(-ENOMEM); + goto error; @@ -39589,18 +39820,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + if (result) + goto error; + /* -+ * We have to drop exclusive access to avoid deadlock -+ * which may happen because called by reiser4_writepages -+ * capture_unix_file requires to get non-exclusive -+ * access to a file. It is safe to drop EA in the middle -+ * of tail2extent conversion because write_unix_file, -+ * setattr_unix_file(truncate), mmap_unix_file, -+ * release_unix_file(extent2tail) checks if conversion -+ * is not in progress (see comments before -+ * get_exclusive_access_careful(). -+ * Other processes that acquire non-exclusive access -+ * (read_unix_file, reiser4_writepages, etc) should work -+ * on partially converted files. ++ * we have to drop exclusive access to avoid deadlock ++ * which may happen because called by ++ * reiser4_writepages capture_unix_file requires to get ++ * non-exclusive access to a file. It is safe to drop ++ * EA in the middle of tail2extent conversion because ++ * write_unix_file/unix_setattr(truncate)/release_unix_file(extent2tail) ++ * are serialized by uf_info->write semaphore and ++ * because read_unix_file works (should at least) on ++ * partially converted files + */ + drop_exclusive_access(uf_info); + /* throttle the conversion */ @@ -39611,17 +39839,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * nobody is allowed to complete conversion but a + * process which started it + */ -+ assert("", reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED)); ++ assert("", inode_get_flag(inode, REISER4_PART_MIXED)); + } + } + -+ reiser4_inode_clr_flag(inode, REISER4_PART_IN_CONV); ++ inode_clr_flag(inode, REISER4_PART_IN_CONV); + + if (result == 0) { + /* file is converted to extent items */ -+ assert("vs-1697", reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED)); ++ assert("vs-1697", inode_get_flag(inode, REISER4_PART_MIXED)); + + uf_info->container = UF_CONTAINER_EXTENTS; + complete_conversion(inode); @@ -39645,7 +39871,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 +{ + reiser4_tree *tree; + -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + /* + * reserve blocks for (in this order): + * @@ -39665,9 +39891,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + inode_file_plugin(inode)->estimate.update(inode), BA_CAN_COMMIT); +} + ++static int filler(void *vp, struct page *page) ++{ ++ return readpage_unix_file_nolock(vp, page); ++} ++ +/* for every page of file: read page, cut part of extent pointing to this page, + put data of page tree by tail item */ -+int extent2tail(struct unix_file_info *uf_info) ++int extent2tail(unix_file_info_t *uf_info) +{ + int result; + struct inode *inode; @@ -39683,10 +39914,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + inode = unix_file_info_to_inode(uf_info); + assert("nikita-3412", !IS_RDONLY(inode)); + assert("vs-1649", uf_info->container != UF_CONTAINER_TAILS); -+ assert("", !reiser4_inode_get_flag(inode, REISER4_PART_IN_CONV)); ++ assert("", !inode_get_flag(inode, REISER4_PART_IN_CONV)); + + offset = 0; -+ if (reiser4_inode_get_flag(inode, REISER4_PART_MIXED)) { ++ if (inode_get_flag(inode, REISER4_PART_MIXED)) { + /* + * file is marked on disk as there was a conversion which did + * not complete due to either crash or some error. Find which @@ -39703,7 +39934,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + return result; + } + -+ reiser4_inode_set_flag(inode, REISER4_PART_IN_CONV); ++ inode_set_flag(inode, REISER4_PART_IN_CONV); + + /* number of pages in the file */ + num_pages = @@ -39721,12 +39952,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + if (result != 0) + break; + if (i == 0 && offset == 0) { -+ reiser4_inode_set_flag(inode, REISER4_PART_MIXED); ++ inode_set_flag(inode, REISER4_PART_MIXED); + reiser4_update_sd(inode); + } + -+ page = read_mapping_page(inode->i_mapping, -+ (unsigned)(i + start_page), NULL); ++ page = read_cache_page(inode->i_mapping, ++ (unsigned)(i + start_page), filler, NULL); + if (IS_ERR(page)) { + result = PTR_ERR(page); + break; @@ -39741,17 +39972,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + } + + /* cut part of file we have read */ -+ start_byte = (__u64) ((i + start_page) << PAGE_CACHE_SHIFT); ++ start_byte = (__u64) (i << PAGE_CACHE_SHIFT); + set_key_offset(&from, start_byte); + set_key_offset(&to, start_byte + PAGE_CACHE_SIZE - 1); + /* -+ * reiser4_cut_tree_object() returns -E_REPEAT to allow atom ++ * cut_tree_object() returns -E_REPEAT to allow atom + * commits during over-long truncates. But + * extent->tail conversion should be performed in one + * transaction. + */ -+ result = reiser4_cut_tree(reiser4_tree_by_inode(inode), &from, -+ &to, inode, 0); ++ result = cut_tree(tree_by_inode(inode), &from, &to, inode, 0); + + if (result) { + page_cache_release(page); @@ -39775,14 +40005,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + file.f_pos = start_byte; + file.private_data = NULL; + pos = start_byte; -+ result = reiser4_write_tail(&file, -+ (char __user *)kmap(page), -+ count, &pos); ++ result = write_tail(&file, (char __user *)kmap(page), ++ count, &pos); + reiser4_free_file_fsdata(&file); + if (result <= 0) { -+ warning("", "reiser4_write_tail failed"); ++ warning("", "write_tail failed"); + page_cache_release(page); -+ reiser4_inode_clr_flag(inode, REISER4_PART_IN_CONV); ++ inode_clr_flag(inode, REISER4_PART_IN_CONV); + return result; + } + count -= result; @@ -39797,7 +40026,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + /* waiting for writeback completion with page lock held is + * perfectly valid. */ + wait_on_page_writeback(page); -+ reiser4_drop_page(page); ++ drop_page(page); + /* release reference taken by read_cache_page() above */ + page_cache_release(page); + @@ -39809,15 +40038,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * nobody is allowed to complete conversion but a process which + * started it + */ -+ assert("", reiser4_inode_get_flag(inode, REISER4_PART_MIXED)); ++ assert("", inode_get_flag(inode, REISER4_PART_MIXED)); + } + -+ reiser4_inode_clr_flag(inode, REISER4_PART_IN_CONV); ++ inode_clr_flag(inode, REISER4_PART_IN_CONV); + + if (i == num_pages) { + /* file is converted to formatted items */ -+ assert("vs-1698", reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED)); ++ assert("vs-1698", inode_get_flag(inode, REISER4_PART_MIXED)); + assert("vs-1260", + inode_has_no_jnodes(reiser4_inode_data(inode))); + @@ -39848,10 +40076,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file/tail_conversion.c linux-2.6.2 + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4/plugin/file_ops.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file_ops.c 2007-07-29 00:25:34.932710971 +0400 -@@ -0,0 +1,168 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file_ops.c +@@ -0,0 +1,167 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + reiser4/README */ + @@ -39867,26 +40096,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4 +/* implementation of vfs's llseek method of struct file_operations for + typical directory can be found in readdir_common.c +*/ -+loff_t reiser4_llseek_dir_common(struct file *, loff_t, int origin); ++loff_t llseek_common_dir(struct file *, loff_t, int origin); + +/* implementation of vfs's readdir method of struct file_operations for + typical directory can be found in readdir_common.c +*/ -+int reiser4_readdir_common(struct file *, void *dirent, filldir_t); ++int readdir_common(struct file *, void *dirent, filldir_t); + +/** -+ * reiser4_release_dir_common - release of struct file_operations ++ * release_dir_common - release of struct file_operations + * @inode: inode of released file + * @file: file to release + * + * Implementation of release method of struct file_operations for typical + * directory. All it does is freeing of reiser4 specific file data. +*/ -+int reiser4_release_dir_common(struct inode *inode, struct file *file) ++int release_dir_common(struct inode *inode, struct file *file) +{ + reiser4_context *ctx; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + reiser4_free_file_fsdata(file); @@ -39897,12 +40126,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4 +/* this is common implementation of vfs's fsync method of struct + file_operations +*/ -+int reiser4_sync_common(struct file *file, struct dentry *dentry, int datasync) ++int sync_common(struct file *file, struct dentry *dentry, int datasync) +{ + reiser4_context *ctx; + int result; + -+ ctx = reiser4_init_context(dentry->d_inode->i_sb); ++ ctx = init_context(dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + result = txnmgr_force_commit_all(dentry->d_inode->i_sb, 0); @@ -39926,7 +40155,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4 + reiser4_context *ctx; + ssize_t result; + -+ ctx = reiser4_init_context(file->f_dentry->d_inode->i_sb); ++ ctx = init_context(file->f_dentry->d_inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + result = generic_file_sendfile(file, ppos, count, actor, target); @@ -39947,7 +40176,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4 + reiser4_context *ctx; + int result; + -+ ctx = reiser4_init_context(page->mapping->host->i_sb); ++ ctx = init_context(page->mapping->host->i_sb); + result = do_prepare_write(file, page, from, to); + + /* don't commit transaction under inode semaphore */ @@ -40017,13 +40246,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops.c linux-2.6.22/fs/reiser4 + * c-basic-offset: 8 + * tab-width: 8 + * fill-column: 79 -+ * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs/reiser4/plugin/file_ops_readdir.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file_ops_readdir.c 2007-07-29 00:25:34.932710971 +0400 -@@ -0,0 +1,658 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file_ops_readdir.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file_ops_readdir.c +@@ -0,0 +1,654 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -40033,13 +40262,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * @inode directory. */ +static int is_valid_dir_coord(struct inode *inode, coord_t * coord) +{ -+ return plugin_of_group(item_plugin_by_coord(coord), -+ DIR_ENTRY_ITEM_TYPE) && -+ inode_file_plugin(inode)->owns_item(inode, coord); ++ return ++ item_type_by_coord(coord) == DIR_ENTRY_ITEM_TYPE && ++ inode_file_plugin(inode)->owns_item(inode, coord); +} + +/* compare two logical positions within the same directory */ -+static cmp_t dir_pos_cmp(const struct dir_pos * p1, const struct dir_pos * p2) ++static cmp_t dir_pos_cmp(const dir_pos * p1, const dir_pos * p2) +{ + cmp_t result; + @@ -40057,13 +40286,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + return result; +} + -+/* see comment before reiser4_readdir_common() for overview of why "adjustment" is ++ ++/* see comment before readdir_common() for overview of why "adjustment" is + * necessary. */ +static void -+adjust_dir_pos(struct file *dir, struct readdir_pos * readdir_spot, -+ const struct dir_pos * mod_point, int adj) ++adjust_dir_pos(struct file *dir, ++ readdir_pos * readdir_spot, const dir_pos * mod_point, int adj) +{ -+ struct dir_pos *pos; ++ dir_pos *pos; + + /* + * new directory entry was added (adj == +1) or removed (adj == -1) at @@ -40085,7 +40315,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * changes */ + readdir_spot->entry_no += adj; + assert("nikita-2577", -+ ergo(dir != NULL, reiser4_get_dir_fpos(dir) + adj >= 0)); ++ ergo(dir != NULL, get_dir_fpos(dir) + adj >= 0)); + if (de_id_cmp(&pos->dir_entry_key, + &mod_point->dir_entry_key) == EQUAL_TO) { + assert("nikita-2575", mod_point->pos < pos->pos); @@ -40123,11 +40353,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs +/* scan all file-descriptors for this directory and adjust their + positions respectively. Should be used by implementations of + add_entry and rem_entry of dir plugin */ -+void reiser4_adjust_dir_file(struct inode *dir, const struct dentry *de, -+ int offset, int adj) ++void ++adjust_dir_file(struct inode *dir, const struct dentry *de, int offset, int adj) +{ + reiser4_file_fsdata *scan; -+ struct dir_pos mod_point; ++ dir_pos mod_point; + + assert("nikita-2536", dir != NULL); + assert("nikita-2538", de != NULL); @@ -40153,7 +40383,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs +/* + * traverse tree to start/continue readdir from the readdir position @pos. + */ -+static int dir_go_to(struct file *dir, struct readdir_pos * pos, tap_t * tap) ++static int dir_go_to(struct file *dir, readdir_pos * pos, tap_t * tap) +{ + reiser4_key key; + int result; @@ -40165,14 +40395,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + result = inode_dir_plugin(inode)->build_readdir_key(dir, &key); + if (result != 0) + return result; -+ result = reiser4_object_lookup(inode, -+ &key, -+ tap->coord, -+ tap->lh, -+ tap->mode, -+ FIND_EXACT, -+ LEAF_LEVEL, LEAF_LEVEL, -+ 0, &tap->ra_info); ++ result = object_lookup(inode, ++ &key, ++ tap->coord, ++ tap->lh, ++ tap->mode, ++ FIND_EXACT, ++ LEAF_LEVEL, LEAF_LEVEL, 0, &tap->ra_info); + if (result == CBK_COORD_FOUND) + result = rewind_right(tap, (int)pos->position.pos); + else { @@ -40187,7 +40416,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * handling of non-unique keys: calculate at what ordinal position within + * sequence of directory items with identical keys @pos is. + */ -+static int set_pos(struct inode *inode, struct readdir_pos * pos, tap_t * tap) ++static int set_pos(struct inode *inode, readdir_pos * pos, tap_t * tap) +{ + int result; + coord_t coord; @@ -40198,9 +40427,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + + coord_init_zero(&coord); + init_lh(&lh); -+ reiser4_tap_init(&scan, &coord, &lh, ZNODE_READ_LOCK); -+ reiser4_tap_copy(&scan, tap); -+ reiser4_tap_load(&scan); ++ tap_init(&scan, &coord, &lh, ZNODE_READ_LOCK); ++ tap_copy(&scan, tap); ++ tap_load(&scan); + pos->position.pos = 0; + + did = &pos->position.dir_entry_key; @@ -40230,15 +40459,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + } + } else + result = RETERR(-ENOENT); -+ reiser4_tap_relse(&scan); -+ reiser4_tap_done(&scan); ++ tap_relse(&scan); ++ tap_done(&scan); + return result; +} + +/* + * "rewind" directory to @offset, i.e., set @pos and @tap correspondingly. + */ -+static int dir_rewind(struct file *dir, struct readdir_pos * pos, tap_t * tap) ++static int dir_rewind(struct file *dir, readdir_pos * pos, tap_t * tap) +{ + __u64 destination; + __s64 shift; @@ -40251,7 +40480,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + assert("nikita-2551", tap->coord != NULL); + assert("nikita-2552", tap->lh != NULL); + -+ dirpos = reiser4_get_dir_fpos(dir); ++ dirpos = get_dir_fpos(dir); + shift = dirpos - pos->fpos; + /* this is logical directory entry within @dir which we are rewinding + * to */ @@ -40284,7 +40513,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + if (result == 0) { + result = rewind_left(tap, shift); + if (result == -E_DEADLOCK) { -+ reiser4_tap_done(tap); ++ tap_done(tap); + continue; + } + } @@ -40321,8 +40550,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * unlocked. + */ +static int -+feed_entry(struct file *f, struct readdir_pos * pos, tap_t * tap, -+ filldir_t filldir, void *dirent) ++feed_entry(struct file *f, ++ readdir_pos * pos, tap_t * tap, filldir_t filldir, void *dirent) +{ + item_plugin *iplug; + char *name; @@ -40351,8 +40580,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + deadlock which may happen if filldir causes page fault. So, copy + name to intermediate buffer */ + if (strlen(name) + 1 > sizeof(name_buf)) { -+ local_name = kmalloc(strlen(name) + 1, -+ reiser4_ctx_gfp_mask_get()); ++ local_name = kmalloc(strlen(name) + 1, get_gfp_mask()); + if (local_name == NULL) + return RETERR(-ENOMEM); + } else @@ -40362,7 +40590,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + file_type = iplug->s.dir.extract_file_type(coord); + + unit_key_by_coord(coord, &entry_key); -+ reiser4_seal_init(&seal, coord, &entry_key); ++ seal_init(&seal, coord, &entry_key); + + longterm_unlock_znode(tap->lh); + @@ -40376,7 +40604,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + */ + assert("nikita-3436", lock_stack_isclean(get_current_lock_stack())); + -+ reiser4_txn_restart_current(); + result = filldir(dirent, name, (int)strlen(name), + /* offset of this entry */ + f->f_pos, @@ -40388,13 +40615,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + /* ->filldir() is satisfied. (no space in buffer, IOW) */ + result = 1; + else -+ result = reiser4_seal_validate(&seal, coord, &entry_key, -+ tap->lh, tap->mode, -+ ZNODE_LOCK_HIPRI); ++ result = seal_validate(&seal, coord, &entry_key, ++ tap->lh, tap->mode, ZNODE_LOCK_HIPRI); + return result; +} + -+static void move_entry(struct readdir_pos * pos, coord_t * coord) ++static void move_entry(readdir_pos * pos, coord_t * coord) +{ + reiser4_key de_key; + de_id *did; @@ -40422,8 +40648,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * + * readdir support in reiser4 relies on ability to update readdir_pos embedded + * into reiser4_file_fsdata on each directory modification (name insertion and -+ * removal), see reiser4_readdir_common() function below. This obviously doesn't -+ * work when reiser4 is accessed over NFS, because NFS doesn't keep any state ++ * removal), see readdir_common() function below. This obviously doesn't work ++ * when reiser4 is accessed over NFS, because NFS doesn't keep any state + * across client READDIR requests for the same directory. + * + * To address this we maintain a "pool" of detached reiser4_file_fsdata @@ -40455,11 +40681,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * + */ + ++ +/* + * prepare for readdir. + */ -+static int dir_readdir_init(struct file *f, tap_t * tap, -+ struct readdir_pos ** pos) ++static int dir_readdir_init(struct file *f, tap_t * tap, readdir_pos ** pos) +{ + struct inode *inode; + reiser4_file_fsdata *fsdata; @@ -40473,7 +40699,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + return RETERR(-ENOTDIR); + + /* try to find detached readdir state */ -+ result = reiser4_attach_fsdata(f, inode); ++ result = try_to_attach_fsdata(f, inode); + if (result != 0) + return result; + @@ -40497,9 +40723,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + +/* this is implementation of vfs's llseek method of struct file_operations for + typical directory -+ See comment before reiser4_readdir_common() for explanation. ++ See comment before readdir_common() for explanation. +*/ -+loff_t reiser4_llseek_dir_common(struct file * file, loff_t off, int origin) ++loff_t llseek_common_dir(struct file * file, loff_t off, int origin) +{ + reiser4_context *ctx; + loff_t result; @@ -40507,7 +40733,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + + inode = file->f_dentry->d_inode; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -40520,19 +40746,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + coord_t coord; + lock_handle lh; + tap_t tap; -+ struct readdir_pos *pos; ++ readdir_pos *pos; + + coord_init_zero(&coord); + init_lh(&lh); -+ reiser4_tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); ++ tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); + + ff = dir_readdir_init(file, &tap, &pos); -+ reiser4_detach_fsdata(file); ++ detach_fsdata(file); + if (ff != 0) + result = (loff_t) ff; -+ reiser4_tap_done(&tap); ++ tap_done(&tap); + } -+ reiser4_detach_fsdata(file); ++ detach_fsdata(file); + mutex_unlock(&inode->i_mutex); + + reiser4_exit_context(ctx); @@ -40582,10 +40808,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + entry all file descriptors for directory inode are scanned and their + readdir_pos are updated accordingly (adjust_dir_pos()). +*/ -+int reiser4_readdir_common(struct file *f /* directory file being read */, -+ void *dirent /* opaque data passed to us by VFS */, -+ filldir_t filld /* filler function passed to us -+ * by VFS */) ++int readdir_common(struct file *f /* directory file being read */ , ++ void *dirent /* opaque data passed to us by VFS */ , ++ filldir_t filld /* filler function passed to us by VFS */ ) +{ + reiser4_context *ctx; + int result; @@ -40593,7 +40818,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + coord_t coord; + lock_handle lh; + tap_t tap; -+ struct readdir_pos *pos; ++ readdir_pos *pos; + + assert("nikita-1359", f != NULL); + inode = f->f_dentry->d_inode; @@ -40602,20 +40827,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + if (!S_ISDIR(inode->i_mode)) + return RETERR(-ENOTDIR); + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + coord_init_zero(&coord); + init_lh(&lh); -+ reiser4_tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); ++ tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); + + reiser4_readdir_readahead_init(inode, &tap); + + repeat: + result = dir_readdir_init(f, &tap, &pos); + if (result == 0) { -+ result = reiser4_tap_load(&tap); ++ result = tap_load(&tap); + /* scan entries one by one feeding them to @filld */ + while (result == 0) { + coord_t *coord; @@ -40643,24 +40868,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + } else if (result == -E_REPEAT) { + /* feed_entry() had to restart. */ + ++f->f_pos; -+ reiser4_tap_relse(&tap); ++ tap_relse(&tap); + goto repeat; + } else + warning("vs-1617", -+ "reiser4_readdir_common: unexpected error %d", ++ "readdir_common: unexpected error %d", + result); + } -+ reiser4_tap_relse(&tap); ++ tap_relse(&tap); + + if (result >= 0) + f->f_version = inode->i_version; + } else if (result == -E_NO_NEIGHBOR || result == -ENOENT) + result = 0; -+ reiser4_tap_done(&tap); -+ reiser4_detach_fsdata(f); ++ tap_done(&tap); ++ detach_fsdata(f); + + /* try to update directory's atime */ -+ if (reiser4_grab_space_force(inode_file_plugin(inode)->estimate.update(inode), ++ if (reiser4_grab_space(inode_file_plugin(inode)->estimate.update(inode), + BA_CAN_COMMIT) != 0) + warning("", "failed to update atime on readdir: %llu", + get_inode_oid(inode)); @@ -40682,10 +40907,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_ops_readdir.c linux-2.6.22/fs + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/fs/reiser4/plugin/file_plugin_common.c ---- linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/file_plugin_common.c 2007-07-29 00:25:34.936712007 +0400 -@@ -0,0 +1,1007 @@ +Index: linux-2.6.16/fs/reiser4/plugin/file_plugin_common.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/file_plugin_common.c +@@ -0,0 +1,929 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + reiser4/README */ + @@ -40711,7 +40937,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + + assert("nikita-730", inode != NULL); + -+ if (reiser4_inode_get_flag(inode, REISER4_NO_SD)) ++ if (inode_get_flag(inode, REISER4_NO_SD)) + /* object doesn't have stat-data yet */ + result = insert_new_sd(inode); + else @@ -40766,7 +40992,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + object->i_gid = current->fsgid; + + /* this object doesn't have stat-data yet */ -+ reiser4_inode_set_flag(object, REISER4_NO_SD); ++ inode_set_flag(object, REISER4_NO_SD); +#if 0 + /* this is now called after all inode plugins are initialized: + do_create_vfs_child after adjust_to_parent */ @@ -40774,7 +41000,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + setup_inode_ops(object, data); +#endif + object->i_nlink = 0; -+ reiser4_seal_init(&reiser4_inode_data(object)->sd_seal, NULL, NULL); ++ seal_init(&reiser4_inode_data(object)->sd_seal, NULL, NULL); + mask = (1 << UNIX_STAT) | (1 << LIGHT_WEIGHT_STAT); + if (!reiser4_is_set(object->i_sb, REISER4_32_BIT_TIMES)) + mask |= (1 << LARGE_TIMES_STAT); @@ -40799,10 +41025,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + * inherit missing plugins from parent + */ + -+ grab_plugin_pset(object, parent, PSET_FILE); -+ grab_plugin_pset(object, parent, PSET_SD); -+ grab_plugin_pset(object, parent, PSET_FORMATTING); -+ grab_plugin_pset(object, parent, PSET_PERM); ++ grab_plugin(object, parent, PSET_FILE); ++ grab_plugin(object, parent, PSET_SD); ++ grab_plugin(object, parent, PSET_FORMATTING); ++ grab_plugin(object, parent, PSET_PERM); + return 0; +} + @@ -40825,7 +41051,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + * inherit missing plugins from parent + */ + for (memb = 0; memb < PSET_LAST; ++memb) { -+ result = grab_plugin_pset(object, parent, memb); ++ result = grab_plugin(object, parent, memb); + if (result != 0) + break; + } @@ -40842,25 +41068,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + return result; + assert("edward-1416", parent != NULL); + -+ grab_plugin_pset(object, parent, PSET_CLUSTER); -+ grab_plugin_pset(object, parent, PSET_CIPHER); -+ grab_plugin_pset(object, parent, PSET_DIGEST); -+ grab_plugin_pset(object, parent, PSET_COMPRESSION); -+ grab_plugin_pset(object, parent, PSET_COMPRESSION_MODE); ++ grab_plugin(object, parent, PSET_CLUSTER); ++ grab_plugin(object, parent, PSET_CIPHER); ++ grab_plugin(object, parent, PSET_DIGEST); ++ grab_plugin(object, parent, PSET_COMPRESSION); ++ grab_plugin(object, parent, PSET_COMPRESSION_MODE); + + return 0; +} + +/* this is common implementation of create_object method of file plugin + */ -+int reiser4_create_object_common(struct inode *object, struct inode *parent, -+ reiser4_object_create_data * data) ++int ++create_object_common(struct inode *object, struct inode *parent UNUSED_ARG, ++ reiser4_object_create_data * data UNUSED_ARG) +{ + reiser4_block_nr reserve; + assert("nikita-744", object != NULL); + assert("nikita-745", parent != NULL); + assert("nikita-747", data != NULL); -+ assert("nikita-748", reiser4_inode_get_flag(object, REISER4_NO_SD)); ++ assert("nikita-748", inode_get_flag(object, REISER4_NO_SD)); + + reserve = estimate_create_common(object); + if (reiser4_grab_space(reserve, BA_CAN_COMMIT)) @@ -40871,14 +41098,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +static int common_object_delete_no_reserve(struct inode *inode); + +/** -+ * reiser4_delete_object_common - delete_object of file_plugin ++ * delete_object_common - delete_object of file_plugin + * @inode: inode to be deleted + * + * This is common implementation of delete_object method of file_plugin. It + * applies to object its deletion consists of removing two items - stat data + * and safe-link. + */ -+int reiser4_delete_object_common(struct inode *inode) ++int delete_object_common(struct inode *inode) +{ + int result; + @@ -40888,13 +41115,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + assert("nikita-3420", inode->i_size == 0 || S_ISLNK(inode->i_mode)); + assert("nikita-3421", inode->i_nlink == 0); + -+ if (!reiser4_inode_get_flag(inode, REISER4_NO_SD)) { ++ ++ if (!inode_get_flag(inode, REISER4_NO_SD)) { + reiser4_block_nr reserve; + + /* grab space which is needed to remove 2 items from the tree: + stat data and safe-link */ -+ reserve = 2 * -+ estimate_one_item_removal(reiser4_tree_by_inode(inode)); ++ reserve = 2 * estimate_one_item_removal(tree_by_inode(inode)); + if (reiser4_grab_space_force(reserve, + BA_RESERVED | BA_CAN_COMMIT)) + return RETERR(-ENOSPC); @@ -40905,14 +41132,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +} + +/** -+ * reiser4_delete_dir_common - delete_object of file_plugin ++ * delete_directory_common - delete_object of file_plugin + * @inode: inode to be deleted + * + * This is common implementation of delete_object method of file_plugin for + * typical directory. It calls done method of dir_plugin to remove "." and + * removes stat data and safe-link. + */ -+int reiser4_delete_dir_common(struct inode *inode) ++int delete_directory_common(struct inode *inode) +{ + int result; + dir_plugin *dplug; @@ -40924,11 +41151,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + assert("vs-1101", dplug && dplug->done); + + /* kill cursors which might be attached to inode */ -+ reiser4_kill_cursors(inode); ++ kill_cursors(inode); + + /* grab space enough for removing two items */ + if (reiser4_grab_space -+ (2 * estimate_one_item_removal(reiser4_tree_by_inode(inode)), ++ (2 * estimate_one_item_removal(tree_by_inode(inode)), + BA_RESERVED | BA_CAN_COMMIT)) + return RETERR(-ENOSPC); + @@ -40940,7 +41167,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + +/* this is common implementation of add_link method of file plugin + */ -+int reiser4_add_link_common(struct inode *object, struct inode *parent) ++int add_link_common(struct inode *object, struct inode *parent UNUSED_ARG) +{ + /* + * increment ->i_nlink and update ->i_ctime @@ -40953,7 +41180,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + +/* this is common implementation of rem_link method of file plugin + */ -+int reiser4_rem_link_common(struct inode *object, struct inode *parent) ++int rem_link_common(struct inode *object, struct inode *parent UNUSED_ARG) +{ + assert("nikita-2021", object != NULL); + assert("nikita-2163", object->i_nlink > 0); @@ -41013,7 +41240,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + assert("nikita-1335", inode != NULL); + assert("nikita-1334", coord != NULL); + -+ if (plugin_of_group(item_plugin_by_coord(coord), DIR_ENTRY_ITEM_TYPE)) ++ if (item_type_by_coord(coord) == DIR_ENTRY_ITEM_TYPE) + return get_key_locality(item_key_by_coord(coord, &item_key)) == + get_inode_oid(inode); + else @@ -41044,7 +41271,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +/* this is common implementation of detach method of file plugin for typical + directory +*/ -+int reiser4_detach_common_dir(struct inode *child, struct inode *parent) ++int detach_common_dir(struct inode *child, struct inode *parent) +{ + dir_plugin *dplug; + @@ -41057,7 +41284,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +/* this is common implementation of bind method of file plugin for typical + directory +*/ -+int reiser4_bind_common_dir(struct inode *child, struct inode *parent) ++int bind_common_dir(struct inode *child, struct inode *parent) +{ + dir_plugin *dplug; + @@ -41094,7 +41321,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +*/ +reiser4_block_nr estimate_create_common(const struct inode * object) +{ -+ return estimate_one_insert_item(reiser4_tree_by_inode(object)); ++ return estimate_one_insert_item(tree_by_inode(object)); +} + +/* this is common implementation of estimate.create method of file plugin for @@ -41104,7 +41331,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +*/ +reiser4_block_nr estimate_create_common_dir(const struct inode * object) +{ -+ return 2 * estimate_one_insert_item(reiser4_tree_by_inode(object)); ++ return 2 * estimate_one_insert_item(tree_by_inode(object)); +} + +/* this is common implementation of estimate.update method of file plugin @@ -41113,7 +41340,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +*/ +reiser4_block_nr estimate_update_common(const struct inode * inode) +{ -+ return estimate_one_insert_into_item(reiser4_tree_by_inode(inode)); ++ return estimate_one_insert_into_item(tree_by_inode(inode)); +} + +/* this is common implementation of estimate.unlink method of file plugin @@ -41198,7 +41425,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + if (code != -ENOMEM) { + warning("nikita-717", "Error for inode %llu (%i)", + (unsigned long long)get_key_objectid(key), code); -+ reiser4_print_key("for key", key); ++ print_key("for key", key); + } +} + @@ -41230,7 +41457,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + (znode_get_level(coord->node) != LEAF_LEVEL) || + !item_is_statdata(coord)) { + warning("nikita-1901", "Conspicuous seal"); -+ reiser4_print_key("key", key); ++ print_key("key", key); + print_coord("coord", coord, 1); + impossible("nikita-2877", "no way"); + } @@ -41256,7 +41483,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + oid_t oid; + + assert("nikita-723", inode != NULL); -+ assert("nikita-3406", reiser4_inode_get_flag(inode, REISER4_NO_SD)); ++ assert("nikita-3406", inode_get_flag(inode, REISER4_NO_SD)); + + ref = reiser4_inode_data(inode); + spin_lock_inode(inode); @@ -41277,7 +41504,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ +/* could be optimized for case where there is only one node format in + * use in the filesystem, probably there are lots of such + * places we could optimize for only one node layout.... -Hans */ -+ if (data.length > reiser4_tree_by_inode(inode)->nplug->max_item_size()){ ++ if (data.length > tree_by_inode(inode)->nplug->max_item_size()) { + /* This is silly check, but we don't know actual node where + insertion will go into. */ + return RETERR(-ENAMETOOLONG); @@ -41292,7 +41519,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + coord_init_zero(&coord); + init_lh(&lh); + -+ result = insert_by_key(reiser4_tree_by_inode(inode), ++ result = insert_by_key(tree_by_inode(inode), + build_sd_key(inode, &key), &data, &coord, &lh, + /* stat data lives on a leaf level */ + LEAF_LEVEL, CBK_UNIQUE); @@ -41329,10 +41556,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + znode_make_dirty(coord.node); + if (result == 0) { + /* object has stat-data now */ -+ reiser4_inode_clr_flag(inode, REISER4_NO_SD); -+ reiser4_inode_set_flag(inode, REISER4_SDLEN_KNOWN); ++ inode_clr_flag(inode, REISER4_NO_SD); ++ inode_set_flag(inode, REISER4_SDLEN_KNOWN); + /* initialise stat-data seal */ -+ reiser4_seal_init(&ref->sd_seal, &coord, &key); ++ seal_init(&ref->sd_seal, &coord, &key); + ref->sd_coord = coord; + check_inode_seal(inode, &coord, &key); + } else if (result != -ENOMEM) @@ -41381,7 +41608,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + * it only covers _body_ of the file, and stat data don't belong + * there. + */ -+ result = coord_by_key(reiser4_tree_by_inode(inode), ++ result = coord_by_key(tree_by_inode(inode), + key, + coord, + lh, @@ -41413,13 +41640,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + spin_unlock_inode(inode); + + build_sd_key(inode, key); -+ if (reiser4_seal_is_set(&seal)) { ++ if (seal_is_set(&seal)) { + /* first, try to use seal */ -+ result = reiser4_seal_validate(&seal, -+ coord, -+ key, -+ lh, ZNODE_WRITE_LOCK, -+ ZNODE_LOCK_LOPRI); ++ result = seal_validate(&seal, ++ coord, ++ key, ++ lh, ZNODE_WRITE_LOCK, ZNODE_LOCK_LOPRI); + if (result == 0) + check_sd_coord(coord, key); + } else @@ -41432,64 +41658,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + return result; +} + -+#if REISER4_DEBUG -+static int all_but_offset_key_eq(const reiser4_key * k1, const reiser4_key * k2) -+{ -+ return (get_key_locality(k1) == get_key_locality(k2) && -+ get_key_type(k1) == get_key_type(k2) && -+ get_key_band(k1) == get_key_band(k2) && -+ get_key_ordering(k1) == get_key_ordering(k2) && -+ get_key_objectid(k1) == get_key_objectid(k2)); -+} -+ -+#include "../tree_walk.h" -+ -+/* make some checks before and after stat-data resize operation */ -+static int check_sd_resize(struct inode * inode, coord_t * coord, -+ int length, int progress /* 1 means after resize */) -+{ -+ int ret = 0; -+ lock_handle left_lock; -+ coord_t left_coord; -+ reiser4_key left_key; -+ reiser4_key key; -+ -+ if (inode_file_plugin(inode) != -+ file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)) -+ return 0; -+ if (!length) -+ return 0; -+ if (coord->item_pos != 0) -+ return 0; -+ -+ init_lh(&left_lock); -+ ret = reiser4_get_left_neighbor(&left_lock, -+ coord->node, -+ ZNODE_WRITE_LOCK, -+ GN_CAN_USE_UPPER_LEVELS); -+ if (ret == -E_REPEAT || ret == -E_NO_NEIGHBOR || -+ ret == -ENOENT || ret == -EINVAL -+ || ret == -E_DEADLOCK) { -+ ret = 0; -+ goto exit; -+ } -+ ret = zload(left_lock.node); -+ if (ret) -+ goto exit; -+ coord_init_last_unit(&left_coord, left_lock.node); -+ item_key_by_coord(&left_coord, &left_key); -+ item_key_by_coord(coord, &key); -+ -+ if (all_but_offset_key_eq(&key, &left_key)) -+ /* corruption occured */ -+ ret = 1; -+ zrelse(left_lock.node); -+ exit: -+ done_lh(&left_lock); -+ return ret; -+} -+#endif -+ +/* update stat-data at @coord */ +static int +update_sd_at(struct inode *inode, coord_t * coord, reiser4_key * key, @@ -41515,54 +41683,39 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + + /* if inode has non-standard plugins, add appropriate stat data + * extension */ -+ if (state->extmask & (1 << PLUGIN_STAT)) { -+ if (state->plugin_mask == 0) -+ inode_clr_extension(inode, PLUGIN_STAT); -+ } else if (state->plugin_mask != 0) ++ if (state->plugin_mask != 0) + inode_set_extension(inode, PLUGIN_STAT); + -+ if (state->extmask & (1 << HEIR_STAT)) { -+ if (state->heir_mask == 0) -+ inode_clr_extension(inode, HEIR_STAT); -+ } else if (state->heir_mask != 0) -+ inode_set_extension(inode, HEIR_STAT); -+ + /* data.length is how much space to add to (or remove + from if negative) sd */ -+ if (!reiser4_inode_get_flag(inode, REISER4_SDLEN_KNOWN)) { ++ if (!inode_get_flag(inode, REISER4_SDLEN_KNOWN)) { + /* recalculate stat-data length */ + data.length = + data.iplug->s.sd.save_len(inode) - + item_length_by_coord(coord); -+ reiser4_inode_set_flag(inode, REISER4_SDLEN_KNOWN); ++ inode_set_flag(inode, REISER4_SDLEN_KNOWN); + } else + data.length = 0; + spin_unlock_inode(inode); + + /* if on-disk stat data is of different length than required + for this inode, resize it */ -+ + if (data.length != 0) { + data.data = NULL; + data.user = 0; + -+ assert("edward-1441", -+ !check_sd_resize(inode, coord, -+ data.length, 0/* before resize */)); -+ + /* insertion code requires that insertion point (coord) was + * between units. */ + coord->between = AFTER_UNIT; -+ result = reiser4_resize_item(coord, &data, key, lh, -+ COPI_DONT_SHIFT_LEFT); ++ result = resize_item(coord, ++ &data, key, lh, COPI_DONT_SHIFT_LEFT); + if (result != 0) { + key_warning(key, inode, result); + zrelse(loaded); + return result; + } + if (loaded != coord->node) { -+ /* reiser4_resize_item moved coord to another node. -+ Zload it */ ++ /* resize_item moved coord to another node. Zload it */ + zrelse(loaded); + coord_clear_iplug(coord); + result = zload(coord->node); @@ -41570,10 +41723,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + return result; + loaded = coord->node; + } -+ assert("edward-1442", -+ !check_sd_resize(inode, coord, -+ data.length, 1/* after resize */)); + } ++ + area = item_body_by_coord(coord); + spin_lock_inode(inode); + result = data.iplug->s.sd.save(inode, &area); @@ -41586,7 +41737,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + * was changed and new extensions were pasted into item. + */ + coord->between = AT_UNIT; -+ reiser4_seal_init(&state->sd_seal, coord, key); ++ seal_init(&state->sd_seal, coord, key); + state->sd_coord = *coord; + spin_unlock_inode(inode); + check_inode_seal(inode, coord, key); @@ -41606,7 +41757,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + assert("nikita-726", inode != NULL); + + /* no stat-data, nothing to update?! */ -+ assert("nikita-3482", !reiser4_inode_get_flag(inode, REISER4_NO_SD)); ++ assert("nikita-3482", !inode_get_flag(inode, REISER4_NO_SD)); + + init_lh(&lh); + @@ -41618,8 +41769,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + return result; +} + -+/* helper for reiser4_delete_object_common and reiser4_delete_dir_common. -+ Remove object stat data. Space for that must be reserved by caller before ++/* helper for delete_object_common and delete_directory_common. Remove object ++ stat data. Space for that must be reserved by caller before +*/ +static int +common_object_delete_no_reserve(struct inode *inode /* object to remove */ ) @@ -41628,7 +41779,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + + assert("nikita-1477", inode != NULL); + -+ if (!reiser4_inode_get_flag(inode, REISER4_NO_SD)) { ++ if (!inode_get_flag(inode, REISER4_NO_SD)) { + reiser4_key sd_key; + + DQUOT_FREE_INODE(inode); @@ -41636,15 +41787,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + + build_sd_key(inode, &sd_key); + result = -+ reiser4_cut_tree(reiser4_tree_by_inode(inode), -+ &sd_key, &sd_key, NULL, 0); ++ cut_tree(tree_by_inode(inode), &sd_key, &sd_key, NULL, 0); + if (result == 0) { -+ reiser4_inode_set_flag(inode, REISER4_NO_SD); ++ inode_set_flag(inode, REISER4_NO_SD); + result = oid_release(inode->i_sb, get_inode_oid(inode)); + if (result == 0) { + oid_count_released(); + -+ result = safe_link_del(reiser4_tree_by_inode(inode), ++ result = safe_link_del(tree_by_inode(inode), + get_inode_oid(inode), + SAFE_UNLINK); + } @@ -41664,7 +41814,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + struct dentry dentry; + + assert("vs-21", is_in_reiser4_context()); -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + assert("vs-22", !IS_ERR(ctx)); + + attr.ia_size = size; @@ -41683,20 +41833,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/file_plugin_common.c linux-2.6.22/ + return result; +} + -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 80 -+ scroll-step: 1 -+ End: ++/* Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/hash.c linux-2.6.22/fs/reiser4/plugin/hash.c ---- linux-2.6.22.orig/fs/reiser4/plugin/hash.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/hash.c 2007-07-29 00:25:34.936712007 +0400 -@@ -0,0 +1,353 @@ +Index: linux-2.6.16/fs/reiser4/plugin/hash.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/hash.c +@@ -0,0 +1,350 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -41946,9 +42095,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/hash.c linux-2.6.22/fs/reiser4/plu + return 0xc0c0c0c010101010ull; +} + -+static int change_hash(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_hash(struct inode *inode, reiser4_plugin * plugin) +{ + int result; + @@ -41956,17 +42103,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/hash.c linux-2.6.22/fs/reiser4/plu + assert("nikita-3504", plugin != NULL); + + assert("nikita-3505", is_reiser4_inode(inode)); ++ assert("nikita-3506", inode_dir_plugin(inode) != NULL); + assert("nikita-3507", plugin->h.type_id == REISER4_HASH_PLUGIN_TYPE); + -+ if (!plugin_of_group(inode_file_plugin(inode), REISER4_DIRECTORY_FILE)) -+ return RETERR(-EINVAL); -+ + result = 0; + if (inode_hash_plugin(inode) == NULL || + inode_hash_plugin(inode)->h.id != plugin->h.id) { + if (is_dir_empty(inode) == 0) -+ result = aset_set_unsafe(&reiser4_inode_data(inode)->pset, -+ PSET_HASH, plugin); ++ result = ++ plugin_set_hash(&reiser4_inode_data(inode)->pset, ++ &plugin->hash); + else + result = RETERR(-ENOTEMPTY); + @@ -42050,10 +42196,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/hash.c linux-2.6.22/fs/reiser4/plu + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser4/plugin/inode_ops.c ---- linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/inode_ops.c 2007-07-29 00:25:34.936712007 +0400 -@@ -0,0 +1,897 @@ +Index: linux-2.6.16/fs/reiser4/plugin/inode_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/inode_ops.c +@@ -0,0 +1,886 @@ +/* + * Copyright 2005 by Hans Reiser, licensing governed by reiser4/README + */ @@ -42069,11 +42216,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +#include +#include + ++ +static int create_vfs_object(struct inode *parent, struct dentry *dentry, + reiser4_object_create_data *data); + +/** -+ * reiser4_create_common - create of inode operations ++ * create_common - create of inode operations + * @parent: inode of parent directory + * @dentry: dentry of new object to create + * @mode: the permissions to use @@ -42083,29 +42231,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * inode_operations. + * Creates regular file using file plugin from parent directory plugin set. + */ -+int reiser4_create_common(struct inode *parent, struct dentry *dentry, -+ int mode, struct nameidata *nameidata) ++int create_common(struct inode *parent, struct dentry *dentry, ++ int mode, struct nameidata *nameidata) +{ + reiser4_object_create_data data; -+ file_plugin *fplug; + + memset(&data, 0, sizeof data); + data.mode = S_IFREG | mode; -+ fplug = child_create_plugin(parent) ? : inode_create_plugin(parent); -+ if (!plugin_of_group(fplug, REISER4_REGULAR_FILE)) { -+ warning("vpf-1900", "'%s' is not a regular file plugin.", -+ fplug->h.label); -+ return RETERR(-EIO); -+ } -+ data.id = fplug->h.id; ++ data.id = inode_regular_plugin(parent)->id; + return create_vfs_object(parent, dentry, &data); +} + -+int reiser4_lookup_name(struct inode *dir, struct dentry *, reiser4_key *); ++int lookup_name(struct inode *dir, struct dentry *, reiser4_key *); +void check_light_weight(struct inode *inode, struct inode *parent); + +/** -+ * reiser4_lookup_common - lookup of inode operations ++ * lookup_common - lookup of inode operations + * @parent: inode of directory to lookup into + * @dentry: name to look for + * @nameidata: @@ -42113,9 +42254,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * This is common implementation of vfs's lookup method of struct + * inode_operations. + */ -+struct dentry *reiser4_lookup_common(struct inode *parent, -+ struct dentry *dentry, -+ struct nameidata *nameidata) ++struct dentry *lookup_common(struct inode *parent, struct dentry *dentry, ++ struct nameidata *nameidata) +{ + reiser4_context *ctx; + int result; @@ -42123,14 +42263,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + struct inode *inode; + reiser4_dir_entry_desc entry; + -+ ctx = reiser4_init_context(parent->i_sb); ++ ctx = init_context(parent->i_sb); + if (IS_ERR(ctx)) + return (struct dentry *)ctx; + + /* set up operations on dentry. */ + dentry->d_op = &get_super_private(parent->i_sb)->ops.dentry; + -+ result = reiser4_lookup_name(parent, dentry, &entry.key); ++ result = lookup_name(parent, dentry, &entry.key); + if (result) { + context_set_commit_async(ctx); + reiser4_exit_context(ctx); @@ -42167,7 +42307,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +int reiser4_update_dir(struct inode *); + +/** -+ * reiser4_link_common - link of inode operations ++ * link_common - link of inode operations + * @existing: dentry of object which is to get new name + * @parent: directory where new name is to be created + * @newname: new name @@ -42175,8 +42315,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * This is common implementation of vfs's link method of struct + * inode_operations. + */ -+int reiser4_link_common(struct dentry *existing, struct inode *parent, -+ struct dentry *newname) ++int link_common(struct dentry *existing, struct inode *parent, ++ struct dentry *newname) +{ + reiser4_context *ctx; + int result; @@ -42186,7 +42326,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + reiser4_object_create_data data; + reiser4_block_nr reserve; + -+ ctx = reiser4_init_context(parent->i_sb); ++ ctx = init_context(parent->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -42198,7 +42338,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + assert("nikita-1434", object != NULL); + + /* check for race with create_object() */ -+ if (reiser4_inode_get_flag(object, REISER4_IMMUTABLE)) { ++ if (inode_get_flag(object, REISER4_IMMUTABLE)) { + context_set_commit_async(ctx); + reiser4_exit_context(ctx); + return RETERR(-E_REPEAT); @@ -42234,7 +42374,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * reiser4_unlink() viz. creation of safe-link. + */ + if (unlikely(object->i_nlink == 0)) { -+ result = safe_link_del(reiser4_tree_by_inode(object), ++ result = safe_link_del(tree_by_inode(object), + get_inode_oid(object), SAFE_UNLINK); + if (result != 0) { + context_set_commit_async(ctx); @@ -42281,21 +42421,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +static int unlink_check_and_grab(struct inode *parent, struct dentry *victim); + +/** -+ * reiser4_unlink_common - unlink of inode operations ++ * unlink_common - unlink of inode operations + * @parent: inode of directory to remove name from + * @victim: name to be removed + * + * This is common implementation of vfs's unlink method of struct + * inode_operations. + */ -+int reiser4_unlink_common(struct inode *parent, struct dentry *victim) ++int unlink_common(struct inode *parent, struct dentry *victim) +{ + reiser4_context *ctx; + int result; + struct inode *object; + file_plugin *fplug; + -+ ctx = reiser4_init_context(parent->i_sb); ++ ctx = init_context(parent->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -42376,7 +42516,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +} + +/** -+ * reiser4_symlink_common - symlink of inode operations ++ * symlink_common - symlink of inode operations + * @parent: inode of parent directory + * @dentry: dentry of object to be created + * @linkname: string symlink is to contain @@ -42385,8 +42525,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * inode_operations. + * Creates object using file plugin SYMLINK_FILE_PLUGIN_ID. + */ -+int reiser4_symlink_common(struct inode *parent, struct dentry *dentry, -+ const char *linkname) ++int symlink_common(struct inode *parent, struct dentry *dentry, ++ const char *linkname) +{ + reiser4_object_create_data data; + @@ -42398,7 +42538,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +} + +/** -+ * reiser4_mkdir_common - mkdir of inode operations ++ * mkdir_common - mkdir of inode operations + * @parent: inode of parent directory + * @dentry: dentry of object to be created + * @mode: the permissions to use @@ -42407,7 +42547,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * inode_operations. + * Creates object using file plugin DIRECTORY_FILE_PLUGIN_ID. + */ -+int reiser4_mkdir_common(struct inode *parent, struct dentry *dentry, int mode) ++int mkdir_common(struct inode *parent, struct dentry *dentry, int mode) +{ + reiser4_object_create_data data; + @@ -42418,7 +42558,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +} + +/** -+ * reiser4_mknod_common - mknod of inode operations ++ * mknod_common - mknod of inode operations + * @parent: inode of parent directory + * @dentry: dentry of object to be created + * @mode: the permissions to use and file type @@ -42428,8 +42568,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + * inode_operations. + * Creates object using file plugin SPECIAL_FILE_PLUGIN_ID. + */ -+int reiser4_mknod_common(struct inode *parent, struct dentry *dentry, -+ int mode, dev_t rdev) ++int mknod_common(struct inode *parent, struct dentry *dentry, ++ int mode, dev_t rdev) +{ + reiser4_object_create_data data; + @@ -42446,36 +42586,35 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + */ + +/** -+ * reiser4_follow_link_common - follow_link of inode operations ++ * follow_link_common - follow_link of inode operations + * @dentry: dentry of symlink + * @data: + * + * This is common implementation of vfs's followlink method of struct + * inode_operations. -+ * Assumes that inode's i_private points to the content of symbolic link. ++ * Assumes that inode's generic_ip points to the content of symbolic link. + */ -+void *reiser4_follow_link_common(struct dentry *dentry, struct nameidata *nd) ++void *follow_link_common(struct dentry *dentry, struct nameidata *nd) +{ + assert("vs-851", S_ISLNK(dentry->d_inode->i_mode)); + -+ if (!dentry->d_inode->i_private -+ || !reiser4_inode_get_flag(dentry->d_inode, -+ REISER4_GENERIC_PTR_USED)) ++ if (!dentry->d_inode->u.generic_ip ++ || !inode_get_flag(dentry->d_inode, REISER4_GENERIC_PTR_USED)) + return ERR_PTR(RETERR(-EINVAL)); -+ nd_set_link(nd, dentry->d_inode->i_private); ++ nd_set_link(nd, dentry->d_inode->u.generic_ip); + return NULL; +} + +/** -+ * reiser4_permission_common - permission of inode operations ++ * permission_common - permission of inode operations + * @inode: inode to check permissions for + * @mask: mode bits to check permissions for + * @nameidata: + * + * Uses generic function to check for rwx permissions. + */ -+int reiser4_permission_common(struct inode *inode, int mask, -+ struct nameidata *nameidata) ++int permission_common(struct inode *inode, int mask, ++ struct nameidata *nameidata) +{ + return generic_permission(inode, mask, NULL); +} @@ -42485,7 +42624,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +/* this is common implementation of vfs's setattr method of struct + inode_operations +*/ -+int reiser4_setattr_common(struct dentry *dentry, struct iattr *attr) ++int setattr_common(struct dentry *dentry, struct iattr *attr) +{ + reiser4_context *ctx; + struct inode *inode; @@ -42496,7 +42635,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + if (result) + return result; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -42505,7 +42644,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + /* + * grab disk space and call standard inode_setattr(). + */ -+ result = setattr_reserve(reiser4_tree_by_inode(inode)); ++ result = setattr_reserve(tree_by_inode(inode)); + if (!result) { + if ((attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) + || (attr->ia_valid & ATTR_GID @@ -42530,8 +42669,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser +/* this is common implementation of vfs's getattr method of struct + inode_operations +*/ -+int reiser4_getattr_common(struct vfsmount *mnt UNUSED_ARG, -+ struct dentry *dentry, struct kstat *stat) ++int ++getattr_common(struct vfsmount *mnt UNUSED_ARG, struct dentry *dentry, ++ struct kstat *stat) +{ + struct inode *obj; + @@ -42657,8 +42797,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + memset(&entry, 0, sizeof entry); + entry.obj = object; + -+ set_plugin(&reiser4_inode_data(object)->pset, PSET_FILE, -+ file_plugin_to_plugin(obj_plug)); ++ plugin_set_file(&reiser4_inode_data(object)->pset, obj_plug); + result = obj_plug->set_plug_in_inode(object, parent, data); + if (result) { + warning("nikita-431", "Cannot install plugin %i on %llx", @@ -42685,8 +42824,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + result = obj_plug->adjust_to_parent(object, + parent, + object->i_sb->s_root->d_inode); -+ if (result == 0) -+ result = finish_pset(object); + if (result != 0) { + warning("nikita-432", "Cannot inherit from %llx to %llx", + (unsigned long long)get_inode_oid(parent), @@ -42730,19 +42867,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + crash. This all only matters if it's possible to access file + without name, for example, by inode number + */ -+ reiser4_inode_set_flag(object, REISER4_IMMUTABLE); ++ inode_set_flag(object, REISER4_IMMUTABLE); + + /* create empty object, this includes allocation of new objectid. For + directories this implies creation of dot and dotdot */ -+ assert("nikita-2265", reiser4_inode_get_flag(object, REISER4_NO_SD)); ++ assert("nikita-2265", inode_get_flag(object, REISER4_NO_SD)); + + /* mark inode as `loaded'. From this point onward + reiser4_delete_inode() will try to remove its stat-data. */ -+ reiser4_inode_set_flag(object, REISER4_LOADED); ++ inode_set_flag(object, REISER4_LOADED); + + result = obj_plug->create_object(object, parent, data); + if (result != 0) { -+ reiser4_inode_clr_flag(object, REISER4_IMMUTABLE); ++ inode_clr_flag(object, REISER4_IMMUTABLE); + if (result != -ENAMETOOLONG && result != -ENOMEM) + warning("nikita-2219", + "Failed to create sd for %llu", @@ -42755,8 +42892,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + if (obj_dir != NULL) + result = obj_dir->init(object, parent, data); + if (result == 0) { -+ assert("nikita-434", !reiser4_inode_get_flag(object, -+ REISER4_NO_SD)); ++ assert("nikita-434", !inode_get_flag(object, REISER4_NO_SD)); + /* insert inode into VFS hash table */ + insert_inode_hash(object); + /* create entry */ @@ -42800,7 +42936,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + } + + /* file has name now, clear immutable flag */ -+ reiser4_inode_clr_flag(object, REISER4_IMMUTABLE); ++ inode_clr_flag(object, REISER4_IMMUTABLE); + + /* on error, iput() will call ->delete_inode(). We should keep track + of the existence of stat-data for this inode and avoid attempt to @@ -42821,7 +42957,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + int result; + struct inode *child; + -+ ctx = reiser4_init_context(parent->i_sb); ++ ctx = init_context(parent->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + context_set_commit_async(ctx); @@ -42869,7 +43005,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + /* update_dir(parent) */ + res += inode_file_plugin(parent)->estimate.update(parent); + /* safe-link */ -+ res += estimate_one_item_removal(reiser4_tree_by_inode(object)); ++ res += estimate_one_item_removal(tree_by_inode(object)); + + return res; +} @@ -42901,12 +43037,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + /* fplug->unlink */ + res += fplug->estimate.unlink(object, parent); + /* safe-link */ -+ res += estimate_one_insert_item(reiser4_tree_by_inode(object)); ++ res += estimate_one_insert_item(tree_by_inode(object)); + + return res; +} + -+/* helper for reiser4_unlink_common. Estimate and grab space for unlink. */ ++/* helper for unlink_common. Estimate and grab space for unlink. */ +static int unlink_check_and_grab(struct inode *parent, struct dentry *victim) +{ + file_plugin *fplug; @@ -42918,10 +43054,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + fplug = inode_file_plugin(child); + + /* check for race with create_object() */ -+ if (reiser4_inode_get_flag(child, REISER4_IMMUTABLE)) ++ if (inode_get_flag(child, REISER4_IMMUTABLE)) + return RETERR(-E_REPEAT); + /* object being deleted should have stat data */ -+ assert("vs-949", !reiser4_inode_get_flag(child, REISER4_NO_SD)); ++ assert("vs-949", !inode_get_flag(child, REISER4_NO_SD)); + + /* ask object plugin */ + if (fplug->can_rem_link != NULL && !fplug->can_rem_link(child)) @@ -42934,7 +43070,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + return reiser4_grab_reserved(child->i_sb, result, BA_CAN_COMMIT); +} + -+/* helper for reiser4_setattr_common */ ++/* helper for setattr_common */ +static int setattr_reserve(reiser4_tree * tree) +{ + assert("vs-1096", is_grab_enabled(get_current_context())); @@ -42951,10 +43087,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops.c linux-2.6.22/fs/reiser + dir->i_ctime = dir->i_mtime = CURRENT_TIME; + return reiser4_update_sd(dir); +} -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs/reiser4/plugin/inode_ops_rename.c ---- linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/inode_ops_rename.c 2007-07-29 00:25:34.940713042 +0400 -@@ -0,0 +1,914 @@ +Index: linux-2.6.16/fs/reiser4/plugin/inode_ops_rename.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/inode_ops_rename.c +@@ -0,0 +1,904 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -42986,9 +43123,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + if (result != 0) + return result; + from_item = item_plugin_by_coord(from_coord); -+ if (plugin_of_group(item_plugin_by_coord(from_coord), -+ DIR_ENTRY_ITEM_TYPE)) -+ { ++ if (item_type_by_coord(from_coord) == DIR_ENTRY_ITEM_TYPE) { + reiser4_key to_key; + + build_sd_key(to_inode, &to_key); @@ -43228,7 +43363,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + return 0; +} + -+int reiser4_find_entry(struct inode *, struct dentry *, lock_handle *, ++int find_entry(struct inode *, struct dentry *, lock_handle *, + znode_lock_mode, reiser4_dir_entry_desc *); +int reiser4_update_dir(struct inode *); + @@ -43243,12 +43378,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + entry. This should be re-considered when more than one different + directory plugin will be implemented. +*/ -+int reiser4_rename_common(struct inode *old_dir /* directory where @old -+ * is located */ , -+ struct dentry *old_name /* old name */ , -+ struct inode *new_dir /* directory where @new -+ * is located */ , -+ struct dentry *new_name /* new name */ ) ++int rename_common(struct inode *old_dir /* directory where @old is located */ , ++ struct dentry *old_name /* old name */ , ++ struct inode *new_dir /* directory where @new is located */ , ++ struct dentry *new_name /* new name */ ) +{ + /* From `The Open Group Base Specifications Issue 6' + @@ -43336,22 +43469,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + struct inode *new_inode; + coord_t *new_coord; + -+ struct reiser4_dentry_fsdata *new_fsdata; ++ reiser4_dentry_fsdata *new_fsdata; + dir_plugin *dplug; + file_plugin *fplug; + + reiser4_dir_entry_desc *old_entry, *new_entry, *dotdot_entry; + lock_handle *new_lh, *dotdot_lh; + struct dentry *dotdot_name; -+ struct reiser4_dentry_fsdata *dataonstack; ++ reiser4_dentry_fsdata *dataonstack; + -+ ctx = reiser4_init_context(old_dir->i_sb); ++ ctx = init_context(old_dir->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + + old_entry = kmalloc(3 * sizeof(*old_entry) + 2 * sizeof(*new_lh) + + sizeof(*dotdot_name) + sizeof(*dataonstack), -+ reiser4_ctx_gfp_mask_get()); ++ GFP_KERNEL); + if (old_entry == NULL) { + context_set_commit_async(ctx); + reiser4_exit_context(ctx); @@ -43365,7 +43498,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + new_lh = (lock_handle *)(old_entry + 3); + dotdot_lh = new_lh + 1; + dotdot_name = (struct dentry *)(new_lh + 2); -+ dataonstack = (struct reiser4_dentry_fsdata *)(dotdot_name + 1); ++ dataonstack = (reiser4_dentry_fsdata *)(dotdot_name + 1); + + assert("nikita-2318", old_dir != NULL); + assert("nikita-2319", new_dir != NULL); @@ -43425,8 +43558,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + init_lh(new_lh); + + /* find entry for @new_name */ -+ result = reiser4_find_entry(new_dir, new_name, new_lh, ZNODE_WRITE_LOCK, -+ new_entry); ++ result = find_entry(new_dir, ++ new_name, new_lh, ZNODE_WRITE_LOCK, new_entry); + + if (IS_CBKERR(result)) { + done_lh(new_lh); @@ -43436,7 +43569,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + return result; + } + -+ reiser4_seal_done(&new_fsdata->dec.entry_seal); ++ seal_done(&new_fsdata->dec.entry_seal); + + /* add or replace name for @old_inode as @new_name */ + if (new_inode != NULL) { @@ -43535,9 +43668,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + dotdot_coord = &dataonstack->dec.entry_coord; + coord_clear_iplug(dotdot_coord); + -+ result = reiser4_find_entry(old_inode, dotdot_name, -+ dotdot_lh, ZNODE_WRITE_LOCK, -+ dotdot_entry); ++ result = find_entry(old_inode, dotdot_name, dotdot_lh, ++ ZNODE_WRITE_LOCK, dotdot_entry); + if (result == 0) { + /* replace_name() decreases i_nlink on + * @old_dir */ @@ -43571,12 +43703,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs +} + +#if 0 -+int reiser4_rename_common(struct inode *old_dir /* directory where @old -+ * is located */ , -+ struct dentry *old_name /* old name */ , -+ struct inode *new_dir /* directory where @new -+ * is located */ , -+ struct dentry *new_name /* new name */ ) ++int rename_common(struct inode *old_dir /* directory where @old is located */ , ++ struct dentry *old_name /* old name */ , ++ struct inode *new_dir /* directory where @new is located */ , ++ struct dentry *new_name /* new name */ ) +{ + /* From `The Open Group Base Specifications Issue 6' + @@ -43664,12 +43794,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + reiser4_dir_entry_desc old_entry; + reiser4_dir_entry_desc new_entry; + coord_t *new_coord; -+ struct reiser4_dentry_fsdata *new_fsdata; ++ reiser4_dentry_fsdata *new_fsdata; + lock_handle new_lh; + dir_plugin *dplug; + file_plugin *fplug; + -+ ctx = reiser4_init_context(old_dir->i_sb); ++ ctx = init_context(old_dir->i_sb); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + @@ -43717,15 +43847,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + init_lh(&new_lh); + + /* find entry for @new_name */ -+ result = reiser4_find_entry(new_dir, new_name, &new_lh, -+ ZNODE_WRITE_LOCK, &new_entry); ++ result = find_entry(new_dir, ++ new_name, &new_lh, ZNODE_WRITE_LOCK, &new_entry); + + if (IS_CBKERR(result)) { + done_lh(&new_lh); + goto exit; + } + -+ reiser4_seal_done(&new_fsdata->dec.entry_seal); ++ seal_done(&new_fsdata->dec.entry_seal); + + /* add or replace name for @old_inode as @new_name */ + if (new_inode != NULL) { @@ -43811,8 +43941,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + lock_handle dotdot_lh; + struct dentry dotdot_name; + reiser4_dir_entry_desc dotdot_entry; -+ struct reiser4_dentry_fsdata dataonstack; -+ struct reiser4_dentry_fsdata *fsdata; ++ reiser4_dentry_fsdata dataonstack; ++ reiser4_dentry_fsdata *fsdata; + + memset(&dataonstack, 0, sizeof dataonstack); + memset(&dotdot_entry, 0, sizeof dotdot_entry); @@ -43832,11 +43962,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + dotdot_coord = &fsdata->dec.entry_coord; + coord_clear_iplug(dotdot_coord); + -+ result = reiser4_find_entry(old_inode, -+ &dotdot_name, -+ &dotdot_lh, -+ ZNODE_WRITE_LOCK, -+ &dotdot_entry); ++ result = find_entry(old_inode, &dotdot_name, &dotdot_lh, ++ ZNODE_WRITE_LOCK, &dotdot_entry); + if (result == 0) { + /* replace_name() decreases i_nlink on + * @old_dir */ @@ -43869,9 +43996,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/inode_ops_rename.c linux-2.6.22/fs + return result; +} +#endif -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/acl.h linux-2.6.22/fs/reiser4/plugin/item/acl.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/acl.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/acl.h 2007-07-29 00:25:34.940713042 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/Makefile +@@ -0,0 +1,18 @@ ++obj-$(CONFIG_REISER4_FS) += item_plugins.o ++ ++item_plugins-objs := \ ++ item.o \ ++ static_stat.o \ ++ sde.o \ ++ cde.o \ ++ blackbox.o \ ++ internal.o \ ++ tail.o \ ++ ctail.o \ ++ extent.o \ ++ extent_item_ops.o \ ++ extent_file_ops.o \ ++ extent_flush_ops.o ++ ++ ++ +Index: linux-2.6.16/fs/reiser4/plugin/item/acl.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/acl.h @@ -0,0 +1,66 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -43939,9 +44090,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/acl.h linux-2.6.22/fs/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.c linux-2.6.22/fs/reiser4/plugin/item/blackbox.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/blackbox.c 2007-07-29 00:25:34.940713042 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/blackbox.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/blackbox.c @@ -0,0 +1,142 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -44073,7 +44225,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.c linux-2.6.22/fs/re + +int kill_black_box(reiser4_tree * tree, const reiser4_key * key) +{ -+ return reiser4_cut_tree(tree, key, key, NULL, 1); ++ return cut_tree(tree, key, key, NULL, 1); +} + +/* Make Linus happy. @@ -44085,9 +44237,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.c linux-2.6.22/fs/re + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.h linux-2.6.22/fs/reiser4/plugin/item/blackbox.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/blackbox.h 2007-07-29 00:25:34.940713042 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/blackbox.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/blackbox.h @@ -0,0 +1,33 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -44122,10 +44275,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/blackbox.h linux-2.6.22/fs/re + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4/plugin/item/cde.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/cde.c 2007-07-29 00:25:34.944714077 +0400 -@@ -0,0 +1,1008 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/cde.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/cde.c +@@ -0,0 +1,1007 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Directory entry implementation */ @@ -44413,7 +44567,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + +/* insert new @entry into item */ +static int expand(const coord_t * coord /* coord of item */ , -+ struct cde_entry * entry /* entry to insert */ , ++ cde_entry * entry /* entry to insert */ , + int len /* length of @entry data */ , + int *pos /* position to insert */ , + reiser4_dir_entry_desc * dir_entry /* parameters for new @@ -44437,7 +44591,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + +/* paste body of @entry into item */ +static int paste_entry(const coord_t * coord /* coord of item */ , -+ struct cde_entry * entry /* new entry */ , ++ cde_entry * entry /* new entry */ , + int pos /* position to insert */ , + reiser4_dir_entry_desc * dir_entry /* parameters for + * new entry */ ) @@ -44473,11 +44627,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 +int estimate_cde(const coord_t * coord /* coord of item */ , + const reiser4_item_data * data /* parameters for new item */ ) +{ -+ struct cde_entry_data *e; ++ cde_entry_data *e; + int result; + int i; + -+ e = (struct cde_entry_data *) data->data; ++ e = (cde_entry_data *) data->data; + + assert("nikita-1288", e != NULL); + assert("nikita-1289", e->num_of_entries >= 0); @@ -44554,9 +44708,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + assert("nikita-1342", coord != NULL); + + item_key_by_coord(coord, result); -+ set_key_ordering(result, get_key_ordering(reiser4_max_key())); -+ set_key_fulloid(result, get_key_fulloid(reiser4_max_key())); -+ set_key_offset(result, get_key_offset(reiser4_max_key())); ++ set_key_ordering(result, get_key_ordering(max_key())); ++ set_key_fulloid(result, get_key_fulloid(max_key())); ++ set_key_offset(result, get_key_offset(max_key())); + return result; +} + @@ -44587,8 +44741,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + possible check of the consistency of the item that the inventor can + construct +*/ -+int reiser4_check_cde(const coord_t * coord /* coord of item to check */, -+ const char **error /* where to store error message */) ++int check_cde(const coord_t * coord /* coord of item to check */ , ++ const char **error /* where to store error message */ ) +{ + int i; + int result; @@ -44696,12 +44850,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + * inserted */ , + carry_plugin_info * info UNUSED_ARG /* todo carry queue */ ) +{ -+ struct cde_entry_data *e; ++ cde_entry_data *e; + int result; + int i; + + CHECKME(coord); -+ e = (struct cde_entry_data *) data->data; ++ e = (cde_entry_data *) data->data; + + result = 0; + for (i = 0; i < e->num_of_entries; ++i) { @@ -45036,8 +45190,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + * directory entry */ ) +{ + reiser4_item_data data; -+ struct cde_entry entry; -+ struct cde_entry_data edata; ++ cde_entry entry; ++ cde_entry_data edata; + int result; + + assert("nikita-1656", coord->node == lh->node); @@ -45066,8 +45220,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + if (result) + result = insert_by_coord(coord, &data, &dir_entry->key, lh, 0); + else -+ result = reiser4_resize_item(coord, &data, &dir_entry->key, -+ lh, 0); ++ result = resize_item(coord, &data, &dir_entry->key, lh, 0); + return result; +} + @@ -45120,9 +45273,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 +int max_name_len_cde(const struct inode *dir /* directory */ ) +{ + return -+ reiser4_tree_by_inode(dir)->nplug->max_item_size() - -+ sizeof(directory_entry_format) - sizeof(cde_item_format) - -+ sizeof(cde_unit_header) - 2; ++ tree_by_inode(dir)->nplug->max_item_size() - ++ sizeof(directory_entry_format) - sizeof(cde_item_format) - ++ sizeof(cde_unit_header) - 2; +} + +/* Make Linus happy. @@ -45134,9 +45287,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.c linux-2.6.22/fs/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.h linux-2.6.22/fs/reiser4/plugin/item/cde.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/cde.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/cde.h 2007-07-29 00:25:34.944714077 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/cde.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/cde.h @@ -0,0 +1,87 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -45162,16 +45316,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.h linux-2.6.22/fs/reiser4 + cde_unit_header entry[0]; +} cde_item_format; + -+struct cde_entry { ++typedef struct cde_entry { + const struct inode *dir; + const struct inode *obj; + const struct qstr *name; -+}; ++} cde_entry; + -+struct cde_entry_data { ++typedef struct cde_entry_data { + int num_of_entries; -+ struct cde_entry *entry; -+}; ++ cde_entry *entry; ++} cde_entry_data; + +/* plugin->item.b.* */ +reiser4_key *max_key_inside_cde(const coord_t * coord, reiser4_key * result); @@ -45199,7 +45353,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.h linux-2.6.22/fs/reiser4 + struct carry_kill_data *, reiser4_key * smallest_removed, + reiser4_key * new_first); +void print_cde(const char *prefix, coord_t * coord); -+int reiser4_check_cde(const coord_t * coord, const char **error); ++int check_cde(const coord_t * coord, const char **error); + +/* plugin->u.item.s.dir.* */ +int extract_key_cde(const coord_t * coord, reiser4_key * key); @@ -45225,10 +45379,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/cde.h linux-2.6.22/fs/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reiser4/plugin/item/ctail.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/ctail.c 2007-07-29 00:25:34.948715113 +0400 -@@ -0,0 +1,1614 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/ctail.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/ctail.c +@@ -0,0 +1,1588 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* ctails (aka "clustered tails") are items for cryptcompress objects */ @@ -45276,26 +45431,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return item_body_by_coord(coord); +} + -+static int cluster_shift_by_coord(const coord_t * coord) ++int cluster_shift_by_coord(const coord_t * coord) +{ + return get_unaligned(&ctail_formatted_at(coord)->cluster_shift); +} + -+static inline void dclust_set_extension_shift(hint_t * hint) -+{ -+ assert("edward-1270", -+ item_id_by_coord(&hint->ext_coord.coord) == CTAIL_ID); -+ hint->ext_coord.extension.ctail.shift = -+ cluster_shift_by_coord(&hint->ext_coord.coord); -+} -+ +static loff_t off_by_coord(const coord_t * coord) +{ + reiser4_key key; + return get_key_offset(item_key_by_coord(coord, &key)); +} + -+int coord_is_unprepped_ctail(const coord_t * coord) ++static int coord_is_unprepped_ctail(const coord_t * coord) +{ + assert("edward-1233", coord != NULL); + assert("edward-1234", item_id_by_coord(coord) == CTAIL_ID); @@ -45374,14 +45521,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return 1; +} + -+/* plugin->u.item.b.mergeable */ ++/* plugin->u.item.b.mergeable ++ c-tails of different clusters are not mergeable */ +int mergeable_ctail(const coord_t * p1, const coord_t * p2) +{ + reiser4_key key1, key2; + + assert("edward-62", item_id_by_coord(p1) == CTAIL_ID); -+ assert("edward-61", plugin_of_group(item_plugin_by_coord(p1), -+ UNIX_FILE_METADATA_ITEM_TYPE)); ++ assert("edward-61", ++ item_type_by_coord(p1) == UNIX_FILE_METADATA_ITEM_TYPE); + + if (item_id_by_coord(p2) != CTAIL_ID) { + /* second item is of another type */ @@ -45592,8 +45740,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +} + +/* plugin->u.item.b.kill_hook */ -+int kill_hook_ctail(const coord_t * coord, pos_in_node_t from, -+ pos_in_node_t count, carry_kill_data * kdata) ++int ++kill_hook_ctail(const coord_t * coord, pos_in_node_t from, pos_in_node_t count, ++ carry_kill_data * kdata) +{ + struct inode *inode; + @@ -45603,24 +45752,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + inode = kdata->inode; + if (inode) { + reiser4_key key; -+ struct cryptcompress_info * info; -+ cloff_t index; -+ + item_key_by_coord(coord, &key); -+ info = cryptcompress_inode_data(inode); -+ index = off_to_clust(get_key_offset(&key), inode); + -+ if (from == 0) { -+ info->trunc_index = index; -+ if (is_disk_cluster_key(&key, coord)) { -+ /* -+ * first item of disk cluster is to be killed -+ */ -+ truncate_complete_page_cluster( -+ inode, index, kdata->params.truncate); -+ inode_sub_bytes(inode, -+ inode_cluster_size(inode)); -+ } ++ if (from == 0 && is_disk_cluster_key(&key, coord)) { ++ cloff_t start = ++ off_to_clust(get_key_offset(&key), inode); ++ truncate_page_cluster(inode, start); + } + } + return 0; @@ -45764,164 +45901,127 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + /* read only whole ctails */ + assert("edward-135", nr_units_ctail(coord) <= f->length); + -+ assert("edward-136", reiser4_schedulable()); ++ assert("edward-136", schedulable()); + assert("edward-886", ctail_ok(coord)); + + if (f->data) + memcpy(f->data, (char *)first_unit(coord), + (size_t) nr_units_ctail(coord)); + -+ dclust_set_extension_shift(hint); ++ dclust_set_extension(hint); + mark_page_accessed(znode_page(coord->node)); + move_flow_forward(f, nr_units_ctail(coord)); + + return 0; +} + -+/** -+ * Prepare transform stream with plain text for page -+ * @page taking into account synchronization issues. -+ */ -+int ctail_read_disk_cluster(struct cluster_handle * clust, struct inode * inode, -+ struct page * page, znode_lock_mode mode) ++/* Reads a disk cluster consists of ctail items, ++ attaches a transform stream with plain text */ ++int ctail_read_disk_cluster(reiser4_cluster_t * clust, struct inode *inode, ++ int write) +{ + int result; -+ -+ assert("edward-1450", mode == ZNODE_READ_LOCK || ZNODE_WRITE_LOCK); + assert("edward-671", clust->hint != NULL); + assert("edward-140", clust->dstat == INVAL_DISK_CLUSTER); -+ assert("edward-672", cryptcompress_inode_ok(inode)); -+ assert("edward-1527", PageLocked(page)); -+ -+ unlock_page(page); ++ assert("edward-672", crc_inode_ok(inode)); + + /* set input stream */ + result = grab_tfm_stream(inode, &clust->tc, INPUT_STREAM); -+ if (result) { -+ lock_page(page); ++ if (result) + return result; -+ } -+ result = find_disk_cluster(clust, inode, 1 /* read items */, mode); -+ lock_page(page); ++ ++ result = find_cluster(clust, inode, 1 /* read */ , write); ++ assert("edward-1340", !result); + if (result) + return result; -+ /* -+ * at this point we have locked position in the tree -+ */ -+ assert("edward-1528", znode_is_any_locked(clust->hint->lh.node)); ++ if (!write) ++ /* write still need the lock to insert unprepped ++ items, etc... */ ++ put_hint_cluster(clust, inode, ZNODE_READ_LOCK); ++ ++ assert("edward-673", ++ ergo(write, znode_is_write_locked(clust->hint->lh.node))); + -+ if (page->mapping != inode->i_mapping) { -+ /* page was truncated */ -+ reiser4_unset_hint(clust->hint); -+ reset_cluster_params(clust); -+ return AOP_TRUNCATED_PAGE; -+ } -+ if (PageUptodate(page)) { -+ /* disk cluster can be obsolete, don't use it! */ -+ reiser4_unset_hint(clust->hint); -+ reset_cluster_params(clust); -+ return 0; -+ } + if (clust->dstat == FAKE_DISK_CLUSTER || -+ clust->dstat == UNPR_DISK_CLUSTER || -+ clust->dstat == TRNC_DISK_CLUSTER) { -+ /* -+ * this information about disk cluster will be valid -+ * as long as we keep the position in the tree locked -+ */ ++ clust->dstat == UNPR_DISK_CLUSTER) { + tfm_cluster_set_uptodate(&clust->tc); + return 0; + } -+ /* now prepare output stream.. */ + result = grab_coa(&clust->tc, inode_compression_plugin(inode)); + if (result) + return result; -+ /* ..and fill this with plain text */ -+ result = reiser4_inflate_cluster(clust, inode); ++ result = inflate_cluster(clust, inode); + if (result) + return result; -+ /* -+ * The stream is ready! It won't be obsolete as -+ * long as we keep last disk cluster item locked. -+ */ + tfm_cluster_set_uptodate(&clust->tc); + return 0; +} + -+/* -+ * fill one page with plain text. -+ */ -+int do_readpage_ctail(struct inode * inode, struct cluster_handle * clust, -+ struct page *page, znode_lock_mode mode) ++/* read one locked page */ ++int do_readpage_ctail(struct inode * inode, reiser4_cluster_t * clust, ++ struct page *page) +{ + int ret; + unsigned cloff; + char *data; -+ size_t to_page; -+ struct tfm_cluster * tc = &clust->tc; ++ size_t pgcnt; ++ tfm_cluster_t *tc = &clust->tc; + + assert("edward-212", PageLocked(page)); + -+ if (unlikely(page->mapping != inode->i_mapping)) -+ return AOP_TRUNCATED_PAGE; + if (PageUptodate(page)) + goto exit; -+ to_page = pbytes(page_index(page), inode); -+ if (to_page == 0) { -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); -+ SetPageUptodate(page); -+ goto exit; -+ } ++ + if (!tfm_cluster_is_uptodate(&clust->tc)) { + clust->index = pg_to_clust(page->index, inode); -+ -+ /* this will unlock/lock the page */ -+ ret = ctail_read_disk_cluster(clust, inode, page, mode); -+ -+ assert("edward-212", PageLocked(page)); ++ unlock_page(page); ++ ret = ctail_read_disk_cluster(clust, inode, 0 /* read */ ); ++ lock_page(page); + if (ret) + return ret; -+ -+ /* refresh bytes */ -+ to_page = pbytes(page_index(page), inode); -+ if (to_page == 0) { -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); -+ SetPageUptodate(page); -+ goto exit; -+ } + } + if (PageUptodate(page)) -+ /* somebody else fill it already */ ++ /* races with another read/write */ + goto exit; + ++ /* bytes in the page */ ++ pgcnt = cnt_to_pgcnt(i_size_read(inode), page->index); ++ ++ if (pgcnt == 0) { ++ assert("edward-1290", 0); ++ return RETERR(-EINVAL); ++ } + assert("edward-119", tfm_cluster_is_uptodate(tc)); -+ assert("edward-1529", znode_is_any_locked(clust->hint->lh.node)); + + switch (clust->dstat) { + case UNPR_DISK_CLUSTER: -+ BUG_ON(1); -+ case TRNC_DISK_CLUSTER: -+ /* -+ * Race with truncate! -+ * We resolve it in favour of the last one (the only way, -+ * as in this case plain text is unrecoverable) -+ */ ++ assert("edward-1285", 0); ++#if REISER4_DEBUG ++ warning("edward-1168", ++ "page %lu is not uptodate and disk cluster %lu (inode %llu) is unprepped\n", ++ page->index, clust->index, ++ (unsigned long long)get_inode_oid(inode)); ++#endif + case FAKE_DISK_CLUSTER: + /* fill the page by zeroes */ -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); ++ data = kmap_atomic(page, KM_USER0); ++ ++ memset(data, 0, PAGE_CACHE_SIZE); ++ flush_dcache_page(page); ++ kunmap_atomic(data, KM_USER0); + SetPageUptodate(page); + break; + case PREP_DISK_CLUSTER: -+ /* fill page by transformed stream with plain text */ ++ /* fill the page by transformed data */ + assert("edward-1058", !PageUptodate(page)); + assert("edward-120", tc->len <= inode_cluster_size(inode)); + -+ /* page index in this logical cluster */ ++ /* start page offset in the cluster */ + cloff = pg_to_off_to_cloff(page->index, inode); + + data = kmap(page); -+ memcpy(data, tfm_stream_data(tc, OUTPUT_STREAM) + cloff, to_page); -+ memset(data + to_page, 0, (size_t) PAGE_CACHE_SIZE - to_page); ++ memcpy(data, tfm_stream_data(tc, OUTPUT_STREAM) + cloff, pgcnt); ++ memset(data + pgcnt, 0, (size_t) PAGE_CACHE_SIZE - pgcnt); + flush_dcache_page(page); + kunmap(page); + SetPageUptodate(page); @@ -45937,33 +46037,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +int readpage_ctail(void *vp, struct page *page) +{ + int result; -+ hint_t * hint; -+ struct cluster_handle * clust = vp; ++ hint_t *hint; ++ reiser4_cluster_t *clust = vp; + + assert("edward-114", clust != NULL); + assert("edward-115", PageLocked(page)); + assert("edward-116", !PageUptodate(page)); ++ assert("edward-117", !jprivate(page) && !PagePrivate(page)); + assert("edward-118", page->mapping && page->mapping->host); + assert("edward-867", !tfm_cluster_is_uptodate(&clust->tc)); + -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); -+ if (hint == NULL) { -+ unlock_page(page); ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); ++ if (hint == NULL) + return RETERR(-ENOMEM); -+ } + clust->hint = hint; + result = load_file_hint(clust->file, hint); + if (result) { + kfree(hint); -+ unlock_page(page); + return result; + } + assert("vs-25", hint->ext_coord.lh == &hint->lh); ++ result = do_readpage_ctail(page->mapping->host, clust, page); + -+ result = do_readpage_ctail(page->mapping->host, clust, page, -+ ZNODE_READ_LOCK); + assert("edward-213", PageLocked(page)); + assert("edward-1163", ergo(!result, PageUptodate(page))); ++ assert("edward-868", ++ ergo(!result, tfm_cluster_is_uptodate(&clust->tc))); + + unlock_page(page); + done_lh(&hint->lh); @@ -45975,9 +46074,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return result; +} + -+/* Helper function for ->readpages() */ -+static int ctail_read_page_cluster(struct cluster_handle * clust, -+ struct inode *inode) ++/* This unconditionally reads a disk cluster. ++ Helper function for ->readpages() */ ++static int ++ctail_read_page_cluster(reiser4_cluster_t * clust, struct inode *inode) +{ + int i; + int result; @@ -45985,102 +46085,132 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-1059", clust->win == NULL); + assert("edward-780", inode != NULL); + -+ result = prepare_page_cluster(inode, clust, READ_OP); ++ result = prepare_page_cluster(inode, clust, 0 /* do not capture */ ); + if (result) + return result; -+ -+ assert("edward-781", !tfm_cluster_is_uptodate(&clust->tc)); ++ result = ctail_read_disk_cluster(clust, inode, 0 /* read */ ); ++ if (result) ++ goto out; ++ /* at this point stream with valid plain text is attached */ ++ assert("edward-781", tfm_cluster_is_uptodate(&clust->tc)); + + for (i = 0; i < clust->nr_pages; i++) { + struct page *page = clust->pages[i]; + lock_page(page); -+ result = do_readpage_ctail(inode, clust, page, ZNODE_READ_LOCK); ++ result = do_readpage_ctail(inode, clust, page); + unlock_page(page); + if (result) + break; + } + tfm_cluster_clr_uptodate(&clust->tc); -+ put_page_cluster(clust, inode, READ_OP); ++ out: ++ release_cluster_pages(clust); + return result; +} + -+/* filler for read_cache_pages() */ -+static int ctail_readpages_filler(void * data, struct page * page) -+{ -+ int ret = 0; -+ struct cluster_handle * clust = data; -+ struct inode * inode = clust->file->f_dentry->d_inode; ++#define list_to_page(head) (list_entry((head)->prev, struct page, lru)) ++#define list_to_next_page(head) (list_entry((head)->prev->prev, struct page, lru)) + -+ assert("edward-1525", page->mapping == inode->i_mapping); -+ -+ if (PageUptodate(page)) { -+ unlock_page(page); -+ return 0; -+ } -+ if (pbytes(page_index(page), inode) == 0) { -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); -+ SetPageUptodate(page); -+ unlock_page(page); -+ return 0; -+ } -+ move_cluster_forward(clust, inode, page->index); -+ unlock_page(page); -+ /* -+ * read the whole page cluster -+ */ -+ ret = ctail_read_page_cluster(clust, inode); -+ -+ assert("edward-869", !tfm_cluster_is_uptodate(&clust->tc)); -+ return ret; -+} ++#if REISER4_DEBUG ++#define check_order(pages) \ ++assert("edward-214", ergo(!list_empty(pages) && pages->next != pages->prev, \ ++ list_to_page(pages)->index < list_to_next_page(pages)->index)) ++#endif + -+/* -+ * We populate a bit more then upper readahead suggests: -+ * with each nominated page we read the whole page cluster -+ * this page belongs to. -+ */ -+int readpages_ctail(struct file *file, struct address_space *mapping, -+ struct list_head *pages) ++/* plugin->u.item.s.file.readpages ++ Populate an address space with some page clusters, ++ and start reads against them. ++ FIXME-EDWARD: this function should return errors? ++*/ ++void ++readpages_ctail(void *vp, struct address_space *mapping, ++ struct list_head *pages) +{ + int ret = 0; + hint_t *hint; -+ struct cluster_handle clust; ++ reiser4_cluster_t clust; ++ struct page *page; ++ struct pagevec lru_pvec; + struct inode *inode = mapping->host; ++ int progress = 0; + -+ assert("edward-1521", inode == file->f_dentry->d_inode); -+ ++ assert("edward-214", ergo(!list_empty(pages) && ++ pages->next != pages->prev, ++ list_to_page(pages)->index < ++ list_to_next_page(pages)->index)); ++ pagevec_init(&lru_pvec, 0); + cluster_init_read(&clust, NULL); -+ clust.file = file; -+ hint = kmalloc(sizeof(*hint), reiser4_ctx_gfp_mask_get()); ++ clust.file = vp; ++ hint = kmalloc(sizeof(*hint), GFP_KERNEL); + if (hint == NULL) { + warning("vs-28", "failed to allocate hint"); -+ ret = RETERR(-ENOMEM); + goto exit1; + } + clust.hint = hint; + ret = load_file_hint(clust.file, hint); -+ if (ret) { -+ warning("edward-1522", "failed to load hint"); ++ if (ret) + goto exit2; -+ } -+ assert("vs-26", hint->ext_coord.lh == &hint->lh); + ret = alloc_cluster_pgset(&clust, cluster_nrpages(inode)); -+ if (ret) { -+ warning("edward-1523", "failed to alloc pgset"); ++ if (ret) + goto exit3; -+ } -+ ret = read_cache_pages(mapping, pages, ctail_readpages_filler, &clust); ++ assert("vs-26", hint->ext_coord.lh == &hint->lh); ++ ++ /* address_space-level file readahead doesn't know about ++ reiser4 concept of clustering, so we work around this ++ fact: with each page of the list @pages address space ++ will be populated with the whole page cluster. ++ */ ++ while (!list_empty(pages)) { ++ page = list_to_page(pages); ++ list_del(&page->lru); ++ if (add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) { ++ page_cache_release(page); ++ continue; ++ } ++ if (PageUptodate(page)) { ++ if (!pagevec_add(&lru_pvec, page)) ++ __pagevec_lru_add(&lru_pvec); ++ unlock_page(page); ++ continue; ++ } ++ unlock_page(page); ++ ++ move_cluster_forward(&clust, inode, page->index, &progress); ++ ret = ctail_read_page_cluster(&clust, inode); ++ if (ret) ++ break; ++ assert("edward-869", !tfm_cluster_is_uptodate(&clust.tc)); ++ lock_page(page); + ++ ret = do_readpage_ctail(inode, &clust, page); ++ if (!pagevec_add(&lru_pvec, page)) ++ __pagevec_lru_add(&lru_pvec); ++ if (ret) { ++ warning("edward-215", "do_readpage_ctail failed"); ++ unlock_page(page); ++ break; ++ } ++ assert("edward-1061", PageUptodate(page)); ++ ++ unlock_page(page); ++ } + assert("edward-870", !tfm_cluster_is_uptodate(&clust.tc)); + exit3: + done_lh(&hint->lh); -+ save_file_hint(file, hint); ++ save_file_hint(clust.file, hint); + hint->ext_coord.valid = 0; + exit2: + kfree(hint); + exit1: ++ while (!list_empty(pages)) { ++ struct page *victim; ++ victim = list_to_page(pages); ++ list_del(&victim->lru); ++ page_cache_release(victim); ++ } + put_cluster_handle(&clust); -+ return ret; ++ pagevec_lru_add(&lru_pvec); ++ return; +} + +/* @@ -46093,13 +46223,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-1242", cluster_shift_ok(cluster_shift_by_coord(coord))); + + item_key_by_coord(coord, key); -+ set_key_offset(key, ((__u64) (clust_by_coord(coord, NULL)) + 1) -+ << cluster_shift_by_coord(coord)); ++ set_key_offset(key, ++ ((__u64) (clust_by_coord(coord, NULL)) + ++ 1) << cluster_shift_by_coord(coord)); + return key; +} + -+static int insert_unprepped_ctail(struct cluster_handle * clust, -+ struct inode *inode) ++static int ++insert_unprepped_ctail(reiser4_cluster_t * clust, struct inode *inode) +{ + int result; + char buf[UCTAIL_NR_UNITS]; @@ -46125,8 +46256,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +} + +static int -+insert_cryptcompress_flow(coord_t * coord, lock_handle * lh, flow_t * f, -+ struct inode *inode) ++insert_crc_flow(coord_t * coord, lock_handle * lh, flow_t * f, ++ struct inode *inode) +{ + int result; + carry_pool *pool; @@ -46153,8 +46284,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + coord->unit_pos = 0; + coord->between = AFTER_ITEM; + } -+ op = reiser4_post_carry(lowest_level, COP_INSERT_FLOW, coord->node, -+ 0 /* operate directly on coord -> node */); ++ op = post_carry(lowest_level, COP_INSERT_FLOW, coord->node, ++ 0 /* operate directly on coord -> node */ ); + if (IS_ERR(op) || (op == NULL)) { + done_carry_pool(pool); + return RETERR(op ? PTR_ERR(op) : -EIO); @@ -46175,16 +46306,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + lowest_level->track_type = CARRY_TRACK_CHANGE; + lowest_level->tracked = lh; + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + done_carry_pool(pool); + + return result; +} + +/* Implementation of CRC_APPEND_ITEM mode of ctail conversion */ -+static int insert_cryptcompress_flow_in_place(coord_t * coord, -+ lock_handle * lh, flow_t * f, -+ struct inode *inode) ++static int ++insert_crc_flow_in_place(coord_t * coord, lock_handle * lh, flow_t * f, ++ struct inode *inode) +{ + int ret; + coord_t pos; @@ -46202,7 +46333,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + init_lh(&lock); + copy_lh(&lock, lh); + -+ ret = insert_cryptcompress_flow(&pos, &lock, f, inode); ++ ret = insert_crc_flow(&pos, &lock, f, inode); + done_lh(&lock); + assert("edward-1347", znode_is_write_locked(lh->node)); + assert("edward-1228", !ret); @@ -46220,7 +46351,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-272", coord_is_existing_unit(coord)); + assert("edward-273", coord->unit_pos == 0); + assert("edward-274", znode_is_write_locked(coord->node)); -+ assert("edward-275", reiser4_schedulable()); ++ assert("edward-275", schedulable()); + assert("edward-467", item_id_by_coord(coord) == CTAIL_ID); + assert("edward-1243", ctail_ok(coord)); + @@ -46253,14 +46384,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return cut_node_content(coord, &stop, NULL, NULL, NULL); +} + -+int ctail_insert_unprepped_cluster(struct cluster_handle * clust, -+ struct inode * inode) ++int ++ctail_insert_unprepped_cluster(reiser4_cluster_t * clust, struct inode *inode) +{ + int result; + assert("edward-1244", inode != NULL); + assert("edward-1245", clust->hint != NULL); + assert("edward-1246", clust->dstat == FAKE_DISK_CLUSTER); + assert("edward-1247", clust->reserved == 1); ++ assert("edward-1248", get_current_context()->grabbed_blocks == ++ estimate_insert_cluster(inode)); + + result = get_disk_cluster_locked(clust, inode, ZNODE_WRITE_LOCK); + if (cbk_errored(result)) @@ -46278,7 +46411,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + all_grabbed2free(); + + assert("edward-1251", !result); -+ assert("edward-1252", cryptcompress_inode_ok(inode)); ++ assert("edward-1252", crc_inode_ok(inode)); + assert("edward-1253", znode_is_write_locked(clust->hint->lh.node)); + assert("edward-1254", + reiser4_clustered_blocks(reiser4_get_current_sb())); @@ -46288,10 +46421,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return result; +} + -+static int do_convert_ctail(flush_pos_t * pos, cryptcompress_write_mode_t mode) ++static int do_convert_ctail(flush_pos_t * pos, crc_write_mode_t mode) +{ + int result = 0; -+ struct convert_item_info * info; ++ convert_item_info_t *info; + + assert("edward-468", pos != NULL); + assert("edward-469", pos->sq != NULL); @@ -46306,10 +46439,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-1256", + cluster_shift_ok(cluster_shift_by_coord(&pos->coord))); + result = -+ insert_cryptcompress_flow_in_place(&pos->coord, -+ &pos->lock, -+ &info->flow, -+ info->inode); ++ insert_crc_flow_in_place(&pos->coord, &pos->lock, ++ &info->flow, info->inode); + break; + case CRC_OVERWRITE_ITEM: + assert("edward-1230", info->flow.length != 0); @@ -46342,7 +46473,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + page = jnode_page(node); + inode = page->mapping->host; + -+ if (!reiser4_scanning_left(scan)) ++ if (!scanning_left(scan)) + return result; + if (!ZF_ISSET(scan->parent_lock.node, JNODE_DIRTY)) + znode_make_dirty(scan->parent_lock.node); @@ -46389,7 +46520,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + +/* plugin->init_convert_data() */ +static int -+init_convert_data_ctail(struct convert_item_info * idata, struct inode *inode) ++init_convert_data_ctail(convert_item_info_t * idata, struct inode *inode) +{ + assert("edward-813", idata != NULL); + assert("edward-814", inode != NULL); @@ -46401,18 +46532,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + return 0; +} + -+static int alloc_item_convert_data(struct convert_info * sq) ++static int alloc_item_convert_data(convert_info_t * sq) +{ + assert("edward-816", sq != NULL); + assert("edward-817", sq->itm == NULL); + -+ sq->itm = kmalloc(sizeof(*sq->itm), reiser4_ctx_gfp_mask_get()); ++ sq->itm = kmalloc(sizeof(*sq->itm), GFP_KERNEL); + if (sq->itm == NULL) + return RETERR(-ENOMEM); + return 0; +} + -+static void free_item_convert_data(struct convert_info * sq) ++static void free_item_convert_data(convert_info_t * sq) +{ + assert("edward-818", sq != NULL); + assert("edward-819", sq->itm != NULL); @@ -46428,17 +46559,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-821", pos != NULL); + assert("edward-822", pos->sq == NULL); + -+ pos->sq = kmalloc(sizeof(*pos->sq), reiser4_ctx_gfp_mask_get()); ++ pos->sq = kmalloc(sizeof(*pos->sq), GFP_KERNEL); + if (!pos->sq) + return RETERR(-ENOMEM); + memset(pos->sq, 0, sizeof(*pos->sq)); -+ cluster_init_write(&pos->sq->clust, NULL); ++ cluster_init_write(&pos->sq->clust, 0); + return 0; +} + +void free_convert_data(flush_pos_t * pos) +{ -+ struct convert_info *sq; ++ convert_info_t *sq; + + assert("edward-823", pos != NULL); + assert("edward-824", pos->sq != NULL); @@ -46454,7 +46585,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + +static int init_item_convert_data(flush_pos_t * pos, struct inode *inode) +{ -+ struct convert_info *sq; ++ convert_info_t *sq; + + assert("edward-825", pos != NULL); + assert("edward-826", pos->sq != NULL); @@ -46474,17 +46605,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +static int attach_convert_idata(flush_pos_t * pos, struct inode *inode) +{ + int ret = 0; -+ struct convert_item_info *info; -+ struct cluster_handle *clust; ++ convert_item_info_t *info; ++ reiser4_cluster_t *clust; + file_plugin *fplug = inode_file_plugin(inode); + compression_plugin *cplug = inode_compression_plugin(inode); + + assert("edward-248", pos != NULL); + assert("edward-249", pos->child != NULL); + assert("edward-251", inode != NULL); -+ assert("edward-682", cryptcompress_inode_ok(inode)); -+ assert("edward-252", -+ fplug == file_plugin_by_id(CRYPTCOMPRESS_FILE_PLUGIN_ID)); ++ assert("edward-682", crc_inode_ok(inode)); ++ assert("edward-252", fplug == file_plugin_by_id(CRC_FILE_PLUGIN_ID)); + assert("edward-473", + item_plugin_by_coord(&pos->coord) == + item_plugin_by_id(CTAIL_ID)); @@ -46517,14 +46647,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + goto err; + info = item_convert_data(pos); + -+ ret = checkout_logical_cluster(clust, pos->child, inode); ++ ret = flush_cluster_pages(clust, pos->child, inode); + if (ret) + goto err; + -+ reiser4_deflate_cluster(clust, inode); ++ deflate_cluster(clust, inode); + inc_item_convert_count(pos); + -+ /* prepare flow for insertion */ ++ /* make flow by transformed stream */ + fplug->flow_by_inode(info->inode, + (const char __user *)tfm_stream_data(&clust->tc, OUTPUT_STREAM), + 0 /* kernel space */ , @@ -46533,7 +46663,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + WRITE_OP, &info->flow); + jput(pos->child); + -+ assert("edward-683", cryptcompress_inode_ok(inode)); ++ assert("edward-683", crc_inode_ok(inode)); + return 0; + err: + jput(pos->child); @@ -46542,9 +46672,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +} + +/* clear up disk cluster info */ -+static void detach_convert_idata(struct convert_info * sq) ++static void detach_convert_idata(convert_info_t * sq) +{ -+ struct convert_item_info *info; ++ convert_item_info_t *info; + + assert("edward-253", sq != NULL); + assert("edward-840", sq->itm != NULL); @@ -46590,14 +46720,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + Disk cluster is a set of items. If ->clustered() != NULL, + with each item the whole disk cluster should be read/modified +*/ ++static int clustered_ctail(const coord_t * p1, const coord_t * p2) ++{ ++ return mergeable_ctail(p1, p2); ++} + +/* Go rightward and check for next disk cluster item, set -+ * d_next to DC_CHAINED_ITEM, if the last one exists. -+ * If the current position is last item, go to right neighbor. -+ * Skip empty nodes. Note, that right neighbors may be not in -+ * the slum because of races. If so, make it dirty and -+ * convertible. -+ */ ++ d_next to DC_CHAINED_ITEM, if the last one exists. ++ If the current position is last item, go to right neighbor. ++ Skip empty nodes. Note, that right neighbors may be not in ++ the slum because of races. If so, make it dirty and ++ convertible. ++*/ +static int next_item_dc_stat(flush_pos_t * pos) +{ + int ret = 0; @@ -46621,10 +46755,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + if (pos->coord.item_pos < coord_num_items(&pos->coord) - 1) + return ret; + -+ /* Check next slum item. -+ * Note, that it can not be killed by concurrent truncate, -+ * as the last one will want the lock held by us. -+ */ ++ /* check next slum item */ + init_lh(&right_lock); + cur = pos->coord.node; + @@ -46647,7 +46778,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + znode_make_dirty(lh.node); + znode_set_convertible(lh.node); + stop = 0; -+ } else if (same_disk_cluster(&pos->coord, &coord)) { ++ } else if (clustered_ctail(&pos->coord, &coord)) { + + item_convert_data(pos)->d_next = DC_CHAINED_ITEM; + @@ -46686,8 +46817,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +} + +static int -+assign_convert_mode(struct convert_item_info * idata, -+ cryptcompress_write_mode_t * mode) ++assign_convert_mode(convert_item_info_t * idata, crc_write_mode_t * mode) +{ + int result = 0; + @@ -46729,7 +46859,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise +{ + int result; + int nr_items; -+ cryptcompress_write_mode_t mode = CRC_OVERWRITE_ITEM; ++ crc_write_mode_t mode = CRC_OVERWRITE_ITEM; + + assert("edward-1020", pos != NULL); + assert("edward-1213", coord_num_items(&pos->coord) != 0); @@ -46770,7 +46900,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + } else { + /* use old convert info */ + -+ struct convert_item_info *idata; ++ convert_item_info_t *idata; + + idata = item_convert_data(pos); + @@ -46787,7 +46917,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + assert("edward-1022", + pos->coord.item_pos < coord_num_items(&pos->coord)); + -+ /* check if next item is of current disk cluster */ + result = next_item_dc_stat(pos); + if (result) { + detach_convert_idata(pos->sq); @@ -46843,36 +46972,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.c linux-2.6.22/fs/reise + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h linux-2.6.22/fs/reiser4/plugin/item/ctail.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/ctail.h 2007-07-29 00:25:34.948715113 +0400 -@@ -0,0 +1,102 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/ctail.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/ctail.h +@@ -0,0 +1,89 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + -+/* Ctail items are fragments (or bodies) of special tipe to provide -+ optimal storage of encrypted and(or) compressed files. */ -+ -+ +#if !defined( __FS_REISER4_CTAIL_H__ ) +#define __FS_REISER4_CTAIL_H__ + -+/* Disk format of ctail item */ ++/* cryptcompress object item. See ctail.c for description. */ ++ ++#define UCTAIL_NR_UNITS 1 ++#define UCTAIL_SHIFT 0xff ++ +typedef struct ctail_item_format { -+ /* packed shift; -+ if its value is different from UCTAIL_SHIFT (see below), then -+ size of disk cluster is calculated as (1 << cluster_shift) */ ++ /* cluster shift */ + d8 cluster_shift; + /* ctail body */ + d8 body[0]; +} __attribute__ ((packed)) ctail_item_format; + -+/* "Unprepped" disk cluster is represented by a single ctail item -+ with the following "magic" attributes: */ -+/* "magic" cluster_shift */ -+#define UCTAIL_SHIFT 0xff -+/* How many units unprepped ctail item has */ -+#define UCTAIL_NR_UNITS 1 -+ +/* The following is a set of various item states in a disk cluster. + Disk cluster is a set of items whose keys belong to the interval + [dc_key , dc_key + disk_cluster_size - 1] */ @@ -46883,15 +47004,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h linux-2.6.22/fs/reise + DC_AFTER_CLUSTER = 3 +} dc_item_stat; + -+/* ctail-specific extension. -+ In particular this describes parameters of disk cluster an item belongs to */ -+struct ctail_coord_extension { -+ int shift; /* this contains cluster_shift extracted from -+ ctail_item_format (above), or UCTAIL_SHIFT -+ (the last one is the "magic" of unprepped disk clusters)*/ -+ int dsize; /* size of a prepped disk cluster */ -+ int ncount; /* count of nodes occupied by a disk cluster */ -+}; ++typedef struct { ++ int shift; /* we keep here a cpu value of cluster_shift field ++ of ctail_item_format (see above) */ ++} ctail_coord_extension_t; + +struct cut_list; + @@ -46925,7 +47041,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h linux-2.6.22/fs/reise +/* plugin->u.item.s.* */ +int read_ctail(struct file *, flow_t *, hint_t *); +int readpage_ctail(void *, struct page *); -+int readpages_ctail(struct file *, struct address_space *, struct list_head *); ++void readpages_ctail(void *, struct address_space *, struct list_head *); +reiser4_key *append_key_ctail(const coord_t *, reiser4_key *); +int create_hook_ctail(const coord_t * coord, void *arg); +int kill_hook_ctail(const coord_t *, pos_in_node_t, pos_in_node_t, @@ -46937,6 +47053,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h linux-2.6.22/fs/reise +int scan_ctail(flush_scan *); +int convert_ctail(flush_pos_t *); +size_t inode_scaled_cluster_size(struct inode *); ++int cluster_shift_by_coord(const coord_t * coord); + +#endif /* __FS_REISER4_CTAIL_H__ */ + @@ -46949,9 +47066,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/ctail.h linux-2.6.22/fs/reise + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reiser4/plugin/item/extent.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/extent.c 2007-07-29 00:25:34.948715113 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/extent.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/extent.c @@ -0,0 +1,197 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -46979,7 +47097,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis +} + +/* how many bytes are addressed by @nr first extents of the extent item */ -+reiser4_block_nr reiser4_extent_size(const coord_t * coord, pos_in_node_t nr) ++reiser4_block_nr extent_size(const coord_t * coord, pos_in_node_t nr) +{ + pos_in_node_t i; + reiser4_block_nr blocks; @@ -47017,15 +47135,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis +} + +/* set extent's start and width */ -+void reiser4_set_extent(reiser4_extent * ext, reiser4_block_nr start, -+ reiser4_block_nr width) ++void ++set_extent(reiser4_extent * ext, reiser4_block_nr start, reiser4_block_nr width) +{ + extent_set_start(ext, start); + extent_set_width(ext, width); +} + ++ +/** -+ * reiser4_replace_extent - replace extent and paste 1 or 2 after it ++ * replace_extent - replace extent and paste 1 or 2 after it + * @un_extent: coordinate of extent to be overwritten + * @lh: need better comment + * @key: need better comment @@ -47039,8 +47158,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis + * first of newly inserted units, if it is 0 - @un_extent and @lh are returned + * set to extent which was overwritten. + */ -+int reiser4_replace_extent(struct replace_handle *h, -+ int return_inserted_position) ++int replace_extent(struct replace_handle *h, int return_inserted_position) +{ + int result; + znode *orig_znode; @@ -47059,8 +47177,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis + coord_dup(&h->coord_after, h->coord); + init_lh(&h->lh_after); + copy_lh(&h->lh_after, h->lh); -+ reiser4_tap_init(&h->watch, &h->coord_after, &h->lh_after, ZNODE_WRITE_LOCK); -+ reiser4_tap_monitor(&h->watch); ++ tap_init(&h->watch, &h->coord_after, &h->lh_after, ZNODE_WRITE_LOCK); ++ tap_monitor(&h->watch); + + ON_DEBUG(h->orig_ext = *extent_by_coord(h->coord)); + orig_znode = h->coord->node; @@ -47128,7 +47246,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis + } + } + } -+ reiser4_tap_done(&h->watch); ++ tap_done(&h->watch); + + return result; +} @@ -47150,10 +47268,244 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.c linux-2.6.22/fs/reis + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.22/fs/reiser4/plugin/item/extent_file_ops.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/extent_file_ops.c 2007-07-29 00:25:34.952716148 +0400 -@@ -0,0 +1,1453 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/extent.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/extent.h +@@ -0,0 +1,228 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++#ifndef __REISER4_EXTENT_H__ ++#define __REISER4_EXTENT_H__ ++ ++/* on disk extent */ ++typedef struct { ++ reiser4_dblock_nr start; ++ reiser4_dblock_nr width; ++} reiser4_extent; ++ ++typedef struct extent_stat { ++ int unallocated_units; ++ int unallocated_blocks; ++ int allocated_units; ++ int allocated_blocks; ++ int hole_units; ++ int hole_blocks; ++} extent_stat; ++ ++/* extents in an extent item can be either holes, or unallocated or allocated ++ extents */ ++typedef enum { ++ HOLE_EXTENT, ++ UNALLOCATED_EXTENT, ++ ALLOCATED_EXTENT ++} extent_state; ++ ++#define HOLE_EXTENT_START 0 ++#define UNALLOCATED_EXTENT_START 1 ++#define UNALLOCATED_EXTENT_START2 2 ++ ++typedef struct { ++ reiser4_block_nr pos_in_unit; ++ reiser4_block_nr width; /* width of current unit */ ++ pos_in_node_t nr_units; /* number of units */ ++ int ext_offset; /* offset from the beginning of zdata() */ ++ unsigned long expected_page; ++#if REISER4_DEBUG ++ reiser4_extent extent; ++#endif ++} extent_coord_extension_t; ++ ++/* macros to set/get fields of on-disk extent */ ++static inline reiser4_block_nr extent_get_start(const reiser4_extent * ext) ++{ ++ return le64_to_cpu(ext->start); ++} ++ ++static inline reiser4_block_nr extent_get_width(const reiser4_extent * ext) ++{ ++ return le64_to_cpu(ext->width); ++} ++ ++extern __u64 reiser4_current_block_count(void); ++ ++static inline void ++extent_set_start(reiser4_extent * ext, reiser4_block_nr start) ++{ ++ cassert(sizeof(ext->start) == 8); ++ assert("nikita-2510", ++ ergo(start > 1, start < reiser4_current_block_count())); ++ put_unaligned(cpu_to_le64(start), &ext->start); ++} ++ ++static inline void ++extent_set_width(reiser4_extent * ext, reiser4_block_nr width) ++{ ++ cassert(sizeof(ext->width) == 8); ++ assert("", width > 0); ++ put_unaligned(cpu_to_le64(width), &ext->width); ++ assert("nikita-2511", ++ ergo(extent_get_start(ext) > 1, ++ extent_get_start(ext) + width <= ++ reiser4_current_block_count())); ++} ++ ++#define extent_item(coord) \ ++({ \ ++ assert("nikita-3143", item_is_extent(coord)); \ ++ ((reiser4_extent *)item_body_by_coord (coord)); \ ++}) ++ ++#define extent_by_coord(coord) \ ++({ \ ++ assert("nikita-3144", item_is_extent(coord)); \ ++ (extent_item (coord) + (coord)->unit_pos); \ ++}) ++ ++#define width_by_coord(coord) \ ++({ \ ++ assert("nikita-3145", item_is_extent(coord)); \ ++ extent_get_width (extent_by_coord(coord)); \ ++}) ++ ++struct carry_cut_data; ++struct carry_kill_data; ++ ++/* plugin->u.item.b.* */ ++reiser4_key *max_key_inside_extent(const coord_t *, reiser4_key *); ++int can_contain_key_extent(const coord_t * coord, const reiser4_key * key, ++ const reiser4_item_data *); ++int mergeable_extent(const coord_t * p1, const coord_t * p2); ++pos_in_node_t nr_units_extent(const coord_t *); ++lookup_result lookup_extent(const reiser4_key *, lookup_bias, coord_t *); ++void init_coord_extent(coord_t *); ++int init_extent(coord_t *, reiser4_item_data *); ++int paste_extent(coord_t *, reiser4_item_data *, carry_plugin_info *); ++int can_shift_extent(unsigned free_space, ++ coord_t * source, znode * target, shift_direction, ++ unsigned *size, unsigned want); ++void copy_units_extent(coord_t * target, coord_t * source, unsigned from, ++ unsigned count, shift_direction where_is_free_space, ++ unsigned free_space); ++int kill_hook_extent(const coord_t *, pos_in_node_t from, pos_in_node_t count, ++ struct carry_kill_data *); ++int create_hook_extent(const coord_t * coord, void *arg); ++int cut_units_extent(coord_t * coord, pos_in_node_t from, pos_in_node_t to, ++ struct carry_cut_data *, reiser4_key * smallest_removed, ++ reiser4_key * new_first); ++int kill_units_extent(coord_t * coord, pos_in_node_t from, pos_in_node_t to, ++ struct carry_kill_data *, reiser4_key * smallest_removed, ++ reiser4_key * new_first); ++reiser4_key *unit_key_extent(const coord_t *, reiser4_key *); ++reiser4_key *max_unit_key_extent(const coord_t *, reiser4_key *); ++void print_extent(const char *, coord_t *); ++int utmost_child_extent(const coord_t * coord, sideof side, jnode ** child); ++int utmost_child_real_block_extent(const coord_t * coord, sideof side, ++ reiser4_block_nr * block); ++void item_stat_extent(const coord_t * coord, void *vp); ++int check_extent(const coord_t * coord, const char **error); ++ ++/* plugin->u.item.s.file.* */ ++ssize_t write_extent(struct file *, const char __user *, size_t, loff_t *); ++int read_extent(struct file *, flow_t *, hint_t *); ++int readpage_extent(void *, struct page *); ++void readpages_extent(void *, struct address_space *, struct list_head *pages); ++reiser4_key *append_key_extent(const coord_t *, reiser4_key *); ++void init_coord_extension_extent(uf_coord_t *, loff_t offset); ++int get_block_address_extent(const coord_t *, sector_t block, ++ sector_t * result); ++ ++/* these are used in flush.c ++ FIXME-VS: should they be somewhere in item_plugin? */ ++int allocate_extent_item_in_place(coord_t *, lock_handle *, flush_pos_t * pos); ++int allocate_and_copy_extent(znode * left, coord_t * right, flush_pos_t * pos, ++ reiser4_key * stop_key); ++ ++int extent_is_unallocated(const coord_t * item); /* True if this extent is unallocated (i.e., not a hole, not allocated). */ ++__u64 extent_unit_index(const coord_t * item); /* Block offset of this unit. */ ++__u64 extent_unit_width(const coord_t * item); /* Number of blocks in this unit. */ ++ ++/* plugin->u.item.f. */ ++int scan_extent(flush_scan * scan); ++extern int key_by_offset_extent(struct inode *, loff_t, reiser4_key *); ++ ++reiser4_item_data *init_new_extent(reiser4_item_data * data, void *ext_unit, ++ int nr_extents); ++reiser4_block_nr extent_size(const coord_t * coord, pos_in_node_t nr); ++extent_state state_of_extent(reiser4_extent * ext); ++void set_extent(reiser4_extent *, reiser4_block_nr start, ++ reiser4_block_nr width); ++int update_extent(struct inode *, jnode *, loff_t pos, int *plugged_hole); ++ ++#include "../../coord.h" ++#include "../../lock.h" ++#include "../../tap.h" ++ ++struct replace_handle { ++ /* these are to be set before calling replace_extent */ ++ coord_t *coord; ++ lock_handle *lh; ++ reiser4_key key; ++ reiser4_key *pkey; ++ reiser4_extent overwrite; ++ reiser4_extent new_extents[2]; ++ int nr_new_extents; ++ unsigned flags; ++ ++ /* these are used by replace_extent */ ++ reiser4_item_data item; ++ coord_t coord_after; ++ lock_handle lh_after; ++ tap_t watch; ++ reiser4_key paste_key; ++#if REISER4_DEBUG ++ reiser4_extent orig_ext; ++ reiser4_key tmp; ++#endif ++}; ++ ++/* this structure is kmalloced before calling make_extent to avoid excessive ++ stack consumption on plug_hole->replace_extent */ ++struct make_extent_handle { ++ uf_coord_t *uf_coord; ++ reiser4_block_nr blocknr; ++ int created; ++ struct inode *inode; ++ union { ++ struct { ++ } append; ++ struct replace_handle replace; ++ } u; ++}; ++ ++int replace_extent(struct replace_handle *, int return_inserted_position); ++lock_handle *znode_lh(znode *); ++ ++/* the reiser4 repacker support */ ++struct repacker_cursor; ++extern int process_extent_backward_for_repacking(tap_t *, ++ struct repacker_cursor *); ++extern int mark_extent_for_repacking(tap_t *, int); ++ ++#define coord_by_uf_coord(uf_coord) (&((uf_coord)->coord)) ++#define ext_coord_by_uf_coord(uf_coord) (&((uf_coord)->extension.extent)) ++ ++/* __REISER4_EXTENT_H__ */ ++#endif ++/* ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/item/extent_file_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/extent_file_ops.c +@@ -0,0 +1,1712 @@ +/* COPYRIGHT 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "item.h" @@ -47163,6 +47515,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + +#include +#include ++#include "../../../../mm/filemap.h" ++ + +static inline reiser4_extent *ext_by_offset(const znode *node, int offset) +{ @@ -47184,7 +47538,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +{ +#if REISER4_DEBUG + const coord_t *coord; -+ const struct extent_coord_extension *ext_coord; ++ const extent_coord_extension_t *ext_coord; + reiser4_extent *ext; + + coord = &uf_coord->coord; @@ -47205,7 +47559,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + sizeof(reiser4_extent)) == 0))); + if (key) { + reiser4_key coord_key; -+ ++ + unit_key_by_coord(&uf_coord->coord, &coord_key); + set_key_offset(&coord_key, + get_key_offset(&coord_key) + @@ -47266,7 +47620,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +#endif + +/** -+ * can_append - ++ * can_append - + * @key: + * @coord: + * @@ -47302,7 +47656,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + append_key_extent(coord, &append_key); + + assert("", keyle(&append_key, key)); -+ ++ + /* + * extent item has to be appended with hole. Calculate length of that + * hole @@ -47322,8 +47676,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * @hole_width blocks. Note that we do not worry about + * overflowing - extent width is 64 bits + */ -+ reiser4_set_extent(ext, HOLE_EXTENT_START, -+ extent_get_width(ext) + hole_width); ++ set_extent(ext, HOLE_EXTENT_START, ++ extent_get_width(ext) + hole_width); + znode_make_dirty(coord->node); + return 0; + } @@ -47332,7 +47686,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + assert("vs-713", (state_of_extent(ext) == ALLOCATED_EXTENT || + state_of_extent(ext) == UNALLOCATED_EXTENT)); + -+ reiser4_set_extent(&new_ext, HOLE_EXTENT_START, hole_width); ++ set_extent(&new_ext, HOLE_EXTENT_START, hole_width); + init_new_extent(&idata, &new_ext, 1); + return insert_into_item(coord, lh, &append_key, &idata, 0); +} @@ -47340,7 +47694,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +/** + * check_jnodes + * @twig: longterm locked twig node -+ * @key: ++ * @key: + * + */ +static void check_jnodes(znode *twig, const reiser4_key *key, int count) @@ -47389,7 +47743,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + reiser4_extent new_ext; + reiser4_item_data idata; + coord_t *coord; -+ struct extent_coord_extension *ext_coord; ++ extent_coord_extension_t *ext_coord; + reiser4_extent *ext; + reiser4_block_nr block; + jnode *node; @@ -47426,8 +47780,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * last extent unit of the file is unallocated one. Increase + * its width by @count + */ -+ reiser4_set_extent(ext, UNALLOCATED_EXTENT_START, -+ extent_get_width(ext) + count); ++ set_extent(ext, UNALLOCATED_EXTENT_START, ++ extent_get_width(ext) + count); + znode_make_dirty(coord->node); + + /* update coord extension */ @@ -47443,7 +47797,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * last extent unit of the file is either hole or allocated + * one. Append one unallocated extent of width @count + */ -+ reiser4_set_extent(&new_ext, UNALLOCATED_EXTENT_START, count); ++ set_extent(&new_ext, UNALLOCATED_EXTENT_START, count); + init_new_extent(&idata, &new_ext, 1); + result = insert_into_item(coord, uf_coord->lh, key, &idata, 0); + uf_coord->valid = 0; @@ -47471,10 +47825,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + spin_lock_jnode(node); + JF_SET(node, JNODE_CREATED); + jnode_set_block(node, &block); -+ result = reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); ++ result = try_capture(node, ZNODE_WRITE_LOCK, 0); + BUG_ON(result != 0); + jnode_make_dirty_locked(node); -+ spin_unlock_jnode(node); ++ spin_unlock_jnode(node); + } + return count; +} @@ -47500,13 +47854,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + item_key = *key; + set_key_offset(&item_key, 0ull); -+ ++ + hole_width = ((get_key_offset(key) + current_blocksize - 1) >> + current_blocksize_bits); + assert("vs-710", hole_width > 0); + + /* compose body of hole extent and insert item into tree */ -+ reiser4_set_extent(&new_ext, HOLE_EXTENT_START, hole_width); ++ set_extent(&new_ext, HOLE_EXTENT_START, hole_width); + init_new_extent(&idata, &new_ext, 1); + return insert_extent_by_coord(coord, &idata, &item_key, lh); +} @@ -47534,7 +47888,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + reiser4_extent new_ext; + reiser4_item_data idata; + reiser4_block_nr block; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + jnode *node; + + /* first extent insertion starts at leaf level */ @@ -47551,10 +47905,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * file or performing tail conversion + */ + assert("", (uf_info->container == UF_CONTAINER_EMPTY || -+ (reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED) && -+ reiser4_inode_get_flag(inode, -+ REISER4_PART_IN_CONV)))); ++ (inode_get_flag(inode, REISER4_PART_MIXED) && ++ inode_get_flag(inode, REISER4_PART_IN_CONV)))); ++ + /* if file was empty - update its state */ + if (result == 0 && uf_info->container == UF_CONTAINER_EMPTY) + uf_info->container = UF_CONTAINER_EXTENTS; @@ -47571,7 +47924,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * prepare for tree modification: compose body of item and item data + * structure needed for insertion + */ -+ reiser4_set_extent(&new_ext, UNALLOCATED_EXTENT_START, count); ++ set_extent(&new_ext, UNALLOCATED_EXTENT_START, count); + init_new_extent(&idata, &new_ext, 1); + + /* insert extent item into the tree */ @@ -47594,10 +47947,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + spin_lock_jnode(node); + JF_SET(node, JNODE_CREATED); + jnode_set_block(node, &block); -+ result = reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); ++ result = try_capture(node, ZNODE_WRITE_LOCK, 0); + BUG_ON(result != 0); + jnode_make_dirty_locked(node); -+ spin_unlock_jnode(node); ++ spin_unlock_jnode(node); + } + + /* @@ -47624,7 +47977,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + reiser4_extent *ext; + reiser4_block_nr width, pos_in_unit; + coord_t *coord; -+ struct extent_coord_extension *ext_coord; ++ extent_coord_extension_t *ext_coord; + int return_inserted_position; + + check_uf_coord(uf_coord, key); @@ -47642,7 +47995,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + *how = 0; + if (width == 1) { -+ reiser4_set_extent(ext, UNALLOCATED_EXTENT_START, 1); ++ set_extent(ext, UNALLOCATED_EXTENT_START, 1); + znode_make_dirty(coord->node); + /* update uf_coord */ + ON_DEBUG(ext_coord->extent = *ext); @@ -47675,14 +48028,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + } + } + /* extent for replace */ -+ reiser4_set_extent(&rh.overwrite, UNALLOCATED_EXTENT_START, 1); ++ set_extent(&rh.overwrite, UNALLOCATED_EXTENT_START, 1); + /* extent to be inserted */ -+ reiser4_set_extent(&rh.new_extents[0], HOLE_EXTENT_START, -+ width - 1); ++ set_extent(&rh.new_extents[0], HOLE_EXTENT_START, width - 1); + rh.nr_new_extents = 1; + -+ /* have reiser4_replace_extent to return with @coord and -+ @uf_coord->lh set to unit which was replaced */ ++ /* have replace_extent to return with @coord and @uf_coord->lh ++ set to unit which was replaced */ + return_inserted_position = 0; + *how = 3; + } else if (pos_in_unit == width - 1) { @@ -47712,29 +48064,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + } + } + /* extent for replace */ -+ reiser4_set_extent(&rh.overwrite, HOLE_EXTENT_START, width - 1); ++ set_extent(&rh.overwrite, HOLE_EXTENT_START, width - 1); + /* extent to be inserted */ -+ reiser4_set_extent(&rh.new_extents[0], UNALLOCATED_EXTENT_START, -+ 1); ++ set_extent(&rh.new_extents[0], UNALLOCATED_EXTENT_START, 1); + rh.nr_new_extents = 1; + -+ /* have reiser4_replace_extent to return with @coord and -+ @uf_coord->lh set to unit which was inserted */ ++ /* have replace_extent to return with @coord and @uf_coord->lh ++ set to unit which was inserted */ + return_inserted_position = 1; + *how = 5; + } else { + /* extent for replace */ -+ reiser4_set_extent(&rh.overwrite, HOLE_EXTENT_START, -+ pos_in_unit); ++ set_extent(&rh.overwrite, HOLE_EXTENT_START, pos_in_unit); + /* extents to be inserted */ -+ reiser4_set_extent(&rh.new_extents[0], UNALLOCATED_EXTENT_START, -+ 1); -+ reiser4_set_extent(&rh.new_extents[1], HOLE_EXTENT_START, -+ width - pos_in_unit - 1); ++ set_extent(&rh.new_extents[0], UNALLOCATED_EXTENT_START, 1); ++ set_extent(&rh.new_extents[1], HOLE_EXTENT_START, ++ width - pos_in_unit - 1); + rh.nr_new_extents = 2; + -+ /* have reiser4_replace_extent to return with @coord and -+ @uf_coord->lh set to first of units which were inserted */ ++ /* have replace_extent to return with @coord and @uf_coord->lh ++ set to first of units which were inserted */ + return_inserted_position = 1; + *how = 6; + } @@ -47743,7 +48092,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + extent_get_width(&rh.overwrite) * current_blocksize); + + uf_coord->valid = 0; -+ return reiser4_replace_extent(&rh, return_inserted_position); ++ return replace_extent(&rh, return_inserted_position); +} + +/** @@ -47760,7 +48109,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + jnode *node, int *hole_plugged) +{ + int result; -+ struct extent_coord_extension *ext_coord; ++ extent_coord_extension_t *ext_coord; + reiser4_extent *ext; + reiser4_block_nr block; + int how; @@ -47806,7 +48155,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + */ +static int move_coord(uf_coord_t *uf_coord) +{ -+ struct extent_coord_extension *ext_coord; ++ extent_coord_extension_t *ext_coord; + + if (uf_coord->valid == 0) + return 1; @@ -47837,7 +48186,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +} + +/** -+ * overwrite_extent - ++ * overwrite_extent - + * @inode: + * + * Returns number of handled jnodes. @@ -47868,7 +48217,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * them dirty + */ + spin_lock_jnode(node); -+ result = reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); ++ result = try_capture(node, ZNODE_WRITE_LOCK, 0); + BUG_ON(result != 0); + jnode_make_dirty_locked(node); + spin_unlock_jnode(node); @@ -47893,15 +48242,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + return count; +} + ++void init_uf_coord(uf_coord_t *uf_coord, lock_handle *lh); ++ +/** -+ * reiser4_update_extent ++ * update_extent + * @file: + * @jnodes: + * @count: + * @off: -+ * ++ * + */ -+int reiser4_update_extent(struct inode *inode, jnode *node, loff_t pos, ++int update_extent(struct inode *inode, jnode *node, loff_t pos, + int *plugged_hole) +{ + int result; @@ -47911,7 +48262,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + lock_handle lh; + reiser4_key key; + -+ assert("", reiser4_lock_counters()->d_refs == 0); ++ assert("", lock_counters()->d_refs == 0); + + key_by_inode_and_offset_common(inode, pos, &key); + @@ -47920,10 +48271,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + result = find_file_item_nohint(coord, &lh, &key, + ZNODE_WRITE_LOCK, inode); + if (IS_CBKERR(result)) { -+ assert("", reiser4_lock_counters()->d_refs == 0); ++ assert("", lock_counters()->d_refs == 0); + return result; + } -+ ++ + result = zload(coord->node); + BUG_ON(result != 0); + loaded = coord->node; @@ -47958,7 +48309,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + assert("", result == 1 || result < 0); + zrelse(loaded); + done_lh(&lh); -+ assert("", reiser4_lock_counters()->d_refs == 0); ++ assert("", lock_counters()->d_refs == 0); + return (result == 1) ? 0 : result; +} + @@ -47968,7 +48319,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * @jnodes: + * @count: + * @off: -+ * ++ * + */ +static int update_extents(struct file *file, jnode **jnodes, int count, loff_t pos) +{ @@ -47977,10 +48328,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + reiser4_key key; + int result; + znode *loaded; -+ ++ + result = load_file_hint(file, &hint); + BUG_ON(result != 0); -+ ++ + inode = file->f_dentry->d_inode; + if (count != 0) + /* @@ -47989,12 +48340,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + pos = (loff_t)index_jnode(jnodes[0]) << PAGE_CACHE_SHIFT; + key_by_inode_and_offset_common(inode, pos, &key); + -+ assert("", reiser4_lock_counters()->d_refs == 0); -+ ++ assert("", lock_counters()->d_refs == 0); ++ + do { + result = find_file_item(&hint, &key, ZNODE_WRITE_LOCK, inode); + if (IS_CBKERR(result)) { -+ assert("", reiser4_lock_counters()->d_refs == 0); ++ assert("", lock_counters()->d_refs == 0); + return result; + } + @@ -48046,14 +48397,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + /* seal and unlock znode */ + if (hint.ext_coord.valid) -+ reiser4_set_hint(&hint, &key, ZNODE_WRITE_LOCK); ++ set_hint(&hint, &key, ZNODE_WRITE_LOCK); + else -+ reiser4_unset_hint(&hint); ++ unset_hint(&hint); + + } while (count > 0); + + save_file_hint(file, &hint); -+ assert("", reiser4_lock_counters()->d_refs == 0); ++ assert("", lock_counters()->d_refs == 0); + return result; +} + @@ -48071,8 +48422,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + /* + * to write WRITE_GRANULARITY pages to a file by extents we have to -+ * reserve disk space for: -+ ++ * reserve disk space for: ++ + * 1. find_file_item may have to insert empty node to the tree (empty + * leaf node between two extent items). This requires 1 block and + * number of blocks which are necessary to perform insertion of an @@ -48084,7 +48435,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + * 3. stat data update + */ -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + count = estimate_one_insert_item(tree) + + WRITE_GRANULARITY * (1 + estimate_one_insert_into_item(tree)) + + estimate_one_insert_item(tree); @@ -48092,44 +48443,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + return reiser4_grab_space(count, 0 /* flags */); +} + -+/* -+ * filemap_copy_from_user no longer exists in generic code, because it -+ * is deadlocky (copying from user while holding the page lock is bad). -+ * As a temporary fix for reiser4, just define it here. -+ */ -+static inline size_t -+filemap_copy_from_user(struct page *page, unsigned long offset, -+ const char __user *buf, unsigned bytes) -+{ -+ char *kaddr; -+ int left; -+ -+ kaddr = kmap_atomic(page, KM_USER0); -+ left = __copy_from_user_inatomic_nocache(kaddr + offset, buf, bytes); -+ kunmap_atomic(kaddr, KM_USER0); -+ -+ if (left != 0) { -+ /* Do it the slow way */ -+ kaddr = kmap(page); -+ left = __copy_from_user_nocache(kaddr + offset, buf, bytes); -+ kunmap(page); -+ } -+ return bytes - left; -+} -+ +/** -+ * reiser4_write_extent - write method of extent item plugin ++ * write_extent - write method of extent item plugin + * @file: file to write to + * @buf: address of user-space buffer -+ * @count: number of bytes to write -+ * @pos: position in file to write to ++ * @write_amount: number of bytes to write ++ * @off: position in file to write to + * + */ -+ssize_t reiser4_write_extent(struct file *file, const char __user *buf, -+ size_t count, loff_t *pos) ++ssize_t write_extent(struct file *file, const char __user *buf, size_t count, ++ loff_t *pos) +{ + int have_to_update_extent; -+ int nr_pages, nr_dirty; ++ int nr_pages; + struct page *page; + jnode *jnodes[WRITE_GRANULARITY + 1]; + struct inode *inode; @@ -48138,7 +48464,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + int i; + int to_page, page_off; + size_t left, written; -+ int result = 0; ++ int result; + + inode = file->f_dentry->d_inode; + if (write_extent_reserve_space(inode)) @@ -48152,31 +48478,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + BUG_ON(get_current_context()->trans->atom != NULL); + -+ left = count; + index = *pos >> PAGE_CACHE_SHIFT; + /* calculate number of pages which are to be written */ + end = ((*pos + count - 1) >> PAGE_CACHE_SHIFT); + nr_pages = end - index + 1; -+ nr_dirty = 0; + assert("", nr_pages <= WRITE_GRANULARITY + 1); + + /* get pages and jnodes */ + for (i = 0; i < nr_pages; i ++) { -+ page = find_or_create_page(inode->i_mapping, index + i, -+ reiser4_ctx_gfp_mask_get()); ++ page = find_or_create_page(inode->i_mapping, index + i, get_gfp_mask()); + if (page == NULL) { -+ nr_pages = i; -+ result = RETERR(-ENOMEM); -+ goto out; ++ while(i --) { ++ unlock_page(jnode_page(jnodes[i])); ++ page_cache_release(jnode_page(jnodes[i])); ++ } ++ return RETERR(-ENOMEM); + } + + jnodes[i] = jnode_of_page(page); + if (IS_ERR(jnodes[i])) { + unlock_page(page); + page_cache_release(page); -+ nr_pages = i; -+ result = RETERR(-ENOMEM); -+ goto out; ++ while (i --) { ++ jput(jnodes[i]); ++ page_cache_release(jnode_page(jnodes[i])); ++ } ++ return RETERR(-ENOMEM); + } + /* prevent jnode and page from disconnecting */ + JF_SET(jnodes[i], JNODE_WRITE_PREPARED); @@ -48187,13 +48514,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + + have_to_update_extent = 0; + ++ left = count; + page_off = (*pos & (PAGE_CACHE_SIZE - 1)); + for (i = 0; i < nr_pages; i ++) { + to_page = PAGE_CACHE_SIZE - page_off; + if (to_page > left) + to_page = left; + page = jnode_page(jnodes[i]); -+ if (page_offset(page) < inode->i_size && ++ if (((loff_t)page->index << PAGE_CACHE_SHIFT) < inode->i_size && + !PageUptodate(page) && to_page != PAGE_CACHE_SIZE) { + /* + * the above is not optimal for partial write to last @@ -48207,9 +48535,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + /* wait for read completion */ + lock_page(page); + BUG_ON(!PageUptodate(page)); ++ unlock_page(page); + } else + result = 0; -+ unlock_page(page); + } + + BUG_ON(get_current_context()->trans->atom != NULL); @@ -48217,24 +48545,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + BUG_ON(get_current_context()->trans->atom != NULL); + + lock_page(page); -+ if (!PageUptodate(page) && to_page != PAGE_CACHE_SIZE) -+ simple_prepare_write(file, page, page_off, -+ page_off + to_page); ++ if (!PageUptodate(page) && to_page != PAGE_CACHE_SIZE) { ++ void *kaddr; ++ ++ kaddr = kmap_atomic(page, KM_USER0); ++ memset(kaddr, 0, page_off); ++ memset(kaddr + page_off + to_page, 0, ++ PAGE_CACHE_SIZE - (page_off + to_page)); ++ flush_dcache_page(page); ++ kunmap_atomic(kaddr, KM_USER0); ++ } + + written = filemap_copy_from_user(page, page_off, buf, to_page); -+ if (unlikely(written != to_page)) { ++ if (written != to_page) { + unlock_page(page); ++ page_cache_release(page); ++ nr_pages = i; ++ jput(jnodes[i]); + result = RETERR(-EFAULT); + break; + } -+ + flush_dcache_page(page); -+ reiser4_set_page_dirty_internal(page); ++ set_page_dirty_internal(page); + unlock_page(page); -+ nr_dirty++; -+ + mark_page_accessed(page); + SetPageUptodate(page); ++ page_cache_release(page); + + if (jnodes[i]->blocknr == 0) + have_to_update_extent ++; @@ -48244,35 +48580,42 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + left -= to_page; + BUG_ON(get_current_context()->trans->atom != NULL); + } -+ ++ + if (have_to_update_extent) { -+ update_extents(file, jnodes, nr_dirty, *pos); ++ update_extents(file, jnodes, nr_pages, *pos); + } else { -+ for (i = 0; i < nr_dirty; i ++) { -+ int ret; ++ for (i = 0; i < nr_pages; i ++) { + spin_lock_jnode(jnodes[i]); -+ ret = reiser4_try_capture(jnodes[i], -+ ZNODE_WRITE_LOCK, 0); -+ BUG_ON(ret != 0); ++ result = try_capture(jnodes[i], ZNODE_WRITE_LOCK, 0); ++ BUG_ON(result != 0); + jnode_make_dirty_locked(jnodes[i]); + spin_unlock_jnode(jnodes[i]); + } + } -+out: ++ + for (i = 0; i < nr_pages; i ++) { -+ page_cache_release(jnode_page(jnodes[i])); + JF_CLR(jnodes[i], JNODE_WRITE_PREPARED); + jput(jnodes[i]); + } + -+ /* the only errors handled so far is ENOMEM and -+ EFAULT on copy_from_user */ ++ /* the only error handled so far is EFAULT on copy_from_user */ ++ return (count - left) ? (count - left) : -EFAULT; ++} + -+ return (count - left) ? (count - left) : result; ++static inline void zero_page(struct page *page) ++{ ++ char *kaddr = kmap_atomic(page, KM_USER0); ++ ++ memset(kaddr, 0, PAGE_CACHE_SIZE); ++ flush_dcache_page(page); ++ kunmap_atomic(kaddr, KM_USER0); ++ SetPageUptodate(page); ++ unlock_page(page); +} + -+int reiser4_do_readpage_extent(reiser4_extent * ext, reiser4_block_nr pos, -+ struct page *page) ++static int ++do_readpage_extent(reiser4_extent * ext, reiser4_block_nr pos, ++ struct page *page) +{ + jnode *j; + struct address_space *mapping; @@ -48292,9 +48635,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + */ + j = jfind(mapping, index); + if (j == NULL) { -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); -+ SetPageUptodate(page); -+ unlock_page(page); ++ zero_page(page); + return 0; + } + spin_lock_jnode(j); @@ -48307,9 +48648,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + block = *jnode_get_io_block(j); + spin_unlock_jnode(j); + if (block == 0) { -+ zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); -+ SetPageUptodate(page); -+ unlock_page(page); ++ zero_page(page); + jput(j); + return 0; + } @@ -48345,13 +48684,242 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + } + + BUG_ON(j == 0); -+ reiser4_page_io(page, j, READ, reiser4_ctx_gfp_mask_get()); ++ page_io(page, j, READ, get_gfp_mask()); + jput(j); + return 0; +} + ++static int ++move_coord_pages(coord_t * coord, extent_coord_extension_t * ext_coord, ++ unsigned count) ++{ ++ reiser4_extent *ext; ++ ++ ext_coord->expected_page += count; ++ ++ ext = ext_by_offset(coord->node, ext_coord->ext_offset); ++ ++ do { ++ if (ext_coord->pos_in_unit + count < ext_coord->width) { ++ ext_coord->pos_in_unit += count; ++ break; ++ } ++ ++ if (coord->unit_pos == ext_coord->nr_units - 1) { ++ coord->between = AFTER_UNIT; ++ return 1; ++ } ++ ++ /* shift to next unit */ ++ count -= (ext_coord->width - ext_coord->pos_in_unit); ++ coord->unit_pos++; ++ ext_coord->pos_in_unit = 0; ++ ext_coord->ext_offset += sizeof(reiser4_extent); ++ ext++; ++ ON_DEBUG(ext_coord->extent = *ext); ++ ext_coord->width = extent_get_width(ext); ++ } while (1); ++ ++ return 0; ++} ++ ++static int readahead_readpage_extent(void *vp, struct page *page) ++{ ++ int result; ++ uf_coord_t *uf_coord; ++ coord_t *coord; ++ extent_coord_extension_t *ext_coord; ++ ++ uf_coord = vp; ++ coord = &uf_coord->coord; ++ ++ if (coord->between != AT_UNIT) { ++ unlock_page(page); ++ return RETERR(-EINVAL); ++ } ++ ++ ext_coord = &uf_coord->extension.extent; ++ if (ext_coord->expected_page != page->index) { ++ /* read_cache_pages skipped few pages. Try to adjust coord to page */ ++ assert("vs-1269", page->index > ext_coord->expected_page); ++ if (move_coord_pages ++ (coord, ext_coord, ++ page->index - ext_coord->expected_page)) { ++ /* extent pointing to this page is not here */ ++ unlock_page(page); ++ return RETERR(-EINVAL); ++ } ++ ++ assert("vs-1274", offset_is_in_unit(coord, ++ (loff_t) page-> ++ index << PAGE_CACHE_SHIFT)); ++ ext_coord->expected_page = page->index; ++ } ++ ++ assert("vs-1281", page->index == ext_coord->expected_page); ++ result = ++ do_readpage_extent(ext_by_ext_coord(uf_coord), ++ ext_coord->pos_in_unit, page); ++ if (!result) ++ move_coord_pages(coord, ext_coord, 1); ++ return result; ++} ++ ++static int move_coord_forward(uf_coord_t *ext_coord) ++{ ++ coord_t *coord; ++ extent_coord_extension_t *extension; ++ ++ check_uf_coord(ext_coord, NULL); ++ ++ extension = &ext_coord->extension.extent; ++ extension->pos_in_unit++; ++ if (extension->pos_in_unit < extension->width) ++ /* stay within the same extent unit */ ++ return 0; ++ ++ coord = &ext_coord->coord; ++ ++ /* try to move to the next extent unit */ ++ coord->unit_pos++; ++ if (coord->unit_pos < extension->nr_units) { ++ /* went to the next extent unit */ ++ reiser4_extent *ext; ++ ++ extension->pos_in_unit = 0; ++ extension->ext_offset += sizeof(reiser4_extent); ++ ext = ext_by_offset(coord->node, extension->ext_offset); ++ ON_DEBUG(extension->extent = *ext); ++ extension->width = extent_get_width(ext); ++ return 0; ++ } ++ ++ /* there is no units in the item anymore */ ++ return 1; ++} ++ ++/* this is called by read_cache_pages for each of readahead pages */ ++static int extent_readpage_filler(void *data, struct page *page) ++{ ++ hint_t *hint; ++ loff_t offset; ++ reiser4_key key; ++ uf_coord_t *ext_coord; ++ int result; ++ ++ offset = (loff_t) page->index << PAGE_CACHE_SHIFT; ++ key_by_inode_and_offset_common(page->mapping->host, offset, &key); ++ ++ hint = (hint_t *) data; ++ ext_coord = &hint->ext_coord; ++ ++ BUG_ON(PageUptodate(page)); ++ unlock_page(page); ++ ++ if (hint_validate(hint, &key, 1 /* check key */ , ZNODE_READ_LOCK) != 0) { ++ result = coord_by_key(current_tree, &key, &ext_coord->coord, ++ ext_coord->lh, ZNODE_READ_LOCK, ++ FIND_EXACT, TWIG_LEVEL, ++ TWIG_LEVEL, CBK_UNIQUE, NULL); ++ if (result != CBK_COORD_FOUND) { ++ unset_hint(hint); ++ return result; ++ } ++ ext_coord->valid = 0; ++ } ++ ++ if (zload(ext_coord->coord.node)) { ++ unset_hint(hint); ++ return RETERR(-EIO); ++ } ++ if (!item_is_extent(&ext_coord->coord)) { ++ /* tail conversion is running in parallel */ ++ zrelse(ext_coord->coord.node); ++ unset_hint(hint); ++ return RETERR(-EIO); ++ } ++ ++ if (ext_coord->valid == 0) ++ init_coord_extension_extent(ext_coord, offset); ++ ++ check_uf_coord(ext_coord, &key); ++ ++ lock_page(page); ++ if (!PageUptodate(page)) { ++ result = do_readpage_extent(ext_by_ext_coord(ext_coord), ++ ext_coord->extension.extent. ++ pos_in_unit, page); ++ if (result) ++ unlock_page(page); ++ } else { ++ unlock_page(page); ++ result = 0; ++ } ++ if (!result && move_coord_forward(ext_coord) == 0) { ++ set_key_offset(&key, offset + PAGE_CACHE_SIZE); ++ set_hint(hint, &key, ZNODE_READ_LOCK); ++ } else ++ unset_hint(hint); ++ zrelse(ext_coord->coord.node); ++ return result; ++} ++ ++/* this is called by reiser4_readpages */ ++static void ++extent_readpages_hook(struct address_space *mapping, struct list_head *pages, ++ void *data) ++{ ++ /* FIXME: try whether having reiser4_read_cache_pages improves anything */ ++ read_cache_pages(mapping, pages, extent_readpage_filler, data); ++} ++ ++static int ++call_page_cache_readahead(struct address_space *mapping, struct file *file, ++ hint_t * hint, ++ unsigned long page_nr, ++ unsigned long ra_pages, struct file_ra_state *ra) ++{ ++ reiser4_file_fsdata *fsdata; ++ int result; ++ ++ fsdata = reiser4_get_file_fsdata(file); ++ if (IS_ERR(fsdata)) ++ return page_nr; ++ fsdata->ra2.data = hint; ++ fsdata->ra2.readpages = extent_readpages_hook; ++ ++ result = page_cache_readahead(mapping, ra, file, page_nr, ra_pages); ++ fsdata->ra2.readpages = NULL; ++ return result; ++} ++ ++/* this is called when readahead did not */ ++static int call_readpage(struct file *file, struct page *page) ++{ ++ int result; ++ ++ result = readpage_unix_file_nolock(file, page); ++ if (result) ++ return result; ++ ++ lock_page(page); ++ if (!PageUptodate(page)) { ++ unlock_page(page); ++ page_detach_jnode(page, page->mapping, page->index); ++ warning("jmacd-97178", "page is not up to date"); ++ return RETERR(-EIO); ++ } ++ unlock_page(page); ++ return 0; ++} ++ ++static int filler(void *vp, struct page *page) ++{ ++ return readpage_unix_file_nolock(vp, page); ++} ++ +/* Implements plugin->u.item.s.file.read operation for extent items. */ -+int reiser4_read_extent(struct file *file, flow_t *flow, hint_t *hint) ++int read_extent(struct file *file, flow_t *flow, hint_t *hint) +{ + int result; + struct page *page; @@ -48361,8 +48929,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + loff_t file_off; + uf_coord_t *uf_coord; + coord_t *coord; -+ struct extent_coord_extension *ext_coord; -+ unsigned long nr_pages; ++ extent_coord_extension_t *ext_coord; ++ unsigned long nr_pages, prev_page; ++ struct file_ra_state ra; + char *kaddr; + + assert("vs-1353", current_blocksize == PAGE_CACHE_SIZE); @@ -48370,7 +48939,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + assert("vs-1351", flow->length > 0); + + uf_coord = &hint->ext_coord; -+ ++ + check_uf_coord(uf_coord, NULL); + assert("vs-33", uf_coord->lh == &hint->lh); + @@ -48400,23 +48969,53 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + /* we start having twig node read locked. However, we do not want to + keep that lock all the time readahead works. So, set a sel and + release twig node. */ -+ reiser4_set_hint(hint, &flow->key, ZNODE_READ_LOCK); ++ set_hint(hint, &flow->key, ZNODE_READ_LOCK); + /* &hint->lh is done-ed */ + ++ ra = file->f_ra; ++ prev_page = ra.prev_page; + do { -+ reiser4_txn_restart_current(); -+ page = read_mapping_page(mapping, cur_page, file); -+ if (IS_ERR(page)) -+ return PTR_ERR(page); -+ lock_page(page); -+ if (!PageUptodate(page)) { ++ txn_restart_current(); ++ if (next_page == cur_page) ++ next_page = ++ call_page_cache_readahead(mapping, file, hint, ++ cur_page, nr_pages, &ra); ++ ++ page = find_get_page(mapping, cur_page); ++ if (unlikely(page == NULL)) { ++ handle_ra_miss(mapping, &ra, cur_page); ++ page = read_cache_page(mapping, cur_page, filler, file); ++ if (IS_ERR(page)) ++ return PTR_ERR(page); ++ lock_page(page); ++ if (!PageUptodate(page)) { ++ unlock_page(page); ++ page_detach_jnode(page, mapping, cur_page); ++ page_cache_release(page); ++ warning("jmacd-97178", ++ "extent_read: page is not up to date"); ++ return RETERR(-EIO); ++ } + unlock_page(page); -+ page_cache_release(page); -+ warning("jmacd-97178", "extent_read: page is not up to date"); -+ return RETERR(-EIO); ++ } else { ++ if (!PageUptodate(page)) { ++ lock_page(page); ++ ++ assert("", page->mapping == mapping); ++ if (PageUptodate(page)) ++ unlock_page(page); ++ else { ++ result = call_readpage(file, page); ++ if (result) { ++ page_cache_release(page); ++ return RETERR(result); ++ } ++ } ++ } ++ if (prev_page != cur_page) ++ mark_page_accessed(page); ++ prev_page = cur_page; + } -+ mark_page_accessed(page); -+ unlock_page(page); + + /* If users can be writing to this page using arbitrary virtual + addresses, take care about potential aliasing before reading @@ -48425,7 +49024,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + if (mapping_writably_mapped(mapping)) + flush_dcache_page(page); + -+ assert("nikita-3034", reiser4_schedulable()); ++ assert("nikita-3034", schedulable()); + + /* number of bytes which are to be read from the page */ + if (count > flow->length) @@ -48460,10 +49059,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + nr_pages--; + } while (flow->length); + ++ file->f_ra = ra; + return 0; +} + +/* ++ plugin->u.item.s.file.readpages ++*/ ++void ++readpages_extent(void *vp, struct address_space *mapping, ++ struct list_head *pages) ++{ ++ assert("vs-1739", 0); ++ if (vp) ++ read_cache_pages(mapping, pages, readahead_readpage_extent, vp); ++} ++ ++/* + plugin->s.file.readpage + reiser4_read->unix_file_read->page_cache_readahead->reiser4_readpage->unix_file_readpage->extent_readpage + or @@ -48472,7 +49084,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + At the beginning: coord->node is read locked, zloaded, page is + locked, coord is set to existing unit inside of extent item (it is not necessary that coord matches to page->index) +*/ -+int reiser4_readpage_extent(void *vp, struct page *page) ++int readpage_extent(void *vp, struct page *page) +{ + uf_coord_t *uf_coord = vp; + ON_DEBUG(coord_t * coord = &uf_coord->coord); @@ -48491,9 +49103,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + get_key_objectid(item_key_by_coord(coord, &key))); + check_uf_coord(uf_coord, NULL); + -+ return reiser4_do_readpage_extent( -+ ext_by_ext_coord(uf_coord), -+ uf_coord->extension.extent.pos_in_unit, page); ++ return do_readpage_extent(ext_by_ext_coord(uf_coord), ++ uf_coord->extension.extent.pos_in_unit, page); +} + +/** @@ -48543,9 +49154,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +{ + item_key_by_coord(coord, key); + set_key_offset(key, -+ get_key_offset(key) + reiser4_extent_size(coord, -+ nr_units_extent -+ (coord))); ++ get_key_offset(key) + extent_size(coord, ++ nr_units_extent ++ (coord))); + + assert("vs-610", get_key_offset(key) + && (get_key_offset(key) & (current_blocksize - 1)) == 0); @@ -48556,7 +49167,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 +void init_coord_extension_extent(uf_coord_t * uf_coord, loff_t lookuped) +{ + coord_t *coord; -+ struct extent_coord_extension *ext_coord; ++ extent_coord_extension_t *ext_coord; + reiser4_key key; + loff_t offset; + @@ -48607,10 +49218,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_file_ops.c linux-2.6.2 + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6.22/fs/reiser4/plugin/item/extent_flush_ops.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/extent_flush_ops.c 2007-07-29 00:25:34.964719254 +0400 -@@ -0,0 +1,1028 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/extent_flush_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/extent_flush_ops.c +@@ -0,0 +1,1018 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "item.h" @@ -48737,10 +49349,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + any case, the code below asserts this case for unallocated extents. Unallocated + extents are thus optimized because we can skip to the endpoint when scanning. + -+ It returns control to reiser4_scan_extent, handles these terminating conditions, -+ e.g., by loading the next twig. ++ It returns control to scan_extent, handles these terminating conditions, e.g., by ++ loading the next twig. +*/ -+int reiser4_scan_extent(flush_scan * scan) ++int scan_extent(flush_scan * scan) +{ + coord_t coord; + jnode *neighbor; @@ -48759,7 +49371,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + + coord_dup(&coord, &scan->parent_coord); + -+ assert("jmacd-1404", !reiser4_scan_finished(scan)); ++ assert("jmacd-1404", !scan_finished(scan)); + assert("jmacd-1405", jnode_get_level(scan->node) == LEAF_LEVEL); + assert("jmacd-1406", jnode_is_unformatted(scan->node)); + @@ -48787,7 +49399,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + (scan_max) and the number of nodes that would be passed if the scan goes the + entire way (scan_dist). Incr is an integer reflecting the incremental + direction of scan_index. */ -+ if (reiser4_scanning_left(scan)) { ++ if (scanning_left(scan)) { + scan_max = unit_index; + scan_dist = scan_index - unit_index; + incr = -1; @@ -48808,8 +49420,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + goto stop_same_parent; + + if (scan->node != neighbor -+ && !reiser4_scan_goto(scan, neighbor)) { -+ /* @neighbor was jput() by reiser4_scan_goto */ ++ && !scan_goto(scan, neighbor)) { ++ /* @neighbor was jput() by scan_goto(). */ + goto stop_same_parent; + } + @@ -48834,8 +49446,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + goto exit; + } + -+ assert("zam-1043", -+ reiser4_blocknr_is_fake(jnode_get_block(neighbor))); ++ assert("zam-1043", blocknr_is_fake(jnode_get_block(neighbor))); + + ret = scan_set_current(scan, neighbor, scan_dist, &coord); + if (ret != 0) { @@ -48849,8 +49460,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + + scan_index = + extent_unit_index(&coord) + -+ (reiser4_scanning_left(scan) ? -+ extent_unit_width(&coord) - 1 : 0); ++ (scanning_left(scan) ? extent_unit_width(&coord) - 1 : 0); + goto repeat; + } + @@ -48860,8 +49470,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + /* If we are scanning left and we stop in the middle of an allocated + extent, we know the preceder immediately.. */ + /* middle of extent is (scan_index - unit_index) != 0. */ -+ if (reiser4_scanning_left(scan) && -+ (scan_index - unit_index) != 0) { ++ if (scanning_left(scan) && (scan_index - unit_index) != 0) { + /* FIXME(B): Someone should step-through and verify that this preceder + calculation is indeed correct. */ + /* @unit_start is starting block (number) of extent @@ -48979,7 +49588,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + assert("vs-1410", state_of_extent(ext) == ALLOCATED_EXTENT); + assert("vs-1411", extent_get_width(ext) > pos_in_unit); + -+ h = kmalloc(sizeof(*h), reiser4_ctx_gfp_mask_get()); ++ h = kmalloc(sizeof(*h), get_gfp_mask()); + if (h == NULL) + return RETERR(-ENOMEM); + h->coord = coord; @@ -48989,19 +49598,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + set_key_offset(h->pkey, + (get_key_offset(h->pkey) + + pos_in_unit * current_blocksize)); -+ reiser4_set_extent(&h->overwrite, extent_get_start(ext), -+ pos_in_unit); -+ reiser4_set_extent(&h->new_extents[0], -+ extent_get_start(ext) + pos_in_unit, -+ extent_get_width(ext) - pos_in_unit); ++ set_extent(&h->overwrite, extent_get_start(ext), pos_in_unit); ++ set_extent(&h->new_extents[0], extent_get_start(ext) + pos_in_unit, ++ extent_get_width(ext) - pos_in_unit); + h->nr_new_extents = 1; + h->flags = COPI_DONT_SHIFT_LEFT; + h->paste_key = h->key; + + /* reserve space for extent unit paste, @grabbed is reserved before */ + grabbed = reserve_replace(); -+ result = reiser4_replace_extent(h, 0 /* leave @coord set to overwritten -+ extent */); ++ result = replace_extent(h, 0 /* leave @coord set to overwritten ++ extent */); + /* restore reserved */ + free_replace_reserved(grabbed); + kfree(h); @@ -49098,7 +49705,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + return 0; + } + -+ h = kmalloc(sizeof(*h), reiser4_ctx_gfp_mask_get()); ++ h = kmalloc(sizeof(*h), get_gfp_mask()); + if (h == NULL) + return RETERR(-ENOMEM); + h->coord = coord; @@ -49110,19 +49717,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + h->overwrite = *replace; + + /* replace @ext with @replace and padding extent */ -+ reiser4_set_extent(&h->new_extents[0], -+ (state == ALLOCATED_EXTENT) ? -+ (start + new_width) : -+ UNALLOCATED_EXTENT_START, -+ width - new_width); ++ set_extent(&h->new_extents[0], ++ (state == ALLOCATED_EXTENT) ? (start + new_width) : UNALLOCATED_EXTENT_START, ++ width - new_width); + h->nr_new_extents = 1; + h->flags = COPI_DONT_SHIFT_LEFT; + h->paste_key = h->key; + + /* reserve space for extent unit paste, @grabbed is reserved before */ + grabbed = reserve_replace(); -+ result = reiser4_replace_extent(h, 0 /* leave @coord set to overwritten -+ extent */); ++ result = replace_extent(h, 0 /* leave @coord set to overwritten ++ extent */); + + /* restore reserved */ + free_replace_reserved(grabbed); @@ -49137,7 +49742,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + * @index: first jnode on the range + * @count: number of jnodes to assign block numbers to + * @first: start of allocated block range -+ * ++ * + * Assigns block numbers to each of @count jnodes. Index of first jnode is + * @index. Jnodes get lookuped with jlookup. + */ @@ -49230,7 +49835,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + + tree = current_tree; + -+ atom = atom_locked_by_fq(reiser4_pos_fq(flush_pos)); ++ atom = atom_locked_by_fq(pos_fq(flush_pos)); + assert("vs-1478", atom); + + for (i = flush_pos->pos_in_unit; i < width; i++, index++) { @@ -49274,7 +49879,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + txn_atom *atom; + int nr; + -+ atom = atom_locked_by_fq(reiser4_pos_fq(flush_pos)); ++ atom = atom_locked_by_fq(pos_fq(flush_pos)); + assert("vs-1468", atom); + + nr = 0; @@ -49298,7 +49903,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + * any formatted nodes. + */ + atomic_dec(&node->x_count); -+ break; ++ break; + } + + assert("vs-1476", atomic_read(&node->x_count) > 1); @@ -49321,7 +49926,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + * within the extent. Slum gets to relocate set if flush_pos->leaf_relocate is + * set to 1 and to overwrite set otherwise + */ -+int reiser4_alloc_extent(flush_pos_t *flush_pos) ++int alloc_extent(flush_pos_t *flush_pos) +{ + coord_t *coord; + reiser4_extent *ext; @@ -49398,13 +50003,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + */ + if (coord->unit_pos && + (state_of_extent(ext - 1) == ALLOCATED_EXTENT)) -+ reiser4_pos_hint(flush_pos)->blk = -+ extent_get_start(ext - 1) + ++ pos_hint(flush_pos)->blk = extent_get_start(ext - 1) + + extent_get_width(ext - 1); + + /* allocate new block numbers for protected nodes */ -+ extent_allocate_blocks(reiser4_pos_hint(flush_pos), -+ protected, ++ extent_allocate_blocks(pos_hint(flush_pos), protected, + &first_allocated, &allocated, + block_stage); + @@ -49419,8 +50022,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + /* assign new block numbers to protected nodes */ + assign_real_blocknrs(flush_pos, oid, index, allocated, first_allocated); + ++ + /* prepare extent which will replace current one */ -+ reiser4_set_extent(&replace_ext, first_allocated, allocated); ++ set_extent(&replace_ext, first_allocated, allocated); + + /* adjust extent item */ + result = conv_extent(coord, &replace_ext); @@ -49558,18 +50162,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + */ + if (coord->unit_pos && + (state_of_extent(ext - 1) == ALLOCATED_EXTENT)) -+ reiser4_pos_hint(flush_pos)->blk = -+ extent_get_start(ext - 1) + ++ pos_hint(flush_pos)->blk = extent_get_start(ext - 1) + + extent_get_width(ext - 1); + + /* allocate new block numbers for protected nodes */ -+ extent_allocate_blocks(reiser4_pos_hint(flush_pos), -+ protected, ++ extent_allocate_blocks(pos_hint(flush_pos), protected, + &first_allocated, &allocated, + block_stage); + + /* prepare extent which will be copied to left */ -+ reiser4_set_extent(©_extent, first_allocated, allocated); ++ set_extent(©_extent, first_allocated, allocated); + + result = put_unit_to_end(left, &key, ©_extent); + if (result == -E_NODE_FULL) { @@ -49609,7 +50211,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + * overwrite: try to copy unit as it is to left neighbor and + * make all first not flushprepped nodes overwrite nodes + */ -+ reiser4_set_extent(©_extent, start, width); ++ set_extent(©_extent, start, width); + result = put_unit_to_end(left, &key, ©_extent); + if (result == -E_NODE_FULL) + return SQUEEZE_TARGET_FULL; @@ -49639,245 +50241,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_flush_ops.c linux-2.6. + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent.h linux-2.6.22/fs/reiser4/plugin/item/extent.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/extent.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/extent.h 2007-07-29 00:25:34.968720289 +0400 -@@ -0,0 +1,231 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+#ifndef __REISER4_EXTENT_H__ -+#define __REISER4_EXTENT_H__ -+ -+/* on disk extent */ -+typedef struct { -+ reiser4_dblock_nr start; -+ reiser4_dblock_nr width; -+} reiser4_extent; -+ -+struct extent_stat { -+ int unallocated_units; -+ int unallocated_blocks; -+ int allocated_units; -+ int allocated_blocks; -+ int hole_units; -+ int hole_blocks; -+}; -+ -+/* extents in an extent item can be either holes, or unallocated or allocated -+ extents */ -+typedef enum { -+ HOLE_EXTENT, -+ UNALLOCATED_EXTENT, -+ ALLOCATED_EXTENT -+} extent_state; -+ -+#define HOLE_EXTENT_START 0 -+#define UNALLOCATED_EXTENT_START 1 -+#define UNALLOCATED_EXTENT_START2 2 -+ -+struct extent_coord_extension { -+ reiser4_block_nr pos_in_unit; -+ reiser4_block_nr width; /* width of current unit */ -+ pos_in_node_t nr_units; /* number of units */ -+ int ext_offset; /* offset from the beginning of zdata() */ -+ unsigned long expected_page; -+#if REISER4_DEBUG -+ reiser4_extent extent; -+#endif -+}; -+ -+/* macros to set/get fields of on-disk extent */ -+static inline reiser4_block_nr extent_get_start(const reiser4_extent * ext) -+{ -+ return le64_to_cpu(ext->start); -+} -+ -+static inline reiser4_block_nr extent_get_width(const reiser4_extent * ext) -+{ -+ return le64_to_cpu(ext->width); -+} -+ -+extern __u64 reiser4_current_block_count(void); -+ -+static inline void -+extent_set_start(reiser4_extent * ext, reiser4_block_nr start) -+{ -+ cassert(sizeof(ext->start) == 8); -+ assert("nikita-2510", -+ ergo(start > 1, start < reiser4_current_block_count())); -+ put_unaligned(cpu_to_le64(start), &ext->start); -+} -+ -+static inline void -+extent_set_width(reiser4_extent * ext, reiser4_block_nr width) -+{ -+ cassert(sizeof(ext->width) == 8); -+ assert("", width > 0); -+ put_unaligned(cpu_to_le64(width), &ext->width); -+ assert("nikita-2511", -+ ergo(extent_get_start(ext) > 1, -+ extent_get_start(ext) + width <= -+ reiser4_current_block_count())); -+} -+ -+#define extent_item(coord) \ -+({ \ -+ assert("nikita-3143", item_is_extent(coord)); \ -+ ((reiser4_extent *)item_body_by_coord (coord)); \ -+}) -+ -+#define extent_by_coord(coord) \ -+({ \ -+ assert("nikita-3144", item_is_extent(coord)); \ -+ (extent_item (coord) + (coord)->unit_pos); \ -+}) -+ -+#define width_by_coord(coord) \ -+({ \ -+ assert("nikita-3145", item_is_extent(coord)); \ -+ extent_get_width (extent_by_coord(coord)); \ -+}) -+ -+struct carry_cut_data; -+struct carry_kill_data; -+ -+/* plugin->u.item.b.* */ -+reiser4_key *max_key_inside_extent(const coord_t *, reiser4_key *); -+int can_contain_key_extent(const coord_t * coord, const reiser4_key * key, -+ const reiser4_item_data *); -+int mergeable_extent(const coord_t * p1, const coord_t * p2); -+pos_in_node_t nr_units_extent(const coord_t *); -+lookup_result lookup_extent(const reiser4_key *, lookup_bias, coord_t *); -+void init_coord_extent(coord_t *); -+int init_extent(coord_t *, reiser4_item_data *); -+int paste_extent(coord_t *, reiser4_item_data *, carry_plugin_info *); -+int can_shift_extent(unsigned free_space, -+ coord_t * source, znode * target, shift_direction, -+ unsigned *size, unsigned want); -+void copy_units_extent(coord_t * target, coord_t * source, unsigned from, -+ unsigned count, shift_direction where_is_free_space, -+ unsigned free_space); -+int kill_hook_extent(const coord_t *, pos_in_node_t from, pos_in_node_t count, -+ struct carry_kill_data *); -+int create_hook_extent(const coord_t * coord, void *arg); -+int cut_units_extent(coord_t * coord, pos_in_node_t from, pos_in_node_t to, -+ struct carry_cut_data *, reiser4_key * smallest_removed, -+ reiser4_key * new_first); -+int kill_units_extent(coord_t * coord, pos_in_node_t from, pos_in_node_t to, -+ struct carry_kill_data *, reiser4_key * smallest_removed, -+ reiser4_key * new_first); -+reiser4_key *unit_key_extent(const coord_t *, reiser4_key *); -+reiser4_key *max_unit_key_extent(const coord_t *, reiser4_key *); -+void print_extent(const char *, coord_t *); -+int utmost_child_extent(const coord_t * coord, sideof side, jnode ** child); -+int utmost_child_real_block_extent(const coord_t * coord, sideof side, -+ reiser4_block_nr * block); -+void item_stat_extent(const coord_t * coord, void *vp); -+int reiser4_check_extent(const coord_t * coord, const char **error); -+ -+/* plugin->u.item.s.file.* */ -+ssize_t reiser4_write_extent(struct file *, const char __user *, -+ size_t, loff_t *); -+int reiser4_read_extent(struct file *, flow_t *, hint_t *); -+int reiser4_readpage_extent(void *, struct page *); -+int reiser4_do_readpage_extent(reiser4_extent*, reiser4_block_nr, struct page*); -+reiser4_key *append_key_extent(const coord_t *, reiser4_key *); -+void init_coord_extension_extent(uf_coord_t *, loff_t offset); -+int get_block_address_extent(const coord_t *, sector_t block, -+ sector_t * result); -+ -+/* these are used in flush.c -+ FIXME-VS: should they be somewhere in item_plugin? */ -+int allocate_extent_item_in_place(coord_t *, lock_handle *, flush_pos_t * pos); -+int allocate_and_copy_extent(znode * left, coord_t * right, flush_pos_t * pos, -+ reiser4_key * stop_key); -+ -+int extent_is_unallocated(const coord_t * item); /* True if this extent is unallocated (i.e., not a hole, not allocated). */ -+__u64 extent_unit_index(const coord_t * item); /* Block offset of this unit. */ -+__u64 extent_unit_width(const coord_t * item); /* Number of blocks in this unit. */ -+ -+/* plugin->u.item.f. */ -+int reiser4_scan_extent(flush_scan * scan); -+extern int key_by_offset_extent(struct inode *, loff_t, reiser4_key *); -+ -+reiser4_item_data *init_new_extent(reiser4_item_data * data, void *ext_unit, -+ int nr_extents); -+reiser4_block_nr reiser4_extent_size(const coord_t * coord, pos_in_node_t nr); -+extent_state state_of_extent(reiser4_extent * ext); -+void reiser4_set_extent(reiser4_extent *, reiser4_block_nr start, -+ reiser4_block_nr width); -+int reiser4_update_extent(struct inode *, jnode *, loff_t pos, -+ int *plugged_hole); -+ -+#include "../../coord.h" -+#include "../../lock.h" -+#include "../../tap.h" -+ -+struct replace_handle { -+ /* these are to be set before calling reiser4_replace_extent */ -+ coord_t *coord; -+ lock_handle *lh; -+ reiser4_key key; -+ reiser4_key *pkey; -+ reiser4_extent overwrite; -+ reiser4_extent new_extents[2]; -+ int nr_new_extents; -+ unsigned flags; -+ -+ /* these are used by reiser4_replace_extent */ -+ reiser4_item_data item; -+ coord_t coord_after; -+ lock_handle lh_after; -+ tap_t watch; -+ reiser4_key paste_key; -+#if REISER4_DEBUG -+ reiser4_extent orig_ext; -+ reiser4_key tmp; -+#endif -+}; -+ -+/* this structure is kmalloced before calling make_extent to avoid excessive -+ stack consumption on plug_hole->reiser4_replace_extent */ -+struct make_extent_handle { -+ uf_coord_t *uf_coord; -+ reiser4_block_nr blocknr; -+ int created; -+ struct inode *inode; -+ union { -+ struct { -+ } append; -+ struct replace_handle replace; -+ } u; -+}; -+ -+int reiser4_replace_extent(struct replace_handle *, -+ int return_inserted_position); -+lock_handle *znode_lh(znode *); -+ -+/* the reiser4 repacker support */ -+struct repacker_cursor; -+extern int process_extent_backward_for_repacking(tap_t *, -+ struct repacker_cursor *); -+extern int mark_extent_for_repacking(tap_t *, int); -+ -+#define coord_by_uf_coord(uf_coord) (&((uf_coord)->coord)) -+#define ext_coord_by_uf_coord(uf_coord) (&((uf_coord)->extension.extent)) -+ -+/* __REISER4_EXTENT_H__ */ -+#endif -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.22/fs/reiser4/plugin/item/extent_item_ops.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/extent_item_ops.c 2007-07-29 00:25:34.968720289 +0400 -@@ -0,0 +1,889 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/extent_item_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/extent_item_ops.c +@@ -0,0 +1,882 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "item.h" @@ -49892,7 +50260,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 +reiser4_key *max_key_inside_extent(const coord_t * coord, reiser4_key * key) +{ + item_key_by_coord(coord, key); -+ set_key_offset(key, get_key_offset(reiser4_max_key())); ++ set_key_offset(key, get_key_offset(max_key())); + return key; +} + @@ -49936,8 +50304,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + get_key_ordering(&key1) != get_key_ordering(&key2) || + get_key_type(&key1) != get_key_type(&key2)) + return 0; -+ if (get_key_offset(&key1) + -+ reiser4_extent_size(p1, nr_units_extent(p1)) != ++ if (get_key_offset(&key1) + extent_size(p1, nr_units_extent(p1)) != + get_key_offset(&key2)) + return 0; + return 1; @@ -50328,7 +50695,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + ext = extent_item(coord) + from; + offset = + (get_key_offset(min_item_key) + -+ reiser4_extent_size(coord, from)) >> PAGE_CACHE_SHIFT; ++ extent_size(coord, from)) >> PAGE_CACHE_SHIFT; + + assert("vs-1551", from_off >= offset); + assert("vs-1552", from_off - offset <= extent_get_width(ext)); @@ -50452,12 +50819,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + if (result == ITEM_TAIL_KILLED) { + assert("vs-1553", + get_key_offset(pfrom_key) >= -+ get_key_offset(&item_key) + -+ reiser4_extent_size(coord, from)); ++ get_key_offset(&item_key) + extent_size(coord, from)); + off = -+ get_key_offset(pfrom_key) - -+ (get_key_offset(&item_key) + -+ reiser4_extent_size(coord, from)); ++ get_key_offset(pfrom_key) - (get_key_offset(&item_key) + ++ extent_size(coord, from)); + if (off) { + /* unit @from is to be cut partially. Its width decreases */ + ext = extent_item(coord) + from; @@ -50477,11 +50842,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + 1)) == 0); + assert("", + get_key_offset(pto_key) + 1 > -+ get_key_offset(&item_key) + -+ reiser4_extent_size(coord, to)); ++ get_key_offset(&item_key) + extent_size(coord, to)); + max_to_offset = -+ get_key_offset(&item_key) + -+ reiser4_extent_size(coord, to + 1) - 1; ++ get_key_offset(&item_key) + extent_size(coord, to + 1) - 1; + assert("", get_key_offset(pto_key) <= max_to_offset); + + rest = @@ -50594,10 +50957,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + + assert("vs-1553", + get_key_offset(pfrom_key) >= -+ get_key_offset(&item_key) + reiser4_extent_size(coord, from)); ++ get_key_offset(&item_key) + extent_size(coord, from)); + off = + get_key_offset(pfrom_key) - (get_key_offset(&item_key) + -+ reiser4_extent_size(coord, from)); ++ extent_size(coord, from)); + if (off) { + /* tail of unit @from is to be cut partially. Its width decreases */ + assert("vs-1582", new_first == NULL); @@ -50608,12 +50971,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + + assert("vs-1554", + get_key_offset(pto_key) <= -+ get_key_offset(&item_key) + -+ reiser4_extent_size(coord, to + 1) - 1); ++ get_key_offset(&item_key) + extent_size(coord, to + 1) - 1); + off = -+ (get_key_offset(&item_key) + -+ reiser4_extent_size(coord, to + 1) - 1) - -+ get_key_offset(pto_key); ++ (get_key_offset(&item_key) + extent_size(coord, to + 1) - 1) - ++ get_key_offset(pto_key); + if (off) { + /* @to_key is smaller than max key of unit @to. Unit @to will not be removed. It gets start increased + and width decreased. */ @@ -50639,7 +51000,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + item_key_by_coord(coord, key); + set_key_offset(key, + (get_key_offset(key) + -+ reiser4_extent_size(coord, coord->unit_pos))); ++ extent_size(coord, coord->unit_pos))); + + return key; +} @@ -50652,7 +51013,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + item_key_by_coord(coord, key); + set_key_offset(key, + (get_key_offset(key) + -+ reiser4_extent_size(coord, coord->unit_pos + 1) - 1)); ++ extent_size(coord, coord->unit_pos + 1) - 1)); + return key; +} + @@ -50666,8 +51027,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + possible check of the consistency of the item that the inventor can + construct +*/ -+int reiser4_check_extent(const coord_t * coord /* coord of item to check */, -+ const char **error /* where to store error message */) ++int check_extent(const coord_t * coord /* coord of item to check */ , ++ const char **error /* where to store error message */ ) +{ + reiser4_extent *ext, *first; + unsigned i, j; @@ -50767,10 +51128,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/extent_item_ops.c linux-2.6.2 + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/reiser4/plugin/item/internal.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/internal.c 2007-07-29 00:25:34.968720289 +0400 -@@ -0,0 +1,396 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/internal.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/internal.c +@@ -0,0 +1,392 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Implementation of internal-item plugin methods. */ @@ -50835,8 +51197,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + return (internal_item_layout *) item_body_by_coord(coord); +} + -+void reiser4_update_internal(const coord_t * coord, -+ const reiser4_block_nr * blocknr) ++void update_internal(const coord_t * coord, const reiser4_block_nr * blocknr) +{ + internal_item_layout *item = internal_at(coord); + assert("nikita-2959", reiser4_blocknr_is_sane(blocknr)); @@ -50888,7 +51249,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + *block = pointer_at(coord); + assert("nikita-2961", reiser4_blocknr_is_sane(block)); + -+ if (reiser4_blocknr_is_fake(block)) { ++ if (blocknr_is_fake(block)) { + *block = 0; + } + @@ -50917,8 +51278,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + return 0; +} + -+#if REISER4_DEBUG -+ +static void check_link(znode * left, znode * right) +{ + znode *scan; @@ -50984,8 +51343,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + return 0; +} + -+#endif /* REISER4_DEBUG */ -+ +/* return true only if this item really points to "block" */ +/* Audited by: green(2002.06.14) */ +int has_pointer_to_internal(const coord_t * coord /* coord of item */ , @@ -51024,7 +51381,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + * item to little endian byte order. + */ + child_ptr = get_unaligned((__u64 *)item_body_by_coord(item)); -+ reiser4_update_internal(item, &child_ptr); ++ update_internal(item, &child_ptr); + + child = znode_at(item, item->node); + if (child != NULL && !IS_ERR(child)) { @@ -51074,6 +51431,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + . when last reference to this node will be dropped, bitmap will be updated + and node will be actually removed from the memory. + ++ +*/ +int kill_hook_internal(const coord_t * item /* coord of item */ , + pos_in_node_t from UNUSED_ARG /* start unit */ , @@ -51167,9 +51525,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.c linux-2.6.22/fs/re + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.h linux-2.6.22/fs/reiser4/plugin/item/internal.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/internal.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/internal.h 2007-07-29 00:25:34.968720289 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/internal.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/internal.h @@ -0,0 +1,57 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* Internal item contains down-link to the child of the internal/twig @@ -51204,15 +51563,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.h linux-2.6.22/fs/re + pos_in_node_t count, struct carry_kill_data *); +extern int shift_hook_internal(const coord_t * item, unsigned from, + unsigned count, znode * old_node); -+extern void reiser4_print_internal(const char *prefix, coord_t * coord); ++extern void print_internal(const char *prefix, coord_t * coord); + +extern int utmost_child_internal(const coord_t * coord, sideof side, + jnode ** child); +int utmost_child_real_block_internal(const coord_t * coord, sideof side, + reiser4_block_nr * block); + -+extern void reiser4_update_internal(const coord_t * coord, -+ const reiser4_block_nr * blocknr); ++extern void update_internal(const coord_t * coord, ++ const reiser4_block_nr * blocknr); +/* FIXME: reiserfs has check_internal */ +extern int check__internal(const coord_t * coord, const char **error); + @@ -51228,10 +51587,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/internal.h linux-2.6.22/fs/re + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser4/plugin/item/item.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/item.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/item.c 2007-07-29 00:25:34.972721325 +0400 -@@ -0,0 +1,719 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/item.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/item.c +@@ -0,0 +1,727 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* definition of item plugins. */ @@ -51309,6 +51669,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + node_plugin_by_node(coord->node)->plugin_by_coord(coord)); +} + ++/* return type of item at @coord */ ++item_type_id item_type_by_coord(const coord_t * coord /* coord to query */ ) ++{ ++ assert("nikita-333", coord != NULL); ++ assert("nikita-334", coord->node != NULL); ++ assert("nikita-335", znode_is_loaded(coord->node)); ++ assert("nikita-336", item_plugin_by_coord(coord) != NULL); ++ ++ return item_plugin_by_coord(coord)->b.item_type; ++} ++ +/* return id of item */ +/* Audited by: green(2002.06.15) */ +item_id item_id_by_coord(const coord_t * coord /* coord to query */ ) @@ -51397,7 +51768,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser +} + +/* ->nr_units() method for items consisting of exactly one unit always */ -+pos_in_node_t ++static pos_in_node_t +nr_units_single_unit(const coord_t * coord UNUSED_ARG /* coord of item */ ) +{ + return 1; @@ -51505,12 +51876,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + return item_id_by_coord(item) == FORMATTING_ID; +} + -+#if REISER4_DEBUG -+ +int item_is_statdata(const coord_t * item) +{ + assert("vs-516", coord_is_existing_item(item)); -+ return plugin_of_group(item_plugin_by_coord(item), STAT_DATA_ITEM_TYPE); ++ return item_type_by_coord(item) == STAT_DATA_ITEM_TYPE; +} + +int item_is_ctail(const coord_t * item) @@ -51519,11 +51888,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + return item_id_by_coord(item) == CTAIL_ID; +} + -+#endif /* REISER4_DEBUG */ -+ -+static int change_item(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_item(struct inode *inode, reiser4_plugin * plugin) +{ + /* cannot change constituent item (sd, or dir_item) */ + return RETERR(-EINVAL); @@ -51542,13 +51907,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = STATIC_STAT_DATA_ID, -+ .groups = (1 << STAT_DATA_ITEM_TYPE), + .pops = &item_plugin_ops, + .label = "sd", + .desc = "stat-data", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = STAT_DATA_ITEM_TYPE, + .max_key_inside = max_key_inside_single_key, + .can_contain_key = NULL, + .mergeable = not_mergeable, @@ -51591,13 +51956,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = SIMPLE_DIR_ENTRY_ID, -+ .groups = (1 << DIR_ENTRY_ITEM_TYPE), + .pops = &item_plugin_ops, + .label = "de", + .desc = "directory entry", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = DIR_ENTRY_ITEM_TYPE, + .max_key_inside = max_key_inside_single_key, + .can_contain_key = NULL, + .mergeable = NULL, @@ -51644,13 +52009,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = COMPOUND_DIR_ID, -+ .groups = (1 << DIR_ENTRY_ITEM_TYPE), + .pops = &item_plugin_ops, + .label = "cde", + .desc = "compressed directory entry", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = DIR_ENTRY_ITEM_TYPE, + .max_key_inside = max_key_inside_cde, + .can_contain_key = can_contain_key_cde, + .mergeable = mergeable_cde, @@ -51671,7 +52036,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .estimate = estimate_cde, + .item_data_by_flow = NULL, +#if REISER4_DEBUG -+ .check = reiser4_check_cde ++ .check = check_cde +#endif + }, + .f = { @@ -51697,13 +52062,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = NODE_POINTER_ID, -+ .groups = (1 << INTERNAL_ITEM_TYPE), + .pops = NULL, + .label = "internal", + .desc = "internal item", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = INTERNAL_ITEM_TYPE, + .max_key_inside = NULL, + .can_contain_key = NULL, + .mergeable = mergeable_internal, @@ -51731,7 +52096,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .utmost_child = utmost_child_internal, + .utmost_child_real_block = + utmost_child_real_block_internal, -+ .update = reiser4_update_internal, ++ .update = update_internal, + .scan = NULL, + .convert = NULL + }, @@ -51746,13 +52111,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = EXTENT_POINTER_ID, -+ .groups = (1 << UNIX_FILE_METADATA_ITEM_TYPE), + .pops = NULL, + .label = "extent", + .desc = "extent item", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = UNIX_FILE_METADATA_ITEM_TYPE, + .max_key_inside = max_key_inside_extent, + .can_contain_key = can_contain_key_extent, + .mergeable = mergeable_extent, @@ -51773,7 +52138,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .estimate = NULL, + .item_data_by_flow = NULL, +#if REISER4_DEBUG -+ .check = reiser4_check_extent ++ .check = check_extent +#endif + }, + .f = { @@ -51781,16 +52146,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .utmost_child_real_block = + utmost_child_real_block_extent, + .update = NULL, -+ .scan = reiser4_scan_extent, ++ .scan = scan_extent, + .convert = NULL, + .key_by_offset = key_by_offset_extent + }, + .s = { + .file = { -+ .write = reiser4_write_extent, -+ .read = reiser4_read_extent, -+ .readpage = reiser4_readpage_extent, ++ .write = write_extent, ++ .read = read_extent, ++ .readpage = readpage_extent, + .get_block = get_block_address_extent, ++ .readpages = readpages_extent, + .append_key = append_key_extent, + .init_coord_extension = + init_coord_extension_extent @@ -51801,13 +52167,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = FORMATTING_ID, -+ .groups = (1 << UNIX_FILE_METADATA_ITEM_TYPE), + .pops = NULL, + .label = "body", + .desc = "body (or tail?) item", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = UNIX_FILE_METADATA_ITEM_TYPE, + .max_key_inside = max_key_inside_tail, + .can_contain_key = can_contain_key_tail, + .mergeable = mergeable_tail, @@ -51840,10 +52206,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + }, + .s = { + .file = { -+ .write = reiser4_write_tail, -+ .read = reiser4_read_tail, ++ .write = write_tail, ++ .read = read_tail, + .readpage = readpage_tail, -+ .get_block = get_block_address_tail, ++ .get_block = NULL, ++ .readpages = NULL, + .append_key = append_key_tail, + .init_coord_extension = + init_coord_extension_tail @@ -51854,13 +52221,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = CTAIL_ID, -+ .groups = (1 << UNIX_FILE_METADATA_ITEM_TYPE), + .pops = NULL, + .label = "ctail", + .desc = "cryptcompress tail item", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = UNIX_FILE_METADATA_ITEM_TYPE, + .max_key_inside = max_key_inside_tail, + .can_contain_key = can_contain_key_ctail, + .mergeable = mergeable_ctail, @@ -51898,6 +52265,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .read = read_ctail, + .readpage = readpage_ctail, + .get_block = get_block_address_tail, ++ .readpages = readpages_ctail, + .append_key = append_key_ctail, + .init_coord_extension = + init_coord_extension_tail @@ -51908,13 +52276,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + .h = { + .type_id = REISER4_ITEM_PLUGIN_TYPE, + .id = BLACK_BOX_ID, -+ .groups = (1 << OTHER_ITEM_TYPE), + .pops = NULL, + .label = "blackbox", + .desc = "black box item", + .linkage = {NULL, NULL} + }, + .b = { ++ .item_type = OTHER_ITEM_TYPE, + .max_key_inside = NULL, + .can_contain_key = NULL, + .mergeable = not_mergeable, @@ -51951,10 +52319,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.c linux-2.6.22/fs/reiser + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser4/plugin/item/item.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/item.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/item.h 2007-07-29 00:25:34.972721325 +0400 -@@ -0,0 +1,397 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/item.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/item.h +@@ -0,0 +1,399 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* first read balance.c comments before reading this */ @@ -51991,7 +52360,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser +/* this is the part of each item plugin that all items are expected to + support or at least explicitly fail to support by setting the + pointer to null. */ -+struct balance_ops { ++typedef struct { ++ item_type_id item_type; ++ + /* operations called by balancing + + It is interesting to consider that some of these item @@ -52011,7 +52382,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + For items that occupy exactly one key (like stat-data) + this method should return this key. For items that can + grow indefinitely (extent, directory item) this should -+ return reiser4_max_key(). ++ return max_key(). + + For example extent with the key + @@ -52031,12 +52402,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + */ + int (*mergeable) (const coord_t *, const coord_t *); + -+ /* number of atomic things in an item. -+ NOTE FOR CONTRIBUTORS: use a generic method -+ nr_units_single_unit() for solid (atomic) items, as -+ tree operations use it as a criterion of solidness -+ (see is_solid_item macro) */ -+ pos_in_node_t(*nr_units) (const coord_t *); ++ /* number of atomic things in an item */ ++ pos_in_node_t(*nr_units) (const coord_t *); + + /* search within item for a unit within the item, and return a + pointer to it. This can be used to calculate how many @@ -52050,8 +52417,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + item */ + int (*init) (coord_t * target, coord_t * from, + reiser4_item_data * data); -+ /* method called (e.g., by reiser4_resize_item()) to place new data -+ into item when it grows */ ++ /* method called (e.g., by resize_item()) to place new data into ++ item when it grows */ + int (*paste) (coord_t *, reiser4_item_data *, carry_plugin_info *); + /* return true if paste into @coord is allowed to skip + carry. That is, if such paste would require any changes @@ -52146,9 +52513,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + int (*check) (const coord_t *, const char **error); +#endif + -+}; ++} balance_ops; + -+struct flush_ops { ++typedef struct { + /* return the right or left child of @coord, only if it is in memory */ + int (*utmost_child) (const coord_t *, sideof side, jnode ** child); + @@ -52164,10 +52531,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + int (*convert) (flush_pos_t * pos); + /* backward mapping from jnode offset to a key. */ + int (*key_by_offset) (struct inode *, loff_t, reiser4_key *); -+}; ++} flush_ops; + +/* operations specific to the directory item */ -+struct dir_entry_iops { ++typedef struct { + /* extract stat-data key from directory entry at @coord and place it + into @key. */ + int (*extract_key) (const coord_t *, reiser4_key * key); @@ -52186,14 +52553,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + coord_t *, lock_handle *, + reiser4_dir_entry_desc * entry); + int (*max_name_len) (const struct inode * dir); -+}; ++} dir_entry_ops; + +/* operations specific to items regular (unix) file metadata are built of */ -+struct file_iops{ ++typedef struct { + int (*write) (struct file *, const char __user *, size_t, loff_t *pos); + int (*read) (struct file *, flow_t *, hint_t *); + int (*readpage) (void *, struct page *); + int (*get_block) (const coord_t *, sector_t, sector_t *); ++ void (*readpages) (void *, struct address_space *, ++ struct list_head * pages); + /* + * key of first byte which is not addressed by the item @coord is set + * to. @@ -52208,17 +52577,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + reiser4_key *(*append_key) (const coord_t *, reiser4_key *); + + void (*init_coord_extension) (uf_coord_t *, loff_t); -+}; ++} file_ops; + +/* operations specific to items of stat data type */ -+struct sd_iops { ++typedef struct { + int (*init_inode) (struct inode * inode, char *sd, int len); + int (*save_len) (struct inode * inode); + int (*save) (struct inode * inode, char **area); -+}; ++} sd_ops; + +/* operations specific to internal item */ -+struct internal_iops{ ++typedef struct { + /* all tree traversal want to know from internal item is where + to go next. */ + void (*down_link) (const coord_t * coord, @@ -52226,25 +52595,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + /* check that given internal item contains given pointer. */ + int (*has_pointer_to) (const coord_t * coord, + const reiser4_block_nr * block); -+}; ++} internal_item_ops; + +struct item_plugin { + /* generic fields */ + plugin_header h; ++ + /* methods common for all item types */ -+ struct balance_ops b; /* balance operations */ -+ struct flush_ops f; /* flush operates with items via this methods */ ++ balance_ops b; ++ /* methods used during flush */ ++ flush_ops f; + + /* methods specific to particular type of item */ + union { -+ struct dir_entry_iops dir; -+ struct file_iops file; -+ struct sd_iops sd; -+ struct internal_iops internal; ++ dir_entry_ops dir; ++ file_ops file; ++ sd_ops sd; ++ internal_item_ops internal; + } s; -+}; + -+#define is_solid_item(iplug) ((iplug)->b.nr_units == nr_units_single_unit) ++}; + +static inline item_id item_id_by_plugin(item_plugin * plugin) +{ @@ -52286,13 +52656,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser +extern int item_is_ctail(const coord_t *); + +extern pos_in_node_t item_length_by_coord(const coord_t * coord); -+extern pos_in_node_t nr_units_single_unit(const coord_t * coord); ++extern item_type_id item_type_by_coord(const coord_t * coord); +extern item_id item_id_by_coord(const coord_t * coord /* coord to query */ ); +extern reiser4_key *item_key_by_coord(const coord_t * coord, reiser4_key * key); +extern reiser4_key *max_item_key_by_coord(const coord_t *, reiser4_key *); +extern reiser4_key *unit_key_by_coord(const coord_t * coord, reiser4_key * key); +extern reiser4_key *max_unit_key_by_coord(const coord_t * coord, + reiser4_key * key); ++ +extern void obtain_item_plugin(const coord_t * coord); + +#if defined(REISER4_DEBUG) @@ -52316,7 +52687,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser +static inline int item_is_internal(const coord_t * item) +{ + assert("vs-483", coord_is_existing_item(item)); -+ return plugin_of_group(item_plugin_by_coord(item), INTERNAL_ITEM_TYPE); ++ return item_type_by_coord(item) == INTERNAL_ITEM_TYPE; +} + +extern void item_body_by_coord_hard(coord_t * coord); @@ -52352,31 +52723,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/item.h linux-2.6.22/fs/reiser + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/Makefile linux-2.6.22/fs/reiser4/plugin/item/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/item/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/Makefile 2007-07-29 00:25:34.972721325 +0400 -@@ -0,0 +1,18 @@ -+obj-$(CONFIG_REISER4_FS) += item_plugins.o -+ -+item_plugins-objs := \ -+ item.o \ -+ static_stat.o \ -+ sde.o \ -+ cde.o \ -+ blackbox.o \ -+ internal.o \ -+ tail.o \ -+ ctail.o \ -+ extent.o \ -+ extent_item_ops.o \ -+ extent_file_ops.o \ -+ extent_flush_ops.o -+ -+ -+ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/sde.c linux-2.6.22/fs/reiser4/plugin/item/sde.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/sde.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/sde.c 2007-07-29 00:25:34.972721325 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/sde.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/sde.c @@ -0,0 +1,190 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -52555,8 +52905,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/sde.c linux-2.6.22/fs/reiser4 + +int max_name_len_de(const struct inode *dir) +{ -+ return reiser4_tree_by_inode(dir)->nplug->max_item_size() - -+ sizeof(directory_entry_format) - 2; ++ return tree_by_inode(dir)->nplug->max_item_size() - ++ sizeof(directory_entry_format) - 2; +} + +/* Make Linus happy. @@ -52568,9 +52918,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/sde.c linux-2.6.22/fs/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/sde.h linux-2.6.22/fs/reiser4/plugin/item/sde.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/sde.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/sde.h 2007-07-29 00:25:34.976722360 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/sde.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/sde.h @@ -0,0 +1,66 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -52638,10 +52989,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/sde.h linux-2.6.22/fs/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs/reiser4/plugin/item/static_stat.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/static_stat.c 2007-07-29 00:25:34.976722360 +0400 -@@ -0,0 +1,1107 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/static_stat.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/static_stat.c +@@ -0,0 +1,1040 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* stat data manipulation. */ @@ -52729,7 +53081,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + state = reiser4_inode_data(inode); + mask = le16_to_cpu(get_unaligned(&sd_base->extmask)); + bigmask = mask; -+ reiser4_inode_set_flag(inode, REISER4_SDLEN_KNOWN); ++ inode_set_flag(inode, REISER4_SDLEN_KNOWN); + + move_on(&len, &sd, sizeof *sd_base); + for (bit = 0, chunk = 0; @@ -52813,6 +53165,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + } + state->extmask = bigmask; + /* common initialisations */ ++ inode->i_blksize = get_super_private(inode->i_sb)->optimal_io_size; + if (len - (bit / 16 * sizeof(d16)) > 0) { + /* alignment in save_len_static_sd() is taken into account + -edward */ @@ -52918,7 +53271,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + if ((inode->i_mode & S_IFMT) == (S_IFREG | S_IFIFO)) { + inode->i_mode &= ~S_IFIFO; + warning("", "partially converted file is encountered"); -+ reiser4_inode_set_flag(inode, REISER4_PART_MIXED); ++ inode_set_flag(inode, REISER4_PART_MIXED); + } + move_on(len, area, sizeof *sd_lw); + return 0; @@ -52944,8 +53297,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + + sd = (reiser4_light_weight_stat *) * area; + -+ delta = (reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED) ? S_IFIFO : 0); ++ delta = (inode_get_flag(inode, REISER4_PART_MIXED) ? S_IFIFO : 0); + put_unaligned(cpu_to_le16(inode->i_mode | delta), &sd->mode); + put_unaligned(cpu_to_le32(inode->i_nlink), &sd->nlink); + put_unaligned(cpu_to_le64((__u64) inode->i_size), &sd->size); @@ -52989,9 +53341,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + inode->i_gid = get_super_private(inode->i_sb)->default_gid; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode_set_bytes(inode, inode->i_size); -+ /* mark inode as lightweight, so that caller (lookup_common) will ++ /* mark inode as lightweight, so that caller (reiser4_lookup) will + complete initialisation by copying [ug]id from a parent. */ -+ reiser4_inode_set_flag(inode, REISER4_LIGHT_WEIGHT); ++ inode_set_flag(inode, REISER4_LIGHT_WEIGHT); + return 0; +} + @@ -53074,23 +53426,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + +/* symlink stat data extension */ + -+/* allocate memory for symlink target and attach it to inode->i_private */ ++/* allocate memory for symlink target and attach it to inode->u.generic_ip */ +static int +symlink_target_to_inode(struct inode *inode, const char *target, int len) +{ -+ assert("vs-845", inode->i_private == NULL); -+ assert("vs-846", !reiser4_inode_get_flag(inode, -+ REISER4_GENERIC_PTR_USED)); ++ assert("vs-845", inode->u.generic_ip == NULL); ++ assert("vs-846", !inode_get_flag(inode, REISER4_GENERIC_PTR_USED)); ++ + /* FIXME-VS: this is prone to deadlock. Not more than other similar + places, though */ -+ inode->i_private = kmalloc((size_t) len + 1, -+ reiser4_ctx_gfp_mask_get()); -+ if (!inode->i_private) ++ inode->u.generic_ip = kmalloc((size_t) len + 1, get_gfp_mask()); ++ if (!inode->u.generic_ip) + return RETERR(-ENOMEM); + -+ memcpy((char *)(inode->i_private), target, (size_t) len); -+ ((char *)(inode->i_private))[len] = 0; -+ reiser4_inode_set_flag(inode, REISER4_GENERIC_PTR_USED); ++ memcpy((char *)(inode->u.generic_ip), target, (size_t) len); ++ ((char *)(inode->u.generic_ip))[len] = 0; ++ inode_set_flag(inode, REISER4_GENERIC_PTR_USED); + return 0; +} + @@ -53141,11 +53492,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + + result = 0; + sd = (reiser4_symlink_stat *) * area; -+ if (!reiser4_inode_get_flag(inode, REISER4_GENERIC_PTR_USED)) { ++ if (!inode_get_flag(inode, REISER4_GENERIC_PTR_USED)) { + const char *target; + -+ target = (const char *)(inode->i_private); -+ inode->i_private = NULL; ++ target = (const char *)(inode->u.generic_ip); ++ inode->u.generic_ip = NULL; + + result = symlink_target_to_inode(inode, target, length); + @@ -53155,7 +53506,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + } else { + /* there is nothing to do in update but move area */ + assert("vs-844", -+ !memcmp(inode->i_private, sd->body, ++ !memcmp(inode->u.generic_ip, sd->body, + (size_t) length + 1)); + } + @@ -53209,12 +53560,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs +static int absent_plugin_sd(struct inode *inode); +static int present_plugin_sd(struct inode *inode /* object being processed */ , + char **area /* position in stat-data */ , -+ int *len /* remaining length */, -+ int is_pset /* 1 if plugin set, 0 if heir set. */) ++ int *len /* remaining length */ ) +{ + reiser4_plugin_stat *sd; + reiser4_plugin *plugin; -+ reiser4_inode *info; + int i; + __u16 mask; + int result; @@ -53230,7 +53579,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + return not_enough_space(inode, "plugin"); + + sd = (reiser4_plugin_stat *) * area; -+ info = reiser4_inode_data(inode); + + mask = 0; + num_of_plugins = le16_to_cpu(get_unaligned(&sd->plugins_no)); @@ -53246,16 +53594,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + return not_enough_space(inode, "additional plugin"); + + memb = le16_to_cpu(get_unaligned(&slot->pset_memb)); -+ type = aset_member_to_type_unsafe(memb); -+ ++ type = pset_member_to_type_unsafe(memb); + if (type == REISER4_PLUGIN_TYPES) { + warning("nikita-3502", -+ "wrong %s member (%i) for %llu", is_pset ? -+ "pset" : "hset", memb, ++ "wrong pset member (%i) for %llu", memb, + (unsigned long long)get_inode_oid(inode)); + return RETERR(-EINVAL); + } -+ plugin = plugin_by_disk_id(reiser4_tree_by_inode(inode), ++ plugin = plugin_by_disk_id(tree_by_inode(inode), + type, &slot->id); + if (plugin == NULL) + return unknown_plugin(le16_to_cpu(get_unaligned(&slot->id)), inode); @@ -53271,31 +53617,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + } + move_on(len, area, sizeof *slot); + /* load plugin data, if any */ -+ if (plugin->h.pops != NULL && plugin->h.pops->load) ++ if (plugin->h.pops != NULL && plugin->h.pops->load) { + result = plugin->h.pops->load(inode, plugin, area, len); -+ else -+ result = aset_set_unsafe(is_pset ? &info->pset : -+ &info->hset, memb, plugin); -+ if (result) -+ return result; ++ if (result != 0) ++ return result; ++ } else ++ result = grab_plugin_from(inode, memb, plugin); + } -+ if (is_pset) { -+ /* if object plugin wasn't loaded from stat-data, guess it by -+ mode bits */ -+ plugin = file_plugin_to_plugin(inode_file_plugin(inode)); -+ if (plugin == NULL) -+ result = absent_plugin_sd(inode); -+ info->plugin_mask = mask; -+ } else -+ info->heir_mask = mask; ++ /* if object plugin wasn't loaded from stat-data, guess it by ++ mode bits */ ++ plugin = file_plugin_to_plugin(inode_file_plugin(inode)); ++ if (plugin == NULL) ++ result = absent_plugin_sd(inode); + ++ reiser4_inode_data(inode)->plugin_mask = mask; + return result; +} + -+static int present_pset_sd(struct inode *inode, char **area, int *len) { -+ return present_plugin_sd(inode, area, len, 1 /* pset */); -+} -+ +/* Determine object plugin for @inode based on i_mode. + + Many objects in reiser4 file system are controlled by standard object @@ -53338,10 +53676,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + break; + } + info = reiser4_inode_data(inode); -+ set_plugin(&info->pset, PSET_FILE, (fplug_id >= 0) ? -+ plugin_by_id(REISER4_FILE_PLUGIN_TYPE, fplug_id) : NULL); -+ set_plugin(&info->pset, PSET_DIR, (dplug_id >= 0) ? -+ plugin_by_id(REISER4_DIR_PLUGIN_TYPE, dplug_id) : NULL); ++ plugin_set_file(&info->pset, ++ (fplug_id >= 0) ? file_plugin_by_id(fplug_id) : NULL); ++ plugin_set_dir(&info->pset, ++ (dplug_id >= 0) ? dir_plugin_by_id(dplug_id) : NULL); + return 0; +} + @@ -53366,19 +53704,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs +/* Audited by: green(2002.06.14) */ +static int len_for(reiser4_plugin * plugin /* plugin to save */ , + struct inode *inode /* object being processed */ , -+ pset_member memb, -+ int len, int is_pset) ++ pset_member memb, int len) +{ + reiser4_inode *info; + assert("nikita-661", inode != NULL); + -+ if (plugin == NULL) -+ return len; -+ + info = reiser4_inode_data(inode); -+ if (is_pset ? -+ info->plugin_mask & (1 << memb) : -+ info->heir_mask & (1 << memb)) { ++ if (plugin != NULL && (info->plugin_mask & (1 << memb))) { + len += sizeof(reiser4_plugin_slot); + if (plugin->h.pops && plugin->h.pops->save_len != NULL) { + /* non-standard plugin, call method */ @@ -53393,44 +53725,33 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + +/* calculate how much space is required to save state of all plugins, + associated with inode */ -+static int save_len_plugin_sd(struct inode *inode /* object being processed */, -+ int is_pset) ++static int save_len_plugin_sd(struct inode *inode /* object being processed */ ) +{ + int len; -+ int last; + reiser4_inode *state; + pset_member memb; + + assert("nikita-663", inode != NULL); + + state = reiser4_inode_data(inode); -+ + /* common case: no non-standard plugins */ -+ if (is_pset ? state->plugin_mask == 0 : state->heir_mask == 0) ++ if (state->plugin_mask == 0) + return 0; + len = sizeof(reiser4_plugin_stat); -+ last = PSET_LAST; -+ -+ for (memb = 0; memb < last; ++memb) { -+ len = len_for(aset_get(is_pset ? state->pset : state->hset, memb), -+ inode, memb, len, is_pset); -+ } ++ for (memb = 0; memb < PSET_LAST; ++memb) ++ len = len_for(pset_get(state->pset, memb), inode, memb, len); + assert("nikita-664", len > (int)sizeof(reiser4_plugin_stat)); + return len; +} + -+static int save_len_pset_sd(struct inode *inode) { -+ return save_len_plugin_sd(inode, 1 /* pset */); -+} -+ +/* helper function for plugin_sd_save(): save plugin, associated with + inode. */ +static int save_plug(reiser4_plugin * plugin /* plugin to save */ , + struct inode *inode /* object being processed */ , -+ int memb /* what element of pset is saved */ , ++ pset_member memb /* what element of pset is saved */ , + char **area /* position in stat-data */ , -+ int *count /* incremented if plugin were actually saved. */, -+ int is_pset /* 1 for plugin set, 0 for heir set */) ++ int *count /* incremented if plugin were actually ++ * saved. */ ) +{ + reiser4_plugin_slot *slot; + int fake_len; @@ -53442,10 +53763,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + + if (plugin == NULL) + return 0; -+ -+ if (is_pset ? -+ !(reiser4_inode_data(inode)->plugin_mask & (1 << memb)) : -+ !(reiser4_inode_data(inode)->heir_mask & (1 << memb))) ++ if (!(reiser4_inode_data(inode)->plugin_mask & (1 << memb))) + return 0; + slot = (reiser4_plugin_slot *) * area; + put_unaligned(cpu_to_le16(memb), &slot->pset_memb); @@ -53463,14 +53781,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + +/* save state of all non-standard plugins associated with inode */ +static int save_plugin_sd(struct inode *inode /* object being processed */ , -+ char **area /* position in stat-data */, -+ int is_pset /* 1 for pset, 0 for hset */) ++ char **area /* position in stat-data */ ) +{ -+ int fake_len; + int result = 0; + int num_of_plugins; + reiser4_plugin_stat *sd; + reiser4_inode *state; ++ int fake_len; + pset_member memb; + + assert("nikita-669", inode != NULL); @@ -53478,7 +53795,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + assert("nikita-671", *area != NULL); + + state = reiser4_inode_data(inode); -+ if (is_pset ? state->plugin_mask == 0 : state->heir_mask == 0) ++ if (state->plugin_mask == 0) + return 0; + sd = (reiser4_plugin_stat *) * area; + fake_len = (int)0xffff; @@ -53486,9 +53803,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + + num_of_plugins = 0; + for (memb = 0; memb < PSET_LAST; ++memb) { -+ result = save_plug(aset_get(is_pset ? state->pset : state->hset, -+ memb), -+ inode, memb, area, &num_of_plugins, is_pset); ++ result = save_plug(pset_get(state->pset, memb), ++ inode, memb, area, &num_of_plugins); + if (result != 0) + break; + } @@ -53497,39 +53813,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + return result; +} + -+static int save_pset_sd(struct inode *inode, char **area) { -+ return save_plugin_sd(inode, area, 1 /* pset */); -+} -+ -+static int present_hset_sd(struct inode *inode, char **area, int *len) { -+ return present_plugin_sd(inode, area, len, 0 /* hset */); -+} -+ -+static int save_len_hset_sd(struct inode *inode) { -+ return save_len_plugin_sd(inode, 0 /* pset */); -+} -+ -+static int save_hset_sd(struct inode *inode, char **area) { -+ return save_plugin_sd(inode, area, 0 /* hset */); -+} -+ +/* helper function for crypto_sd_present(), crypto_sd_save. -+ Extract crypto info from stat-data and attach it to inode */ -+static int extract_crypto_info (struct inode * inode, ++ Allocates memory for crypto stat, keyid and attaches it to the inode */ ++static int extract_crypto_stat (struct inode * inode, + reiser4_crypto_stat * sd) +{ -+ struct reiser4_crypto_info * info; -+ assert("edward-11", !inode_crypto_info(inode)); ++ crypto_stat_t * info; ++ assert("edward-11", !inode_crypto_stat(inode)); + assert("edward-1413", -+ !reiser4_inode_get_flag(inode, REISER4_CRYPTO_STAT_LOADED)); ++ !inode_get_flag(inode, REISER4_CRYPTO_STAT_LOADED)); + /* create and attach a crypto-stat without secret key loaded */ -+ info = reiser4_alloc_crypto_info(inode); ++ info = alloc_crypto_stat(inode); + if (IS_ERR(info)) + return PTR_ERR(info); + info->keysize = le16_to_cpu(get_unaligned(&sd->keysize)); + memcpy(info->keyid, sd->keyid, inode_digest_plugin(inode)->fipsize); -+ reiser4_attach_crypto_info(inode, info); -+ reiser4_inode_set_flag(inode, REISER4_CRYPTO_STAT_LOADED); ++ attach_crypto_stat(inode, info); ++ inode_set_flag(inode, REISER4_CRYPTO_STAT_LOADED); + return 0; +} + @@ -53556,7 +53856,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + assert("edward-75", sizeof(*sd) + dplug->fipsize <= *len); + + sd = (reiser4_crypto_stat *) * area; -+ result = extract_crypto_info(inode, sd); ++ result = extract_crypto_stat(inode, sd); + move_on(len, area, sizeof(*sd) + dplug->fipsize); + + return result; @@ -53572,7 +53872,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs +{ + int result = 0; + reiser4_crypto_stat *sd; -+ struct reiser4_crypto_info * info = inode_crypto_info(inode); ++ crypto_stat_t * info = inode_crypto_stat(inode); + digest_plugin *dplug = inode_digest_plugin(inode); + + assert("edward-12", dplug != NULL); @@ -53583,13 +53883,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + assert("edward-1415", info->keysize != 0); + assert("edward-76", reiser4_inode_data(inode) != NULL); + -+ if (!reiser4_inode_get_flag(inode, REISER4_CRYPTO_STAT_LOADED)) { ++ if (!inode_get_flag(inode, REISER4_CRYPTO_STAT_LOADED)) { + /* file is just created */ + sd = (reiser4_crypto_stat *) *area; + /* copy everything but private key to the disk stat-data */ + put_unaligned(cpu_to_le16(info->keysize), &sd->keysize); + memcpy(sd->keyid, info->keyid, (size_t) dplug->fipsize); -+ reiser4_inode_set_flag(inode, REISER4_CRYPTO_STAT_LOADED); ++ inode_set_flag(inode, REISER4_CRYPTO_STAT_LOADED); + } + *area += (sizeof(*sd) + dplug->fipsize); + return result; @@ -53672,25 +53972,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + .desc = "plugin stat-data fields", + .linkage = {NULL,NULL} + }, -+ .present = present_pset_sd, ++ .present = present_plugin_sd, + .absent = absent_plugin_sd, -+ .save_len = save_len_pset_sd, -+ .save = save_pset_sd, -+ .alignment = 8 -+ }, -+ [HEIR_STAT] = { -+ .h = { -+ .type_id = REISER4_SD_EXT_PLUGIN_TYPE, -+ .id = HEIR_STAT, -+ .pops = NULL, -+ .label = "heir-plugin-sd", -+ .desc = "heir plugin stat-data fields", -+ .linkage = {NULL,NULL} -+ }, -+ .present = present_hset_sd, -+ .absent = NULL, -+ .save_len = save_len_hset_sd, -+ .save = save_hset_sd, ++ .save_len = save_len_plugin_sd, ++ .save = save_plugin_sd, + .alignment = 8 + }, + [FLAGS_STAT] = { @@ -53749,10 +54034,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.c linux-2.6.22/fs + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs/reiser4/plugin/item/static_stat.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/static_stat.h 2007-07-29 00:25:34.976722360 +0400 -@@ -0,0 +1,224 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/static_stat.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/static_stat.h +@@ -0,0 +1,219 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* This describes the static_stat item, used to hold all information needed by the stat() syscall. @@ -53823,9 +54109,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs + LARGE_TIMES_STAT, + /* stat data has link name included */ + SYMLINK_STAT, -+ /* on-disk slots of non-standard plugins for main plugin table -+ (@reiser4_inode->pset), that is, plugins that cannot be deduced -+ from file mode bits), for example, aggregation, interpolation etc. */ ++ /* if this is present, file is controlled by non-standard ++ plugin (that is, plugin that cannot be deduced from file ++ mode bits), for example, aggregation, interpolation etc. */ + PLUGIN_STAT, + /* this extension contains persistent inode flags. These flags are + single bits: immutable, append, only, etc. Layout is in @@ -53837,11 +54123,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs + /* this extension contains size and public id of the secret key. + Layout is in reiser4_crypto_stat */ + CRYPTO_STAT, -+ /* on-disk slots of non-default plugins for inheritance, which -+ are extracted to special plugin table (@reiser4_inode->hset). -+ By default, children of the object will inherit plugins from -+ its main plugin table (pset). */ -+ HEIR_STAT, + LAST_SD_EXTENSION, + /* + * init_inode_static_sd() iterates over extension mask until all @@ -53855,7 +54136,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs + * ->present(), or ->absent() method will be called, independently of + * what other extensions are present. + */ -+ LAST_IMPORTANT_SD_EXTENSION = PLUGIN_STAT ++ LAST_IMPORTANT_SD_EXTENSION = PLUGIN_STAT, +} sd_ext_bits; + +/* minimal stat-data. This allows to support light-weight files. */ @@ -53867,9 +54148,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs +typedef struct reiser4_light_weight_stat { + /* 0 */ __le16 mode; + /* 2 */ __le32 nlink; -+ /* 6 */ __le64 size; ++ /* 8 */ __le64 size; + /* size in bytes */ -+ /* 14 */ ++ /* 16 */ +} PACKED reiser4_light_weight_stat; + +typedef struct reiser4_unix_stat { @@ -53941,12 +54222,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs + +typedef struct reiser4_large_times_stat { + /* access time */ -+ /* 0 */ d32 atime; ++ /* 0 */ d32 atime; + /* modification time */ -+ /* 4 */ d32 mtime; ++ /* 8 */ d32 mtime; + /* change time */ -+ /* 8 */ d32 ctime; -+ /* 12 */ ++ /* 16 */ d32 ctime; ++ /* 24 */ +} PACKED reiser4_large_times_stat; + +/* this structure is filled by sd_item_stat */ @@ -53977,10 +54258,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/static_stat.h linux-2.6.22/fs + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser4/plugin/item/tail.c ---- linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/tail.c 2007-07-29 00:25:34.980723395 +0400 -@@ -0,0 +1,809 @@ +Index: linux-2.6.16/fs/reiser4/plugin/item/tail.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/tail.c +@@ -0,0 +1,805 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "item.h" @@ -53998,7 +54280,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +reiser4_key *max_key_inside_tail(const coord_t *coord, reiser4_key *key) +{ + item_key_by_coord(coord, key); -+ set_key_offset(key, get_key_offset(reiser4_max_key())); ++ set_key_offset(key, get_key_offset(max_key())); + return key; +} + @@ -54026,8 +54308,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +{ + reiser4_key key1, key2; + -+ assert("vs-535", plugin_of_group(item_plugin_by_coord(p1), -+ UNIX_FILE_METADATA_ITEM_TYPE)); ++ assert("vs-535", ++ item_type_by_coord(p1) == UNIX_FILE_METADATA_ITEM_TYPE); + assert("vs-365", item_id_by_coord(p1) == FORMATTING_ID); + + if (item_id_by_coord(p2) != FORMATTING_ID) { @@ -54122,7 +54404,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + if (data->data) { + assert("vs-554", data->user == 0 || data->user == 1); + if (data->user) { -+ assert("nikita-3035", reiser4_schedulable()); ++ assert("nikita-3035", schedulable()); + /* copy from user space */ + if (__copy_from_user(item + coord->unit_pos, + (const char __user *)data->data, @@ -54303,9 +54585,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + inode = page->mapping->host; + coord_dup(&coord, &uf_coord->coord); + -+ reiser4_tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); ++ tap_init(&tap, &coord, &lh, ZNODE_READ_LOCK); + -+ if ((result = reiser4_tap_load(&tap))) ++ if ((result = tap_load(&tap))) + goto out_tap_done; + + /* lookup until page is filled up. */ @@ -54374,16 +54656,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + } + + done: -+ if (mapped != PAGE_CACHE_SIZE) -+ zero_user_page(page, mapped, PAGE_CACHE_SIZE - mapped, -+ KM_USER0); ++ if (mapped != PAGE_CACHE_SIZE) { ++ pagedata = kmap_atomic(page, KM_USER0); ++ memset(pagedata + mapped, 0, PAGE_CACHE_SIZE - mapped); ++ flush_dcache_page(page); ++ kunmap_atomic(pagedata, KM_USER0); ++ } + SetPageUptodate(page); + out_unlock_page: + unlock_page(page); + out_tap_relse: -+ reiser4_tap_relse(&tap); ++ tap_relse(&tap); + out_tap_done: -+ reiser4_tap_done(&tap); ++ tap_done(&tap); + return result; +} + @@ -54433,7 +54718,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + assert("vs-946", flow->data); + assert("vs-947", coord_is_existing_unit(coord)); + assert("vs-948", znode_is_write_locked(coord->node)); -+ assert("nikita-3036", reiser4_schedulable()); ++ assert("nikita-3036", schedulable()); + + count = item_length_by_coord(coord) - coord->unit_pos; + if (count > flow->length) @@ -54461,7 +54746,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +{ + int result; + loff_t to_write; -+ struct unix_file_info *uf_info; ++ unix_file_info_t *uf_info; + + if (get_key_offset(&flow->key) != 0) { + /* @@ -54480,7 +54765,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + */ + if (DQUOT_ALLOC_SPACE_NODIRTY(inode, flow->length)) + return RETERR(-EDQUOT); -+ result = reiser4_insert_flow(coord, lh, flow); ++ result = insert_flow(coord, lh, flow); + if (flow->length) + DQUOT_FREE_SPACE_NODIRTY(inode, flow->length); + @@ -54491,10 +54776,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + * file or performing tail conversion + */ + assert("", (uf_info->container == UF_CONTAINER_EMPTY || -+ (reiser4_inode_get_flag(inode, -+ REISER4_PART_MIXED) && -+ reiser4_inode_get_flag(inode, -+ REISER4_PART_IN_CONV)))); ++ (inode_get_flag(inode, REISER4_PART_MIXED) && ++ inode_get_flag(inode, REISER4_PART_IN_CONV)))); ++ + /* if file was empty - update its state */ + if (result == 0 && uf_info->container == UF_CONTAINER_EMPTY) + uf_info->container = UF_CONTAINER_TAILS; @@ -54506,7 +54790,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + return RETERR(-EDQUOT); + + to_write = flow->length; -+ result = reiser4_insert_flow(coord, lh, flow); ++ result = insert_flow(coord, lh, flow); + if (flow->length) + DQUOT_FREE_SPACE_NODIRTY(inode, flow->length); + return (to_write - flow->length) ? (to_write - flow->length) : result; @@ -54527,7 +54811,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + int result; + reiser4_key append_key; + loff_t to_write; -+ ++ + if (!keyeq(&flow->key, append_key_tail(coord, &append_key))) { + flow->data = NULL; + flow->length = get_key_offset(&flow->key) - get_key_offset(&append_key); @@ -54539,7 +54823,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + */ + if (DQUOT_ALLOC_SPACE_NODIRTY(inode, flow->length)) + return RETERR(-EDQUOT); -+ result = reiser4_insert_flow(coord, lh, flow); ++ result = insert_flow(coord, lh, flow); + if (flow->length) + DQUOT_FREE_SPACE_NODIRTY(inode, flow->length); + return result; @@ -54550,7 +54834,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + return RETERR(-EDQUOT); + + to_write = flow->length; -+ result = reiser4_insert_flow(coord, lh, flow); ++ result = insert_flow(coord, lh, flow); + if (flow->length) + DQUOT_FREE_SPACE_NODIRTY(inode, flow->length); + return (to_write - flow->length) ? (to_write - flow->length) : result; @@ -54570,7 +54854,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + + /* + * to write one flow to a file by tails we have to reserve disk space for: -+ ++ + * 1. find_file_item may have to insert empty node to the tree (empty + * leaf node between two extent items). This requires 1 block and + * number of blocks which are necessary to perform insertion of an @@ -54580,8 +54864,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + * + * 3. stat data update + */ -+ tree = reiser4_tree_by_inode(inode); -+ count = estimate_one_insert_item(tree) + ++ tree = tree_by_inode(inode); ++ count = estimate_one_insert_item(tree) + + estimate_insert_flow(tree->height) + + estimate_one_insert_item(tree); + grab_space_enable(); @@ -54592,7 +54876,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + +static loff_t faultin_user_pages(const char __user *buf, size_t count) +{ -+ loff_t faulted; ++ loff_t faulted; + int to_fault; + + if (count > PAGE_PER_FLOW * PAGE_CACHE_SIZE) @@ -54610,7 +54894,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +} + +/** -+ * reiser4_write_extent - write method of tail item plugin ++ * write_extent - write method of tail item plugin + * @file: file to write to + * @buf: address of user-space buffer + * @count: number of bytes to write @@ -54618,8 +54902,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + * + * Returns number of written bytes or error code. + */ -+ssize_t reiser4_write_tail(struct file *file, const char __user *buf, -+ size_t count, loff_t *pos) ++ssize_t write_tail(struct file *file, const char __user *buf, size_t count, ++ loff_t *pos) +{ + struct inode *inode; + struct hint hint; @@ -54653,7 +54937,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + result = zload(coord->node); + BUG_ON(result != 0); + loaded = coord->node; -+ ++ + if (coord->between == AFTER_UNIT) { + /* append with data or hole */ + result = append_tail(inode, &flow, coord, lh); @@ -54669,13 +54953,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + done_lh(lh); + return result; + } -+ ++ + /* seal and unlock znode */ + hint.ext_coord.valid = 0; + if (hint.ext_coord.valid) -+ reiser4_set_hint(&hint, &flow.key, ZNODE_WRITE_LOCK); ++ set_hint(&hint, &flow.key, ZNODE_WRITE_LOCK); + else -+ reiser4_unset_hint(&hint); ++ unset_hint(&hint); + + save_file_hint(file, &hint); + return result; @@ -54699,7 +54983,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +#endif + +/* plugin->u.item.s.file.read */ -+int reiser4_read_tail(struct file *file UNUSED_ARG, flow_t *f, hint_t *hint) ++int read_tail(struct file *file UNUSED_ARG, flow_t *f, hint_t *hint) +{ + unsigned count; + int item_length; @@ -54715,7 +54999,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + assert("vs-1117", znode_is_rlocked(coord->node)); + assert("vs-1118", znode_is_loaded(coord->node)); + -+ assert("nikita-3037", reiser4_schedulable()); ++ assert("nikita-3037", schedulable()); + assert("vs-1357", coord_matches_key_tail(coord, &f->key)); + + /* calculate number of bytes to read off the item */ @@ -54741,7 +55025,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + coord->unit_pos--; + coord->between = AFTER_UNIT; + } -+ reiser4_set_hint(hint, &f->key, ZNODE_READ_LOCK); ++ + return 0; +} + @@ -54770,13 +55054,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser +{ + assert("nikita-3252", znode_get_level(coord->node) == LEAF_LEVEL); + -+ if (reiser4_blocknr_is_fake(znode_get_block(coord->node))) -+ /* if node has'nt obtainet its block number yet, return 0. -+ * Lets avoid upsetting users with some cosmic numbers beyond -+ * the device capacity.*/ -+ *block = 0; -+ else -+ *block = *znode_get_block(coord->node); ++ *block = *znode_get_block(coord->node); + return 0; +} + @@ -54790,18 +55068,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.c linux-2.6.22/fs/reiser + * scroll-step: 1 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.h linux-2.6.22/fs/reiser4/plugin/item/tail.h ---- linux-2.6.22.orig/fs/reiser4/plugin/item/tail.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/item/tail.h 2007-07-29 00:25:34.980723395 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/item/tail.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/item/tail.h @@ -0,0 +1,58 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#if !defined( __REISER4_TAIL_H__ ) +#define __REISER4_TAIL_H__ + -+struct tail_coord_extension { ++typedef struct { + int not_used; -+}; ++} tail_coord_extension_t; + +struct cut_list; + @@ -54829,9 +55108,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.h linux-2.6.22/fs/reiser +reiser4_key *unit_key_tail(const coord_t *, reiser4_key *); + +/* plugin->u.item.s.* */ -+ssize_t reiser4_write_tail(struct file *file, const char __user *buf, -+ size_t count, loff_t *pos); -+int reiser4_read_tail(struct file *, flow_t *, hint_t *); ++ssize_t write_tail(struct file *file, const char __user *buf, size_t count, ++ loff_t *pos); ++int read_tail(struct file *, flow_t *, hint_t *); +int readpage_tail(void *vp, struct page *page); +reiser4_key *append_key_tail(const coord_t *, reiser4_key *); +void init_coord_extension_tail(uf_coord_t *, loff_t offset); @@ -54852,48 +55131,433 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/item/tail.h linux-2.6.22/fs/reiser + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/Makefile linux-2.6.22/fs/reiser4/plugin/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/Makefile 2007-07-29 00:25:34.980723395 +0400 -@@ -0,0 +1,26 @@ -+obj-$(CONFIG_REISER4_FS) += plugins.o -+ -+plugins-objs := \ -+ plugin.o \ -+ plugin_set.o \ -+ object.o \ -+ inode_ops.o \ -+ inode_ops_rename.o \ -+ file_ops.o \ -+ file_ops_readdir.o \ -+ file_plugin_common.o \ -+ dir_plugin_common.o \ -+ digest.o \ -+ hash.o \ -+ fibration.o \ -+ tail_policy.o \ -+ regular.o -+ -+obj-$(CONFIG_REISER4_FS) += item/ -+obj-$(CONFIG_REISER4_FS) += file/ -+obj-$(CONFIG_REISER4_FS) += dir/ -+obj-$(CONFIG_REISER4_FS) += node/ -+obj-$(CONFIG_REISER4_FS) += compress/ -+obj-$(CONFIG_REISER4_FS) += space/ -+obj-$(CONFIG_REISER4_FS) += disk_format/ -+obj-$(CONFIG_REISER4_FS) += security/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/Makefile linux-2.6.22/fs/reiser4/plugin/node/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/node/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/node/Makefile 2007-07-29 00:25:34.980723395 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/node/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/node/Makefile @@ -0,0 +1,5 @@ +obj-$(CONFIG_REISER4_FS) += node_plugins.o + +node_plugins-objs := \ + node.o \ + node40.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reiser4/plugin/node/node40.c ---- linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/node/node40.c 2007-07-29 00:25:34.988725466 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/node/node.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/node/node.c +@@ -0,0 +1,131 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++/* Node plugin interface. ++ ++ Description: The tree provides the abstraction of flows, which it ++ internally fragments into items which it stores in nodes. ++ ++ A key_atom is a piece of data bound to a single key. ++ ++ For reasonable space efficiency to be achieved it is often ++ necessary to store key_atoms in the nodes in the form of items, where ++ an item is a sequence of key_atoms of the same or similar type. It is ++ more space-efficient, because the item can implement (very) ++ efficient compression of key_atom's bodies using internal knowledge ++ about their semantics, and it can often avoid having a key for each ++ key_atom. Each type of item has specific operations implemented by its ++ item handler (see balance.c). ++ ++ Rationale: the rest of the code (specifically balancing routines) ++ accesses leaf level nodes through this interface. This way we can ++ implement various block layouts and even combine various layouts ++ within the same tree. Balancing/allocating algorithms should not ++ care about peculiarities of splitting/merging specific item types, ++ but rather should leave that to the item's item handler. ++ ++ Items, including those that provide the abstraction of flows, have ++ the property that if you move them in part or in whole to another ++ node, the balancing code invokes their is_left_mergeable() ++ item_operation to determine if they are mergeable with their new ++ neighbor in the node you have moved them to. For some items the ++ is_left_mergeable() function always returns null. ++ ++ When moving the bodies of items from one node to another: ++ ++ if a partial item is shifted to another node the balancing code invokes ++ an item handler method to handle the item splitting. ++ ++ if the balancing code needs to merge with an item in the node it ++ is shifting to, it will invoke an item handler method to handle ++ the item merging. ++ ++ if it needs to move whole item bodies unchanged, the balancing code uses xmemcpy() ++ adjusting the item headers after the move is done using the node handler. ++*/ ++ ++#include "../../forward.h" ++#include "../../debug.h" ++#include "../../key.h" ++#include "../../coord.h" ++#include "../plugin_header.h" ++#include "../item/item.h" ++#include "node.h" ++#include "../plugin.h" ++#include "../../znode.h" ++#include "../../tree.h" ++#include "../../super.h" ++#include "../../reiser4.h" ++ ++/** ++ * leftmost_key_in_node - get the smallest key in node ++ * @node: ++ * @key: store result here ++ * ++ * Stores the leftmost key of @node in @key. ++ */ ++reiser4_key *leftmost_key_in_node(const znode *node, reiser4_key *key) ++{ ++ assert("nikita-1634", node != NULL); ++ assert("nikita-1635", key != NULL); ++ ++ if (!node_is_empty(node)) { ++ coord_t first_item; ++ ++ coord_init_first_unit(&first_item, (znode *) node); ++ item_key_by_coord(&first_item, key); ++ } else ++ *key = *max_key(); ++ return key; ++} ++ ++node_plugin node_plugins[LAST_NODE_ID] = { ++ [NODE40_ID] = { ++ .h = { ++ .type_id = REISER4_NODE_PLUGIN_TYPE, ++ .id = NODE40_ID, ++ .pops = NULL, ++ .label = "unified", ++ .desc = "unified node layout", ++ .linkage = {NULL, NULL} ++ }, ++ .item_overhead = item_overhead_node40, ++ .free_space = free_space_node40, ++ .lookup = lookup_node40, ++ .num_of_items = num_of_items_node40, ++ .item_by_coord = item_by_coord_node40, ++ .length_by_coord = length_by_coord_node40, ++ .plugin_by_coord = plugin_by_coord_node40, ++ .key_at = key_at_node40, ++ .estimate = estimate_node40, ++ .check = check_node40, ++ .parse = parse_node40, ++ .init = init_node40, ++#ifdef GUESS_EXISTS ++ .guess = guess_node40, ++#endif ++ .change_item_size = change_item_size_node40, ++ .create_item = create_item_node40, ++ .update_item_key = update_item_key_node40, ++ .cut_and_kill = kill_node40, ++ .cut = cut_node40, ++ .shift = shift_node40, ++ .shrink_item = shrink_item_node40, ++ .fast_insert = fast_insert_node40, ++ .fast_paste = fast_paste_node40, ++ .fast_cut = fast_cut_node40, ++ .max_item_size = max_item_size_node40, ++ .prepare_removal = prepare_removal_node40, ++ .set_item_plugin = set_item_plugin_node40 ++ } ++}; ++ ++/* ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/node/node.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/node/node.h +@@ -0,0 +1,272 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++/* We need a definition of the default node layout here. */ ++ ++/* Generally speaking, it is best to have free space in the middle of the ++ node so that two sets of things can grow towards it, and to have the ++ item bodies on the left so that the last one of them grows into free ++ space. We optimize for the case where we append new items to the end ++ of the node, or grow the last item, because it hurts nothing to so ++ optimize and it is a common special case to do massive insertions in ++ increasing key order (and one of cases more likely to have a real user ++ notice the delay time for). ++ ++ formatted leaf default layout: (leaf1) ++ ++ |node header:item bodies:free space:key + pluginid + item offset| ++ ++ We grow towards the middle, optimizing layout for the case where we ++ append new items to the end of the node. The node header is fixed ++ length. Keys, and item offsets plus pluginids for the items ++ corresponding to them are in increasing key order, and are fixed ++ length. Item offsets are relative to start of node (16 bits creating ++ a node size limit of 64k, 12 bits might be a better choice....). Item ++ bodies are in decreasing key order. Item bodies have a variable size. ++ There is a one to one to one mapping of keys to item offsets to item ++ bodies. Item offsets consist of pointers to the zeroth byte of the ++ item body. Item length equals the start of the next item minus the ++ start of this item, except the zeroth item whose length equals the end ++ of the node minus the start of that item (plus a byte). In other ++ words, the item length is not recorded anywhere, and it does not need ++ to be since it is computable. ++ ++ Leaf variable length items and keys layout : (lvar) ++ ++ |node header:key offset + item offset + pluginid triplets:free space:key bodies:item bodies| ++ ++ We grow towards the middle, optimizing layout for the case where we ++ append new items to the end of the node. The node header is fixed ++ length. Keys and item offsets for the items corresponding to them are ++ in increasing key order, and keys are variable length. Item offsets ++ are relative to start of node (16 bits). Item bodies are in ++ decreasing key order. Item bodies have a variable size. There is a ++ one to one to one mapping of keys to item offsets to item bodies. ++ Item offsets consist of pointers to the zeroth byte of the item body. ++ Item length equals the start of the next item's key minus the start of ++ this item, except the zeroth item whose length equals the end of the ++ node minus the start of that item (plus a byte). ++ ++ leaf compressed keys layout: (lcomp) ++ ++ |node header:key offset + key inherit + item offset pairs:free space:key bodies:item bodies| ++ ++ We grow towards the middle, optimizing layout for the case where we ++ append new items to the end of the node. The node header is fixed ++ length. Keys and item offsets for the items corresponding to them are ++ in increasing key order, and keys are variable length. The "key ++ inherit" field indicates how much of the key prefix is identical to ++ the previous key (stem compression as described in "Managing ++ Gigabytes" is used). key_inherit is a one byte integer. The ++ intra-node searches performed through this layout are linear searches, ++ and this is theorized to not hurt performance much due to the high ++ cost of processor stalls on modern CPUs, and the small number of keys ++ in a single node. Item offsets are relative to start of node (16 ++ bits). Item bodies are in decreasing key order. Item bodies have a ++ variable size. There is a one to one to one mapping of keys to item ++ offsets to item bodies. Item offsets consist of pointers to the ++ zeroth byte of the item body. Item length equals the start of the ++ next item minus the start of this item, except the zeroth item whose ++ length equals the end of the node minus the start of that item (plus a ++ byte). In other words, item length and key length is not recorded ++ anywhere, and it does not need to be since it is computable. ++ ++ internal node default layout: (idef1) ++ ++ just like ldef1 except that item bodies are either blocknrs of ++ children or extents, and moving them may require updating parent ++ pointers in the nodes that they point to. ++*/ ++ ++/* There is an inherent 3-way tradeoff between optimizing and ++ exchanging disks between different architectures and code ++ complexity. This is optimal and simple and inexchangeable. ++ Someone else can do the code for exchanging disks and make it ++ complex. It would not be that hard. Using other than the PAGE_SIZE ++ might be suboptimal. ++*/ ++ ++#if !defined( __REISER4_NODE_H__ ) ++#define __REISER4_NODE_H__ ++ ++#define LEAF40_NODE_SIZE PAGE_CACHE_SIZE ++ ++#include "../../dformat.h" ++#include "../plugin_header.h" ++ ++#include ++ ++typedef enum { ++ NS_FOUND = 0, ++ NS_NOT_FOUND = -ENOENT ++} node_search_result; ++ ++/* Maximal possible space overhead for creation of new item in a node */ ++#define REISER4_NODE_MAX_OVERHEAD ( sizeof( reiser4_key ) + 32 ) ++ ++typedef enum { ++ REISER4_NODE_DKEYS = (1 << 0), ++ REISER4_NODE_TREE_STABLE = (1 << 1) ++} reiser4_node_check_flag; ++ ++/* cut and cut_and_kill have too long list of parameters. This structure is just to safe some space on stack */ ++struct cut_list { ++ coord_t *from; ++ coord_t *to; ++ const reiser4_key *from_key; ++ const reiser4_key *to_key; ++ reiser4_key *smallest_removed; ++ carry_plugin_info *info; ++ __u32 flags; ++ struct inode *inode; /* this is to pass list of eflushed jnodes down to extent_kill_hook */ ++ lock_handle *left; ++ lock_handle *right; ++}; ++ ++struct carry_cut_data; ++struct carry_kill_data; ++ ++/* The responsibility of the node plugin is to store and give access ++ to the sequence of items within the node. */ ++typedef struct node_plugin { ++ /* generic plugin fields */ ++ plugin_header h; ++ ++ /* calculates the amount of space that will be required to store an ++ item which is in addition to the space consumed by the item body. ++ (the space consumed by the item body can be gotten by calling ++ item->estimate) */ ++ size_t(*item_overhead) (const znode * node, flow_t * f); ++ ++ /* returns free space by looking into node (i.e., without using ++ znode->free_space). */ ++ size_t(*free_space) (znode * node); ++ /* search within the node for the one item which might ++ contain the key, invoking item->search_within to search within ++ that item to see if it is in there */ ++ node_search_result(*lookup) (znode * node, const reiser4_key * key, ++ lookup_bias bias, coord_t * coord); ++ /* number of items in node */ ++ int (*num_of_items) (const znode * node); ++ ++ /* store information about item in @coord in @data */ ++ /* break into several node ops, don't add any more uses of this before doing so */ ++ /*int ( *item_at )( const coord_t *coord, reiser4_item_data *data ); */ ++ char *(*item_by_coord) (const coord_t * coord); ++ int (*length_by_coord) (const coord_t * coord); ++ item_plugin *(*plugin_by_coord) (const coord_t * coord); ++ ++ /* store item key in @key */ ++ reiser4_key *(*key_at) (const coord_t * coord, reiser4_key * key); ++ /* conservatively estimate whether unit of what size can fit ++ into node. This estimation should be performed without ++ actually looking into the node's content (free space is saved in ++ znode). */ ++ size_t(*estimate) (znode * node); ++ ++ /* performs every consistency check the node plugin author could ++ imagine. Optional. */ ++ int (*check) (const znode * node, __u32 flags, const char **error); ++ ++ /* Called when node is read into memory and node plugin is ++ already detected. This should read some data into znode (like free ++ space counter) and, optionally, check data consistency. ++ */ ++ int (*parse) (znode * node); ++ /* This method is called on a new node to initialise plugin specific ++ data (header, etc.) */ ++ int (*init) (znode * node); ++ /* Check whether @node content conforms to this plugin format. ++ Probably only useful after support for old V3.x formats is added. ++ Uncomment after 4.0 only. ++ */ ++ /* int ( *guess )( const znode *node ); */ ++#if REISER4_DEBUG ++ void (*print) (const char *prefix, const znode * node, __u32 flags); ++#endif ++ /* change size of @item by @by bytes. @item->node has enough free ++ space. When @by > 0 - free space is appended to end of item. When ++ @by < 0 - item is truncated - it is assumed that last @by bytes if ++ the item are freed already */ ++ void (*change_item_size) (coord_t * item, int by); ++ ++ /* create new item @length bytes long in coord @target */ ++ int (*create_item) (coord_t * target, const reiser4_key * key, ++ reiser4_item_data * data, carry_plugin_info * info); ++ ++ /* update key of item. */ ++ void (*update_item_key) (coord_t * target, const reiser4_key * key, ++ carry_plugin_info * info); ++ ++ int (*cut_and_kill) (struct carry_kill_data *, carry_plugin_info *); ++ int (*cut) (struct carry_cut_data *, carry_plugin_info *); ++ ++ /* ++ * shrink item pointed to by @coord by @delta bytes. ++ */ ++ int (*shrink_item) (coord_t * coord, int delta); ++ ++ /* copy as much as possible but not more than up to @stop from ++ @stop->node to @target. If (pend == append) then data from beginning of ++ @stop->node are copied to the end of @target. If (pend == prepend) then ++ data from the end of @stop->node are copied to the beginning of ++ @target. Copied data are removed from @stop->node. Information ++ about what to do on upper level is stored in @todo */ ++ int (*shift) (coord_t * stop, znode * target, shift_direction pend, ++ int delete_node, int including_insert_coord, ++ carry_plugin_info * info); ++ /* return true if this node allows skip carry() in some situations ++ (see fs/reiser4/tree.c:insert_by_coord()). Reiser3.x format ++ emulation doesn't. ++ ++ This will speedup insertions that doesn't require updates to the ++ parent, by bypassing initialisation of carry() structures. It's ++ believed that majority of insertions will fit there. ++ ++ */ ++ int (*fast_insert) (const coord_t * coord); ++ int (*fast_paste) (const coord_t * coord); ++ int (*fast_cut) (const coord_t * coord); ++ /* this limits max size of item which can be inserted into a node and ++ number of bytes item in a node may be appended with */ ++ int (*max_item_size) (void); ++ int (*prepare_removal) (znode * empty, carry_plugin_info * info); ++ /* change plugin id of items which are in a node already. Currently it is Used in tail conversion for regular ++ * files */ ++ int (*set_item_plugin) (coord_t * coord, item_id); ++} node_plugin; ++ ++typedef enum { ++ /* standard unified node layout used for both leaf and internal ++ nodes */ ++ NODE40_ID, ++ LAST_NODE_ID ++} reiser4_node_id; ++ ++extern reiser4_key *leftmost_key_in_node(const znode * node, reiser4_key * key); ++#if REISER4_DEBUG ++extern void print_node_content(const char *prefix, const znode * node, ++ __u32 flags); ++#endif ++ ++extern void indent_znode(const znode * node); ++ ++typedef struct common_node_header { ++ /* ++ * identifier of node plugin. Must be located at the very beginning of ++ * a node. ++ */ ++ __le16 plugin_id; ++} common_node_header; ++ ++/* __REISER4_NODE_H__ */ ++#endif ++/* ++ * Local variables: ++ * c-indentation-style: "K&R" ++ * mode-name: "LC" ++ * c-basic-offset: 8 ++ * tab-width: 8 ++ * fill-column: 79 ++ * scroll-step: 1 ++ * End: ++ */ +Index: linux-2.6.16/fs/reiser4/plugin/node/node40.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/node/node40.c @@ -0,0 +1,2924 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -54961,6 +55625,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis +#define nh40_set_num_items(nh, value) put_unaligned(cpu_to_le16(value), &(nh)->nr_items) +#define nh40_set_mkfs_id(nh, value) put_unaligned(cpu_to_le32(value), &(nh)->mkfs_id) + ++ +/* plugin field of node header should be read/set by + plugin_by_disk_id/save_disk_plugin */ + @@ -55285,8 +55950,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + /* screw up */ + warning("nikita-587", "Key less than %i key in a node", + left); -+ reiser4_print_key("key", key); -+ reiser4_print_key("min", &bstop->key); ++ print_key("key", key); ++ print_key("min", &bstop->key); + print_coord_content("coord", coord); + return RETERR(-EIO); + } else { @@ -55300,7 +55965,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + if (unlikely(iplug == NULL)) { + warning("nikita-588", "Unknown plugin %i", + le16_to_cpu(get_unaligned(&bstop->plugin_id))); -+ reiser4_print_key("key", key); ++ print_key("key", key); + print_coord_content("coord", coord); + return RETERR(-EIO); + } @@ -55389,7 +56054,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + if (flags & REISER4_NODE_DKEYS) + prev = *znode_get_ld_key((znode *) node); + else -+ prev = *reiser4_min_key(); ++ prev = *min_key(); + + old_offset = 0; + coord_init_zero(&coord); @@ -55575,6 +56240,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + node->nr_items = node40_num_of_items_internal(node); + result = 0; + } ++ if (unlikely(result != 0)) ++ /* print_znode("node", node) */ ; + return RETERR(result); +} + @@ -55744,7 +56411,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + from userspace was valid and data bytes were + available? How will we return -EFAULT of some kind + without this check? */ -+ assert("nikita-3038", reiser4_schedulable()); ++ assert("nikita-3038", schedulable()); + /* copy data from user space */ + __copy_from_user(zdata(target->node) + offset, + (const char __user *)data->data, @@ -56961,7 +57628,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + else + reference = op->node; + assert("nikita-2992", reference != NULL); -+ cn = reiser4_add_carry(info->todo, POOLO_BEFORE, reference); ++ cn = add_carry(info->todo, POOLO_BEFORE, reference); + if (IS_ERR(cn)) + return PTR_ERR(cn); + cn->parent = 1; @@ -57380,8 +58047,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + node40_num_of_items_internal(left) + + node40_num_of_items_internal(right) - (mergeable ? 1 : 0); + data = -+ kmalloc(sizeof(struct shift_check) * nr_items, -+ reiser4_ctx_gfp_mask_get()); ++ kmalloc(sizeof(struct shift_check) * nr_items, get_gfp_mask()); + if (data != NULL) { + coord_t coord; + pos_in_node_t item_pos; @@ -57405,8 +58071,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + data[i].u.bytes = -+ reiser4_extent_size(&coord, -+ coord_num_units(&coord)); ++ extent_size(&coord, ++ coord_num_units(&coord)); + break; + case COMPOUND_DIR_ID: + data[i].u.entries = coord_num_units(&coord); @@ -57435,7 +58101,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + data[i - 1].u.bytes += -+ reiser4_extent_size(&coord, ++ extent_size(&coord, + coord_num_units(&coord)); + break; + case COMPOUND_DIR_ID: @@ -57465,7 +58131,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + data[i].u.bytes = -+ reiser4_extent_size(&coord, ++ extent_size(&coord, + coord_num_units(&coord)); + break; + case COMPOUND_DIR_ID: @@ -57537,10 +58203,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + assert("vs-1593", -+ data[i].u.bytes == -+ reiser4_extent_size(&coord, -+ coord_num_units -+ (&coord))); ++ data[i].u.bytes == extent_size(&coord, ++ coord_num_units ++ (&coord))); + break; + case COMPOUND_DIR_ID: + assert("vs-1594", @@ -57560,7 +58225,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + last_bytes = -+ reiser4_extent_size(&coord, ++ extent_size(&coord, + coord_num_units(&coord)); + break; + case COMPOUND_DIR_ID: @@ -57592,9 +58257,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + case EXTENT_POINTER_ID: + assert("vs-1597", + data[i - 1].u.bytes == -+ last_bytes + reiser4_extent_size(&coord, -+ coord_num_units -+ (&coord))); ++ last_bytes + extent_size(&coord, ++ coord_num_units ++ (&coord))); + break; + + case COMPOUND_DIR_ID: @@ -57626,10 +58291,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + break; + case EXTENT_POINTER_ID: + assert("vs-1601", -+ data[i].u.bytes == -+ reiser4_extent_size(&coord, -+ coord_num_units -+ (&coord))); ++ data[i].u.bytes == extent_size(&coord, ++ coord_num_units ++ (&coord))); + break; + case COMPOUND_DIR_ID: + assert("vs-1602", @@ -57772,597 +58436,188 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.c linux-2.6.22/fs/reis + look for description of this method in plugin/node/node.h */ +int fast_insert_node40(const coord_t * coord UNUSED_ARG /* node to query */ ) +{ -+ return 1; -+} -+ -+/* plugin->u.node.fast_paste() -+ look for description of this method in plugin/node/node.h */ -+int fast_paste_node40(const coord_t * coord UNUSED_ARG /* node to query */ ) -+{ -+ return 1; -+} -+ -+/* plugin->u.node.fast_cut() -+ look for description of this method in plugin/node/node.h */ -+int fast_cut_node40(const coord_t * coord UNUSED_ARG /* node to query */ ) -+{ -+ return 1; -+} -+ -+/* plugin->u.node.modify - not defined */ -+ -+/* plugin->u.node.max_item_size */ -+int max_item_size_node40(void) -+{ -+ return reiser4_get_current_sb()->s_blocksize - sizeof(node40_header) - -+ sizeof(item_header40); -+} -+ -+/* plugin->u.node.set_item_plugin */ -+int set_item_plugin_node40(coord_t *coord, item_id id) -+{ -+ item_header40 *ih; -+ -+ ih = node40_ih_at_coord(coord); -+ put_unaligned(cpu_to_le16(id), &ih->plugin_id); -+ coord->iplugid = id; -+ return 0; -+} -+ -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node40.h linux-2.6.22/fs/reiser4/plugin/node/node40.h ---- linux-2.6.22.orig/fs/reiser4/plugin/node/node40.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/node/node40.h 2007-07-29 00:25:34.988725466 +0400 -@@ -0,0 +1,125 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+#if !defined( __REISER4_NODE40_H__ ) -+#define __REISER4_NODE40_H__ -+ -+#include "../../forward.h" -+#include "../../dformat.h" -+#include "node.h" -+ -+#include -+ -+/* format of node header for 40 node layouts. Keep bloat out of this struct. */ -+typedef struct node40_header { -+ /* identifier of node plugin. Must be located at the very beginning -+ of a node. */ -+ common_node_header common_header; /* this is 16 bits */ -+ /* number of items. Should be first element in the node header, -+ because we haven't yet finally decided whether it shouldn't go into -+ common_header. -+ */ -+/* NIKITA-FIXME-HANS: Create a macro such that if there is only one -+ * node format at compile time, and it is this one, accesses do not function dereference when -+ * accessing these fields (and otherwise they do). Probably 80% of users will only have one node format at a time throughout the life of reiser4. */ -+ d16 nr_items; -+ /* free space in node measured in bytes */ -+ d16 free_space; -+ /* offset to start of free space in node */ -+ d16 free_space_start; -+ /* for reiser4_fsck. When information about what is a free -+ block is corrupted, and we try to recover everything even -+ if marked as freed, then old versions of data may -+ duplicate newer versions, and this field allows us to -+ restore the newer version. Also useful for when users -+ who don't have the new trashcan installed on their linux distro -+ delete the wrong files and send us desperate emails -+ offering $25 for them back. */ -+ -+ /* magic field we need to tell formatted nodes NIKITA-FIXME-HANS: improve this comment */ -+ d32 magic; -+ /* flushstamp is made of mk_id and write_counter. mk_id is an -+ id generated randomly at mkreiserfs time. So we can just -+ skip all nodes with different mk_id. write_counter is d64 -+ incrementing counter of writes on disk. It is used for -+ choosing the newest data at fsck time. NIKITA-FIXME-HANS: why was field name changed but not comment? */ -+ -+ d32 mkfs_id; -+ d64 flush_id; -+ /* node flags to be used by fsck (reiser4ck or reiser4fsck?) -+ and repacker NIKITA-FIXME-HANS: say more or reference elsewhere that says more */ -+ d16 flags; -+ -+ /* 1 is leaf level, 2 is twig level, root is the numerically -+ largest level */ -+ d8 level; -+ -+ d8 pad; -+} PACKED node40_header; -+ -+/* item headers are not standard across all node layouts, pass -+ pos_in_node to functions instead */ -+typedef struct item_header40 { -+ /* key of item */ -+ /* 0 */ reiser4_key key; -+ /* offset from start of a node measured in 8-byte chunks */ -+ /* 24 */ d16 offset; -+ /* 26 */ d16 flags; -+ /* 28 */ d16 plugin_id; -+} PACKED item_header40; -+ -+size_t item_overhead_node40(const znode * node, flow_t * aflow); -+size_t free_space_node40(znode * node); -+node_search_result lookup_node40(znode * node, const reiser4_key * key, -+ lookup_bias bias, coord_t * coord); -+int num_of_items_node40(const znode * node); -+char *item_by_coord_node40(const coord_t * coord); -+int length_by_coord_node40(const coord_t * coord); -+item_plugin *plugin_by_coord_node40(const coord_t * coord); -+reiser4_key *key_at_node40(const coord_t * coord, reiser4_key * key); -+size_t estimate_node40(znode * node); -+int check_node40(const znode * node, __u32 flags, const char **error); -+int parse_node40(znode * node); -+int init_node40(znode * node); -+#ifdef GUESS_EXISTS -+int guess_node40(const znode * node); -+#endif -+void change_item_size_node40(coord_t * coord, int by); -+int create_item_node40(coord_t * target, const reiser4_key * key, -+ reiser4_item_data * data, carry_plugin_info * info); -+void update_item_key_node40(coord_t * target, const reiser4_key * key, -+ carry_plugin_info * info); -+int kill_node40(struct carry_kill_data *, carry_plugin_info *); -+int cut_node40(struct carry_cut_data *, carry_plugin_info *); -+int shift_node40(coord_t * from, znode * to, shift_direction pend, -+ /* if @from->node becomes -+ empty - it will be deleted from -+ the tree if this is set to 1 -+ */ -+ int delete_child, int including_stop_coord, -+ carry_plugin_info * info); -+ -+int fast_insert_node40(const coord_t * coord); -+int fast_paste_node40(const coord_t * coord); -+int fast_cut_node40(const coord_t * coord); -+int max_item_size_node40(void); -+int prepare_removal_node40(znode * empty, carry_plugin_info * info); -+int set_item_plugin_node40(coord_t * coord, item_id id); -+int shrink_item_node40(coord_t * coord, int delta); -+ -+#if REISER4_DEBUG -+void *shift_check_prepare(const znode *left, const znode *right); -+void shift_check(void *vp, const znode *left, const znode *right); -+#endif -+ -+/* __REISER4_NODE40_H__ */ -+#endif -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node.c linux-2.6.22/fs/reiser4/plugin/node/node.c ---- linux-2.6.22.orig/fs/reiser4/plugin/node/node.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/node/node.c 2007-07-29 00:25:34.988725466 +0400 -@@ -0,0 +1,131 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+/* Node plugin interface. -+ -+ Description: The tree provides the abstraction of flows, which it -+ internally fragments into items which it stores in nodes. -+ -+ A key_atom is a piece of data bound to a single key. -+ -+ For reasonable space efficiency to be achieved it is often -+ necessary to store key_atoms in the nodes in the form of items, where -+ an item is a sequence of key_atoms of the same or similar type. It is -+ more space-efficient, because the item can implement (very) -+ efficient compression of key_atom's bodies using internal knowledge -+ about their semantics, and it can often avoid having a key for each -+ key_atom. Each type of item has specific operations implemented by its -+ item handler (see balance.c). -+ -+ Rationale: the rest of the code (specifically balancing routines) -+ accesses leaf level nodes through this interface. This way we can -+ implement various block layouts and even combine various layouts -+ within the same tree. Balancing/allocating algorithms should not -+ care about peculiarities of splitting/merging specific item types, -+ but rather should leave that to the item's item handler. -+ -+ Items, including those that provide the abstraction of flows, have -+ the property that if you move them in part or in whole to another -+ node, the balancing code invokes their is_left_mergeable() -+ item_operation to determine if they are mergeable with their new -+ neighbor in the node you have moved them to. For some items the -+ is_left_mergeable() function always returns null. -+ -+ When moving the bodies of items from one node to another: -+ -+ if a partial item is shifted to another node the balancing code invokes -+ an item handler method to handle the item splitting. -+ -+ if the balancing code needs to merge with an item in the node it -+ is shifting to, it will invoke an item handler method to handle -+ the item merging. -+ -+ if it needs to move whole item bodies unchanged, the balancing code uses xmemcpy() -+ adjusting the item headers after the move is done using the node handler. -+*/ -+ -+#include "../../forward.h" -+#include "../../debug.h" -+#include "../../key.h" -+#include "../../coord.h" -+#include "../plugin_header.h" -+#include "../item/item.h" -+#include "node.h" -+#include "../plugin.h" -+#include "../../znode.h" -+#include "../../tree.h" -+#include "../../super.h" -+#include "../../reiser4.h" -+ -+/** -+ * leftmost_key_in_node - get the smallest key in node -+ * @node: -+ * @key: store result here -+ * -+ * Stores the leftmost key of @node in @key. -+ */ -+reiser4_key *leftmost_key_in_node(const znode *node, reiser4_key *key) -+{ -+ assert("nikita-1634", node != NULL); -+ assert("nikita-1635", key != NULL); -+ -+ if (!node_is_empty(node)) { -+ coord_t first_item; -+ -+ coord_init_first_unit(&first_item, (znode *) node); -+ item_key_by_coord(&first_item, key); -+ } else -+ *key = *reiser4_max_key(); -+ return key; -+} -+ -+node_plugin node_plugins[LAST_NODE_ID] = { -+ [NODE40_ID] = { -+ .h = { -+ .type_id = REISER4_NODE_PLUGIN_TYPE, -+ .id = NODE40_ID, -+ .pops = NULL, -+ .label = "unified", -+ .desc = "unified node layout", -+ .linkage = {NULL, NULL} -+ }, -+ .item_overhead = item_overhead_node40, -+ .free_space = free_space_node40, -+ .lookup = lookup_node40, -+ .num_of_items = num_of_items_node40, -+ .item_by_coord = item_by_coord_node40, -+ .length_by_coord = length_by_coord_node40, -+ .plugin_by_coord = plugin_by_coord_node40, -+ .key_at = key_at_node40, -+ .estimate = estimate_node40, -+ .check = check_node40, -+ .parse = parse_node40, -+ .init = init_node40, -+#ifdef GUESS_EXISTS -+ .guess = guess_node40, -+#endif -+ .change_item_size = change_item_size_node40, -+ .create_item = create_item_node40, -+ .update_item_key = update_item_key_node40, -+ .cut_and_kill = kill_node40, -+ .cut = cut_node40, -+ .shift = shift_node40, -+ .shrink_item = shrink_item_node40, -+ .fast_insert = fast_insert_node40, -+ .fast_paste = fast_paste_node40, -+ .fast_cut = fast_cut_node40, -+ .max_item_size = max_item_size_node40, -+ .prepare_removal = prepare_removal_node40, -+ .set_item_plugin = set_item_plugin_node40 -+ } -+}; -+ -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 120 -+ scroll-step: 1 -+ End: -+*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/node/node.h linux-2.6.22/fs/reiser4/plugin/node/node.h ---- linux-2.6.22.orig/fs/reiser4/plugin/node/node.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/node/node.h 2007-07-29 00:25:34.988725466 +0400 -@@ -0,0 +1,272 @@ -+/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ -+ -+/* We need a definition of the default node layout here. */ -+ -+/* Generally speaking, it is best to have free space in the middle of the -+ node so that two sets of things can grow towards it, and to have the -+ item bodies on the left so that the last one of them grows into free -+ space. We optimize for the case where we append new items to the end -+ of the node, or grow the last item, because it hurts nothing to so -+ optimize and it is a common special case to do massive insertions in -+ increasing key order (and one of cases more likely to have a real user -+ notice the delay time for). -+ -+ formatted leaf default layout: (leaf1) -+ -+ |node header:item bodies:free space:key + pluginid + item offset| -+ -+ We grow towards the middle, optimizing layout for the case where we -+ append new items to the end of the node. The node header is fixed -+ length. Keys, and item offsets plus pluginids for the items -+ corresponding to them are in increasing key order, and are fixed -+ length. Item offsets are relative to start of node (16 bits creating -+ a node size limit of 64k, 12 bits might be a better choice....). Item -+ bodies are in decreasing key order. Item bodies have a variable size. -+ There is a one to one to one mapping of keys to item offsets to item -+ bodies. Item offsets consist of pointers to the zeroth byte of the -+ item body. Item length equals the start of the next item minus the -+ start of this item, except the zeroth item whose length equals the end -+ of the node minus the start of that item (plus a byte). In other -+ words, the item length is not recorded anywhere, and it does not need -+ to be since it is computable. -+ -+ Leaf variable length items and keys layout : (lvar) -+ -+ |node header:key offset + item offset + pluginid triplets:free space:key bodies:item bodies| -+ -+ We grow towards the middle, optimizing layout for the case where we -+ append new items to the end of the node. The node header is fixed -+ length. Keys and item offsets for the items corresponding to them are -+ in increasing key order, and keys are variable length. Item offsets -+ are relative to start of node (16 bits). Item bodies are in -+ decreasing key order. Item bodies have a variable size. There is a -+ one to one to one mapping of keys to item offsets to item bodies. -+ Item offsets consist of pointers to the zeroth byte of the item body. -+ Item length equals the start of the next item's key minus the start of -+ this item, except the zeroth item whose length equals the end of the -+ node minus the start of that item (plus a byte). -+ -+ leaf compressed keys layout: (lcomp) -+ -+ |node header:key offset + key inherit + item offset pairs:free space:key bodies:item bodies| -+ -+ We grow towards the middle, optimizing layout for the case where we -+ append new items to the end of the node. The node header is fixed -+ length. Keys and item offsets for the items corresponding to them are -+ in increasing key order, and keys are variable length. The "key -+ inherit" field indicates how much of the key prefix is identical to -+ the previous key (stem compression as described in "Managing -+ Gigabytes" is used). key_inherit is a one byte integer. The -+ intra-node searches performed through this layout are linear searches, -+ and this is theorized to not hurt performance much due to the high -+ cost of processor stalls on modern CPUs, and the small number of keys -+ in a single node. Item offsets are relative to start of node (16 -+ bits). Item bodies are in decreasing key order. Item bodies have a -+ variable size. There is a one to one to one mapping of keys to item -+ offsets to item bodies. Item offsets consist of pointers to the -+ zeroth byte of the item body. Item length equals the start of the -+ next item minus the start of this item, except the zeroth item whose -+ length equals the end of the node minus the start of that item (plus a -+ byte). In other words, item length and key length is not recorded -+ anywhere, and it does not need to be since it is computable. -+ -+ internal node default layout: (idef1) -+ -+ just like ldef1 except that item bodies are either blocknrs of -+ children or extents, and moving them may require updating parent -+ pointers in the nodes that they point to. -+*/ -+ -+/* There is an inherent 3-way tradeoff between optimizing and -+ exchanging disks between different architectures and code -+ complexity. This is optimal and simple and inexchangeable. -+ Someone else can do the code for exchanging disks and make it -+ complex. It would not be that hard. Using other than the PAGE_SIZE -+ might be suboptimal. -+*/ -+ -+#if !defined( __REISER4_NODE_H__ ) -+#define __REISER4_NODE_H__ -+ -+#define LEAF40_NODE_SIZE PAGE_CACHE_SIZE -+ -+#include "../../dformat.h" -+#include "../plugin_header.h" -+ -+#include -+ -+typedef enum { -+ NS_FOUND = 0, -+ NS_NOT_FOUND = -ENOENT -+} node_search_result; -+ -+/* Maximal possible space overhead for creation of new item in a node */ -+#define REISER4_NODE_MAX_OVERHEAD ( sizeof( reiser4_key ) + 32 ) -+ -+typedef enum { -+ REISER4_NODE_DKEYS = (1 << 0), -+ REISER4_NODE_TREE_STABLE = (1 << 1) -+} reiser4_node_check_flag; -+ -+/* cut and cut_and_kill have too long list of parameters. This structure is just to safe some space on stack */ -+struct cut_list { -+ coord_t *from; -+ coord_t *to; -+ const reiser4_key *from_key; -+ const reiser4_key *to_key; -+ reiser4_key *smallest_removed; -+ carry_plugin_info *info; -+ __u32 flags; -+ struct inode *inode; /* this is to pass list of eflushed jnodes down to extent_kill_hook */ -+ lock_handle *left; -+ lock_handle *right; -+}; -+ -+struct carry_cut_data; -+struct carry_kill_data; -+ -+/* The responsibility of the node plugin is to store and give access -+ to the sequence of items within the node. */ -+typedef struct node_plugin { -+ /* generic plugin fields */ -+ plugin_header h; ++ return 1; ++} + -+ /* calculates the amount of space that will be required to store an -+ item which is in addition to the space consumed by the item body. -+ (the space consumed by the item body can be gotten by calling -+ item->estimate) */ -+ size_t(*item_overhead) (const znode * node, flow_t * f); ++/* plugin->u.node.fast_paste() ++ look for description of this method in plugin/node/node.h */ ++int fast_paste_node40(const coord_t * coord UNUSED_ARG /* node to query */ ) ++{ ++ return 1; ++} + -+ /* returns free space by looking into node (i.e., without using -+ znode->free_space). */ -+ size_t(*free_space) (znode * node); -+ /* search within the node for the one item which might -+ contain the key, invoking item->search_within to search within -+ that item to see if it is in there */ -+ node_search_result(*lookup) (znode * node, const reiser4_key * key, -+ lookup_bias bias, coord_t * coord); -+ /* number of items in node */ -+ int (*num_of_items) (const znode * node); ++/* plugin->u.node.fast_cut() ++ look for description of this method in plugin/node/node.h */ ++int fast_cut_node40(const coord_t * coord UNUSED_ARG /* node to query */ ) ++{ ++ return 1; ++} + -+ /* store information about item in @coord in @data */ -+ /* break into several node ops, don't add any more uses of this before doing so */ -+ /*int ( *item_at )( const coord_t *coord, reiser4_item_data *data ); */ -+ char *(*item_by_coord) (const coord_t * coord); -+ int (*length_by_coord) (const coord_t * coord); -+ item_plugin *(*plugin_by_coord) (const coord_t * coord); ++/* plugin->u.node.modify - not defined */ + -+ /* store item key in @key */ -+ reiser4_key *(*key_at) (const coord_t * coord, reiser4_key * key); -+ /* conservatively estimate whether unit of what size can fit -+ into node. This estimation should be performed without -+ actually looking into the node's content (free space is saved in -+ znode). */ -+ size_t(*estimate) (znode * node); ++/* plugin->u.node.max_item_size */ ++int max_item_size_node40(void) ++{ ++ return reiser4_get_current_sb()->s_blocksize - sizeof(node40_header) - ++ sizeof(item_header40); ++} + -+ /* performs every consistency check the node plugin author could -+ imagine. Optional. */ -+ int (*check) (const znode * node, __u32 flags, const char **error); ++/* plugin->u.node.set_item_plugin */ ++int set_item_plugin_node40(coord_t *coord, item_id id) ++{ ++ item_header40 *ih; + -+ /* Called when node is read into memory and node plugin is -+ already detected. This should read some data into znode (like free -+ space counter) and, optionally, check data consistency. -+ */ -+ int (*parse) (znode * node); -+ /* This method is called on a new node to initialise plugin specific -+ data (header, etc.) */ -+ int (*init) (znode * node); -+ /* Check whether @node content conforms to this plugin format. -+ Probably only useful after support for old V3.x formats is added. -+ Uncomment after 4.0 only. -+ */ -+ /* int ( *guess )( const znode *node ); */ -+#if REISER4_DEBUG -+ void (*print) (const char *prefix, const znode * node, __u32 flags); -+#endif -+ /* change size of @item by @by bytes. @item->node has enough free -+ space. When @by > 0 - free space is appended to end of item. When -+ @by < 0 - item is truncated - it is assumed that last @by bytes if -+ the item are freed already */ -+ void (*change_item_size) (coord_t * item, int by); ++ ih = node40_ih_at_coord(coord); ++ put_unaligned(cpu_to_le16(id), &ih->plugin_id); ++ coord->iplugid = id; ++ return 0; ++} + -+ /* create new item @length bytes long in coord @target */ -+ int (*create_item) (coord_t * target, const reiser4_key * key, -+ reiser4_item_data * data, carry_plugin_info * info); ++/* ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/node/node40.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/node/node40.h +@@ -0,0 +1,125 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + -+ /* update key of item. */ -+ void (*update_item_key) (coord_t * target, const reiser4_key * key, -+ carry_plugin_info * info); ++#if !defined( __REISER4_NODE40_H__ ) ++#define __REISER4_NODE40_H__ + -+ int (*cut_and_kill) (struct carry_kill_data *, carry_plugin_info *); -+ int (*cut) (struct carry_cut_data *, carry_plugin_info *); ++#include "../../forward.h" ++#include "../../dformat.h" ++#include "node.h" + -+ /* -+ * shrink item pointed to by @coord by @delta bytes. ++#include ++ ++/* format of node header for 40 node layouts. Keep bloat out of this struct. */ ++typedef struct node40_header { ++ /* identifier of node plugin. Must be located at the very beginning ++ of a node. */ ++ common_node_header common_header; /* this is 16 bits */ ++ /* number of items. Should be first element in the node header, ++ because we haven't yet finally decided whether it shouldn't go into ++ common_header. + */ -+ int (*shrink_item) (coord_t * coord, int delta); ++/* NIKITA-FIXME-HANS: Create a macro such that if there is only one ++ * node format at compile time, and it is this one, accesses do not function dereference when ++ * accessing these fields (and otherwise they do). Probably 80% of users will only have one node format at a time throughout the life of reiser4. */ ++ d16 nr_items; ++ /* free space in node measured in bytes */ ++ d16 free_space; ++ /* offset to start of free space in node */ ++ d16 free_space_start; ++ /* for reiser4_fsck. When information about what is a free ++ block is corrupted, and we try to recover everything even ++ if marked as freed, then old versions of data may ++ duplicate newer versions, and this field allows us to ++ restore the newer version. Also useful for when users ++ who don't have the new trashcan installed on their linux distro ++ delete the wrong files and send us desperate emails ++ offering $25 for them back. */ + -+ /* copy as much as possible but not more than up to @stop from -+ @stop->node to @target. If (pend == append) then data from beginning of -+ @stop->node are copied to the end of @target. If (pend == prepend) then -+ data from the end of @stop->node are copied to the beginning of -+ @target. Copied data are removed from @stop->node. Information -+ about what to do on upper level is stored in @todo */ -+ int (*shift) (coord_t * stop, znode * target, shift_direction pend, -+ int delete_node, int including_insert_coord, -+ carry_plugin_info * info); -+ /* return true if this node allows skip carry() in some situations -+ (see fs/reiser4/tree.c:insert_by_coord()). Reiser3.x format -+ emulation doesn't. ++ /* magic field we need to tell formatted nodes NIKITA-FIXME-HANS: improve this comment */ ++ d32 magic; ++ /* flushstamp is made of mk_id and write_counter. mk_id is an ++ id generated randomly at mkreiserfs time. So we can just ++ skip all nodes with different mk_id. write_counter is d64 ++ incrementing counter of writes on disk. It is used for ++ choosing the newest data at fsck time. NIKITA-FIXME-HANS: why was field name changed but not comment? */ + -+ This will speedup insertions that doesn't require updates to the -+ parent, by bypassing initialisation of carry() structures. It's -+ believed that majority of insertions will fit there. ++ d32 mkfs_id; ++ d64 flush_id; ++ /* node flags to be used by fsck (reiser4ck or reiser4fsck?) ++ and repacker NIKITA-FIXME-HANS: say more or reference elsewhere that says more */ ++ d16 flags; + -+ */ -+ int (*fast_insert) (const coord_t * coord); -+ int (*fast_paste) (const coord_t * coord); -+ int (*fast_cut) (const coord_t * coord); -+ /* this limits max size of item which can be inserted into a node and -+ number of bytes item in a node may be appended with */ -+ int (*max_item_size) (void); -+ int (*prepare_removal) (znode * empty, carry_plugin_info * info); -+ /* change plugin id of items which are in a node already. Currently it is Used in tail conversion for regular -+ * files */ -+ int (*set_item_plugin) (coord_t * coord, item_id); -+} node_plugin; ++ /* 1 is leaf level, 2 is twig level, root is the numerically ++ largest level */ ++ d8 level; + -+typedef enum { -+ /* standard unified node layout used for both leaf and internal -+ nodes */ -+ NODE40_ID, -+ LAST_NODE_ID -+} reiser4_node_id; ++ d8 pad; ++} PACKED node40_header; + -+extern reiser4_key *leftmost_key_in_node(const znode * node, reiser4_key * key); -+#if REISER4_DEBUG -+extern void print_node_content(const char *prefix, const znode * node, -+ __u32 flags); ++/* item headers are not standard across all node layouts, pass ++ pos_in_node to functions instead */ ++typedef struct item_header40 { ++ /* key of item */ ++ /* 0 */ reiser4_key key; ++ /* offset from start of a node measured in 8-byte chunks */ ++ /* 24 */ d16 offset; ++ /* 26 */ d16 flags; ++ /* 28 */ d16 plugin_id; ++} PACKED item_header40; ++ ++size_t item_overhead_node40(const znode * node, flow_t * aflow); ++size_t free_space_node40(znode * node); ++node_search_result lookup_node40(znode * node, const reiser4_key * key, ++ lookup_bias bias, coord_t * coord); ++int num_of_items_node40(const znode * node); ++char *item_by_coord_node40(const coord_t * coord); ++int length_by_coord_node40(const coord_t * coord); ++item_plugin *plugin_by_coord_node40(const coord_t * coord); ++reiser4_key *key_at_node40(const coord_t * coord, reiser4_key * key); ++size_t estimate_node40(znode * node); ++int check_node40(const znode * node, __u32 flags, const char **error); ++int parse_node40(znode * node); ++int init_node40(znode * node); ++#ifdef GUESS_EXISTS ++int guess_node40(const znode * node); +#endif ++void change_item_size_node40(coord_t * coord, int by); ++int create_item_node40(coord_t * target, const reiser4_key * key, ++ reiser4_item_data * data, carry_plugin_info * info); ++void update_item_key_node40(coord_t * target, const reiser4_key * key, ++ carry_plugin_info * info); ++int kill_node40(struct carry_kill_data *, carry_plugin_info *); ++int cut_node40(struct carry_cut_data *, carry_plugin_info *); ++int shift_node40(coord_t * from, znode * to, shift_direction pend, ++ /* if @from->node becomes ++ empty - it will be deleted from ++ the tree if this is set to 1 ++ */ ++ int delete_child, int including_stop_coord, ++ carry_plugin_info * info); + -+extern void indent_znode(const znode * node); ++int fast_insert_node40(const coord_t * coord); ++int fast_paste_node40(const coord_t * coord); ++int fast_cut_node40(const coord_t * coord); ++int max_item_size_node40(void); ++int prepare_removal_node40(znode * empty, carry_plugin_info * info); ++int set_item_plugin_node40(coord_t * coord, item_id id); ++int shrink_item_node40(coord_t * coord, int delta); + -+typedef struct common_node_header { -+ /* -+ * identifier of node plugin. Must be located at the very beginning of -+ * a node. -+ */ -+ __le16 plugin_id; -+} common_node_header; ++#if REISER4_DEBUG ++void *shift_check_prepare(const znode *left, const znode *right); ++void shift_check(void *vp, const znode *left, const znode *right); ++#endif + -+/* __REISER4_NODE_H__ */ ++/* __REISER4_NODE40_H__ */ +#endif +/* -+ * Local variables: -+ * c-indentation-style: "K&R" -+ * mode-name: "LC" -+ * c-basic-offset: 8 -+ * tab-width: 8 -+ * fill-column: 79 -+ * scroll-step: 1 -+ * End: -+ */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/plugin/object.c ---- linux-2.6.22.orig/fs/reiser4/plugin/object.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/object.c 2007-07-29 00:25:34.992726502 +0400 -@@ -0,0 +1,516 @@ ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/object.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/object.c +@@ -0,0 +1,501 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -58433,16 +58688,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + +#define dummyop ((void *)_dummyop) + -+static int change_file(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_file(struct inode *inode, reiser4_plugin * plugin) +{ + /* cannot change object plugin of already existing object */ -+ if (memb == PSET_FILE) -+ return RETERR(-EINVAL); -+ -+ /* Change PSET_CREATE */ -+ return aset_set_unsafe(&reiser4_inode_data(inode)->pset, memb, plugin); ++ return RETERR(-EINVAL); +} + +static reiser4_plugin_ops file_plugin_ops = { @@ -58458,22 +58707,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .h = { + .type_id = REISER4_FILE_PLUGIN_TYPE, + .id = UNIX_FILE_PLUGIN_ID, -+ .groups = (1 << REISER4_REGULAR_FILE), + .pops = &file_plugin_ops, + .label = "reg", + .desc = "regular file", + .linkage = {NULL, NULL}, + }, + .inode_ops = { -+ .permission = reiser4_permission_common, ++ .permission = permission_common, + .setattr = setattr_unix_file, -+ .getattr = reiser4_getattr_common ++ .getattr = getattr_common + }, + .file_ops = { + .llseek = generic_file_llseek, + .read = read_unix_file, + .write = write_unix_file, -+ .aio_read = generic_file_aio_read, + .ioctl = ioctl_unix_file, + .mmap = mmap_unix_file, + .open = open_unix_file, @@ -58487,7 +58734,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .sync_page = block_sync_page, + .writepages = writepages_unix_file, + .set_page_dirty = reiser4_set_page_dirty, -+ .readpages = readpages_unix_file, ++ .readpages = reiser4_readpages, + .prepare_write = prepare_write_unix_file, + .commit_write = commit_write_unix_file, + .bmap = bmap_unix_file, @@ -58499,10 +58746,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .key_by_inode = key_by_inode_and_offset_common, + .set_plug_in_inode = set_plug_in_inode_common, + .adjust_to_parent = adjust_to_parent_common, -+ .create_object = reiser4_create_object_common, ++ .create_object = create_object_common, /* this is not inode_operations's create */ + .delete_object = delete_object_unix_file, -+ .add_link = reiser4_add_link_common, -+ .rem_link = reiser4_rem_link_common, ++ .add_link = add_link_common, ++ .rem_link = rem_link_common, + .owns_item = owns_item_unix_file, + .can_add_link = can_add_link_common, + .detach = dummyop, @@ -58527,30 +58774,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .h = { + .type_id = REISER4_FILE_PLUGIN_TYPE, + .id = DIRECTORY_FILE_PLUGIN_ID, -+ .groups = (1 << REISER4_DIRECTORY_FILE), + .pops = &file_plugin_ops, + .label = "dir", + .desc = "directory", + .linkage = {NULL, NULL} + }, -+ .inode_ops = {.create = NULL}, -+ .file_ops = {.owner = NULL}, -+ .as_ops = {.writepage = NULL}, ++ .inode_ops = {NULL,}, ++ .file_ops = {NULL,}, ++ .as_ops = {NULL,}, + + .write_sd_by_inode = write_sd_by_inode_common, + .flow_by_inode = bugop, + .key_by_inode = bugop, + .set_plug_in_inode = set_plug_in_inode_common, + .adjust_to_parent = adjust_to_parent_common_dir, -+ .create_object = reiser4_create_object_common, -+ .delete_object = reiser4_delete_dir_common, -+ .add_link = reiser4_add_link_common, ++ .create_object = create_object_common, ++ .delete_object = delete_directory_common, ++ .add_link = add_link_common, + .rem_link = rem_link_common_dir, + .owns_item = owns_item_common_dir, + .can_add_link = can_add_link_common, + .can_rem_link = can_rem_link_common_dir, -+ .detach = reiser4_detach_common_dir, -+ .bind = reiser4_bind_common_dir, ++ .detach = detach_common_dir, ++ .bind = bind_common_dir, + .safelink = safelink_common, + .estimate = { + .create = estimate_create_common_dir, @@ -58571,7 +58817,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .h = { + .type_id = REISER4_FILE_PLUGIN_TYPE, + .id = SYMLINK_FILE_PLUGIN_ID, -+ .groups = (1 << REISER4_SYMLINK_FILE), + .pops = &file_plugin_ops, + .label = "symlink", + .desc = "symbolic link", @@ -58579,22 +58824,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + }, + .inode_ops = { + .readlink = generic_readlink, -+ .follow_link = reiser4_follow_link_common, -+ .permission = reiser4_permission_common, -+ .setattr = reiser4_setattr_common, -+ .getattr = reiser4_getattr_common ++ .follow_link = follow_link_common, ++ .permission = permission_common, ++ .setattr = setattr_common, ++ .getattr = getattr_common + }, + /* inode->i_fop of symlink is initialized by NULL in setup_inode_ops */ -+ .file_ops = {.owner = NULL}, -+ .as_ops = {.writepage = NULL}, ++ .file_ops = {NULL,}, ++ .as_ops = {NULL,}, + + .write_sd_by_inode = write_sd_by_inode_common, + .set_plug_in_inode = set_plug_in_inode_common, + .adjust_to_parent = adjust_to_parent_common, -+ .create_object = reiser4_create_symlink, -+ .delete_object = reiser4_delete_object_common, -+ .add_link = reiser4_add_link_common, -+ .rem_link = reiser4_rem_link_common, ++ .create_object = create_symlink, ++ .delete_object = delete_object_common, ++ .add_link = add_link_common, ++ .rem_link = rem_link_common, + .can_add_link = can_add_link_common, + .detach = dummyop, + .bind = dummyop, @@ -58619,7 +58864,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .h = { + .type_id = REISER4_FILE_PLUGIN_TYPE, + .id = SPECIAL_FILE_PLUGIN_ID, -+ .groups = (1 << REISER4_SPECIAL_FILE), + .pops = &file_plugin_ops, + .label = "special", + .desc = @@ -58627,22 +58871,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .linkage = {NULL, NULL} + }, + .inode_ops = { -+ .permission = reiser4_permission_common, -+ .setattr = reiser4_setattr_common, -+ .getattr = reiser4_getattr_common ++ .permission = permission_common, ++ .setattr = setattr_common, ++ .getattr = getattr_common + }, + /* file_ops of special files (sockets, block, char, fifo) are + initialized by init_special_inode. */ -+ .file_ops = {.owner = NULL}, -+ .as_ops = {.writepage = NULL}, ++ .file_ops = {NULL,}, ++ .as_ops = {NULL,}, + + .write_sd_by_inode = write_sd_by_inode_common, + .set_plug_in_inode = set_plug_in_inode_common, + .adjust_to_parent = adjust_to_parent_common, -+ .create_object = reiser4_create_object_common, -+ .delete_object = reiser4_delete_object_common, -+ .add_link = reiser4_add_link_common, -+ .rem_link = reiser4_rem_link_common, ++ .create_object = create_object_common, ++ .delete_object = delete_object_common, ++ .add_link = add_link_common, ++ .rem_link = rem_link_common, + .owns_item = owns_item_common, + .can_add_link = can_add_link_common, + .detach = dummyop, @@ -58663,30 +58907,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .done = wire_done_common + } + }, -+ [CRYPTCOMPRESS_FILE_PLUGIN_ID] = { ++ [CRC_FILE_PLUGIN_ID] = { + .h = { + .type_id = REISER4_FILE_PLUGIN_TYPE, -+ .id = CRYPTCOMPRESS_FILE_PLUGIN_ID, -+ .groups = (1 << REISER4_REGULAR_FILE), -+ .pops = &file_plugin_ops, ++ .id = CRC_FILE_PLUGIN_ID, ++ .pops = &cryptcompress_plugin_ops, + .label = "cryptcompress", + .desc = "cryptcompress file", + .linkage = {NULL, NULL} + }, + .inode_ops = { -+ .permission = reiser4_permission_common, -+ .setattr = prot_setattr_cryptcompress, -+ .getattr = reiser4_getattr_common ++ .permission = permission_common, ++ .setattr = setattr_cryptcompress, ++ .getattr = getattr_common + }, + .file_ops = { + .llseek = generic_file_llseek, -+ .read = prot_read_cryptcompress, -+ .write = prot_write_cryptcompress, -+ .aio_read = generic_file_aio_read, -+ .mmap = prot_mmap_cryptcompress, -+ .release = prot_release_cryptcompress, -+ .fsync = reiser4_sync_common, -+ .sendfile = prot_sendfile_cryptcompress ++ .read = read_cryptcompress, ++ .write = write_cryptcompress, ++ .mmap = mmap_cryptcompress, ++ .release = release_cryptcompress, ++ .fsync = sync_common, ++ .sendfile = sendfile_cryptcompress + }, + .as_ops = { + .writepage = reiser4_writepage, @@ -58694,7 +58936,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .sync_page = block_sync_page, + .writepages = writepages_cryptcompress, + .set_page_dirty = reiser4_set_page_dirty, -+ .readpages = readpages_cryptcompress, ++ .readpages = reiser4_readpages, + .prepare_write = prepare_write_common, + .invalidatepage = reiser4_invalidatepage, + .releasepage = reiser4_releasepage @@ -58705,10 +58947,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .set_plug_in_inode = set_plug_in_inode_common, + .adjust_to_parent = adjust_to_parent_cryptcompress, + .create_object = create_cryptcompress, -+ .open_object = open_object_cryptcompress, -+ .delete_object = delete_object_cryptcompress, -+ .add_link = reiser4_add_link_common, -+ .rem_link = reiser4_rem_link_common, ++ .open_object = open_cryptcompress, ++ .delete_object = delete_cryptcompress, ++ .add_link = add_link_common, ++ .rem_link = rem_link_common, + .owns_item = owns_item_common, + .can_add_link = can_add_link_common, + .detach = dummyop, @@ -58732,9 +58974,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + } +}; + -+static int change_dir(struct inode *inode, -+ reiser4_plugin * plugin, -+ pset_member memb) ++static int change_dir(struct inode *inode, reiser4_plugin * plugin) +{ + /* cannot change dir plugin of already existing object */ + return RETERR(-EINVAL); @@ -58760,25 +59000,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .linkage = {NULL, NULL} + }, + .inode_ops = { -+ .create = reiser4_create_common, -+ .lookup = reiser4_lookup_common, -+ .link = reiser4_link_common, -+ .unlink = reiser4_unlink_common, -+ .symlink = reiser4_symlink_common, -+ .mkdir = reiser4_mkdir_common, -+ .rmdir = reiser4_unlink_common, -+ .mknod = reiser4_mknod_common, -+ .rename = reiser4_rename_common, -+ .permission = reiser4_permission_common, -+ .setattr = reiser4_setattr_common, -+ .getattr = reiser4_getattr_common ++ .create = create_common, ++ .lookup = lookup_common, ++ .link = link_common, ++ .unlink = unlink_common, ++ .symlink = symlink_common, ++ .mkdir = mkdir_common, ++ .rmdir = unlink_common, ++ .mknod = mknod_common, ++ .rename = rename_common, ++ .permission = permission_common, ++ .setattr = setattr_common, ++ .getattr = getattr_common + }, + .file_ops = { -+ .llseek = reiser4_llseek_dir_common, ++ .llseek = llseek_common_dir, + .read = generic_read_dir, -+ .readdir = reiser4_readdir_common, -+ .release = reiser4_release_dir_common, -+ .fsync = reiser4_sync_common ++ .readdir = readdir_common, ++ .release = release_dir_common, ++ .fsync = sync_common + }, + .as_ops = { + .writepage = bugop, @@ -58796,12 +59036,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .is_name_acceptable = is_name_acceptable_common, + .build_entry_key = build_entry_key_hashed, + .build_readdir_key = build_readdir_key_common, -+ .add_entry = reiser4_add_entry_common, -+ .rem_entry = reiser4_rem_entry_common, -+ .init = reiser4_dir_init_common, -+ .done = reiser4_dir_done_common, -+ .attach = reiser4_attach_common, -+ .detach = reiser4_detach_common, ++ .add_entry = add_entry_common, ++ .rem_entry = rem_entry_common, ++ .init = init_common, ++ .done = done_common, ++ .attach = attach_common, ++ .detach = detach_common, + .estimate = { + .add_entry = estimate_add_entry_common, + .rem_entry = estimate_rem_entry_common, @@ -58820,25 +59060,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .linkage = {NULL, NULL} + }, + .inode_ops = { -+ .create = reiser4_create_common, -+ .lookup = reiser4_lookup_common, -+ .link = reiser4_link_common, -+ .unlink = reiser4_unlink_common, -+ .symlink = reiser4_symlink_common, -+ .mkdir = reiser4_mkdir_common, -+ .rmdir = reiser4_unlink_common, -+ .mknod = reiser4_mknod_common, -+ .rename = reiser4_rename_common, -+ .permission = reiser4_permission_common, -+ .setattr = reiser4_setattr_common, -+ .getattr = reiser4_getattr_common ++ .create = create_common, ++ .lookup = lookup_common, ++ .link = link_common, ++ .unlink = unlink_common, ++ .symlink = symlink_common, ++ .mkdir = mkdir_common, ++ .rmdir = unlink_common, ++ .mknod = mknod_common, ++ .rename = rename_common, ++ .permission = permission_common, ++ .setattr = setattr_common, ++ .getattr = getattr_common + }, + .file_ops = { -+ .llseek = reiser4_llseek_dir_common, ++ .llseek = llseek_common_dir, + .read = generic_read_dir, -+ .readdir = reiser4_readdir_common, -+ .release = reiser4_release_dir_common, -+ .fsync = reiser4_sync_common ++ .readdir = readdir_common, ++ .release = release_dir_common, ++ .fsync = sync_common + }, + .as_ops = { + .writepage = bugop, @@ -58856,12 +59096,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + .is_name_acceptable = is_name_acceptable_common, + .build_entry_key = build_entry_key_seekable, + .build_readdir_key = build_readdir_key_common, -+ .add_entry = reiser4_add_entry_common, -+ .rem_entry = reiser4_rem_entry_common, -+ .init = reiser4_dir_init_common, -+ .done = reiser4_dir_done_common, -+ .attach = reiser4_attach_common, -+ .detach = reiser4_detach_common, ++ .add_entry = add_entry_common, ++ .rem_entry = rem_entry_common, ++ .init = init_common, ++ .done = done_common, ++ .attach = attach_common, ++ .detach = detach_common, + .estimate = { + .add_entry = estimate_add_entry_common, + .rem_entry = estimate_rem_entry_common, @@ -58879,9 +59119,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.c linux-2.6.22/fs/reiser4/p + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/plugin/object.h ---- linux-2.6.22.orig/fs/reiser4/plugin/object.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/object.h 2007-07-29 00:25:34.992726502 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/object.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/object.h @@ -0,0 +1,121 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -58894,33 +59135,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/p +#include "../type_safe_hash.h" + +/* common implementations of inode operations */ -+int reiser4_create_common(struct inode *parent, struct dentry *dentry, -+ int mode, struct nameidata *); -+struct dentry * reiser4_lookup_common(struct inode *parent, -+ struct dentry *dentry, -+ struct nameidata *nameidata); -+int reiser4_link_common(struct dentry *existing, struct inode *parent, -+ struct dentry *newname); -+int reiser4_unlink_common(struct inode *parent, struct dentry *victim); -+int reiser4_mkdir_common(struct inode *parent, struct dentry *dentry, int mode); -+int reiser4_symlink_common(struct inode *parent, struct dentry *dentry, ++int create_common(struct inode *parent, struct dentry *dentry, ++ int mode, struct nameidata *); ++struct dentry *lookup_common(struct inode *parent, struct dentry *dentry, ++ struct nameidata *nameidata); ++int link_common(struct dentry *existing, struct inode *parent, ++ struct dentry *newname); ++int unlink_common(struct inode *parent, struct dentry *victim); ++int mkdir_common(struct inode *parent, struct dentry *dentry, int mode); ++int symlink_common(struct inode *parent, struct dentry *dentry, + const char *linkname); -+int reiser4_mknod_common(struct inode *parent, struct dentry *dentry, ++int mknod_common(struct inode *parent, struct dentry *dentry, + int mode, dev_t rdev); -+int reiser4_rename_common(struct inode *old_dir, struct dentry *old_name, -+ struct inode *new_dir, struct dentry *new_name); -+void *reiser4_follow_link_common(struct dentry *, struct nameidata *data); -+int reiser4_permission_common(struct inode *, int mask, -+ struct nameidata *nameidata); -+int reiser4_setattr_common(struct dentry *, struct iattr *); -+int reiser4_getattr_common(struct vfsmount *mnt, struct dentry *, -+ struct kstat *); ++int rename_common(struct inode *old_dir, struct dentry *old_name, ++ struct inode *new_dir, struct dentry *new_name); ++void *follow_link_common(struct dentry *, struct nameidata *data); ++int permission_common(struct inode *, int mask, /* mode bits to check permissions for */ ++ struct nameidata *nameidata); ++int setattr_common(struct dentry *, struct iattr *); ++int getattr_common(struct vfsmount *mnt, struct dentry *, struct kstat *); + +/* common implementations of file operations */ -+loff_t reiser4_llseek_dir_common(struct file *, loff_t off, int origin); -+int reiser4_readdir_common(struct file *, void *dirent, filldir_t); -+int reiser4_release_dir_common(struct inode *, struct file *); -+int reiser4_sync_common(struct file *, struct dentry *, int datasync); ++loff_t llseek_common_dir(struct file *, loff_t off, int origin); ++int readdir_common(struct file *, void *dirent, filldir_t); ++int release_dir_common(struct inode *, struct file *); ++int sync_common(struct file *, struct dentry *, int datasync); + +/* common implementations of address space operations */ +int prepare_write_common(struct file *, struct page *, unsigned from, @@ -58937,19 +59176,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/p + struct inode *root); +int adjust_to_parent_cryptcompress(struct inode *object, struct inode *parent, + struct inode *root); -+int reiser4_create_object_common(struct inode *object, struct inode *parent, -+ reiser4_object_create_data *); -+int reiser4_delete_object_common(struct inode *); -+int reiser4_delete_dir_common(struct inode *); -+int reiser4_add_link_common(struct inode *object, struct inode *parent); -+int reiser4_rem_link_common(struct inode *object, struct inode *parent); ++int create_object_common(struct inode *object, struct inode *parent, ++ reiser4_object_create_data *); ++int delete_object_common(struct inode *); ++int delete_directory_common(struct inode *); ++int add_link_common(struct inode *object, struct inode *parent); ++int rem_link_common(struct inode *object, struct inode *parent); +int rem_link_common_dir(struct inode *object, struct inode *parent); +int owns_item_common(const struct inode *, const coord_t *); +int owns_item_common_dir(const struct inode *, const coord_t *); +int can_add_link_common(const struct inode *); +int can_rem_link_common_dir(const struct inode *); -+int reiser4_detach_common_dir(struct inode *child, struct inode *parent); -+int reiser4_bind_common_dir(struct inode *child, struct inode *parent); ++int detach_common_dir(struct inode *child, struct inode *parent); ++int open_cryptcompress(struct inode * inode, struct file * file); ++int bind_common_dir(struct inode *child, struct inode *parent); +int safelink_common(struct inode *, reiser4_safe_link_t, __u64 value); +reiser4_block_nr estimate_create_common(const struct inode *); +reiser4_block_nr estimate_create_common_dir(const struct inode *); @@ -58970,15 +59210,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/p +void build_entry_key_common(const struct inode *, + const struct qstr *qname, reiser4_key *); +int build_readdir_key_common(struct file *dir, reiser4_key *); -+int reiser4_add_entry_common(struct inode *object, struct dentry *where, ++int add_entry_common(struct inode *object, struct dentry *where, + reiser4_object_create_data *, reiser4_dir_entry_desc *); -+int reiser4_rem_entry_common(struct inode *object, struct dentry *where, ++int rem_entry_common(struct inode *object, struct dentry *where, + reiser4_dir_entry_desc *); -+int reiser4_dir_init_common(struct inode *object, struct inode *parent, -+ reiser4_object_create_data *); -+int reiser4_dir_done_common(struct inode *); -+int reiser4_attach_common(struct inode *child, struct inode *parent); -+int reiser4_detach_common(struct inode *object, struct inode *parent); ++int init_common(struct inode *object, struct inode *parent, ++ reiser4_object_create_data *); ++int done_common(struct inode *); ++int attach_common(struct inode *child, struct inode *parent); ++int detach_common(struct inode *object, struct inode *parent); +reiser4_block_nr estimate_add_entry_common(const struct inode *); +reiser4_block_nr estimate_rem_entry_common(const struct inode *); +reiser4_block_nr dir_estimate_unlink_common(const struct inode *, @@ -58992,6 +59232,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/p +int lookup_sd(struct inode *, znode_lock_mode, coord_t *, lock_handle *, + const reiser4_key *, int silent); + ++ +/* __FS_REISER4_PLUGIN_OBJECT_H__ */ +#endif + @@ -59004,10 +59245,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/object.h linux-2.6.22/fs/reiser4/p + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/plugin/plugin.c ---- linux-2.6.22.orig/fs/reiser4/plugin/plugin.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/plugin.c 2007-07-29 00:25:34.992726502 +0400 -@@ -0,0 +1,559 @@ +Index: linux-2.6.16/fs/reiser4/plugin/plugin.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/plugin.c +@@ -0,0 +1,533 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -59021,8 +59263,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + + Plugins are classified into several disjoint "types". Plugins + belonging to the particular plugin type are termed "instances" of -+ this type. Existing types are listed by enum reiser4_plugin_type -+ (see plugin/plugin_header.h) ++ this type. Currently the following types are present: ++ ++ . object plugin ++ . hash plugin ++ . tail plugin ++ . perm plugin ++ . item plugin ++ . node layout plugin + +NIKITA-FIXME-HANS: update this list, and review this entire comment for currency + @@ -59039,6 +59287,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + Tail plugins (or, more precisely, tail policy plugins) determine + when last part of the file should be stored in a formatted item. + ++ Perm plugins control permissions granted for a process accessing a file. ++ + Scope and lookup: + + label such that pair ( type_label, plugin_label ) is unique. This @@ -59051,15 +59301,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + store the offset into the plugin array for that plugin type as the + plugin id in the stat data of the filesystem object. + ++ plugin_labels have meaning for the user interface that assigns ++ plugins to files, and may someday have meaning for dynamic loading of ++ plugins and for copying of plugins from one fs instance to ++ another by utilities like cp and tar. ++ + Internal kernel plugin type identifier (index in plugins[] array) is + of type reiser4_plugin_type. Set of available plugin types is + currently static, but dynamic loading doesn't seem to pose + insurmountable problems. + + Within each type plugins are addressed by the identifiers of type -+ reiser4_plugin_id (indices in reiser4_plugin_type_data.builtin[]). -+ Such identifiers are only required to be unique within one type, -+ not globally. ++ reiser4_plugin_id (indices in ++ reiser4_plugin_type_data.builtin[]). Such identifiers are only ++ required to be unique within one type, not globally. + + Thus, plugin in memory is uniquely identified by the pair (type_id, + id). @@ -59080,7 +59335,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + + With each subject the plugin possibly stores some state. For example, + the state of a directory plugin (instance of object plugin type) is pointer -+ to hash plugin (if directories always use hashing that is). ++ to hash plugin (if directories always use hashing that is). State of ++ audit plugin is file descriptor (struct file) of log file or some ++ magic value to do logging through printk(). + + Interface: + @@ -59092,7 +59349,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + .desc fields of reiser4_plugin_header respectively. It's possible to + locate plugin by the pair of labels. + -+ Features (not implemented): ++ Features: + + . user-level plugin manipulations: + + reiser4("filename/..file_plugin<='audit'"); @@ -59102,9 +59359,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + Utilities are not of primary priority. Possibly they will be not + working on v4.0 + -+ NIKITA-FIXME-HANS: this should be a mkreiserfs option not a mount -+ option, do you agree? I don't think that specifying it at mount time, -+ and then changing it with each mount, is a good model for usage. ++NIKITA-FIXME-HANS: this should be a mkreiserfs option not a mount option, do you agree? I don't think that specifying it at mount time, and then changing it with each mount, is a good model for usage. + + . mount option "plug" to set-up plugins of root-directory. + "plug=foo:bar" will set "bar" as default plugin of type "foo". @@ -59132,7 +59387,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + + . perm:acl + -+ . audi---audit plugin intercepting and possibly logging all ++ d audi---audit plugin intercepting and possibly logging all + accesses to object. Requires to put stub functions in file_operations + in stead of generic_file_*. + @@ -59157,10 +59412,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + but not for directories, how such plugins would be inherited? + . always store them with directories also + -+NIKTIA-FIXME-HANS: Do the line above. It is not exclusive of doing -+the line below which is also useful. ++NIKTIA-FIXME-HANS: Do the line above. It is not exclusive of doing the line below which is also useful. + + . use inheritance hierarchy, independent of file-system namespace ++ +*/ + +#include "../debug.h" @@ -59178,9 +59433,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + +#include /* for struct super_block */ + -+/* -+ * init_plugins - initialize plugin sub-system. -+ * Just call this once on reiser4 startup. ++/* public interface */ ++ ++/* initialise plugin sub-system. Just call this once on reiser4 startup. */ ++int init_plugins(void); ++int setup_plugins(struct super_block *super, reiser4_plugin ** area); ++int locate_plugin(struct inode *inode, plugin_locator * loc); ++ ++ ++/** ++ * init_plugins - initialize plugins + * + * Initializes plugin sub-system. It is part of reiser4 module + * initialization. For each plugin of each type init method is called and each @@ -59191,7 +59453,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + reiser4_plugin_type type_id; + + for (type_id = 0; type_id < REISER4_PLUGIN_TYPES; ++type_id) { -+ struct reiser4_plugin_type_data *ptype; ++ reiser4_plugin_type_data *ptype; + int i; + + ptype = &plugins[type_id]; @@ -59226,21 +59488,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p +} + +/* true if plugin type id is valid */ -+int is_plugin_type_valid(reiser4_plugin_type type) ++int is_type_id_valid(reiser4_plugin_type type_id /* plugin type id */ ) +{ -+ /* "type" is unsigned, so no comparison with 0 is ++ /* "type_id" is unsigned, so no comparison with 0 is + necessary */ -+ return (type < REISER4_PLUGIN_TYPES); ++ return (type_id < REISER4_PLUGIN_TYPES); +} + +/* true if plugin id is valid */ -+int is_plugin_id_valid(reiser4_plugin_type type, reiser4_plugin_id id) ++int is_plugin_id_valid(reiser4_plugin_type type_id /* plugin type id */ , ++ reiser4_plugin_id id /* plugin id */ ) +{ -+ assert("nikita-1653", is_plugin_type_valid(type)); -+ return id < plugins[type].builtin_num; ++ assert("nikita-1653", is_type_id_valid(type_id)); ++ return id < plugins[type_id].builtin_num; +} + -+/* return plugin by its @type and @id. ++/* return plugin by its @type_id and @id. + + Both arguments are checked for validness: this is supposed to be called + from user-level. @@ -59250,21 +59513,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p +comment really confused me on the first reading.... + +*/ -+reiser4_plugin *plugin_by_unsafe_id(reiser4_plugin_type type /* plugin type -+ * unchecked */, ++reiser4_plugin *plugin_by_unsafe_id(reiser4_plugin_type type_id /* plugin ++ * type id, ++ * unchecked */ , + reiser4_plugin_id id /* plugin id, -+ * unchecked */) ++ * unchecked */ ) +{ -+ if (is_plugin_type_valid(type)) { -+ if (is_plugin_id_valid(type, id)) -+ return plugin_at(&plugins[type], id); ++ if (is_type_id_valid(type_id)) { ++ if (is_plugin_id_valid(type_id, id)) ++ return plugin_at(&plugins[type_id], id); + else + /* id out of bounds */ + warning("nikita-2913", -+ "Invalid plugin id: [%i:%i]", type, id); ++ "Invalid plugin id: [%i:%i]", type_id, id); + } else + /* type_id out of bounds */ -+ warning("nikita-2914", "Invalid type_id: %i", type); ++ warning("nikita-2914", "Invalid type_id: %i", type_id); + return NULL; +} + @@ -59286,19 +59550,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p +} + +/* list of all plugins of given type */ -+struct list_head *get_plugin_list(reiser4_plugin_type type) ++struct list_head *get_plugin_list(reiser4_plugin_type type_id /* plugin type ++ * id */ ) +{ -+ assert("nikita-1056", is_plugin_type_valid(type)); -+ return &plugins[type].plugins_list; ++ assert("nikita-1056", is_type_id_valid(type_id)); ++ return &plugins[type_id].plugins_list; ++} ++ ++int grab_plugin(struct inode *self, struct inode *ancestor, pset_member memb) ++{ ++ reiser4_plugin *plug; ++ reiser4_inode *parent; ++ ++ parent = reiser4_inode_data(ancestor); ++ plug = pset_get(parent->hset, memb) ? : pset_get(parent->pset, memb); ++ return grab_plugin_from(self, memb, plug); +} + -+static void update_pset_mask(reiser4_inode * info, pset_member memb) ++static void update_plugin_mask(reiser4_inode * info, pset_member memb) +{ + struct dentry *rootdir; + reiser4_inode *root; + -+ assert("edward-1443", memb != PSET_FILE); -+ + rootdir = inode_by_reiser4_inode(info)->i_sb->s_root; + if (rootdir != NULL) { + root = reiser4_inode_data(rootdir->d_inode); @@ -59306,110 +59579,43 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + * if inode is different from the default one, or we are + * changing plugin of root directory, update plugin_mask + */ -+ if (aset_get(info->pset, memb) != -+ aset_get(root->pset, memb) || ++ if (pset_get(info->pset, memb) != pset_get(root->pset, memb) || + info == root) + info->plugin_mask |= (1 << memb); -+ else -+ info->plugin_mask &= ~(1 << memb); + } +} + -+/* Get specified plugin set member from parent, -+ or from fs-defaults (if no parent is given) and -+ install the result to pset of @self */ -+int grab_plugin_pset(struct inode *self, -+ struct inode *ancestor, -+ pset_member memb) ++int ++grab_plugin_from(struct inode *self, pset_member memb, reiser4_plugin * plug) +{ -+ reiser4_plugin *plug; + reiser4_inode *info; + int result = 0; + -+ /* Do not grab if initialised already. */ + info = reiser4_inode_data(self); -+ if (aset_get(info->pset, memb) != NULL) -+ return 0; -+ if (ancestor) { -+ reiser4_inode *parent; -+ -+ parent = reiser4_inode_data(ancestor); -+ plug = aset_get(parent->hset, memb) ? : -+ aset_get(parent->pset, memb); -+ } -+ else -+ plug = get_default_plugin(memb); -+ -+ result = set_plugin(&info->pset, memb, plug); -+ if (result == 0) { -+ if (!ancestor || self->i_sb->s_root->d_inode != self) -+ update_pset_mask(info, memb); -+ } -+ return result; -+} -+ -+/* Take missing pset members from root inode */ -+int finish_pset(struct inode *inode) -+{ -+ reiser4_plugin *plug; -+ reiser4_inode *root; -+ reiser4_inode *info; -+ pset_member memb; -+ int result = 0; -+ -+ root = reiser4_inode_data(inode->i_sb->s_root->d_inode); -+ info = reiser4_inode_data(inode); -+ -+ assert("edward-1455", root != NULL); -+ assert("edward-1456", info != NULL); -+ -+ /* file and directory plugins are already initialized. */ -+ for (memb = PSET_DIR + 1; memb < PSET_LAST; ++memb) { -+ -+ /* Do not grab if initialised already. */ -+ if (aset_get(info->pset, memb) != NULL) -+ continue; -+ -+ plug = aset_get(root->pset, memb); -+ result = set_plugin(&info->pset, memb, plug); -+ if (result != 0) -+ break; -+ } -+ if (result != 0) { -+ warning("nikita-3447", -+ "Cannot set up plugins for %lli", -+ (unsigned long long) -+ get_inode_oid(inode)); ++ if (pset_get(info->pset, memb) == NULL) { ++ result = pset_set(&info->pset, memb, plug); ++ if (result == 0) ++ update_plugin_mask(info, memb); + } + return result; +} + -+int force_plugin_pset(struct inode *self, pset_member memb, reiser4_plugin * plug) ++int force_plugin(struct inode *self, pset_member memb, reiser4_plugin * plug) +{ + reiser4_inode *info; + int result = 0; + -+ if (!self->i_sb->s_root || self->i_sb->s_root->d_inode == self) { -+ /* Changing pset in the root object. */ -+ return RETERR(-EINVAL); -+ } -+ + info = reiser4_inode_data(self); + if (plug->h.pops != NULL && plug->h.pops->change != NULL) -+ result = plug->h.pops->change(self, plug, memb); ++ result = plug->h.pops->change(self, plug); + else -+ result = aset_set_unsafe(&info->pset, memb, plug); -+ if (result == 0) { -+ __u16 oldmask = info->plugin_mask; -+ -+ update_pset_mask(info, memb); -+ if (oldmask != info->plugin_mask) -+ reiser4_inode_clr_flag(self, REISER4_SDLEN_KNOWN); -+ } ++ result = pset_set(&info->pset, memb, plug); ++ if (result == 0) ++ update_plugin_mask(info, memb); + return result; +} + -+struct reiser4_plugin_type_data plugins[REISER4_PLUGIN_TYPES] = { ++reiser4_plugin_type_data plugins[REISER4_PLUGIN_TYPES] = { + /* C90 initializers */ + [REISER4_FILE_PLUGIN_TYPE] = { + .type_id = REISER4_FILE_PLUGIN_TYPE, @@ -59555,6 +59761,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + .builtin = cluster_plugins, + .plugins_list = {NULL, NULL}, + .size = sizeof(cluster_plugin) ++ }, ++ [REISER4_REGULAR_PLUGIN_TYPE] = { ++ .type_id = REISER4_REGULAR_PLUGIN_TYPE, ++ .label = "regular", ++ .desc = "Defines kind of regular file", ++ .builtin_num = ++ sizeof_array(regular_plugins), ++ .builtin = regular_plugins, ++ .plugins_list = {NULL, NULL}, ++ .size = sizeof(regular_plugin) + } +}; + @@ -59567,10 +59783,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.c linux-2.6.22/fs/reiser4/p + * fill-column: 120 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/plugin/plugin.h ---- linux-2.6.22.orig/fs/reiser4/plugin/plugin.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/plugin.h 2007-07-29 00:25:34.996727537 +0400 -@@ -0,0 +1,899 @@ +Index: linux-2.6.16/fs/reiser4/plugin/plugin.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/plugin.h +@@ -0,0 +1,936 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Basic plugin data-types. @@ -59723,32 +59940,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + * them, and which are only invoked by other plugins. + */ + -+/* This should be incremented with each new contributed -+ pair (plugin type, plugin id). -+ NOTE: Make sure there is a release of reiser4progs -+ with the corresponding version number */ -+#define PLUGIN_LIBRARY_VERSION 0 -+ -+ /* enumeration of fields within plugin_set */ -+typedef enum { -+ PSET_FILE, -+ PSET_DIR, /* PSET_FILE and PSET_DIR should be first elements: -+ * inode.c:read_inode() depends on this. */ -+ PSET_PERM, -+ PSET_FORMATTING, -+ PSET_HASH, -+ PSET_FIBRATION, -+ PSET_SD, -+ PSET_DIR_ITEM, -+ PSET_CIPHER, -+ PSET_DIGEST, -+ PSET_COMPRESSION, -+ PSET_COMPRESSION_MODE, -+ PSET_CLUSTER, -+ PSET_CREATE, -+ PSET_LAST -+} pset_member; -+ +/* builtin file-plugins */ +typedef enum { + /* regular file */ @@ -59761,7 +59952,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + sockets */ + SPECIAL_FILE_PLUGIN_ID, + /* regular cryptcompress file */ -+ CRYPTCOMPRESS_FILE_PLUGIN_ID, ++ CRC_FILE_PLUGIN_ID, + /* number of file plugins. Used as size of arrays to hold + file plugins. */ + LAST_FILE_PLUGIN_ID @@ -60048,8 +60239,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p +typedef struct cipher_plugin { + /* generic fields */ + plugin_header h; -+ struct crypto_blkcipher * (*alloc) (void); -+ void (*free) (struct crypto_blkcipher * tfm); ++ struct crypto_tfm * (*alloc) (void); ++ void (*free) (struct crypto_tfm * tfm); + /* Offset translator. For each offset this returns (k * offset), where + k (k >= 1) is an expansion factor of the cipher algorithm. + For all symmetric algorithms k == 1. For asymmetric algorithms (which @@ -60075,8 +60266,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + plugin_header h; + /* fingerprint size in bytes */ + int fipsize; -+ struct crypto_hash * (*alloc) (void); -+ void (*free) (struct crypto_hash * tfm); ++ struct crypto_tfm * (*alloc) (void); ++ void (*free) (struct crypto_tfm * tfm); +} digest_plugin; + +typedef struct compression_plugin { @@ -60110,6 +60301,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + int (*discard_hook) (struct inode * inode, cloff_t index); +} compression_mode_plugin; + ++typedef struct regular_plugin { ++ /* generic fields */ ++ plugin_header h; ++ /* file plugin id which implements regular file */ ++ reiser4_file_id id; ++} regular_plugin; ++ +typedef struct cluster_plugin { + /* generic fields */ + plugin_header h; @@ -60168,7 +60366,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + int (*release) (struct super_block *); + jnode *(*log_super) (struct super_block *); + int (*check_open) (const struct inode * object); -+ int (*version_update) (struct super_block *); +} disk_format_plugin; + +struct jnode_plugin { @@ -60231,6 +60428,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + compression_mode_plugin compression_mode; + /* cluster plugin, used by object plugin */ + cluster_plugin clust; ++ /* regular plugin, used by directory plugin */ ++ regular_plugin regular; + /* place-holder for new plugin types that can be registered + dynamically, and used by other dynamically loaded plugins. */ + void *generic; @@ -60255,8 +60454,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + int alignment; + /* install itself into given inode. This can return error + (e.g., you cannot change hash of non-empty directory). */ -+ int (*change) (struct inode * inode, reiser4_plugin * plugin, -+ pset_member memb); ++ int (*change) (struct inode * inode, reiser4_plugin * plugin); + /* install itself into given inode. This can return error + (e.g., you cannot change hash of non-empty directory). */ + int (*inherit) (struct inode * inode, struct inode * parent, @@ -60267,6 +60465,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + +/* stores plugin reference in reiser4-specific part of inode */ +extern int set_object_plugin(struct inode *inode, reiser4_plugin_id id); ++extern int setup_plugins(struct super_block *super, reiser4_plugin ** area); +extern int init_plugins(void); + +/* builtin plugins */ @@ -60286,6 +60485,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + +typedef enum { + NONE_CIPHER_ID, ++ AES_CIPHER_ID, + LAST_CIPHER_ID +} reiser4_cipher_id; + @@ -60299,11 +60499,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p +/* builtin compression mode plugins */ +typedef enum { + NONE_COMPRESSION_MODE_ID, -+ LATTD_COMPRESSION_MODE_ID, -+ ULTIM_COMPRESSION_MODE_ID, ++ COL_8_COMPRESSION_MODE_ID, ++ COL_16_COMPRESSION_MODE_ID, ++ COL_32_COMPRESSION_MODE_ID, ++ COZ_COMPRESSION_MODE_ID, + FORCE_COMPRESSION_MODE_ID, -+ CONVX_COMPRESSION_MODE_ID, -+ LAST_COMPRESSION_MODE_ID ++ TEST_COMPRESSION_MODE_ID, ++ LAST_COMPRESSION_MODE_ID +} reiser4_compression_mode_id; + +/* builtin cluster plugins */ @@ -60316,6 +60518,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + LAST_CLUSTER_ID +} reiser4_cluster_id; + ++/* builtin regular plugins */ ++typedef enum { ++ UF_REGULAR_ID, ++ CRC_REGULAR_ID, ++ LAST_REGULAR_ID ++} reiser4_regular_id; ++ +/* builtin tail-plugins */ + +typedef enum { @@ -60325,6 +60534,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + LAST_TAIL_FORMATTING_ID +} reiser4_formatting_id; + ++/* compression/clustering specific data */ ++typedef struct compression_data { ++ reiser4_compression_id coa; /* id of the compression algorithm */ ++} compression_data_t; ++ ++typedef __u8 cluster_data_t; /* cluster info */ ++ +/* data type used to pack parameters that we pass to vfs object creation + function create_object() */ +struct reiser4_object_create_data { @@ -60340,7 +60556,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + /* add here something for non-standard objects you invent, like + query for interpolation file etc. */ + -+ struct reiser4_crypto_info * crypto; ++ crypto_stat_t * crypto; ++ compression_data_t *compression; ++ cluster_data_t *cluster; + + struct inode *parent; + struct dentry *dentry; @@ -60368,6 +60586,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p +#define MAX_PLUGIN_TYPE_LABEL_LEN 32 +#define MAX_PLUGIN_PLUG_LABEL_LEN 32 + ++/* used for interface with user-land: table-driven parsing in ++ reiser4(). */ ++typedef struct plugin_locator { ++ reiser4_plugin_type type_id; ++ reiser4_plugin_id id; ++ char type_label[MAX_PLUGIN_TYPE_LABEL_LEN]; ++ char plug_label[MAX_PLUGIN_PLUG_LABEL_LEN]; ++} plugin_locator; ++ ++extern int locate_plugin(struct inode *inode, plugin_locator * loc); ++ ++ +#define PLUGIN_BY_ID(TYPE,ID,FIELD) \ +static inline TYPE *TYPE ## _by_id( reiser4_plugin_id id ) \ +{ \ @@ -60411,6 +60641,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p +PLUGIN_BY_ID(compression_mode_plugin, REISER4_COMPRESSION_MODE_PLUGIN_TYPE, + compression_mode); +PLUGIN_BY_ID(cluster_plugin, REISER4_CLUSTER_PLUGIN_TYPE, clust); ++PLUGIN_BY_ID(regular_plugin, REISER4_REGULAR_PLUGIN_TYPE, regular); + +extern int save_plugin_id(reiser4_plugin * plugin, d16 * area); + @@ -60422,9 +60653,30 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + plugin = list_entry(plugin->h.linkage.next, reiser4_plugin, h.linkage)) + + -+extern int grab_plugin_pset(struct inode *self, struct inode *ancestor, pset_member memb); -+extern int force_plugin_pset(struct inode *self, pset_member memb, reiser4_plugin *plug); -+extern int finish_pset(struct inode *inode); ++/* enumeration of fields within plugin_set */ ++typedef enum { ++ PSET_FILE, ++ PSET_DIR, /* PSET_FILE and PSET_DIR should be first elements: ++ * inode.c:read_inode() depends on this. */ ++ PSET_PERM, ++ PSET_FORMATTING, ++ PSET_HASH, ++ PSET_FIBRATION, ++ PSET_SD, ++ PSET_DIR_ITEM, ++ PSET_CIPHER, ++ PSET_DIGEST, ++ PSET_COMPRESSION, ++ PSET_COMPRESSION_MODE, ++ PSET_CLUSTER, ++ PSET_REGULAR_ENTRY, ++ PSET_LAST ++} pset_member; ++ ++int grab_plugin(struct inode *self, struct inode *ancestor, pset_member memb); ++int grab_plugin_from(struct inode *self, pset_member memb, ++ reiser4_plugin * plug); ++int force_plugin(struct inode *self, pset_member memb, reiser4_plugin * plug); + +/* defined in fs/reiser4/plugin/object.c */ +extern file_plugin file_plugins[LAST_FILE_PLUGIN_ID]; @@ -60447,6 +60699,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p +compression_mode_plugins[LAST_COMPRESSION_MODE_ID]; +/* defined in fs/reiser4/plugin/cluster.c */ +extern cluster_plugin cluster_plugins[LAST_CLUSTER_ID]; ++/* defined in fs/reiser4/plugin/regular.c */ ++extern regular_plugin regular_plugins[LAST_REGULAR_ID]; +/* defined in fs/reiser4/plugin/tail.c */ +extern formatting_plugin formatting_plugins[LAST_TAIL_FORMATTING_ID]; +/* defined in fs/reiser4/plugin/security/security.c */ @@ -60470,10 +60724,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin.h linux-2.6.22/fs/reiser4/p + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/reiser4/plugin/plugin_header.h ---- linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/plugin_header.h 2007-07-29 00:25:34.996727537 +0400 -@@ -0,0 +1,155 @@ +Index: linux-2.6.16/fs/reiser4/plugin/plugin_header.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/plugin_header.h +@@ -0,0 +1,136 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* plugin header. Data structures required by all plugin types. */ @@ -60486,43 +60741,27 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re +#include "../debug.h" +#include "../dformat.h" + -+/* Every plugin type can be considered as a class of virtual objects -+ {(type, i) | i = 0, 1, ...}, which has one the following categories -+ of virtualization: -+ A - no virtualization; -+ F - per-file virtualization; -+ S - per-superblock virtualization; -+ FIXME-EDWARD: Define every such category */ -+ -+/* Supported plugin types: (id, (virtualization category), short description) */ +typedef enum { -+ REISER4_FILE_PLUGIN_TYPE, /* (F) service VFS enry-points */ -+ REISER4_DIR_PLUGIN_TYPE, /* (F) service VFS enry-points */ -+ REISER4_ITEM_PLUGIN_TYPE, /* (F) manage items */ -+ REISER4_NODE_PLUGIN_TYPE, /* (S) manage formatted nodes */ -+ REISER4_HASH_PLUGIN_TYPE, /* (F) compute hash */ -+ REISER4_FIBRATION_PLUGIN_TYPE, /* (F) directory fibrations */ -+ REISER4_FORMATTING_PLUGIN_TYPE, /* (F) tail-packing policy */ -+ REISER4_PERM_PLUGIN_TYPE, /* stub (vacancy) */ -+ REISER4_SD_EXT_PLUGIN_TYPE, /* (A) stat-data extensions */ -+ REISER4_FORMAT_PLUGIN_TYPE, /* (S) specify disk format */ -+ REISER4_JNODE_PLUGIN_TYPE, /* (A) in-memory node headers */ -+ REISER4_CIPHER_PLUGIN_TYPE, /* (F) cipher transform algs */ -+ REISER4_DIGEST_PLUGIN_TYPE, /* (F) digest transform algs */ -+ REISER4_COMPRESSION_PLUGIN_TYPE, /* (F) compression tfm algs */ -+ REISER4_COMPRESSION_MODE_PLUGIN_TYPE, /* (F) compression heuristic */ -+ REISER4_CLUSTER_PLUGIN_TYPE, /* (F) size of logical cluster */ ++ REISER4_FILE_PLUGIN_TYPE, ++ REISER4_DIR_PLUGIN_TYPE, ++ REISER4_ITEM_PLUGIN_TYPE, ++ REISER4_NODE_PLUGIN_TYPE, ++ REISER4_HASH_PLUGIN_TYPE, ++ REISER4_FIBRATION_PLUGIN_TYPE, ++ REISER4_FORMATTING_PLUGIN_TYPE, ++ REISER4_PERM_PLUGIN_TYPE, ++ REISER4_SD_EXT_PLUGIN_TYPE, ++ REISER4_FORMAT_PLUGIN_TYPE, ++ REISER4_JNODE_PLUGIN_TYPE, ++ REISER4_CIPHER_PLUGIN_TYPE, ++ REISER4_DIGEST_PLUGIN_TYPE, ++ REISER4_COMPRESSION_PLUGIN_TYPE, ++ REISER4_COMPRESSION_MODE_PLUGIN_TYPE, ++ REISER4_CLUSTER_PLUGIN_TYPE, ++ REISER4_REGULAR_PLUGIN_TYPE, + REISER4_PLUGIN_TYPES +} reiser4_plugin_type; + -+/* Supported plugin groups */ -+typedef enum { -+ REISER4_DIRECTORY_FILE, -+ REISER4_REGULAR_FILE, -+ REISER4_SYMLINK_FILE, -+ REISER4_SPECIAL_FILE, -+} file_plugin_group; -+ +struct reiser4_plugin_ops; +/* generic plugin operations, supported by each + plugin type. */ @@ -60534,8 +60773,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re + reiser4_plugin_type type_id; + /* id of this plugin */ + reiser4_plugin_id id; -+ /* bitmask of groups the plugin belongs to. */ -+ reiser4_plugin_groups groups; + /* plugin operations */ + reiser4_plugin_ops *pops; +/* NIKITA-FIXME-HANS: usage of and access to label and desc is not commented and defined. */ @@ -60547,12 +60784,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re + struct list_head linkage; +} plugin_header; + -+#define plugin_of_group(plug, group) (plug->h.groups & (1 << group)) -+ +/* PRIVATE INTERFACES */ +/* NIKITA-FIXME-HANS: what is this for and why does it duplicate what is in plugin_header? */ +/* plugin type representation. */ -+struct reiser4_plugin_type_data { ++typedef struct reiser4_plugin_type_data { + /* internal plugin type identifier. Should coincide with + index of this item in plugins[] array. */ + reiser4_plugin_type type_id; @@ -60569,15 +60804,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re + void *builtin; + struct list_head plugins_list; + size_t size; -+}; ++} reiser4_plugin_type_data; + -+extern struct reiser4_plugin_type_data plugins[REISER4_PLUGIN_TYPES]; ++extern reiser4_plugin_type_data plugins[REISER4_PLUGIN_TYPES]; + -+int is_plugin_type_valid(reiser4_plugin_type type); -+int is_plugin_id_valid(reiser4_plugin_type type, reiser4_plugin_id id); ++int is_type_id_valid(reiser4_plugin_type type_id); ++int is_plugin_id_valid(reiser4_plugin_type type_id, reiser4_plugin_id id); + -+static inline reiser4_plugin *plugin_at(struct reiser4_plugin_type_data * ptype, -+ int i) ++static inline reiser4_plugin *plugin_at(reiser4_plugin_type_data * ptype, int i) +{ + char *builtin; + @@ -60586,12 +60820,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re +} + +/* return plugin by its @type_id and @id */ -+static inline reiser4_plugin *plugin_by_id(reiser4_plugin_type type, -+ reiser4_plugin_id id) ++static inline reiser4_plugin *plugin_by_id(reiser4_plugin_type type_id ++ /* plugin type id */ , ++ reiser4_plugin_id id /* plugin id */ ++ ) +{ -+ assert("nikita-1651", is_plugin_type_valid(type)); -+ assert("nikita-1652", is_plugin_id_valid(type, id)); -+ return plugin_at(&plugins[type], id); ++ assert("nikita-1651", is_type_id_valid(type_id)); ++ assert("nikita-1652", is_plugin_id_valid(type_id, id)); ++ return plugin_at(&plugins[type_id], id); +} + +extern reiser4_plugin *plugin_by_unsafe_id(reiser4_plugin_type type_id, @@ -60629,33 +60865,32 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_header.h linux-2.6.22/fs/re + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reiser4/plugin/plugin_set.c ---- linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/plugin_set.c 2007-07-29 00:25:35.000728572 +0400 -@@ -0,0 +1,379 @@ +Index: linux-2.6.16/fs/reiser4/plugin/plugin_set.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/plugin_set.c +@@ -0,0 +1,378 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ -+/* This file contains Reiser4 plugin set operations */ -+ -+/* plugin sets -+ * -+ * Each file in reiser4 is controlled by a whole set of plugins (file plugin, -+ * directory plugin, hash plugin, tail policy plugin, security plugin, etc.) -+ * assigned (inherited, deduced from mode bits, etc.) at creation time. This -+ * set of plugins (so called pset) is described by structure plugin_set (see -+ * plugin/plugin_set.h), which contains pointers to all required plugins. -+ * -+ * Children can inherit some pset members from their parent, however sometimes -+ * it is useful to specify members different from parent ones. Since object's -+ * pset can not be easily changed without fatal consequences, we use for this -+ * purpose another special plugin table (so called hset, or heir set) described -+ * by the same structure. -+ * -+ * Inode only stores a pointers to pset and hset. Different inodes with the -+ * same set of pset (hset) members point to the same pset (hset). This is -+ * archived by storing psets and hsets in global hash table. Races are avoided -+ * by simple (and efficient so far) solution of never recycling psets, even -+ * when last inode pointing to it is destroyed. ++/* NIKITA-FIXME-HANS: you didn't discuss this with me before coding it did you? Remove plugin-sets from code by March 15th, 2004 */ ++/* plugin-sets */ ++ ++/* ++ * Each inode comes with a whole set of plugins: file plugin, directory ++ * plugin, hash plugin, tail policy plugin, security plugin, etc. ++ * ++ * Storing them (pointers to them, that is) in inode is a waste of ++ * space. Especially, given that on average file system plugins of vast ++ * majority of files will belong to few sets (e.g., one set for regular files, ++ * another set for standard directory, etc.) ++ * ++ * Plugin set (pset) is an object containing pointers to all plugins required ++ * by inode. Inode only stores a pointer to pset. psets are "interned", that ++ * is, different inodes with the same set of plugins point to the same ++ * pset. This is archived by storing psets in global hash table. Races are ++ * avoided by simple (and efficient so far) solution of never recycling psets, ++ * even when last inode pointing to it is destroyed. ++ * + */ + +#include "../debug.h" @@ -60666,7 +60901,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise +#include + +/* slab for plugin sets */ -+static struct kmem_cache *plugin_set_slab; ++static kmem_cache_t *plugin_set_slab; + +static spinlock_t plugin_set_lock[8] __cacheline_aligned_in_smp = { + [0 ... 7] = SPIN_LOCK_UNLOCKED @@ -60702,8 +60937,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + sizeof set1->digest + + sizeof set1->compression + + sizeof set1->compression_mode + -+ sizeof set1->cluster + -+ sizeof set1->create); ++ sizeof set1->cluster + sizeof set1->regular_entry); + + set1 = cast_to(a1); + set2 = cast_to(a2); @@ -60722,7 +60956,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + set1->compression == set2->compression && + set1->compression_mode == set2->compression_mode && + set1->cluster == set2->cluster && -+ set1->create == set2->create; ++ set1->regular_entry == set2->regular_entry; +} + +#define HASH_FIELD(hash, set, field) \ @@ -60748,7 +60982,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + HASH_FIELD(result, set, compression); + HASH_FIELD(result, set, compression_mode); + HASH_FIELD(result, set, cluster); -+ HASH_FIELD(result, set, create); ++ HASH_FIELD(result, set, regular_entry); + return result & (PS_TABLE_SIZE - 1); +} + @@ -60759,7 +60993,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise +} + +/* The hash table definition */ -+#define KMALLOC(size) kmalloc((size), reiser4_ctx_gfp_mask_get()) ++#define KMALLOC(size) kmalloc((size), get_gfp_mask()) +#define KFREE(ptr, size) kfree(ptr) +TYPE_SAFE_HASH_DEFINE(ps, plugin_set, unsigned long, hashval, link, pshash, + pseq); @@ -60782,7 +61016,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + .compression = NULL, + .compression_mode = NULL, + .cluster = NULL, -+ .create = NULL, ++ .regular_entry = NULL, + .link = {NULL} +}; + @@ -60824,8 +61058,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + twin = ps_hash_find(&ps_table, &replica.hashval); + if (unlikely(twin == NULL)) { + rcu_read_unlock(); -+ psal = kmem_cache_alloc(plugin_set_slab, -+ reiser4_ctx_gfp_mask_get()); ++ psal = kmem_cache_alloc(plugin_set_slab, get_gfp_mask()); + if (psal == NULL) + return RETERR(-ENOMEM); + *psal = replica; @@ -60849,123 +61082,126 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + +static struct { + int offset; -+ reiser4_plugin_groups groups; + reiser4_plugin_type type; +} pset_descr[PSET_LAST] = { + [PSET_FILE] = { + .offset = offsetof(plugin_set, file), -+ .type = REISER4_FILE_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_FILE_PLUGIN_TYPE + }, + [PSET_DIR] = { + .offset = offsetof(plugin_set, dir), -+ .type = REISER4_DIR_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_DIR_PLUGIN_TYPE + }, + [PSET_PERM] = { + .offset = offsetof(plugin_set, perm), -+ .type = REISER4_PERM_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_PERM_PLUGIN_TYPE + }, + [PSET_FORMATTING] = { + .offset = offsetof(plugin_set, formatting), -+ .type = REISER4_FORMATTING_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_FORMATTING_PLUGIN_TYPE + }, + [PSET_HASH] = { + .offset = offsetof(plugin_set, hash), -+ .type = REISER4_HASH_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_HASH_PLUGIN_TYPE + }, + [PSET_FIBRATION] = { + .offset = offsetof(plugin_set, fibration), -+ .type = REISER4_FIBRATION_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_FIBRATION_PLUGIN_TYPE + }, + [PSET_SD] = { + .offset = offsetof(plugin_set, sd), -+ .type = REISER4_ITEM_PLUGIN_TYPE, -+ .groups = (1 << STAT_DATA_ITEM_TYPE) ++ .type = REISER4_ITEM_PLUGIN_TYPE + }, + [PSET_DIR_ITEM] = { + .offset = offsetof(plugin_set, dir_item), -+ .type = REISER4_ITEM_PLUGIN_TYPE, -+ .groups = (1 << DIR_ENTRY_ITEM_TYPE) ++ .type = REISER4_ITEM_PLUGIN_TYPE + }, + [PSET_CIPHER] = { + .offset = offsetof(plugin_set, cipher), -+ .type = REISER4_CIPHER_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_CIPHER_PLUGIN_TYPE + }, + [PSET_DIGEST] = { + .offset = offsetof(plugin_set, digest), -+ .type = REISER4_DIGEST_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_DIGEST_PLUGIN_TYPE + }, + [PSET_COMPRESSION] = { + .offset = offsetof(plugin_set, compression), -+ .type = REISER4_COMPRESSION_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_COMPRESSION_PLUGIN_TYPE + }, + [PSET_COMPRESSION_MODE] = { + .offset = offsetof(plugin_set, compression_mode), -+ .type = REISER4_COMPRESSION_MODE_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_COMPRESSION_MODE_PLUGIN_TYPE + }, + [PSET_CLUSTER] = { + .offset = offsetof(plugin_set, cluster), -+ .type = REISER4_CLUSTER_PLUGIN_TYPE, -+ .groups = 0 ++ .type = REISER4_CLUSTER_PLUGIN_TYPE + }, -+ [PSET_CREATE] = { -+ .offset = offsetof(plugin_set, create), -+ .type = REISER4_FILE_PLUGIN_TYPE, -+ .groups = (1 << REISER4_REGULAR_FILE) ++ [PSET_REGULAR_ENTRY] = { ++ .offset = offsetof(plugin_set, regular_entry), ++ .type = REISER4_REGULAR_PLUGIN_TYPE + } +}; + -+#define DEFINE_PSET_OPS(PREFIX) \ -+ reiser4_plugin_type PREFIX##_member_to_type_unsafe(pset_member memb) \ -+{ \ -+ if (memb > PSET_LAST) \ -+ return REISER4_PLUGIN_TYPES; \ -+ return pset_descr[memb].type; \ -+} \ -+ \ -+int PREFIX##_set_unsafe(plugin_set ** set, pset_member memb, \ -+ reiser4_plugin * plugin) \ -+{ \ -+ assert("nikita-3492", set != NULL); \ -+ assert("nikita-3493", *set != NULL); \ -+ assert("nikita-3494", plugin != NULL); \ -+ assert("nikita-3495", 0 <= memb && memb < PSET_LAST); \ -+ assert("nikita-3496", plugin->h.type_id == pset_descr[memb].type); \ -+ \ -+ if (pset_descr[memb].groups) \ -+ if (!(pset_descr[memb].groups & plugin->h.groups)) \ -+ return -EINVAL; \ -+ \ -+ return plugin_set_field(set, \ -+ (unsigned long)plugin, pset_descr[memb].offset); \ -+} \ -+ \ -+reiser4_plugin *PREFIX##_get(plugin_set * set, pset_member memb) \ -+{ \ -+ assert("nikita-3497", set != NULL); \ -+ assert("nikita-3498", 0 <= memb && memb < PSET_LAST); \ -+ \ -+ return *(reiser4_plugin **) (((char *)set) + pset_descr[memb].offset); \ -+} -+ -+DEFINE_PSET_OPS(aset); -+ -+int set_plugin(plugin_set ** set, pset_member memb, reiser4_plugin * plugin) { ++#if REISER4_DEBUG ++static reiser4_plugin_type pset_member_to_type(pset_member memb) ++{ ++ assert("nikita-3501", 0 <= memb && memb < PSET_LAST); ++ return pset_descr[memb].type; ++} ++#endif ++ ++reiser4_plugin_type pset_member_to_type_unsafe(pset_member memb) ++{ ++ if (0 <= memb && memb < PSET_LAST) ++ return pset_descr[memb].type; ++ else ++ return REISER4_PLUGIN_TYPES; ++} ++ ++int pset_set(plugin_set ** set, pset_member memb, reiser4_plugin * plugin) ++{ ++ assert("nikita-3492", set != NULL); ++ assert("nikita-3493", *set != NULL); ++ assert("nikita-3494", plugin != NULL); ++ assert("nikita-3495", 0 <= memb && memb < PSET_LAST); ++ assert("nikita-3496", plugin->h.type_id == pset_member_to_type(memb)); ++ + return plugin_set_field(set, -+ (unsigned long)plugin, pset_descr[memb].offset); ++ (unsigned long)plugin, pset_descr[memb].offset); +} + ++reiser4_plugin *pset_get(plugin_set * set, pset_member memb) ++{ ++ assert("nikita-3497", set != NULL); ++ assert("nikita-3498", 0 <= memb && memb < PSET_LAST); ++ ++ return *(reiser4_plugin **) (((char *)set) + pset_descr[memb].offset); ++} ++ ++#define DEFINE_PLUGIN_SET(type, field) \ ++int plugin_set_ ## field(plugin_set **set, type *val) \ ++{ \ ++ cassert(sizeof val == sizeof(unsigned long)); \ ++ return plugin_set_field(set, (unsigned long)val, \ ++ offsetof(plugin_set, field)); \ ++} ++ ++DEFINE_PLUGIN_SET(file_plugin, file) ++ DEFINE_PLUGIN_SET(dir_plugin, dir) ++ DEFINE_PLUGIN_SET(formatting_plugin, formatting) ++ DEFINE_PLUGIN_SET(hash_plugin, hash) ++ DEFINE_PLUGIN_SET(fibration_plugin, fibration) ++ DEFINE_PLUGIN_SET(item_plugin, sd) ++ /* DEFINE_PLUGIN_SET(cipher_plugin, cipher) */ ++ /* DEFINE_PLUGIN_SET(digest_plugin, digest) */ ++ DEFINE_PLUGIN_SET(compression_plugin, compression) ++ /* DEFINE_PLUGIN_SET(compression_mode_plugin, compression_mode) */ ++ DEFINE_PLUGIN_SET(cluster_plugin, cluster) ++ /* DEFINE_PLUGIN_SET(regular_plugin, regular_entry) */ ++ ++ +/** -+ * init_plugin_set - create plugin set cache and hash table ++ * init_plugin_set - create pset cache and hash table + * + * Initializes slab cache of plugin_set-s and their hash table. It is part of + * reiser4 module initialization. @@ -61012,14 +61248,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.c linux-2.6.22/fs/reise + * fill-column: 120 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.h linux-2.6.22/fs/reiser4/plugin/plugin_set.h ---- linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/plugin_set.h 2007-07-29 00:25:35.000728572 +0400 -@@ -0,0 +1,77 @@ +Index: linux-2.6.16/fs/reiser4/plugin/plugin_set.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/plugin_set.h +@@ -0,0 +1,83 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + -+/* Reiser4 plugin set definition. -+ See fs/reiser4/plugin/plugin_set.c for details */ ++/* plugin-sets. see fs/reiser4/plugin/plugin_set.c for details */ + +#if !defined( __PLUGIN_SET_H__ ) +#define __PLUGIN_SET_H__ @@ -61062,24 +61298,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.h linux-2.6.22/fs/reise + compression_mode_plugin *compression_mode; + /* cluster plugin */ + cluster_plugin *cluster; -+ /* this specifies file plugin of regular children. -+ only meaningful for directories */ -+ file_plugin *create; ++ /* plugin of regular child should be created */ ++ regular_plugin *regular_entry; + ps_hash_link link; +}; + +extern plugin_set *plugin_set_get_empty(void); +extern void plugin_set_put(plugin_set * set); + ++extern int plugin_set_file(plugin_set ** set, file_plugin * plug); ++extern int plugin_set_dir(plugin_set ** set, dir_plugin * plug); ++extern int plugin_set_formatting(plugin_set ** set, formatting_plugin * plug); ++extern int plugin_set_hash(plugin_set ** set, hash_plugin * plug); ++extern int plugin_set_fibration(plugin_set ** set, fibration_plugin * plug); ++extern int plugin_set_sd(plugin_set ** set, item_plugin * plug); ++extern int plugin_set_compression(plugin_set ** set, compression_plugin * plug); ++extern int plugin_set_cluster(plugin_set ** set, cluster_plugin * plug); ++ +extern int init_plugin_set(void); +extern void done_plugin_set(void); + -+extern reiser4_plugin *aset_get(plugin_set * set, pset_member memb); -+extern int set_plugin(plugin_set ** set, pset_member memb, -+ reiser4_plugin * plugin); -+extern int aset_set_unsafe(plugin_set ** set, pset_member memb, -+ reiser4_plugin * plugin); -+extern reiser4_plugin_type aset_member_to_type_unsafe(pset_member memb); ++extern int pset_set(plugin_set ** set, pset_member memb, ++ reiser4_plugin * plugin); ++extern reiser4_plugin *pset_get(plugin_set * set, pset_member memb); ++ ++extern reiser4_plugin_type pset_member_to_type_unsafe(pset_member memb); + +/* __PLUGIN_SET_H__ */ +#endif @@ -61093,23 +61336,74 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/plugin_set.h linux-2.6.22/fs/reise + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/Makefile linux-2.6.22/fs/reiser4/plugin/security/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/security/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/security/Makefile 2007-07-29 00:25:35.000728572 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/regular.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/regular.c +@@ -0,0 +1,44 @@ ++/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ ++ ++/* Contains Reiser4 regular plugins which: ++ . specify a set of reiser4 regular object plugins, ++ . used by directory plugin to create entries powered by specified ++ regular plugins */ ++ ++#include "plugin.h" ++ ++regular_plugin regular_plugins[LAST_REGULAR_ID] = { ++ [UF_REGULAR_ID] = { ++ .h = { ++ .type_id = REISER4_REGULAR_PLUGIN_TYPE, ++ .id = UF_REGULAR_ID, ++ .pops = NULL, ++ .label = "unixfile", ++ .desc = "Unix file regular plugin", ++ .linkage = {NULL, NULL} ++ }, ++ .id = UNIX_FILE_PLUGIN_ID ++ }, ++ [CRC_REGULAR_ID] = { ++ .h = { ++ .type_id = REISER4_REGULAR_PLUGIN_TYPE, ++ .id = CRC_REGULAR_ID, ++ .pops = NULL, ++ .label = "cryptcompress", ++ .desc = "Cryptcompress regular plugin", ++ .linkage = {NULL, NULL} ++ }, ++ .id = CRC_FILE_PLUGIN_ID ++ } ++}; ++ ++/* ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 120 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/security/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/security/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_REISER4_FS) += security_plugins.o + +security_plugins-objs := \ + perm.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.c linux-2.6.22/fs/reiser4/plugin/security/perm.c ---- linux-2.6.22.orig/fs/reiser4/plugin/security/perm.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/security/perm.c 2007-07-29 00:25:35.000728572 +0400 -@@ -0,0 +1,33 @@ +Index: linux-2.6.16/fs/reiser4/plugin/security/perm.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/security/perm.c +@@ -0,0 +1,44 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* -+ * This file contains implementation of permission plugins. -+ * See the comments in perm.h ++ * this file contains implementation of permission plugins. Currently, only ++ * RWX_PERM_ID is implemented + */ + +#include "../plugin.h" @@ -61125,7 +61419,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.c linux-2.6.22/fs/re + .label = "null", + .desc = "stub permission plugin", + .linkage = {NULL, NULL} -+ } ++ }, ++ .read_ok = NULL, ++ .write_ok = NULL, ++ .lookup_ok = NULL, ++ .create_ok = NULL, ++ .link_ok = NULL, ++ .unlink_ok = NULL, ++ .delete_ok = NULL, ++ .mask_ok = NULL, ++ .setattr_ok = NULL, ++ .getattr_ok = NULL, ++ .rename_ok = NULL, + } +}; + @@ -61138,10 +61443,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.c linux-2.6.22/fs/re + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.h linux-2.6.22/fs/reiser4/plugin/security/perm.h ---- linux-2.6.22.orig/fs/reiser4/plugin/security/perm.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/security/perm.h 2007-07-29 00:25:35.000728572 +0400 -@@ -0,0 +1,38 @@ +Index: linux-2.6.16/fs/reiser4/plugin/security/perm.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/security/perm.h +@@ -0,0 +1,82 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Perm (short for "permissions") plugins common stuff. */ @@ -61153,17 +61459,61 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.h linux-2.6.22/fs/re +#include "../plugin_header.h" + +#include ++#include /* for struct file */ ++#include /* for struct dentry */ ++ ++/* interface for perm plugin. ++ ++ Perm plugin method can be implemented through: ++ ++ 1. consulting ->i_mode bits in stat data + -+/* Definition of permission plugin */ -+/* NIKITA-FIXME-HANS: define what this is targeted for. -+ It does not seem to be intended for use with sys_reiser4. Explain. */ ++ 2. obtaining acl from the tree and inspecting it + -+/* NOTE-EDWARD: This seems to be intended for deprecated sys_reiser4. -+ Consider it like a temporary "seam" and reserved pset member. -+ If you have something usefull to add, then rename this plugin and add here */ ++ 3. asking some kernel module or user-level program to authorize access. ++ ++ This allows for integration with things like capabilities, SELinux-style ++ secutiry contexts, etc. ++ ++*/ ++/* NIKITA-FIXME-HANS: define what this is targeted for. It does not seem to be intended for use with sys_reiser4. Explain. */ +typedef struct perm_plugin { + /* generic plugin fields */ + plugin_header h; ++ ++ /* check permissions for read/write */ ++ int (*read_ok) (struct file *file, const char __user *buf, ++ size_t size, loff_t *off); ++ int (*write_ok) (struct file *file, const char __user *buf, ++ size_t size, loff_t *off); ++ ++ /* check permissions for lookup */ ++ int (*lookup_ok) (struct inode * parent, struct dentry * dentry); ++ ++ /* check permissions for create */ ++ int (*create_ok) (struct inode * parent, struct dentry * dentry, ++ reiser4_object_create_data * data); ++ ++ /* check permissions for linking @where to @existing */ ++ int (*link_ok) (struct dentry * existing, struct inode * parent, ++ struct dentry * where); ++ ++ /* check permissions for unlinking @victim from @parent */ ++ int (*unlink_ok) (struct inode * parent, struct dentry * victim); ++ ++ /* check permissions for deletion of @object whose last reference is ++ by @parent */ ++ int (*delete_ok) (struct inode * parent, struct dentry * victim); ++ int (*mask_ok) (struct inode * inode, int mask); ++ /* check whether attribute change is acceptable */ ++ int (*setattr_ok) (struct dentry * dentry, struct iattr * attr); ++ ++ /* check whether stat(2) is allowed */ ++ int (*getattr_ok) (struct vfsmount * mnt UNUSED_ARG, ++ struct dentry * dentry, struct kstat * stat); ++ /* check whether rename(2) is allowed */ ++ int (*rename_ok) (struct inode * old_dir, struct dentry * old, ++ struct inode * new_dir, struct dentry * new); +} perm_plugin; + +typedef enum { NULL_PERM_ID, LAST_PERM_ID } reiser4_perm_id; @@ -61180,10 +61530,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/security/perm.h linux-2.6.22/fs/re + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/reiser4/plugin/space/bitmap.c ---- linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/space/bitmap.c 2007-07-29 00:25:35.004729608 +0400 -@@ -0,0 +1,1585 @@ +Index: linux-2.6.16/fs/reiser4/plugin/space/Makefile +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/space/Makefile +@@ -0,0 +1,4 @@ ++obj-$(CONFIG_REISER4_FS) += space_plugins.o ++ ++space_plugins-objs := \ ++ bitmap.o +Index: linux-2.6.16/fs/reiser4/plugin/space/bitmap.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/space/bitmap.c +@@ -0,0 +1,1592 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#include "../../debug.h" @@ -61199,7 +61559,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + +#include +#include /* for struct super_block */ -+#include ++#include ++#include +#include + +/* Proposed (but discarded) optimization: dynamic loading/unloading of bitmap @@ -61257,7 +61618,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +/* Block allocation/deallocation are done through special bitmap objects which + are allocated in an array at fs mount. */ +struct bitmap_node { -+ struct mutex mutex; /* long term lock object */ ++ struct semaphore sema; /* long term lock object */ + + jnode *wjnode; /* j-nodes for WORKING ... */ + jnode *cjnode; /* ... and COMMIT bitmap blocks */ @@ -61493,6 +61854,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + int last_bit; + int nr; + ++ assert("zam-961", high_off >= 0); + assert("zam-962", high_off >= low_off); + + last_word = high_off >> LONG_INT_SHIFT; @@ -61802,7 +62164,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + + assert("zam-455", start != NULL); + assert("zam-437", *start != 0); -+ assert("zam-541", !reiser4_blocknr_is_fake(start)); ++ assert("zam-541", !blocknr_is_fake(start)); + assert("zam-441", *start < reiser4_block_count(sb)); + + if (len != NULL) { @@ -61887,7 +62249,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +{ + memset(bnode, 0, sizeof(struct bitmap_node)); + -+ mutex_init(&bnode->mutex); ++ sema_init(&bnode->sema, 1); + atomic_set(&bnode->loaded, 0); +} + @@ -61913,8 +62275,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +} + +/* ZAM-FIXME-HANS: comment this. Called only by load_and_lock_bnode()*/ -+static int prepare_bnode(struct bitmap_node *bnode, jnode **cjnode_ret, -+ jnode **wjnode_ret) ++static int ++prepare_bnode(struct bitmap_node *bnode, jnode ** cjnode_ret, ++ jnode ** wjnode_ret) +{ + struct super_block *super; + jnode *cjnode; @@ -62002,7 +62365,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + jnode *cjnode; + jnode *wjnode; + -+ assert("nikita-3040", reiser4_schedulable()); ++ assert("nikita-3040", schedulable()); + +/* ZAM-FIXME-HANS: since bitmaps are never unloaded, this does not + * need to be atomic, right? Just leave a comment that if bitmaps were @@ -62010,14 +62373,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + if (atomic_read(&bnode->loaded)) { + /* bitmap is already loaded, nothing to do */ + check_bnode_loaded(bnode); -+ mutex_lock(&bnode->mutex); ++ down(&bnode->sema); + assert("nikita-2827", atomic_read(&bnode->loaded)); + return 0; + } + + ret = prepare_bnode(bnode, &cjnode, &wjnode); + if (ret == 0) { -+ mutex_lock(&bnode->mutex); ++ down(&bnode->sema); + + if (!atomic_read(&bnode->loaded)) { + assert("nikita-2822", cjnode != NULL); @@ -62034,12 +62397,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + atomic_set(&bnode->loaded, 1); + /* working bitmap is initialized by on-disk + * commit bitmap. This should be performed -+ * under mutex. */ ++ * under semaphore. */ + memcpy(bnode_working_data(bnode), + bnode_commit_data(bnode), + bmap_size(current_blocksize)); -+ } else -+ mutex_unlock(&bnode->mutex); ++ } else { ++ up(&bnode->sema); ++ } + } else + /* race: someone already loaded bitmap while we were + * busy initializing data. */ @@ -62061,7 +62425,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +static void release_and_unlock_bnode(struct bitmap_node *bnode) +{ + check_bnode_loaded(bnode); -+ mutex_unlock(&bnode->mutex); ++ up(&bnode->sema); +} + +/* This function does all block allocation work but only for one bitmap @@ -62363,9 +62727,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +} + +/* plugin->u.space_allocator.alloc_blocks() */ -+int reiser4_alloc_blocks_bitmap(reiser4_space_allocator * allocator, -+ reiser4_blocknr_hint * hint, int needed, -+ reiser4_block_nr * start, reiser4_block_nr * len) ++int ++alloc_blocks_bitmap(reiser4_space_allocator * allocator UNUSED_ARG, ++ reiser4_blocknr_hint * hint, int needed, ++ reiser4_block_nr * start, reiser4_block_nr * len) +{ + if (hint->backward) + return alloc_blocks_backward(hint, needed, start, len); @@ -62377,8 +62742,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + nodes deletion is deferred until transaction commit. However, deallocation + of temporary objects like wandered blocks and transaction commit records + requires immediate node deletion from WORKING BITMAP.*/ -+void reiser4_dealloc_blocks_bitmap(reiser4_space_allocator * allocator, -+ reiser4_block_nr start, reiser4_block_nr len) ++void ++dealloc_blocks_bitmap(reiser4_space_allocator * allocator UNUSED_ARG, ++ reiser4_block_nr start, reiser4_block_nr len) +{ + struct super_block *super = reiser4_get_current_sb(); + @@ -62411,8 +62777,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +} + +/* plugin->u.space_allocator.check_blocks(). */ -+void reiser4_check_blocks_bitmap(const reiser4_block_nr * start, -+ const reiser4_block_nr * len, int desired) ++void ++check_blocks_bitmap(const reiser4_block_nr * start, ++ const reiser4_block_nr * len, int desired) +{ +#if REISER4_DEBUG + struct super_block *super = reiser4_get_current_sb(); @@ -62547,7 +62914,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + only one transaction can be committed a time, therefore it is safe to access + some global variables without any locking */ + -+int reiser4_pre_commit_hook_bitmap(void) ++int pre_commit_hook_bitmap(void) +{ + struct super_block *super = reiser4_get_current_sb(); + txn_atom *atom; @@ -62578,7 +62945,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + + assert("zam-559", !JF_ISSET(node, JNODE_OVRWR)); + assert("zam-460", -+ !reiser4_blocknr_is_fake(&node->blocknr)); ++ !blocknr_is_fake(&node->blocknr)); + + parse_blocknr(&node->blocknr, &bmap, &offset); + bn = get_bnode(super, bmap); @@ -62639,19 +63006,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + +/* plugin->u.space_allocator.init_allocator + constructor of reiser4_space_allocator object. It is called on fs mount */ -+int reiser4_init_allocator_bitmap(reiser4_space_allocator * allocator, -+ struct super_block *super, void *arg) ++int ++init_allocator_bitmap(reiser4_space_allocator * allocator, ++ struct super_block *super, void *arg UNUSED_ARG) +{ + struct bitmap_allocator_data *data = NULL; + bmap_nr_t bitmap_blocks_nr; + bmap_nr_t i; + -+ assert("nikita-3039", reiser4_schedulable()); ++ assert("nikita-3039", schedulable()); + + /* getting memory for bitmap allocator private data holder */ + data = -+ kmalloc(sizeof(struct bitmap_allocator_data), -+ reiser4_ctx_gfp_mask_get()); ++ kmalloc(sizeof(struct bitmap_allocator_data), GFP_KERNEL); + + if (data == NULL) + return RETERR(-ENOMEM); @@ -62667,7 +63034,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + probably, another dynamic data structure should replace a static + array of bnodes. */ + /*data->bitmap = reiser4_kmalloc((size_t) (sizeof (struct bitmap_node) * bitmap_blocks_nr), GFP_KERNEL); */ -+ data->bitmap = reiser4_vmalloc(sizeof(struct bitmap_node) * bitmap_blocks_nr); ++ data->bitmap = vmalloc(sizeof(struct bitmap_node) * bitmap_blocks_nr); + if (data->bitmap == NULL) { + kfree(data); + return RETERR(-ENOMEM); @@ -62697,8 +63064,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + bnode = data->bitmap + i; + ret = load_and_lock_bnode(bnode); + if (ret) { -+ reiser4_destroy_allocator_bitmap(allocator, -+ super); ++ destroy_allocator_bitmap(allocator, super); + return ret; + } + release_and_unlock_bnode(bnode); @@ -62715,8 +63081,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + +/* plugin->u.space_allocator.destroy_allocator + destructor. It is called on fs unmount */ -+int reiser4_destroy_allocator_bitmap(reiser4_space_allocator * allocator, -+ struct super_block *super) ++int ++destroy_allocator_bitmap(reiser4_space_allocator * allocator, ++ struct super_block *super) +{ + bmap_nr_t bitmap_blocks_nr; + bmap_nr_t i; @@ -62731,7 +63098,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + for (i = 0; i < bitmap_blocks_nr; i++) { + struct bitmap_node *bnode = data->bitmap + i; + -+ mutex_lock(&bnode->mutex); ++ down(&bnode->sema); + +#if REISER4_DEBUG + if (atomic_read(&bnode->loaded)) { @@ -62748,7 +63115,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei + } +#endif + done_bnode(bnode); -+ mutex_unlock(&bnode->mutex); ++ up(&bnode->sema); + } + + vfree(data->bitmap); @@ -62760,18 +63127,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.c linux-2.6.22/fs/rei +} + +/* -+ * Local variables: -+ * c-indentation-style: "K&R" -+ * mode-name: "LC" -+ * c-basic-offset: 8 -+ * tab-width: 8 -+ * fill-column: 79 -+ * scroll-step: 1 -+ * End: -+ */ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.h linux-2.6.22/fs/reiser4/plugin/space/bitmap.h ---- linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/space/bitmap.h 2007-07-29 00:25:35.004729608 +0400 ++ Local variables: ++ c-indentation-style: "K&R" ++ mode-name: "LC" ++ c-basic-offset: 8 ++ tab-width: 8 ++ fill-column: 80 ++ scroll-step: 1 ++ End: ++*/ +Index: linux-2.6.16/fs/reiser4/plugin/space/bitmap.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/space/bitmap.h @@ -0,0 +1,47 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -62786,24 +63154,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.h linux-2.6.22/fs/rei +/* EDWARD-FIXME-HANS: write something as informative as the below for every .h file lacking it. */ +/* declarations of functions implementing methods of space allocator plugin for + bitmap based allocator. The functions themselves are in bitmap.c */ -+extern int reiser4_init_allocator_bitmap(reiser4_space_allocator *, -+ struct super_block *, void *); -+extern int reiser4_destroy_allocator_bitmap(reiser4_space_allocator *, -+ struct super_block *); -+extern int reiser4_alloc_blocks_bitmap(reiser4_space_allocator *, -+ reiser4_blocknr_hint *, int needed, -+ reiser4_block_nr * start, -+ reiser4_block_nr * len); -+extern void reiser4_check_blocks_bitmap(const reiser4_block_nr *, -+ const reiser4_block_nr *, int); -+extern void reiser4_dealloc_blocks_bitmap(reiser4_space_allocator *, -+ reiser4_block_nr, -+ reiser4_block_nr); -+extern int reiser4_pre_commit_hook_bitmap(void); -+ -+#define reiser4_post_commit_hook_bitmap() do{}while(0) -+#define reiser4_post_write_back_hook_bitmap() do{}while(0) -+#define reiser4_print_info_bitmap(pref, al) do{}while(0) ++extern int init_allocator_bitmap(reiser4_space_allocator *, ++ struct super_block *, void *); ++extern int destroy_allocator_bitmap(reiser4_space_allocator *, ++ struct super_block *); ++extern int alloc_blocks_bitmap(reiser4_space_allocator *, ++ reiser4_blocknr_hint *, int needed, ++ reiser4_block_nr * start, ++ reiser4_block_nr * len); ++extern void check_blocks_bitmap(const reiser4_block_nr *, ++ const reiser4_block_nr *, int); ++ ++extern void dealloc_blocks_bitmap(reiser4_space_allocator *, reiser4_block_nr, ++ reiser4_block_nr); ++extern int pre_commit_hook_bitmap(void); ++ ++#define post_commit_hook_bitmap() do{}while(0) ++#define post_write_back_hook_bitmap() do{}while(0) ++#define print_info_bitmap(pref, al) do{}while(0) + +typedef __u64 bmap_nr_t; +typedef __u32 bmap_off_t; @@ -62820,17 +63188,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/bitmap.h linux-2.6.22/fs/rei + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/Makefile linux-2.6.22/fs/reiser4/plugin/space/Makefile ---- linux-2.6.22.orig/fs/reiser4/plugin/space/Makefile 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/space/Makefile 2007-07-29 00:25:35.004729608 +0400 -@@ -0,0 +1,4 @@ -+obj-$(CONFIG_REISER4_FS) += space_plugins.o -+ -+space_plugins-objs := \ -+ bitmap.o -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/space_allocator.h linux-2.6.22/fs/reiser4/plugin/space/space_allocator.h ---- linux-2.6.22.orig/fs/reiser4/plugin/space/space_allocator.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/space/space_allocator.h 2007-07-29 00:25:35.004729608 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/space/space_allocator.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/space/space_allocator.h @@ -0,0 +1,80 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -62845,47 +63206,47 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/space_allocator.h linux-2.6. + \ +static inline int sa_init_allocator (reiser4_space_allocator * al, struct super_block *s, void * opaque) \ +{ \ -+ return reiser4_init_allocator_##allocator (al, s, opaque); \ ++ return init_allocator_##allocator (al, s, opaque); \ +} \ + \ +static inline void sa_destroy_allocator (reiser4_space_allocator *al, struct super_block *s) \ +{ \ -+ reiser4_destroy_allocator_##allocator (al, s); \ ++ destroy_allocator_##allocator (al, s); \ +} \ + \ +static inline int sa_alloc_blocks (reiser4_space_allocator *al, reiser4_blocknr_hint * hint, \ + int needed, reiser4_block_nr * start, reiser4_block_nr * len) \ +{ \ -+ return reiser4_alloc_blocks_##allocator (al, hint, needed, start, len); \ ++ return alloc_blocks_##allocator (al, hint, needed, start, len); \ +} \ +static inline void sa_dealloc_blocks (reiser4_space_allocator * al, reiser4_block_nr start, reiser4_block_nr len) \ +{ \ -+ reiser4_dealloc_blocks_##allocator (al, start, len); \ ++ dealloc_blocks_##allocator (al, start, len); \ +} \ + \ +static inline void sa_check_blocks (const reiser4_block_nr * start, const reiser4_block_nr * end, int desired) \ +{ \ -+ reiser4_check_blocks_##allocator (start, end, desired); \ ++ check_blocks_##allocator (start, end, desired); \ +} \ + \ +static inline void sa_pre_commit_hook (void) \ +{ \ -+ reiser4_pre_commit_hook_##allocator (); \ ++ pre_commit_hook_##allocator (); \ +} \ + \ +static inline void sa_post_commit_hook (void) \ +{ \ -+ reiser4_post_commit_hook_##allocator (); \ ++ post_commit_hook_##allocator (); \ +} \ + \ +static inline void sa_post_write_back_hook (void) \ +{ \ -+ reiser4_post_write_back_hook_##allocator(); \ ++ post_write_back_hook_##allocator(); \ +} \ + \ +static inline void sa_print_info(const char * prefix, reiser4_space_allocator * al) \ +{ \ -+ reiser4_print_info_##allocator (prefix, al); \ ++ print_info_##allocator (prefix, al); \ +} + +DEF_SPACE_ALLOCATOR(bitmap) @@ -62912,9 +63273,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/space/space_allocator.h linux-2.6. + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/plugin/tail_policy.c linux-2.6.22/fs/reiser4/plugin/tail_policy.c ---- linux-2.6.22.orig/fs/reiser4/plugin/tail_policy.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/plugin/tail_policy.c 2007-07-29 00:25:35.008730643 +0400 +Index: linux-2.6.16/fs/reiser4/plugin/tail_policy.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/plugin/tail_policy.c @@ -0,0 +1,113 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -63029,10 +63391,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/plugin/tail_policy.c linux-2.6.22/fs/reis + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c ---- linux-2.6.22.orig/fs/reiser4/pool.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/pool.c 2007-07-29 00:25:35.008730643 +0400 -@@ -0,0 +1,231 @@ +Index: linux-2.6.16/fs/reiser4/pool.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/pool.c +@@ -0,0 +1,236 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -63076,6 +63439,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + functions in the style of tslist/tshash, i.e., make them unreadable, but + type-safe. + ++ +*/ + +#include "debug.h" @@ -63085,8 +63449,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c +#include +#include + -+/* initialize new pool object @h */ -+static void reiser4_init_pool_obj(struct reiser4_pool_header * h) ++/* initialize new pool object */ ++static void reiser4_init_pool_obj(reiser4_pool_header * h /* pool object to ++ * initialize */ ) +{ + INIT_LIST_HEAD(&h->usage_linkage); + INIT_LIST_HEAD(&h->level_linkage); @@ -63094,12 +63459,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c +} + +/* initialize new pool */ -+void reiser4_init_pool(struct reiser4_pool * pool /* pool to initialize */ , ++void reiser4_init_pool(reiser4_pool * pool /* pool to initialize */ , + size_t obj_size /* size of objects in @pool */ , + int num_of_objs /* number of preallocated objects */ , + char *data /* area for preallocated objects */ ) +{ -+ struct reiser4_pool_header *h; ++ reiser4_pool_header *h; + int i; + + assert("nikita-955", pool != NULL); @@ -63115,7 +63480,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + INIT_LIST_HEAD(&pool->extra); + memset(data, 0, obj_size * num_of_objs); + for (i = 0; i < num_of_objs; ++i) { -+ h = (struct reiser4_pool_header *) (data + i * obj_size); ++ h = (reiser4_pool_header *) (data + i * obj_size); + reiser4_init_pool_obj(h); + /* add pool header to the end of pool's free list */ + list_add_tail(&h->usage_linkage, &pool->free); @@ -63128,19 +63493,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + allocated objects. + +*/ -+void reiser4_done_pool(struct reiser4_pool * pool UNUSED_ARG) ++void reiser4_done_pool(reiser4_pool * pool UNUSED_ARG /* pool to destroy */ ) +{ +} + -+/* allocate carry object from @pool ++/* allocate carry object from pool + + First, try to get preallocated object. If this fails, resort to dynamic + allocation. + +*/ -+static void *reiser4_pool_alloc(struct reiser4_pool * pool) ++static void *reiser4_pool_alloc(reiser4_pool * pool /* pool to allocate object ++ * from */ ) +{ -+ struct reiser4_pool_header *result; ++ reiser4_pool_header *result; + + assert("nikita-959", pool != NULL); + @@ -63150,14 +63516,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + linkage = pool->free.next; + list_del(linkage); + INIT_LIST_HEAD(linkage); -+ result = list_entry(linkage, struct reiser4_pool_header, -+ usage_linkage); ++ result = list_entry(linkage, reiser4_pool_header, usage_linkage); + BUG_ON(!list_empty(&result->level_linkage) || + !list_empty(&result->extra_linkage)); + } else { + /* pool is empty. Extra allocations don't deserve dedicated + slab to be served from, as they are expected to be rare. */ -+ result = kmalloc(pool->obj_size, reiser4_ctx_gfp_mask_get()); ++ result = kmalloc(pool->obj_size, get_gfp_mask()); + if (result != 0) { + reiser4_init_pool_obj(result); + list_add(&result->extra_linkage, &pool->extra); @@ -63173,8 +63538,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c +} + +/* return object back to the pool */ -+void reiser4_pool_free(struct reiser4_pool * pool, -+ struct reiser4_pool_header * h) ++void reiser4_pool_free(reiser4_pool * pool, reiser4_pool_header * h /* pool to return object back ++ * into */ ) +{ + assert("nikita-961", h != NULL); + assert("nikita-962", pool != NULL); @@ -63213,16 +63578,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + supplied with at least node whose left delimiting key is to be updated + (that is "right" node). + -+ @pool - from which to allocate new object; -+ @list - where to add object; -+ @reference - after (or before) which existing object to add +*/ -+struct reiser4_pool_header *reiser4_add_obj(struct reiser4_pool * pool, -+ struct list_head *list, -+ pool_ordering order, -+ struct reiser4_pool_header * reference) -+{ -+ struct reiser4_pool_header *result; ++reiser4_pool_header *add_obj(reiser4_pool * pool /* pool from which to ++ * allocate new object */ , ++ struct list_head *list, /* list where to add ++ * object */ ++ pool_ordering order /* where to add */ , ++ reiser4_pool_header * reference /* after (or ++ * before) which ++ * existing ++ * object to ++ * add */ ) ++{ ++ reiser4_pool_header *result; + + assert("nikita-972", pool != NULL); + @@ -63264,10 +63632,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.c linux-2.6.22/fs/reiser4/pool.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/pool.h linux-2.6.22/fs/reiser4/pool.h ---- linux-2.6.22.orig/fs/reiser4/pool.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/pool.h 2007-07-29 00:25:35.008730643 +0400 -@@ -0,0 +1,56 @@ +Index: linux-2.6.16/fs/reiser4/pool.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/pool.h +@@ -0,0 +1,54 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Fast pool allocation */ @@ -63277,21 +63646,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.h linux-2.6.22/fs/reiser4/pool.h + +#include + -+struct reiser4_pool { ++typedef struct reiser4_pool { + size_t obj_size; + int objs; + char *data; + struct list_head free; + struct list_head used; + struct list_head extra; -+}; ++} reiser4_pool; + -+struct reiser4_pool_header { ++typedef struct reiser4_pool_header { + /* object is either on free or "used" lists */ + struct list_head usage_linkage; + struct list_head level_linkage; + struct list_head extra_linkage; -+}; ++} reiser4_pool_header; + +typedef enum { + POOLO_BEFORE, @@ -63302,15 +63671,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.h linux-2.6.22/fs/reiser4/pool.h + +/* pool manipulation functions */ + -+extern void reiser4_init_pool(struct reiser4_pool * pool, size_t obj_size, ++extern void reiser4_init_pool(reiser4_pool * pool, size_t obj_size, + int num_of_objs, char *data); -+extern void reiser4_done_pool(struct reiser4_pool * pool); -+extern void reiser4_pool_free(struct reiser4_pool * pool, -+ struct reiser4_pool_header * h); -+struct reiser4_pool_header *reiser4_add_obj(struct reiser4_pool * pool, -+ struct list_head * list, -+ pool_ordering order, -+ struct reiser4_pool_header *reference); ++extern void reiser4_done_pool(reiser4_pool * pool); ++extern void reiser4_pool_free(reiser4_pool * pool, reiser4_pool_header * h); ++reiser4_pool_header *add_obj(reiser4_pool * pool, struct list_head * list, ++ pool_ordering order, ++ reiser4_pool_header * reference); + +/* __REISER4_POOL_H__ */ +#endif @@ -63324,9 +63691,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/pool.h linux-2.6.22/fs/reiser4/pool.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/readahead.c ---- linux-2.6.22.orig/fs/reiser4/readahead.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/readahead.c 2007-07-29 00:25:35.008730643 +0400 +Index: linux-2.6.16/fs/reiser4/readahead.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/readahead.c @@ -0,0 +1,138 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -63341,9 +63709,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/reada + +#include /* for totalram_pages */ + -+void reiser4_init_ra_info(ra_info_t * rai) ++void init_ra_info(ra_info_t * rai) +{ -+ rai->key_to_stop = *reiser4_min_key(); ++ rai->key_to_stop = *min_key(); +} + +/* global formatted node readahead parameter. It can be set by mount option -o readahead:NUM:1 */ @@ -63377,14 +63745,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/reada +/* start read for @node and for a few of its right neighbors */ +void formatted_readahead(znode * node, ra_info_t * info) +{ -+ struct formatted_ra_params *ra_params; ++ ra_params_t *ra_params; + znode *cur; + int i; + int grn_flags; + lock_handle next_lh; + + /* do nothing if node block number has not been assigned to node (which means it is still in cache). */ -+ if (reiser4_blocknr_is_fake(znode_get_block(node))) ++ if (blocknr_is_fake(znode_get_block(node))) + return; + + ra_params = get_current_super_ra_params(); @@ -63418,7 +63786,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/reada + break; + + nextblk = znode_get_block(next_lh.node); -+ if (reiser4_blocknr_is_fake(nextblk) || ++ if (blocknr_is_fake(nextblk) || + (ra_adjacent_only(ra_params->flags) + && *nextblk != *znode_get_block(cur) + 1)) { + break; @@ -63452,9 +63820,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/reada + * stat data of all files of the directory */ + set_key_locality(stop_key, get_inode_oid(dir)); + set_key_type(stop_key, KEY_SD_MINOR); -+ set_key_ordering(stop_key, get_key_ordering(reiser4_max_key())); -+ set_key_objectid(stop_key, get_key_objectid(reiser4_max_key())); -+ set_key_offset(stop_key, get_key_offset(reiser4_max_key())); ++ set_key_ordering(stop_key, get_key_ordering(max_key())); ++ set_key_objectid(stop_key, get_key_objectid(max_key())); ++ set_key_offset(stop_key, get_key_offset(max_key())); +} + +/* @@ -63466,10 +63834,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.c linux-2.6.22/fs/reiser4/reada + fill-column: 80 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/readahead.h linux-2.6.22/fs/reiser4/readahead.h ---- linux-2.6.22.orig/fs/reiser4/readahead.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/readahead.h 2007-07-29 00:25:35.008730643 +0400 -@@ -0,0 +1,51 @@ +Index: linux-2.6.16/fs/reiser4/readahead.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/readahead.h +@@ -0,0 +1,48 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +#ifndef __READAHEAD_H__ @@ -63478,24 +63847,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.h linux-2.6.22/fs/reiser4/reada +#include "key.h" + +typedef enum { -+ RA_ADJACENT_ONLY = 1, /* only requests nodes which are adjacent. -+ Default is NO (not only adjacent) */ ++ RA_ADJACENT_ONLY = 1, /* only requests nodes which are adjacent. Default is NO (not only adjacent) */ +} ra_global_flags; + -+/* reiser4 super block has a field of this type. -+ It controls readahead during tree traversals */ -+struct formatted_ra_params { -+ unsigned long max; /* request not more than this amount of nodes. -+ Default is totalram_pages / 4 */ ++/* reiser4 super block has a field of this type. It controls readahead during tree traversals */ ++typedef struct formatted_read_ahead_params { ++ unsigned long max; /* request not more than this amount of nodes. Default is totalram_pages / 4 */ + int flags; -+}; ++} ra_params_t; + +typedef struct { + reiser4_key key_to_stop; +} ra_info_t; + +void formatted_readahead(znode *, ra_info_t *); -+void reiser4_init_ra_info(ra_info_t * rai); ++void init_ra_info(ra_info_t * rai); + +struct reiser4_file_ra_state { + loff_t start; /* Current window */ @@ -63521,142 +63887,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/readahead.h linux-2.6.22/fs/reiser4/reada + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/README linux-2.6.22/fs/reiser4/README ---- linux-2.6.22.orig/fs/reiser4/README 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/README 2007-07-29 00:25:35.008730643 +0400 -@@ -0,0 +1,128 @@ -+[LICENSING] -+ -+Reiser4 is hereby licensed under the GNU General -+Public License version 2. -+ -+Source code files that contain the phrase "licensing governed by -+reiser4/README" are "governed files" throughout this file. Governed -+files are licensed under the GPL. The portions of them owned by Hans -+Reiser, or authorized to be licensed by him, have been in the past, -+and likely will be in the future, licensed to other parties under -+other licenses. If you add your code to governed files, and don't -+want it to be owned by Hans Reiser, put your copyright label on that -+code so the poor blight and his customers can keep things straight. -+All portions of governed files not labeled otherwise are owned by Hans -+Reiser, and by adding your code to it, widely distributing it to -+others or sending us a patch, and leaving the sentence in stating that -+licensing is governed by the statement in this file, you accept this. -+It will be a kindness if you identify whether Hans Reiser is allowed -+to license code labeled as owned by you on your behalf other than -+under the GPL, because he wants to know if it is okay to do so and put -+a check in the mail to you (for non-trivial improvements) when he -+makes his next sale. He makes no guarantees as to the amount if any, -+though he feels motivated to motivate contributors, and you can surely -+discuss this with him before or after contributing. You have the -+right to decline to allow him to license your code contribution other -+than under the GPL. -+ -+Further licensing options are available for commercial and/or other -+interests directly from Hans Reiser: reiser@namesys.com. If you interpret -+the GPL as not allowing those additional licensing options, you read -+it wrongly, and Richard Stallman agrees with me, when carefully read -+you can see that those restrictions on additional terms do not apply -+to the owner of the copyright, and my interpretation of this shall -+govern for this license. -+ -+[END LICENSING] -+ -+Reiser4 is a file system based on dancing tree algorithms, and is -+described at http://www.namesys.com -+ -+mkfs.reiser4 and other utilities are on our webpage or wherever your -+Linux provider put them. You really want to be running the latest -+version off the website if you use fsck. -+ -+Yes, if you update your reiser4 kernel module you do have to -+recompile your kernel, most of the time. The errors you get will be -+quite cryptic if your forget to do so. -+ -+Hideous Commercial Pitch: Spread your development costs across other OS -+vendors. Select from the best in the world, not the best in your -+building, by buying from third party OS component suppliers. Leverage -+the software component development power of the internet. Be the most -+aggressive in taking advantage of the commercial possibilities of -+decentralized internet development, and add value through your branded -+integration that you sell as an operating system. Let your competitors -+be the ones to compete against the entire internet by themselves. Be -+hip, get with the new economic trend, before your competitors do. Send -+email to reiser@namesys.com -+ -+Hans Reiser was the primary architect of Reiser4, but a whole team -+chipped their ideas in. He invested everything he had into Namesys -+for 5.5 dark years of no money before Reiser3 finally started to work well -+enough to bring in money. He owns the copyright. -+ -+DARPA was the primary sponsor of Reiser4. DARPA does not endorse -+Reiser4, it merely sponsors it. DARPA is, in solely Hans's personal -+opinion, unique in its willingness to invest into things more -+theoretical than the VC community can readily understand, and more -+longterm than allows them to be sure that they will be the ones to -+extract the economic benefits from. DARPA also integrated us into a -+security community that transformed our security worldview. -+ -+Vladimir Saveliev is our lead programmer, with us from the beginning, -+and he worked long hours writing the cleanest code. This is why he is -+now the lead programmer after years of commitment to our work. He -+always made the effort to be the best he could be, and to make his -+code the best that it could be. What resulted was quite remarkable. I -+don't think that money can ever motivate someone to work the way he -+did, he is one of the most selfless men I know. -+ -+Alexander Lyamin was our sysadmin, and helped to educate us in -+security issues. Moscow State University and IMT were very generous -+in the internet access they provided us, and in lots of other little -+ways that a generous institution can be. -+ -+Alexander Zarochentcev (sometimes known as zam, or sasha), wrote the -+locking code, the block allocator, and finished the flushing code. -+His code is always crystal clean and well structured. -+ -+Nikita Danilov wrote the core of the balancing code, the core of the -+plugins code, and the directory code. He worked a steady pace of long -+hours that produced a whole lot of well abstracted code. He is our -+senior computer scientist. -+ -+Vladimir Demidov wrote the parser. Writing an in kernel parser is -+something very few persons have the skills for, and it is thanks to -+him that we can say that the parser is really not so big compared to -+various bits of our other code, and making a parser work in the kernel -+was not so complicated as everyone would imagine mainly because it was -+him doing it... -+ -+Joshua McDonald wrote the transaction manager, and the flush code. -+The flush code unexpectedly turned out be extremely hairy for reasons -+you can read about on our web page, and he did a great job on an -+extremely difficult task. -+ -+Nina Reiser handled our accounting, government relations, and much -+more. -+ -+Ramon Reiser developed our website. -+ -+Beverly Palmer drew our graphics. -+ -+Vitaly Fertman developed librepair, userspace plugins repair code, fsck -+and worked with Umka on developing libreiser4 and userspace plugins. -+ -+Yury Umanets (aka Umka) developed libreiser4, userspace plugins and -+userspace tools (reiser4progs). -+ -+Oleg Drokin (aka Green) is the release manager who fixes everything. -+It is so nice to have someone like that on the team. He (plus Chris -+and Jeff) make it possible for the entire rest of the Namesys team to -+focus on Reiser4, and he fixed a whole lot of Reiser4 bugs also. It -+is just amazing to watch his talent for spotting bugs in action. -+ -+Edward Shishkin wrote cryptcompress file plugin (which manages files -+built of encrypted and(or) compressed bodies) and other plugins related -+to transparent encryption and compression support. -diff -urN linux-2.6.22.orig/fs/reiser4/reiser4.h linux-2.6.22/fs/reiser4/reiser4.h ---- linux-2.6.22.orig/fs/reiser4/reiser4.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/reiser4.h 2007-07-29 00:25:35.012731678 +0400 -@@ -0,0 +1,269 @@ +Index: linux-2.6.16/fs/reiser4/reiser4.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/reiser4.h +@@ -0,0 +1,276 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -63665,11 +63900,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/reiser4.h linux-2.6.22/fs/reiser4/reiser4 +#if !defined( __REISER4_H__ ) +#define __REISER4_H__ + ++#include +#include /* for HZ */ +#include +#include +#include -+#include ++#include +#include + +/* @@ -63696,6 +63932,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/reiser4.h linux-2.6.22/fs/reiser4/reiser4 +#define REISER4_SHA256 (0) +#endif + ++#if defined(CONFIG_CRYPTO_AES_586) ++#define REISER4_AES (1) ++#else ++#define REISER4_AES (0) ++#endif ++ +/* + * Turn on large keys mode. In his mode (which is default), reiser4 key has 4 + * 8-byte components. In the old "small key" mode, it's 3 8-byte @@ -63926,10 +64168,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/reiser4.h linux-2.6.22/fs/reiser4/reiser4 + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_link.c ---- linux-2.6.22.orig/fs/reiser4/safe_link.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/safe_link.c 2007-07-29 00:25:35.012731678 +0400 -@@ -0,0 +1,352 @@ +Index: linux-2.6.16/fs/reiser4/safe_link.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/safe_link.c +@@ -0,0 +1,351 @@ +/* Copyright 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -64063,7 +64306,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + int result; + + grab_space_enable(); -+ /* The sbinfo->delete_mutex can be taken here. ++ /* The sbinfo->delete semaphore can be taken here. + * safe_link_release() should be called before leaving reiser4 + * context. */ + result = @@ -64102,7 +64345,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + length += sizeof(sl.size); + put_unaligned(cpu_to_le64(inode->i_size), &sl.size); + } -+ tree = reiser4_tree_by_inode(inode); ++ tree = tree_by_inode(inode); + build_link_key(tree, get_inode_oid(inode), link, &key); + + result = store_black_box(tree, &key, &sl, length); @@ -64126,32 +64369,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + * in-memory structure to keep information extracted from safe-link. This is + * used to iterate over all safe-links. + */ -+struct safe_link_context { ++typedef struct { + reiser4_tree *tree; /* internal tree */ + reiser4_key key; /* safe-link key */ + reiser4_key sdkey; /* key of object stat-data */ + reiser4_safe_link_t link; /* safe-link type */ + oid_t oid; /* object oid */ + __u64 size; /* final size for truncate */ -+}; ++} safe_link_context; + +/* + * start iterating over all safe-links. + */ -+static void safe_link_iter_begin(reiser4_tree * tree, -+ struct safe_link_context * ctx) ++static void safe_link_iter_begin(reiser4_tree * tree, safe_link_context * ctx) +{ + ctx->tree = tree; + reiser4_key_init(&ctx->key); + set_key_locality(&ctx->key, safe_link_locality(tree)); -+ set_key_objectid(&ctx->key, get_key_objectid(reiser4_max_key())); -+ set_key_offset(&ctx->key, get_key_offset(reiser4_max_key())); ++ set_key_objectid(&ctx->key, get_key_objectid(max_key())); ++ set_key_offset(&ctx->key, get_key_offset(max_key())); +} + +/* + * return next safe-link. + */ -+static int safe_link_iter_next(struct safe_link_context * ctx) ++static int safe_link_iter_next(safe_link_context * ctx) +{ + int result; + safelink_t sl; @@ -64170,7 +64412,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ +/* + * check are there any more safe-links left in the tree. + */ -+static int safe_link_iter_finished(struct safe_link_context * ctx) ++static int safe_link_iter_finished(safe_link_context * ctx) +{ + return get_key_locality(&ctx->key) != safe_link_locality(ctx->tree); +} @@ -64178,7 +64420,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ +/* + * finish safe-link iteration. + */ -+static void safe_link_iter_end(struct safe_link_context * ctx) ++static void safe_link_iter_end(safe_link_context * ctx) +{ + /* nothing special */ +} @@ -64205,17 +64447,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + assert("nikita-3428", fplug != NULL); + assert("", oid == get_inode_oid(inode)); + if (fplug->safelink != NULL) { -+ /* reiser4_txn_restart_current is not necessary because ++ /* txn_restart_current is not necessary because + * mounting is signle thread. However, without it + * deadlock detection code will complain (see + * nikita-3361). */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + result = fplug->safelink(inode, link, size); + } else { + warning("nikita-3430", + "Cannot handle safelink for %lli", + (unsigned long long)oid); -+ reiser4_print_key("key", sdkey); ++ print_key("key", sdkey); + result = 0; + } + if (result != 0) { @@ -64226,18 +64468,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + reiser4_iget_complete(inode); + iput(inode); + if (result == 0) { -+ result = safe_link_grab(reiser4_get_tree(super), BA_CAN_COMMIT); ++ result = safe_link_grab(get_tree(super), BA_CAN_COMMIT); + if (result == 0) + result = -+ safe_link_del(reiser4_get_tree(super), oid, link); -+ safe_link_release(reiser4_get_tree(super)); ++ safe_link_del(get_tree(super), oid, link); ++ safe_link_release(get_tree(super)); + /* + * restart transaction: if there was large number of + * safe-links, their processing may fail to fit into + * single transaction. + */ + if (result == 0) -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + } + } else + result = PTR_ERR(inode); @@ -64249,7 +64491,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + */ +int process_safelinks(struct super_block *super) +{ -+ struct safe_link_context ctx; ++ safe_link_context ctx; + int result; + + if (rofs_super(super)) @@ -64282,9 +64524,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.c linux-2.6.22/fs/reiser4/safe_ + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.h linux-2.6.22/fs/reiser4/safe_link.h ---- linux-2.6.22.orig/fs/reiser4/safe_link.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/safe_link.h 2007-07-29 00:25:35.012731678 +0400 +Index: linux-2.6.16/fs/reiser4/safe_link.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/safe_link.h @@ -0,0 +1,29 @@ +/* Copyright 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -64315,10 +64558,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/safe_link.h linux-2.6.22/fs/reiser4/safe_ + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c ---- linux-2.6.22.orig/fs/reiser4/seal.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/seal.c 2007-07-29 00:25:35.012731678 +0400 -@@ -0,0 +1,218 @@ +Index: linux-2.6.16/fs/reiser4/seal.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/seal.c +@@ -0,0 +1,217 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ +/* Seals implementation. */ +/* Seals are "weak" tree pointers. They are analogous to tree coords in @@ -64327,9 +64571,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c + even a reference) to znode. In stead, each znode contains a version number, + increased on each znode modification. This version number is copied into a + seal when seal is created. Later, one can "validate" seal by calling -+ reiser4_seal_validate(). If znode is in cache and its version number is -+ still the same, seal is "pristine" and coord associated with it can be -+ re-used immediately. ++ seal_validate(). If znode is in cache and its version number is still the ++ same, seal is "pristine" and coord associated with it can be re-used ++ immediately. + + If, on the other hand, znode is out of cache, or it is obviously different + one from the znode seal was initially attached to (for example, it is on @@ -64369,11 +64613,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c + +/* initialise seal. This can be called several times on the same seal. @coord + and @key can be NULL. */ -+void reiser4_seal_init(seal_t * seal /* seal to initialise */ , -+ const coord_t * coord /* coord @seal will be -+ * attached to */ , -+ const reiser4_key * key UNUSED_ARG /* key @seal will be -+ * attached to */ ) ++void seal_init(seal_t * seal /* seal to initialise */ , ++ const coord_t * coord /* coord @seal will be attached to */ , ++ const reiser4_key * key UNUSED_ARG /* key @seal will be ++ * attached to */ ) +{ + assert("nikita-1886", seal != NULL); + memset(seal, 0, sizeof *seal); @@ -64396,22 +64639,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c +} + +/* finish with seal */ -+void reiser4_seal_done(seal_t * seal /* seal to clear */ ) ++void seal_done(seal_t * seal /* seal to clear */ ) +{ + assert("nikita-1887", seal != NULL); + seal->version = 0; +} + +/* true if seal was initialised */ -+int reiser4_seal_is_set(const seal_t * seal /* seal to query */ ) ++int seal_is_set(const seal_t * seal /* seal to query */ ) +{ + assert("nikita-1890", seal != NULL); + return seal->version != 0; +} + +#if REISER4_DEBUG -+/* helper function for reiser4_seal_validate(). It checks that item at @coord -+ * has expected key. This is to detect cases where node was modified but wasn't ++/* helper function for seal_validate(). It checks that item at @coord has ++ * expected key. This is to detect cases where node was modified but wasn't + * marked dirty. */ +static inline int check_seal_match(const coord_t * coord /* coord to check */ , + const reiser4_key * k /* expected key */ ) @@ -64429,12 +64672,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c +} +#endif + -+/* this is used by reiser4_seal_validate. It accepts return value of ++/* this is used by seal_validate. It accepts return value of + * longterm_lock_znode and returns 1 if it can be interpreted as seal + * validation failure. For instance, when longterm_lock_znode returns -EINVAL, -+ * reiser4_seal_validate returns -E_REPEAT and caller will call tre search. -+ * We cannot do this in longterm_lock_znode(), because sometimes we want to -+ * distinguish between -EINVAL and -E_REPEAT. */ ++ * seal_validate returns -E_REPEAT and caller will call tre search. We cannot ++ * do this in longterm_lock_znode(), because sometimes we want to distinguish ++ * between -EINVAL and -E_REPEAT. */ +static int should_repeat(int return_code) +{ + return return_code == -EINVAL; @@ -64446,24 +64689,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c + + If seal was burned, or broken irreparably, return -E_REPEAT. + -+ NOTE-NIKITA currently reiser4_seal_validate() returns -E_REPEAT if key we are ++ NOTE-NIKITA currently seal_validate() returns -E_REPEAT if key we are + looking for is in range of keys covered by the sealed node, but item wasn't + found by node ->lookup() method. Alternative is to return -ENOENT in this + case, but this would complicate callers logic. + +*/ -+int reiser4_seal_validate(seal_t * seal /* seal to validate */, -+ coord_t * coord /* coord to validate against */, -+ const reiser4_key * key /* key to validate against */, -+ lock_handle * lh /* resulting lock handle */, -+ znode_lock_mode mode /* lock node */, -+ znode_lock_request request /* locking priority */) ++int seal_validate(seal_t * seal /* seal to validate */ , ++ coord_t * coord /* coord to validate against */ , ++ const reiser4_key * key /* key to validate against */ , ++ lock_handle * lh /* resulting lock handle */ , ++ znode_lock_mode mode /* lock node */ , ++ znode_lock_request request /* locking priority */ ) +{ + znode *node; + int result; + + assert("nikita-1889", seal != NULL); -+ assert("nikita-1881", reiser4_seal_is_set(seal)); ++ assert("nikita-1881", seal_is_set(seal)); + assert("nikita-1882", key != NULL); + assert("nikita-1883", coord != NULL); + assert("nikita-1884", lh != NULL); @@ -64537,9 +64780,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.c linux-2.6.22/fs/reiser4/seal.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/seal.h linux-2.6.22/fs/reiser4/seal.h ---- linux-2.6.22.orig/fs/reiser4/seal.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/seal.h 2007-07-29 00:25:35.012731678 +0400 +Index: linux-2.6.16/fs/reiser4/seal.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/seal.h @@ -0,0 +1,49 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -64571,10 +64815,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.h linux-2.6.22/fs/reiser4/seal.h +#endif +} seal_t; + -+extern void reiser4_seal_init(seal_t *, const coord_t *, const reiser4_key *); -+extern void reiser4_seal_done(seal_t *); -+extern int reiser4_seal_is_set(const seal_t *); -+extern int reiser4_seal_validate(seal_t *, coord_t *, ++extern void seal_init(seal_t *, const coord_t *, const reiser4_key *); ++extern void seal_done(seal_t *); ++extern int seal_is_set(const seal_t *); ++extern int seal_validate(seal_t *, coord_t *, + const reiser4_key *, lock_handle *, + znode_lock_mode mode, znode_lock_request request); + @@ -64590,9 +64834,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/seal.h linux-2.6.22/fs/reiser4/seal.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c ---- linux-2.6.22.orig/fs/reiser4/search.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/search.c 2007-07-29 00:25:35.016732714 +0400 +Index: linux-2.6.16/fs/reiser4/search.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/search.c @@ -0,0 +1,1611 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -64651,8 +64896,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + assert("nikita-346", cache != NULL); + + cache->slot = -+ kmalloc(sizeof(cbk_cache_slot) * cache->nr_slots, -+ reiser4_ctx_gfp_mask_get()); ++ kmalloc(sizeof(cbk_cache_slot) * cache->nr_slots, GFP_KERNEL); + if (cache->slot == NULL) + return RETERR(-ENOMEM); + @@ -64681,6 +64925,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + &(cache)->lru != &(slot)->lru; \ + (slot) = list_entry(slot->lru.next, cbk_cache_slot, lru)) + ++ +#if REISER4_DEBUG +/* this function assures that [cbk-cache-invariant] invariant holds */ +static int cbk_cache_invariant(const cbk_cache *cache) @@ -64891,7 +65136,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + init_lh(lh); + init_lh(&parent_lh); + -+ assert("nikita-3023", reiser4_schedulable()); ++ assert("nikita-3023", schedulable()); + + assert("nikita-353", tree != NULL); + assert("nikita-354", key != NULL); @@ -64918,15 +65163,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + +/* like coord_by_key(), but starts traversal from vroot of @object rather than + * from tree root. */ -+lookup_result reiser4_object_lookup(struct inode * object, -+ const reiser4_key * key, -+ coord_t * coord, -+ lock_handle * lh, -+ znode_lock_mode lock_mode, -+ lookup_bias bias, -+ tree_level lock_level, -+ tree_level stop_level, __u32 flags, -+ ra_info_t * info) ++lookup_result ++object_lookup(struct inode * object, ++ const reiser4_key * key, ++ coord_t * coord, ++ lock_handle * lh, ++ znode_lock_mode lock_mode, ++ lookup_bias bias, ++ tree_level lock_level, ++ tree_level stop_level, __u32 flags, ra_info_t * info) +{ + cbk_handle handle; + lock_handle parent_lh; @@ -64935,7 +65180,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + init_lh(lh); + init_lh(&parent_lh); + -+ assert("nikita-3023", reiser4_schedulable()); ++ assert("nikita-3023", schedulable()); + + assert("nikita-354", key != NULL); + assert("nikita-355", coord != NULL); @@ -64946,7 +65191,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + assert("nikita-2104", lock_stack_isclean(get_current_lock_stack())); + + cbk_pack(&handle, -+ object != NULL ? reiser4_tree_by_inode(object) : current_tree, ++ object != NULL ? tree_by_inode(object) : current_tree, + key, + coord, + lh, @@ -64960,8 +65205,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + return result; +} + -+/* lookup by cbk_handle. Common part of coord_by_key() and -+ reiser4_object_lookup(). */ ++/* lookup by cbk_handle. Common part of coord_by_key() and object_lookup(). */ +static lookup_result coord_by_handle(cbk_handle * handle) +{ + /* @@ -64985,19 +65229,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + + Error code, or last actor return value is returned. + -+ This is used by plugin/dir/hashe_dir.c:reiser4_find_entry() to move through ++ This is used by plugin/dir/hashe_dir.c:find_entry() to move through + sequence of entries with identical keys and alikes. +*/ -+int reiser4_iterate_tree(reiser4_tree * tree /* tree to scan */ , -+ coord_t * coord /* coord to start from */ , -+ lock_handle * lh /* lock handle to start with and to -+ * update along the way */ , -+ tree_iterate_actor_t actor /* function to call on each -+ * item/unit */ , -+ void *arg /* argument to pass to @actor */ , -+ znode_lock_mode mode /* lock mode on scanned nodes */ , -+ int through_units_p /* call @actor on each item or on -+ * each unit */ ) ++int iterate_tree(reiser4_tree * tree /* tree to scan */ , ++ coord_t * coord /* coord to start from */ , ++ lock_handle * lh /* lock handle to start with and to ++ * update along the way */ , ++ tree_iterate_actor_t actor /* function to call on each ++ * item/unit */ , ++ void *arg /* argument to pass to @actor */ , ++ znode_lock_mode mode /* lock mode on scanned nodes */ , ++ int through_units_p /* call @actor on each item or on each ++ * unit */ ) +{ + int result; + @@ -65210,7 +65454,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + } + } + } -+ } ++ } else ++ /* long-term locking failed. Restart. */ ++ ; + + zput(vroot); + @@ -65244,12 +65490,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + /* loop for restarts */ + restart: + -+ assert("nikita-3024", reiser4_schedulable()); ++ assert("nikita-3024", schedulable()); + + h->result = CBK_COORD_FOUND; + /* connect_znode() needs it */ -+ h->ld_key = *reiser4_min_key(); -+ h->rd_key = *reiser4_max_key(); ++ h->ld_key = *min_key(); ++ h->rd_key = *max_key(); + h->flags |= CBK_DKSET; + h->error = NULL; + @@ -65283,7 +65529,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + IS_POW(iterations))) { + warning("nikita-1481", "Too many iterations: %i", + iterations); -+ reiser4_print_key("key", h->key); ++ print_key("key", h->key); + ++iterations; + } else if (unlikely(iterations > REISER4_MAX_CBK_ITERATIONS)) { + h->error = @@ -65305,7 +65551,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + /* deadlock avoidance is normal case. */ + if (h->result != -E_DEADLOCK) + ++iterations; -+ reiser4_preempt_point(); ++ preempt_point(); + goto restart; + } + } @@ -65317,7 +65563,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + h->error, h->level, h->lock_level, h->stop_level, + lock_mode_name(h->lock_mode), bias_name(h->bias)); + reiser4_print_address("block", &h->block); -+ reiser4_print_key("key", h->key); ++ print_key("key", h->key); + print_coord_content("coord", h->coord); + } + /* `unlikely' error case */ @@ -65432,12 +65678,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + reiser4_key key; + znode *active; + -+ assert("nikita-3025", reiser4_schedulable()); ++ assert("nikita-3025", schedulable()); + + /* acquire reference to @active node */ + active = -+ zget(h->tree, &h->block, h->parent_lh->node, h->level, -+ reiser4_ctx_gfp_mask_get()); ++ zget(h->tree, &h->block, h->parent_lh->node, h->level, get_gfp_mask()); + + if (IS_ERR(active)) { + h->result = PTR_ERR(active); @@ -65555,8 +65800,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + if (ldkeyset && !node_is_empty(active) && + !keyeq(leftmost_key_in_node(active, &key), &ldkey)) { + warning("vs-3533", "Keys are inconsistent. Fsck?"); -+ reiser4_print_key("inparent", &ldkey); -+ reiser4_print_key("inchild", &key); ++ print_key("inparent", &ldkey); ++ print_key("inchild", &key); + h->result = RETERR(-EIO); + zrelse(active); + return LOOKUP_DONE; @@ -65785,7 +66030,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + * are rechecked under dk lock below. + */ + if (znode_get_level(node) == level && -+ /* reiser4_min_key < key < reiser4_max_key */ ++ /* min_key < key < max_key */ + znode_contains_key_strict(node, key, isunique)) { + zref(node); + result = 0; @@ -66093,7 +66338,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + item_body_by_coord(p), item_length_by_coord(p)); + if (znode_is_loaded(p->node)) { + item_key_by_coord(p, &key); -+ reiser4_print_key(prefix, &key); ++ print_key(prefix, &key); + } +} + @@ -66113,7 +66358,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + + if (block == NULL) + sprintf(address, "null"); -+ else if (reiser4_blocknr_is_fake(block)) ++ else if (blocknr_is_fake(block)) + sprintf(address, "%llx", (unsigned long long)(*block)); + else + sprintf(address, "%llu", (unsigned long long)(*block)); @@ -66205,10 +66450,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/search.c linux-2.6.22/fs/reiser4/search.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.c linux-2.6.22/fs/reiser4/status_flags.c ---- linux-2.6.22.orig/fs/reiser4/status_flags.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/status_flags.c 2007-07-29 00:25:35.016732714 +0400 -@@ -0,0 +1,175 @@ +Index: linux-2.6.16/fs/reiser4/status_flags.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/status_flags.c +@@ -0,0 +1,176 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -66251,14 +66497,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.c linux-2.6.22/fs/reiser4/st + struct bio *bio; + struct page *page; + ++ + get_super_private(sb)->status_page = NULL; + get_super_private(sb)->status_bio = NULL; + -+ page = alloc_pages(reiser4_ctx_gfp_mask_get(), 0); ++ page = alloc_pages(GFP_KERNEL, 0); + if (!page) + return -ENOMEM; + -+ bio = bio_alloc(reiser4_ctx_gfp_mask_get(), 1); ++ bio = bio_alloc(GFP_KERNEL, 1); + if (bio != NULL) { + bio->bi_sector = block * (sb->s_blocksize >> 9); + bio->bi_bdev = sb->s_bdev; @@ -66274,7 +66521,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.c linux-2.6.22/fs/reiser4/st + } + lock_page(page); + submit_bio(READ, bio); -+ blk_run_address_space(reiser4_get_super_fake(sb)->i_mapping); ++ blk_run_address_space(get_super_fake(sb)->i_mapping); + wait_on_page_locked(page); + if (!PageUptodate(page)) { + warning("green-2007", @@ -66369,7 +66616,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.c linux-2.6.22/fs/reiser4/st + lock_page(get_super_private(sb)->status_page); // Safe as nobody should touch our page. + /* We can block now, but we have no other choice anyway */ + submit_bio(WRITE, bio); -+ blk_run_address_space(reiser4_get_super_fake(sb)->i_mapping); ++ blk_run_address_space(get_super_fake(sb)->i_mapping); + return 0; // We do not wait for io to finish. +} + @@ -66384,9 +66631,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.c linux-2.6.22/fs/reiser4/st + get_super_private(sb)->status_bio = NULL; + return 0; +} -diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.h linux-2.6.22/fs/reiser4/status_flags.h ---- linux-2.6.22.orig/fs/reiser4/status_flags.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/status_flags.h 2007-07-29 00:25:35.016732714 +0400 +Index: linux-2.6.16/fs/reiser4/status_flags.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/status_flags.h @@ -0,0 +1,43 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -66431,10 +66679,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/status_flags.h linux-2.6.22/fs/reiser4/st +int reiser4_status_finish(void); + +#endif -diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c ---- linux-2.6.22.orig/fs/reiser4/super.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/super.c 2007-07-29 00:25:35.020733749 +0400 -@@ -0,0 +1,316 @@ +Index: linux-2.6.16/fs/reiser4/super.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/super.c +@@ -0,0 +1,313 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -66454,6 +66703,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +#include /* for __u?? */ +#include /* for struct super_block */ + ++ +static __u64 reserved_for_gid(const struct super_block *super, gid_t gid); +static __u64 reserved_for_uid(const struct super_block *super, uid_t uid); +static __u64 reserved_for_root(const struct super_block *super); @@ -66466,7 +66716,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +} + +/* Return reiser4 fstype: value that is returned in ->f_type field by statfs() */ -+long reiser4_statfs_type(const struct super_block *super UNUSED_ARG) ++long statfs_type(const struct super_block *super UNUSED_ARG /* super block ++ * queried */ ) +{ + assert("nikita-448", super != NULL); + assert("nikita-449", is_reiser4_super(super)); @@ -66484,7 +66735,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c + return get_super_private(super)->block_count; +} + -+#if REISER4_DEBUG +/* + * number of blocks in the current file system + */ @@ -66492,7 +66742,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +{ + return get_current_super_private()->block_count; +} -+#endif /* REISER4_DEBUG */ + +/* set number of block in filesystem */ +void reiser4_set_block_count(const struct super_block *super, __u64 nr) @@ -66595,7 +66844,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c + return get_super_private(super)->blocks_grabbed; +} + -+__u64 reiser4_flush_reserved(const struct super_block * super) ++__u64 flush_reserved(const struct super_block * super) +{ + assert("vpf-285", super != NULL); + assert("vpf-286", is_reiser4_super(super)); @@ -66631,8 +66880,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +} + +/* space allocator used by this file system */ -+reiser4_space_allocator * reiser4_get_space_allocator(const struct super_block -+ *super) ++reiser4_space_allocator *get_space_allocator(const struct super_block * super) +{ + assert("nikita-1965", super != NULL); + assert("nikita-1966", is_reiser4_super(super)); @@ -66640,7 +66888,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +} + +/* return fake inode used to bind formatted nodes in the page cache */ -+struct inode *reiser4_get_super_fake(const struct super_block *super /* super block ++struct inode *get_super_fake(const struct super_block *super /* super block + queried */ ) +{ + assert("nikita-1757", super != NULL); @@ -66648,7 +66896,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +} + +/* return fake inode used to bind copied on capture nodes in the page cache */ -+struct inode *reiser4_get_cc_fake(const struct super_block *super /* super block ++struct inode *get_cc_fake(const struct super_block *super /* super block + queried */ ) +{ + assert("nikita-1757", super != NULL); @@ -66656,14 +66904,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +} + +/* return fake inode used to bind bitmaps and journlal heads */ -+struct inode *reiser4_get_bitmap_fake(const struct super_block *super) ++struct inode *get_bitmap_fake(const struct super_block *super) +{ + assert("nikita-17571", super != NULL); + return get_super_private(super)->bitmap; +} + +/* tree used by this file system */ -+reiser4_tree *reiser4_get_tree(const struct super_block * super /* super block ++reiser4_tree *get_tree(const struct super_block * super /* super block + * queried */ ) +{ + assert("nikita-460", super != NULL); @@ -66725,14 +66973,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c + assert("nikita-2957", super != NULL); + assert("nikita-2958", blk != NULL); + -+ if (reiser4_blocknr_is_fake(blk)) ++ if (blocknr_is_fake(blk)) + return 1; + + sbinfo = get_super_private(super); + return *blk < sbinfo->block_count; +} + -+#if REISER4_DEBUG +/* + * true, if block number @blk makes sense for the current file system + */ @@ -66740,7 +66987,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c +{ + return reiser4_blocknr_is_sane_for(reiser4_get_current_sb(), blk); +} -+#endif /* REISER4_DEBUG */ + +/* Make Linus happy. + Local variables: @@ -66751,10 +66997,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.c linux-2.6.22/fs/reiser4/super.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h ---- linux-2.6.22.orig/fs/reiser4/super.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/super.h 2007-07-29 00:25:35.020733749 +0400 -@@ -0,0 +1,464 @@ +Index: linux-2.6.16/fs/reiser4/super.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/super.h +@@ -0,0 +1,468 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -66773,12 +67020,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h +/* + * Flush algorithms parameters. + */ -+struct flush_params { ++typedef struct { + unsigned relocate_threshold; + unsigned relocate_distance; + unsigned written_threshold; + unsigned scan_maxnodes; -+}; ++} flush_params; + +typedef enum { + /* @@ -66801,22 +67048,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + REISER4_BSD_GID = 2, + /* [mac]_time are 32 bit in inode */ + REISER4_32_BIT_TIMES = 3, ++ /* allow concurrent flushes */ ++ REISER4_MTFLUSH = 4, + /* load all bitmap blocks at mount time */ + REISER4_DONT_LOAD_BITMAP = 5, + /* enforce atomicity during write(2) */ + REISER4_ATOMIC_WRITE = 6, + /* don't use write barriers in the log writer code. */ + REISER4_NO_WRITE_BARRIER = 7 ++ +} reiser4_fs_flag; + +/* + * VFS related operation vectors. + */ -+struct object_ops { ++typedef struct object_ops { + struct super_operations super; + struct dentry_operations dentry; + struct export_operations export; -+}; ++} object_ops; + +/* reiser4-specific part of super block + @@ -66863,7 +67113,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + + ->last_committed_tx + -+ is protected by ->tmgr.commit_mutex ++ is protected by ->tmgr.commit_semaphore + + Invariants involving this data-type: + @@ -66945,11 +67195,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + /* unique file-system identifier */ + __u32 fsuid; + -+ /* On-disk format version. If does not equal to the disk_format -+ plugin version, some format updates (e.g. enlarging plugin -+ set, etc) may have place on mount. */ -+ int version; -+ + /* file-system wide flags. See reiser4_fs_flag enum */ + unsigned long fs_flags; + @@ -66978,7 +67223,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + unsigned long optimal_io_size; + + /* parameters for the flush algorithm */ -+ struct flush_params flush; ++ flush_params flush; + + /* pointers to jnodes for journal header and footer */ + jnode *journal_header; @@ -66998,16 +67243,19 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + /* committed number of files (oid allocator state variable ) */ + __u64 nr_files_committed; + -+ struct formatted_ra_params ra_params; ++ ra_params_t ra_params; + + /* -+ * A mutex for serializing cut tree operation if out-of-free-space: ++ * A semaphore for serializing cut tree operation if out-of-free-space: + * the only one cut_tree thread is allowed to grab space from reserved + * area (it is 5% of disk space) + */ -+ struct mutex delete_mutex; -+ /* task owning ->delete_mutex */ -+ struct task_struct *delete_mutex_owner; ++ struct semaphore delete_sema; ++ /* task owning ->delete_sema */ ++ struct task_struct *delete_sema_owner; ++ ++ /* serialize semaphore */ ++ struct semaphore flush_sema; + + /* Diskmap's blocknumber */ + __u64 diskmap_block; @@ -67016,13 +67264,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + int onerror; + + /* operations for objects on this file system */ -+ struct object_ops ops; ++ object_ops ops; + + /* + * structure to maintain d_cursors. See plugin/file_ops_readdir.c for + * more details + */ -+ struct d_cursor_info d_info; ++ d_cursor_info d_info; + +#ifdef CONFIG_REISER4_BADBLOCKS + /* Alternative master superblock offset (in bytes) */ @@ -67056,6 +67304,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h +extern reiser4_super_info_data *get_super_private_nocheck(const struct + super_block *super); + ++ +/* Return reiser4-specific part of super block */ +static inline reiser4_super_info_data *get_super_private(const struct + super_block *super) @@ -67071,6 +67320,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + return &get_super_private(super)->entd; +} + ++ +/* "Current" super-block: main super block used during current system + call. Reference to this super block is stored in reiser4_context. */ +static inline struct super_block *reiser4_get_current_sb(void) @@ -67086,7 +67336,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + return get_super_private(reiser4_get_current_sb()); +} + -+static inline struct formatted_ra_params *get_current_super_ra_params(void) ++static inline ra_params_t *get_current_super_ra_params(void) +{ + return &(get_current_super_private()->ra_params); +} @@ -67125,7 +67375,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + +extern __u64 reiser4_current_block_count(void); + -+extern void build_object_ops(struct super_block *super, struct object_ops * ops); ++extern void build_object_ops(struct super_block *super, object_ops * ops); + +#define REISER4_SUPER_MAGIC 0x52345362 /* (*(__u32 *)"R4Sb"); */ + @@ -67140,9 +67390,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + spin_unlock(&(sbinfo->guard)); +} + -+extern __u64 reiser4_flush_reserved(const struct super_block *); ++extern __u64 flush_reserved(const struct super_block *); +extern int reiser4_is_set(const struct super_block *super, reiser4_fs_flag f); -+extern long reiser4_statfs_type(const struct super_block *super); ++extern long statfs_type(const struct super_block *super); +extern __u64 reiser4_block_count(const struct super_block *super); +extern void reiser4_set_block_count(const struct super_block *super, __u64 nr); +extern __u64 reiser4_data_blocks(const struct super_block *super); @@ -67161,14 +67411,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h +extern long reiser4_reserved_blocks(const struct super_block *super, uid_t uid, + gid_t gid); + -+extern reiser4_space_allocator * -+reiser4_get_space_allocator(const struct super_block *super); -+extern reiser4_oid_allocator * -+reiser4_get_oid_allocator(const struct super_block *super); -+extern struct inode *reiser4_get_super_fake(const struct super_block *super); -+extern struct inode *reiser4_get_cc_fake(const struct super_block *super); -+extern struct inode *reiser4_get_bitmap_fake(const struct super_block *super); -+extern reiser4_tree *reiser4_get_tree(const struct super_block *super); ++extern reiser4_space_allocator *get_space_allocator(const struct super_block ++ *super); ++extern reiser4_oid_allocator *get_oid_allocator(const struct super_block ++ *super); ++extern struct inode *get_super_fake(const struct super_block *super); ++extern struct inode *get_cc_fake(const struct super_block *super); ++extern struct inode *get_bitmap_fake(const struct super_block *super); ++extern reiser4_tree *get_tree(const struct super_block *super); +extern int is_reiser4_super(const struct super_block *super); + +extern int reiser4_blocknr_is_sane(const reiser4_block_nr * blk); @@ -67178,12 +67428,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h +extern int reiser4_done_super(struct super_block *s); + +/* step of fill super */ -+extern int reiser4_init_fs_info(struct super_block *); -+extern void reiser4_done_fs_info(struct super_block *); -+extern int reiser4_init_super_data(struct super_block *, char *opt_string); -+extern int reiser4_init_read_super(struct super_block *, int silent); -+extern int reiser4_init_root_inode(struct super_block *); -+extern reiser4_plugin *get_default_plugin(pset_member memb); ++extern int init_fs_info(struct super_block *); ++extern void done_fs_info(struct super_block *); ++extern int init_super_data(struct super_block *, char *opt_string); ++extern int init_read_super(struct super_block *, int silent); ++extern int init_root_inode(struct super_block *); ++ + +/* Maximal possible object id. */ +#define ABSOLUTE_MAX_OID ((oid_t)~0) @@ -67201,11 +67451,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h +void print_fs_info(const char *prefix, const struct super_block *); +#endif + -+extern void destroy_reiser4_cache(struct kmem_cache **); ++extern void destroy_reiser4_cache(kmem_cache_t **); + +extern struct super_operations reiser4_super_operations; +extern struct export_operations reiser4_export_operations; +extern struct dentry_operations reiser4_dentry_operations; ++extern struct dentry *reiser4_debugfs_root; + +/* __REISER4_SUPER_H__ */ +#endif @@ -67219,10 +67470,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super.h linux-2.6.22/fs/reiser4/super.h + * fill-column: 120 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super_ops.c ---- linux-2.6.22.orig/fs/reiser4/super_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/super_ops.c 2007-07-29 00:25:35.020733749 +0400 -@@ -0,0 +1,725 @@ +Index: linux-2.6.16/fs/reiser4/super_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/super_ops.c +@@ -0,0 +1,721 @@ +/* Copyright 2005 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -67239,9 +67491,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super +#include + +/* slab cache for inodes */ -+static struct kmem_cache *inode_cache; -+ -+static struct dentry *reiser4_debugfs_root = NULL; ++static kmem_cache_t *inode_cache; + +/** + * init_once - constructor for reiser4 inodes @@ -67252,29 +67502,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + * Initialization function to be called when new page is allocated by reiser4 + * inode cache. It is set on inode cache creation. + */ -+static void init_once(void *obj, struct kmem_cache *cache, unsigned long flags) ++static void init_once(void *obj, kmem_cache_t *cache, unsigned long flags) +{ -+ struct reiser4_inode_object *info; ++ reiser4_inode_object *info; + + info = obj; + -+ /* initialize vfs inode */ -+ inode_init_once(&info->vfs_inode); ++ if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) == ++ SLAB_CTOR_CONSTRUCTOR) { ++ /* initialize vfs inode */ ++ inode_init_once(&info->vfs_inode); + -+ /* -+ * initialize reiser4 specific part fo inode. -+ * NOTE-NIKITA add here initializations for locks, list heads, -+ * etc. that will be added to our private inode part. -+ */ -+ INIT_LIST_HEAD(get_readdir_list(&info->vfs_inode)); -+ init_rwsem(&info->p.conv_sem); -+ /* init semaphore which is used during inode loading */ -+ loading_init_once(&info->p); -+ INIT_RADIX_TREE(jnode_tree_by_reiser4_inode(&info->p), -+ GFP_ATOMIC); ++ /* ++ * initialize reiser4 specific part fo inode. ++ * NOTE-NIKITA add here initializations for locks, list heads, ++ * etc. that will be added to our private inode part. ++ */ ++ INIT_LIST_HEAD(get_readdir_list(&info->vfs_inode)); ++ /* init semaphore which is used during inode loading */ ++ loading_init_once(&info->p); ++ INIT_RADIX_TREE(jnode_tree_by_reiser4_inode(&info->p), ++ GFP_ATOMIC); +#if REISER4_DEBUG -+ info->p.nr_jnodes = 0; ++ info->p.nr_jnodes = 0; +#endif ++ } +} + +/** @@ -67285,7 +67537,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super +static int init_inodes(void) +{ + inode_cache = kmem_cache_create("reiser4_inode", -+ sizeof(struct reiser4_inode_object), ++ sizeof(reiser4_inode_object), + 0, + SLAB_HWCACHE_ALIGN | + SLAB_RECLAIM_ACCOUNT, init_once, NULL); @@ -67312,25 +67564,23 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + */ +static struct inode *reiser4_alloc_inode(struct super_block *super) +{ -+ struct reiser4_inode_object *obj; ++ reiser4_inode_object *obj; + + assert("nikita-1696", super != NULL); -+ obj = kmem_cache_alloc(inode_cache, reiser4_ctx_gfp_mask_get()); ++ obj = kmem_cache_alloc(inode_cache, SLAB_KERNEL); + if (obj != NULL) { + reiser4_inode *info; + + info = &obj->p; + -+ info->pset = plugin_set_get_empty(); -+ info->hset = plugin_set_get_empty(); ++ info->hset = info->pset = plugin_set_get_empty(); + info->extmask = 0; + info->locality_id = 0ull; + info->plugin_mask = 0; -+ info->heir_mask = 0; +#if !REISER4_INO_IS_OID + info->oid_hi = 0; +#endif -+ reiser4_seal_init(&info->sd_seal, NULL, NULL); ++ seal_init(&info->sd_seal, NULL, NULL); + coord_init_invalid(&info->sd_coord, NULL); + info->flags = 0; + spin_lock_init(&info->guard); @@ -67361,11 +67611,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + if (fplug->destroy_inode != NULL) + fplug->destroy_inode(inode); + } -+ reiser4_dispose_cursors(inode); ++ dispose_cursors(inode); + if (info->pset) + plugin_set_put(info->pset); -+ if (info->hset) -+ plugin_set_put(info->hset); + + /* + * cannot add similar assertion about ->i_list as prune_icache return @@ -67380,7 +67628,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + loading_destroy(info); + + kmem_cache_free(inode_cache, -+ container_of(info, struct reiser4_inode_object, p)); ++ container_of(info, reiser4_inode_object, p)); +} + +/** @@ -67417,7 +67665,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + reiser4_context *ctx; + file_plugin *fplug; + -+ ctx = reiser4_init_context(inode->i_sb); ++ ctx = init_context(inode->i_sb); + if (IS_ERR(ctx)) { + warning("vs-15", "failed to init context"); + return; @@ -67429,7 +67677,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + fplug->delete_object(inode); + } + -+ truncate_inode_pages(&inode->i_data, 0); + inode->i_blocks = 0; + clear_inode(inode); + reiser4_exit_context(ctx); @@ -67453,24 +67700,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + debugfs_remove(sbinfo->tmgr.debugfs_id_count); + debugfs_remove(sbinfo->debugfs_root); + -+ ctx = reiser4_init_context(super); ++ ctx = init_context(super); + if (IS_ERR(ctx)) { + warning("vs-17", "failed to init context"); + return; -+ } ++ } + + /* have disk format plugin to free its resources */ + if (get_super_private(super)->df_plug->release) + get_super_private(super)->df_plug->release(super); + -+ reiser4_done_formatted_fake(super); ++ done_formatted_fake(super); + + /* stop daemons: ktxnmgr and entd */ -+ reiser4_done_entd(super); -+ reiser4_done_ktxnmgrd(super); -+ reiser4_done_txnmgr(&sbinfo->tmgr); ++ done_entd(super); ++ done_ktxnmgrd(super); ++ done_txnmgr(&sbinfo->tmgr); + -+ reiser4_done_fs_info(super); ++ done_fs_info(super); + reiser4_exit_context(ctx); +} + @@ -67487,17 +67734,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + + assert("vs-1700", !rofs_super(super)); + -+ ctx = reiser4_init_context(super); ++ ctx = init_context(super); + if (IS_ERR(ctx)) { + warning("vs-16", "failed to init context"); + return; + } + -+ ret = reiser4_capture_super_block(super); ++ ret = capture_super_block(super); + if (ret != 0) + warning("vs-1701", -+ "reiser4_capture_super_block failed in write_super: %d", -+ ret); ++ "capture_super_block failed in write_super: %d", ret); + ret = txnmgr_force_commit_all(super, 0); + if (ret != 0) + warning("jmacd-77113", @@ -67515,7 +67761,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + * + * Returns information about filesystem. + */ -+static int reiser4_statfs(struct dentry *dentry, struct kstatfs *statfs) ++static int reiser4_statfs(struct super_block *super, struct kstatfs *statfs) +{ + sector_t total; + sector_t reserved; @@ -67523,16 +67769,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + sector_t forroot; + sector_t deleted; + reiser4_context *ctx; -+ struct super_block *super = dentry->d_sb; + + assert("nikita-408", super != NULL); + assert("nikita-409", statfs != NULL); + -+ ctx = reiser4_init_context(super); ++ ctx = init_context(super); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + -+ statfs->f_type = reiser4_statfs_type(super); ++ statfs->f_type = statfs_type(super); + statfs->f_bsize = super->s_blocksize; + + /* @@ -67628,7 +67873,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + to_write = wbc->nr_to_write; + assert("vs-49", wbc->older_than_this == NULL); + -+ ctx = reiser4_init_context(super); ++ ctx = init_context(super); + if (IS_ERR(ctx)) { + warning("vs-13", "failed to init context"); + return; @@ -67642,7 +67887,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + + /* flush goes here */ + wbc->nr_to_write = to_write; -+ reiser4_writeout(super, wbc); ++ writeout(super, wbc); + + /* avoid recursive calls to ->sync_inodes */ + context_set_commit_async(ctx); @@ -67708,31 +67953,31 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + init_stack_context(&ctx, super); + + /* allocate reiser4 specific super block */ -+ if ((result = reiser4_init_fs_info(super)) != 0) ++ if ((result = init_fs_info(super)) != 0) + goto failed_init_sinfo; + + sbinfo = get_super_private(super); + /* initialize various reiser4 parameters, parse mount options */ -+ if ((result = reiser4_init_super_data(super, data)) != 0) ++ if ((result = init_super_data(super, data)) != 0) + goto failed_init_super_data; + + /* read reiser4 master super block, initialize disk format plugin */ -+ if ((result = reiser4_init_read_super(super, silent)) != 0) ++ if ((result = init_read_super(super, silent)) != 0) + goto failed_init_read_super; + + /* initialize transaction manager */ -+ reiser4_init_txnmgr(&sbinfo->tmgr); ++ init_txnmgr(&sbinfo->tmgr); + + /* initialize ktxnmgrd context and start kernel thread ktxnmrgd */ -+ if ((result = reiser4_init_ktxnmgrd(super)) != 0) ++ if ((result = init_ktxnmgrd(super)) != 0) + goto failed_init_ktxnmgrd; + + /* initialize entd context and start kernel thread entd */ -+ if ((result = reiser4_init_entd(super)) != 0) ++ if ((result = init_entd(super)) != 0) + goto failed_init_entd; + + /* initialize address spaces for formatted nodes and bitmaps */ -+ if ((result = reiser4_init_formatted_fake(super)) != 0) ++ if ((result = init_formatted_fake(super)) != 0) + goto failed_init_formatted_fake; + + /* initialize disk format plugin */ @@ -67748,12 +67993,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + sbinfo->nr_files_committed = oids_used(super); + + /* get inode of root directory */ -+ if ((result = reiser4_init_root_inode(super)) != 0) ++ if ((result = init_root_inode(super)) != 0) + goto failed_init_root_inode; + -+ if ((result = get_super_private(super)->df_plug->version_update(super)) != 0 ) -+ goto failed_update_format_version; -+ + process_safelinks(super); + reiser4_exit_context(&ctx); + @@ -67771,21 +68013,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + } + return 0; + -+ failed_update_format_version: + failed_init_root_inode: + if (sbinfo->df_plug->release) + sbinfo->df_plug->release(super); + failed_init_disk_format: -+ reiser4_done_formatted_fake(super); ++ done_formatted_fake(super); + failed_init_formatted_fake: -+ reiser4_done_entd(super); ++ done_entd(super); + failed_init_entd: -+ reiser4_done_ktxnmgrd(super); ++ done_ktxnmgrd(super); + failed_init_ktxnmgrd: -+ reiser4_done_txnmgr(&sbinfo->tmgr); ++ done_txnmgr(&sbinfo->tmgr); + failed_init_read_super: + failed_init_super_data: -+ reiser4_done_fs_info(super); ++ done_fs_info(super); + failed_init_sinfo: + reiser4_exit_context(&ctx); + return result; @@ -67800,10 +68041,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + * + * Reiser4 mount entry. + */ -+static int reiser4_get_sb(struct file_system_type *fs_type, int flags, -+ const char *dev_name, void *data, struct vfsmount *mnt) ++static struct super_block *reiser4_get_sb(struct file_system_type *fs_type, ++ int flags, ++ const char *dev_name, ++ void *data) +{ -+ return get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt); ++ return get_sb_bdev(fs_type, flags, dev_name, data, fill_super); +} + +/* structure describing the reiser4 filesystem implementation */ @@ -67816,13 +68059,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + .next = NULL +}; + -+void destroy_reiser4_cache(struct kmem_cache **cachep) ++void destroy_reiser4_cache(kmem_cache_t **cachep) +{ ++ int result; ++ + BUG_ON(*cachep == NULL); -+ kmem_cache_destroy(*cachep); ++ result = kmem_cache_destroy(*cachep); ++ BUG_ON(result != 0); + *cachep = NULL; +} + ++struct dentry *reiser4_debugfs_root = NULL; ++ +/** + * init_reiser4 - reiser4 initialization entry point + * @@ -67862,22 +68110,22 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + goto failed_init_jnodes; + + /* initialize cache of flush queues */ -+ if ((result = reiser4_init_fqs()) != 0) ++ if ((result = init_fqs()) != 0) + goto failed_init_fqs; + + /* initialize cache of structures attached to dentry->d_fsdata */ -+ if ((result = reiser4_init_dentry_fsdata()) != 0) ++ if ((result = init_dentry_fsdata()) != 0) + goto failed_init_dentry_fsdata; + + /* initialize cache of structures attached to file->private_data */ -+ if ((result = reiser4_init_file_fsdata()) != 0) ++ if ((result = init_file_fsdata()) != 0) + goto failed_init_file_fsdata; + + /* + * initialize cache of d_cursors. See plugin/file_ops_readdir.c for + * more details + */ -+ if ((result = reiser4_init_d_cursor()) != 0) ++ if ((result = init_d_cursor()) != 0) + goto failed_init_d_cursor; + + if ((result = register_filesystem(&reiser4_fs_type)) == 0) { @@ -67885,13 +68133,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + return 0; + } + -+ reiser4_done_d_cursor(); ++ done_d_cursor(); + failed_init_d_cursor: -+ reiser4_done_file_fsdata(); ++ done_file_fsdata(); + failed_init_file_fsdata: -+ reiser4_done_dentry_fsdata(); ++ done_dentry_fsdata(); + failed_init_dentry_fsdata: -+ reiser4_done_fqs(); ++ done_fqs(); + failed_init_fqs: + done_jnodes(); + failed_init_jnodes: @@ -67920,10 +68168,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + debugfs_remove(reiser4_debugfs_root); + result = unregister_filesystem(&reiser4_fs_type); + BUG_ON(result != 0); -+ reiser4_done_d_cursor(); -+ reiser4_done_file_fsdata(); -+ reiser4_done_dentry_fsdata(); -+ reiser4_done_fqs(); ++ done_d_cursor(); ++ done_file_fsdata(); ++ done_dentry_fsdata(); ++ done_fqs(); + done_jnodes(); + done_txnmgr_static(); + done_plugin_set(); @@ -67948,9 +68196,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/super_ops.c linux-2.6.22/fs/reiser4/super + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c ---- linux-2.6.22.orig/fs/reiser4/tap.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tap.c 2007-07-29 00:25:35.024734784 +0400 +Index: linux-2.6.16/fs/reiser4/tap.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tap.c @@ -0,0 +1,377 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -67984,7 +68233,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c +#endif + +/** load node tap is pointing to, if not loaded already */ -+int reiser4_tap_load(tap_t * tap) ++int tap_load(tap_t * tap) +{ + tap_check(tap); + if (tap->loaded == 0) { @@ -68001,7 +68250,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c +} + +/** release node tap is pointing to. Dual to tap_load() */ -+void reiser4_tap_relse(tap_t * tap) ++void tap_relse(tap_t * tap) +{ + tap_check(tap); + if (tap->loaded > 0) { @@ -68017,29 +68266,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + * init tap to consist of @coord and @lh. Locks on nodes will be acquired with + * @mode + */ -+void reiser4_tap_init(tap_t * tap, coord_t * coord, lock_handle * lh, -+ znode_lock_mode mode) ++void ++tap_init(tap_t * tap, coord_t * coord, lock_handle * lh, znode_lock_mode mode) +{ + tap->coord = coord; + tap->lh = lh; + tap->mode = mode; + tap->loaded = 0; + INIT_LIST_HEAD(&tap->linkage); -+ reiser4_init_ra_info(&tap->ra_info); ++ init_ra_info(&tap->ra_info); +} + +/** add @tap to the per-thread list of all taps */ -+void reiser4_tap_monitor(tap_t * tap) ++void tap_monitor(tap_t * tap) +{ + assert("nikita-2623", tap != NULL); + tap_check(tap); -+ list_add(&tap->linkage, reiser4_taps_list()); ++ list_add(&tap->linkage, taps_list()); + tap_check(tap); +} + +/* duplicate @src into @dst. Copy lock handle. @dst is not initially + * loaded. */ -+void reiser4_tap_copy(tap_t * dst, tap_t * src) ++void tap_copy(tap_t * dst, tap_t * src) +{ + assert("nikita-3193", src != NULL); + assert("nikita-3194", dst != NULL); @@ -68054,7 +68303,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c +} + +/** finish with @tap */ -+void reiser4_tap_done(tap_t * tap) ++void tap_done(tap_t * tap) +{ + assert("nikita-2565", tap != NULL); + tap_check(tap); @@ -68070,7 +68319,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + * move @tap to the new node, locked with @target. Load @target, if @tap was + * already loaded. + */ -+int reiser4_tap_move(tap_t * tap, lock_handle * target) ++int tap_move(tap_t * tap, lock_handle * target) +{ + int result = 0; + @@ -68115,7 +68364,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + result = longterm_lock_znode(&here, target, + tap->mode, ZNODE_LOCK_HIPRI); + if (result == 0) { -+ result = reiser4_tap_move(tap, &here); ++ result = tap_move(tap, &here); + done_lh(&here); + } + } @@ -68140,7 +68389,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c +} + +/** return list of all taps */ -+struct list_head *reiser4_taps_list(void) ++struct list_head *taps_list(void) +{ + return &get_current_context()->taps; +} @@ -68188,7 +68437,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + get_dir_neighbor(&dup, coord->node, (int)tap->mode, + GN_CAN_USE_UPPER_LEVELS); + if (result == 0) { -+ result = reiser4_tap_move(tap, &dup); ++ result = tap_move(tap, &dup); + if (result == 0) + coord_init(tap->coord, dup.node); + done_lh(&dup); @@ -68234,7 +68483,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + assert("nikita-2562", tap->coord->node == tap->lh->node); + + tap_check(tap); -+ result = reiser4_tap_load(tap); ++ result = tap_load(tap); + if (result != 0) + return result; + @@ -68244,7 +68493,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + if (result != 0) + break; + } -+ reiser4_tap_relse(tap); ++ tap_relse(tap); + tap_check(tap); + return result; +} @@ -68329,10 +68578,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.c linux-2.6.22/fs/reiser4/tap.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tap.h linux-2.6.22/fs/reiser4/tap.h ---- linux-2.6.22.orig/fs/reiser4/tap.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tap.h 2007-07-29 00:25:35.024734784 +0400 -@@ -0,0 +1,70 @@ +Index: linux-2.6.16/fs/reiser4/tap.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tap.h +@@ -0,0 +1,69 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + +/* Tree Access Pointers. See tap.c for more details. */ @@ -68357,8 +68607,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.h linux-2.6.22/fs/reiser4/tap.h + lock_handle *lh; + /* mode of lock acquired by this tap */ + znode_lock_mode mode; -+ /* incremented by reiser4_tap_load(). -+ Decremented by reiser4_tap_relse(). */ ++ /* incremented by tap_load(). Decremented by tap_relse(). */ + int loaded; + /* list of taps */ + struct list_head linkage; @@ -68368,14 +68617,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.h linux-2.6.22/fs/reiser4/tap.h + +typedef int (*go_actor_t) (tap_t * tap); + -+extern int reiser4_tap_load(tap_t * tap); -+extern void reiser4_tap_relse(tap_t * tap); -+extern void reiser4_tap_init(tap_t * tap, coord_t * coord, lock_handle * lh, ++extern int tap_load(tap_t * tap); ++extern void tap_relse(tap_t * tap); ++extern void tap_init(tap_t * tap, coord_t * coord, lock_handle * lh, + znode_lock_mode mode); -+extern void reiser4_tap_monitor(tap_t * tap); -+extern void reiser4_tap_copy(tap_t * dst, tap_t * src); -+extern void reiser4_tap_done(tap_t * tap); -+extern int reiser4_tap_move(tap_t * tap, lock_handle * target); ++extern void tap_monitor(tap_t * tap); ++extern void tap_copy(tap_t * dst, tap_t * src); ++extern void tap_done(tap_t * tap); ++extern int tap_move(tap_t * tap, lock_handle * target); +extern int tap_to_coord(tap_t * tap, coord_t * target); + +extern int go_dir_el(tap_t * tap, sideof dir, int units_p); @@ -68384,11 +68633,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.h linux-2.6.22/fs/reiser4/tap.h +extern int rewind_right(tap_t * tap, int shift); +extern int rewind_left(tap_t * tap, int shift); + -+extern struct list_head *reiser4_taps_list(void); ++extern struct list_head *taps_list(void); + -+#define for_all_taps(tap) \ -+ for (tap = list_entry(reiser4_taps_list()->next, tap_t, linkage); \ -+ reiser4_taps_list() != &tap->linkage; \ ++#define for_all_taps(tap) \ ++ for (tap = list_entry(taps_list()->next, tap_t, linkage); \ ++ taps_list() != &tap->linkage; \ + tap = list_entry(tap->linkage.next, tap_t, linkage)) + +/* __REISER4_TAP_H__ */ @@ -68403,10 +68652,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tap.h linux-2.6.22/fs/reiser4/tap.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c ---- linux-2.6.22.orig/fs/reiser4/tree.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree.c 2007-07-29 00:25:35.028735820 +0400 -@@ -0,0 +1,1876 @@ +Index: linux-2.6.16/fs/reiser4/tree.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree.c +@@ -0,0 +1,1875 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -68456,7 +68706,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * ->max_key_inside() can be larger that any key actually located in the item, + * intervals + * -+ * [ reiser4_min_key( item ), ->max_key_inside( item ) ] ++ * [ min_key( item ), ->max_key_inside( item ) ] + * + * are still disjoint for all items within the _same_ node. + * @@ -68689,7 +68939,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level = (carry_level *) (pool + 1); + init_carry_level(lowest_level, pool); + -+ op = reiser4_post_carry(lowest_level, cop, coord->node, 0); ++ op = post_carry(lowest_level, cop, coord->node, 0); + if (IS_ERR(op) || (op == NULL)) { + done_carry_pool(pool); + return RETERR(op ? PTR_ERR(op) : -EIO); @@ -68710,7 +68960,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level->tracked = lh; + } + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + done_carry_pool(pool); + + return result; @@ -68749,7 +68999,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level = (carry_level *) (pool + 1); + init_carry_level(lowest_level, pool); + -+ op = reiser4_post_carry(lowest_level, COP_PASTE, coord->node, 0); ++ op = post_carry(lowest_level, COP_PASTE, coord->node, 0); + if (IS_ERR(op) || (op == NULL)) { + done_carry_pool(pool); + return RETERR(op ? PTR_ERR(op) : -EIO); @@ -68768,7 +69018,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level->tracked = lh; + } + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + done_carry_pool(pool); + + return result; @@ -68945,12 +69195,12 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c +} + +/* this either appends or truncates item @coord */ -+int reiser4_resize_item(coord_t * coord /* coord of item being resized */ , -+ reiser4_item_data * data /* parameters of resize */ , -+ reiser4_key * key /* key of new unit */ , -+ lock_handle * lh /* lock handle of node -+ * being modified */ , -+ cop_insert_flag flags /* carry flags */ ) ++int resize_item(coord_t * coord /* coord of item being resized */ , ++ reiser4_item_data * data /* parameters of resize */ , ++ reiser4_key * key /* key of new unit */ , ++ lock_handle * lh /* lock handle of node ++ * being modified */ , ++ cop_insert_flag flags /* carry flags */ ) +{ + int result; + znode *node; @@ -68976,7 +69226,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c +} + +/* insert flow @f */ -+int reiser4_insert_flow(coord_t * coord, lock_handle * lh, flow_t * f) ++int insert_flow(coord_t * coord, lock_handle * lh, flow_t * f) +{ + int result; + carry_pool *pool; @@ -68992,7 +69242,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level = (carry_level *) (pool + 1); + init_carry_level(lowest_level, pool); + -+ op = reiser4_post_carry(lowest_level, COP_INSERT_FLOW, coord->node, ++ op = post_carry(lowest_level, COP_INSERT_FLOW, coord->node, + 0 /* operate directly on coord -> node */ ); + if (IS_ERR(op) || (op == NULL)) { + done_carry_pool(pool); @@ -69018,7 +69268,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level->track_type = CARRY_TRACK_CHANGE; + lowest_level->tracked = lh; + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + done_carry_pool(pool); + + return result; @@ -69063,8 +69313,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + else + child = + zget(tree, &addr, parent, -+ znode_get_level(parent) - 1, -+ reiser4_ctx_gfp_mask_get()); ++ znode_get_level(parent) - 1, get_gfp_mask()); + if ((child != NULL) && !IS_ERR(child) && setup_dkeys_p) + set_child_delimiting_keys(parent, parent_coord, child); + } else { @@ -69081,7 +69330,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + + assert("zam-1001", ZF_ISSET(node, JNODE_HEARD_BANSHEE)); + -+ if (!reiser4_blocknr_is_fake(znode_get_block(node))) { ++ if (!blocknr_is_fake(znode_get_block(node))) { + int ret; + + /* An already allocated block goes right to the atom's delete set. */ @@ -69117,21 +69366,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * uncapture page from transaction. There is a possibility of a race + * with ->releasepage(): reiser4_releasepage() detaches page from this + * jnode and we have nothing to uncapture. To avoid this, get -+ * reference of node->pg under jnode spin lock. reiser4_uncapture_page() -+ * will deal with released page itself. ++ * reference of node->pg under jnode spin lock. uncapture_page() will ++ * deal with released page itself. + */ + spin_lock_znode(node); + page = znode_page(node); + if (likely(page != NULL)) { + /* -+ * reiser4_uncapture_page() can only be called when we are sure -+ * that znode is pinned in memory, which we are, because ++ * uncapture_page() can only be called when we are sure that ++ * znode is pinned in memory, which we are, because + * forget_znode() is only called from longterm_unlock_znode(). + */ + page_cache_get(page); + spin_unlock_znode(node); + lock_page(page); -+ reiser4_uncapture_page(page); ++ uncapture_page(page); + unlock_page(page); + page_cache_release(page); + } else { @@ -69147,11 +69396,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + break; + + spin_unlock_znode(node); -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + spin_lock_znode(node); + } + -+ reiser4_uncapture_block(ZJNODE(node)); ++ uncapture_block(ZJNODE(node)); + spin_unlock_atom(atom); + zput(node); + } @@ -69195,7 +69444,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * invalidation does not allow other threads to waste cpu time is a busy + * loop, trying to lock dying object. The exception is in the flush + * code when we take node directly from atom's capture list.*/ -+ reiser4_invalidate_lock(handle); ++ invalidate_lock(handle); + uncapture_znode(node); +} + @@ -69652,7 +69901,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + +/* this is used to remove part of node content between coordinates @from and @to. Units to which @from and @to are set + are to be cut completely */ -+/* for try_to_merge_with_left, delete_copied, reiser4_delete_node */ ++/* for try_to_merge_with_left, delete_copied, delete_node */ +int cut_node_content(coord_t * from, coord_t * to, const reiser4_key * from_key, /* first key to be removed */ + const reiser4_key * to_key, /* last key to be removed */ + reiser4_key * @@ -69674,7 +69923,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + lowest_level = (carry_level *) (pool + 1); + init_carry_level(lowest_level, pool); + -+ op = reiser4_post_carry(lowest_level, COP_CUT, from->node, 0); ++ op = post_carry(lowest_level, COP_CUT, from->node, 0); + assert("vs-1509", op != 0); + if (IS_ERR(op)) { + done_carry_pool(pool); @@ -69691,7 +69940,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + op->u.cut_or_kill.is_cut = 1; + op->u.cut_or_kill.u.cut = cut_data; + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + done_carry_pool(pool); + + return result; @@ -69774,7 +70023,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + } + } + -+ op = reiser4_post_carry(lowest_level, COP_CUT, from->node, 0); ++ op = post_carry(lowest_level, COP_CUT, from->node, 0); + if (IS_ERR(op) || (op == NULL)) { + done_children(kdata); + done_carry_pool(pool); @@ -69784,7 +70033,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + op->u.cut_or_kill.is_cut = 0; + op->u.cut_or_kill.u.kill = kdata; + -+ result = reiser4_carry(lowest_level, NULL); ++ result = carry(lowest_level, NULL); + + done_children(kdata); + done_carry_pool(pool); @@ -69794,7 +70043,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c +void +fake_kill_hook_tail(struct inode *inode, loff_t start, loff_t end, int truncate) +{ -+ if (reiser4_inode_get_flag(inode, REISER4_HAS_MMAP)) { ++ if (inode_get_flag(inode, REISER4_HAS_MMAP)) { + pgoff_t start_pg, end_pg; + + start_pg = start >> PAGE_CACHE_SHIFT; @@ -69835,8 +70084,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * cut_worker() iteration. This is needed for proper accounting of + * "i_blocks" and "i_bytes" fields of the @object. + */ -+int reiser4_delete_node(znode * node, reiser4_key * smallest_removed, -+ struct inode *object, int truncate) ++int delete_node(znode * node, reiser4_key * smallest_removed, ++ struct inode *object, int truncate) +{ + lock_handle parent_lock; + coord_t cut_from; @@ -69955,8 +70204,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * @progress: return true if a progress in file items deletions was made, + * @smallest_removed value is actual in that case. + * -+ * @return: 0 if success, error code otherwise, -E_REPEAT means that long -+ * reiser4_cut_tree operation was interrupted for allowing atom commit. ++ * @return: 0 if success, error code otherwise, -E_REPEAT means that long cut_tree ++ * operation was interrupted for allowing atom commit . + */ +int +cut_tree_worker_common(tap_t * tap, const reiser4_key * from_key, @@ -69990,10 +70239,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + /* Check can we delete the node as a whole. */ + if (*progress && znode_get_level(node) == LEAF_LEVEL && + can_delete(from_key, node)) { -+ result = reiser4_delete_node(node, smallest_removed, -+ object, truncate); ++ result = delete_node(node, smallest_removed, object, ++ truncate); + } else { -+ result = reiser4_tap_load(tap); ++ result = tap_load(tap); + if (result) + return result; + @@ -70047,13 +70296,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + } + + /* cut data from one node */ -+ // *smallest_removed = *reiser4_min_key(); ++ // *smallest_removed = *min_key(); + result = + kill_node_content(&left_coord, tap->coord, from_key, + to_key, smallest_removed, + next_node_lock.node, object, + truncate); -+ reiser4_tap_relse(tap); ++ tap_relse(tap); + } + if (result) + break; @@ -70069,13 +70318,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + if (next_node_lock.node == NULL) + break; + -+ result = reiser4_tap_move(tap, &next_node_lock); ++ result = tap_move(tap, &next_node_lock); + done_lh(&next_node_lock); + if (result) + break; + -+ /* Break long reiser4_cut_tree operation (deletion of a large -+ file) if atom requires commit. */ ++ /* Break long cut_tree operation (deletion of a large file) if ++ * atom requires commit. */ + if (*progress > CUT_TREE_MIN_ITERATIONS + && current_atom_should_commit()) { + result = -E_REPEAT; @@ -70083,7 +70332,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + } + } + done_lh(&next_node_lock); -+ // assert("vs-301", !keyeq(&smallest_removed, reiser4_min_key())); ++ // assert("vs-301", !keyeq(&smallest_removed, min_key())); + return result; +} + @@ -70130,10 +70379,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + * operation was interrupted for allowing atom commit . + */ + -+int reiser4_cut_tree_object(reiser4_tree * tree, const reiser4_key * from_key, -+ const reiser4_key * to_key, -+ reiser4_key * smallest_removed_p, -+ struct inode *object, int truncate, int *progress) ++int ++cut_tree_object(reiser4_tree * tree, const reiser4_key * from_key, ++ const reiser4_key * to_key, reiser4_key * smallest_removed_p, ++ struct inode *object, int truncate, int *progress) +{ + lock_handle lock; + int result; @@ -70157,11 +70406,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + + do { + /* Find rightmost item to cut away from the tree. */ -+ result = reiser4_object_lookup(object, to_key, &right_coord, -+ &lock, ZNODE_WRITE_LOCK, -+ FIND_MAX_NOT_MORE_THAN, -+ TWIG_LEVEL, LEAF_LEVEL, -+ CBK_UNIQUE, NULL /*ra_info */); ++ result = object_lookup(object, to_key, &right_coord, &lock, ++ ZNODE_WRITE_LOCK, FIND_MAX_NOT_MORE_THAN, ++ TWIG_LEVEL, LEAF_LEVEL, CBK_UNIQUE, ++ NULL /*ra_info */ ); + if (result != CBK_COORD_FOUND) + break; + if (object == NULL @@ -70170,13 +70418,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + else + cut_tree_worker = + inode_file_plugin(object)->cut_tree_worker; -+ reiser4_tap_init(&tap, &right_coord, &lock, ZNODE_WRITE_LOCK); ++ tap_init(&tap, &right_coord, &lock, ZNODE_WRITE_LOCK); + result = + cut_tree_worker(&tap, from_key, to_key, smallest_removed_p, + object, truncate, progress); -+ reiser4_tap_done(&tap); ++ tap_done(&tap); + -+ reiser4_preempt_point(); ++ preempt_point(); + + } while (0); + @@ -70202,25 +70450,27 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + return result; +} + -+/* repeat reiser4_cut_tree_object until everything is deleted. -+ * unlike cut_file_items, it does not end current transaction if -E_REPEAT -+ * is returned by cut_tree_object. */ -+int reiser4_cut_tree(reiser4_tree * tree, const reiser4_key * from, -+ const reiser4_key * to, struct inode *inode, int truncate) ++/* repeat cut_tree_object until everything is deleted. unlike cut_file_items, it ++ * does not end current transaction if -E_REPEAT is returned by ++ * cut_tree_object. */ ++int ++cut_tree(reiser4_tree * tree, const reiser4_key * from, const reiser4_key * to, ++ struct inode *inode, int truncate) +{ + int result; + int progress; + + do { -+ result = reiser4_cut_tree_object(tree, from, to, NULL, -+ inode, truncate, &progress); ++ result = ++ cut_tree_object(tree, from, to, NULL, inode, truncate, ++ &progress); + } while (result == -E_REPEAT); + + return result; +} + +/* finishing reiser4 initialization */ -+int reiser4_init_tree(reiser4_tree * tree /* pointer to structure being ++int init_tree(reiser4_tree * tree /* pointer to structure being + * initialized */ , + const reiser4_block_nr * root_block /* address of a root block + * on a disk */ , @@ -70248,8 +70498,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + if (result == 0) + result = jnodes_tree_init(tree); + if (result == 0) { -+ tree->uber = zget(tree, &UBER_TREE_ADDR, NULL, 0, -+ reiser4_ctx_gfp_mask_get()); ++ tree->uber = zget(tree, &UBER_TREE_ADDR, NULL, 0, get_gfp_mask()); + if (IS_ERR(tree->uber)) { + result = PTR_ERR(tree->uber); + tree->uber = NULL; @@ -70259,7 +70508,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c +} + +/* release resources associated with @tree */ -+void reiser4_done_tree(reiser4_tree * tree /* tree to release */ ) ++void done_tree(reiser4_tree * tree /* tree to release */ ) +{ + if (tree == NULL) + return; @@ -70283,10 +70532,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.c linux-2.6.22/fs/reiser4/tree.c + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h ---- linux-2.6.22.orig/fs/reiser4/tree.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree.h 2007-07-29 00:25:35.028735820 +0400 -@@ -0,0 +1,577 @@ +Index: linux-2.6.16/fs/reiser4/tree.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree.h +@@ -0,0 +1,579 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -70355,6 +70605,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + cbk_cache_slot *slot; +} cbk_cache; + ++ +/* level_lookup_result - possible outcome of looking up key at some level. + This is used by coord_by_key when traversing tree downward. */ +typedef enum { @@ -70448,10 +70699,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + } carry; +}; + -+extern int reiser4_init_tree(reiser4_tree * tree, -+ const reiser4_block_nr * root_block, -+ tree_level height, node_plugin * default_plugin); -+extern void reiser4_done_tree(reiser4_tree * tree); ++extern int init_tree(reiser4_tree * tree, ++ const reiser4_block_nr * root_block, tree_level height, ++ node_plugin * default_plugin); ++extern void done_tree(reiser4_tree * tree); + +/* cbk flags: options for coord_by_key() */ +typedef enum { @@ -70493,10 +70744,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + +typedef int (*tree_iterate_actor_t) (reiser4_tree * tree, coord_t * coord, + lock_handle * lh, void *arg); -+extern int reiser4_iterate_tree(reiser4_tree * tree, coord_t * coord, -+ lock_handle * lh, -+ tree_iterate_actor_t actor, void *arg, -+ znode_lock_mode mode, int through_units_p); ++extern int iterate_tree(reiser4_tree * tree, coord_t * coord, lock_handle * lh, ++ tree_iterate_actor_t actor, void *arg, ++ znode_lock_mode mode, int through_units_p); +extern int get_uber_znode(reiser4_tree * tree, znode_lock_mode mode, + znode_lock_request pri, lock_handle * lh); + @@ -70581,15 +70831,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + tree_level lock_level, tree_level stop_level, + __u32 flags, ra_info_t *); + -+lookup_result reiser4_object_lookup(struct inode *object, -+ const reiser4_key * key, -+ coord_t * coord, -+ lock_handle * lh, -+ znode_lock_mode lock_mode, -+ lookup_bias bias, -+ tree_level lock_level, -+ tree_level stop_level, -+ __u32 flags, ra_info_t * info); ++lookup_result object_lookup(struct inode *object, ++ const reiser4_key * key, ++ coord_t * coord, ++ lock_handle * lh, ++ znode_lock_mode lock_mode, ++ lookup_bias bias, ++ tree_level lock_level, ++ tree_level stop_level, ++ __u32 flags, ra_info_t * info); + +insert_result insert_by_key(reiser4_tree * tree, const reiser4_key * key, + reiser4_item_data * data, coord_t * coord, @@ -70610,11 +70860,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + znode * locked_left_neighbor, struct inode *inode, + int truncate); + -+int reiser4_resize_item(coord_t * coord, reiser4_item_data * data, -+ reiser4_key * key, lock_handle * lh, cop_insert_flag); ++int resize_item(coord_t * coord, reiser4_item_data * data, ++ reiser4_key * key, lock_handle * lh, cop_insert_flag); +int insert_into_item(coord_t * coord, lock_handle * lh, const reiser4_key * key, + reiser4_item_data * data, unsigned); -+int reiser4_insert_flow(coord_t * coord, lock_handle * lh, flow_t * f); ++int insert_flow(coord_t * coord, lock_handle * lh, flow_t * f); +int find_new_child_ptr(znode * parent, znode * child, znode * left, + coord_t * result); + @@ -70626,13 +70876,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h +extern int cut_tree_worker_common(tap_t *, const reiser4_key *, + const reiser4_key *, reiser4_key *, + struct inode *, int, int *); -+extern int reiser4_cut_tree_object(reiser4_tree *, const reiser4_key *, -+ const reiser4_key *, reiser4_key *, -+ struct inode *, int, int *); -+extern int reiser4_cut_tree(reiser4_tree * tree, const reiser4_key * from, -+ const reiser4_key * to, struct inode *, int); ++extern int cut_tree_object(reiser4_tree *, const reiser4_key *, ++ const reiser4_key *, reiser4_key *, struct inode *, ++ int, int *); ++extern int cut_tree(reiser4_tree * tree, const reiser4_key * from, ++ const reiser4_key * to, struct inode *, int); + -+extern int reiser4_delete_node(znode *, reiser4_key *, struct inode *, int); ++extern int delete_node(znode * node, reiser4_key *, struct inode *, int); +extern int check_tree_pointer(const coord_t * pointer, const znode * child); +extern int find_new_child_ptr(znode * parent, znode * child UNUSED_ARG, + znode * left, coord_t * result); @@ -70721,6 +70971,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + tree_level lock_level, tree_level stop_level, __u32 flags, + int *result1, int *result2); + ++ +static inline void read_lock_tree(reiser4_tree *tree) +{ + /* check that tree is not locked */ @@ -70851,6 +71102,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h +reiser4_block_nr estimate_insert_cluster(struct inode *); +reiser4_block_nr estimate_update_cluster(struct inode *); + ++ +/* __REISER4_TREE_H__ */ +#endif + @@ -70864,10 +71116,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree.h linux-2.6.22/fs/reiser4/tree.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_mod.c ---- linux-2.6.22.orig/fs/reiser4/tree_mod.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree_mod.c 2007-07-29 00:25:35.032736855 +0400 -@@ -0,0 +1,386 @@ +Index: linux-2.6.16/fs/reiser4/tree_mod.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree_mod.c +@@ -0,0 +1,383 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -70907,10 +71160,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + warning( __VA_ARGS__ ) + +/* allocate new node on the @level and immediately on the right of @brother. */ -+znode * reiser4_new_node(znode * brother /* existing left neighbor -+ * of new node */, -+ tree_level level /* tree level at which new node is to -+ * be allocated */) ++znode *new_node(znode * brother /* existing left neighbor of new node */ , ++ tree_level level /* tree level at which new node is to ++ * be allocated */ ) +{ + znode *result; + int retcode; @@ -70923,7 +71175,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + if (retcode == 0) { + result = + zget(znode_get_tree(brother), &blocknr, NULL, level, -+ reiser4_ctx_gfp_mask_get()); ++ get_gfp_mask()); + if (IS_ERR(result)) { + ewarning(PTR_ERR(result), "nikita-929", + "Cannot allocate znode for carry: %li", @@ -70943,7 +71195,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + result->nplug = znode_get_tree(brother)->nplug; + assert("nikita-933", result->nplug != NULL); + -+ retcode = zinit_new(result, reiser4_ctx_gfp_mask_get()); ++ retcode = zinit_new(result, get_gfp_mask()); + if (retcode == 0) { + ZF_SET(result, JNODE_CREATED); + zrelse(result); @@ -70970,7 +71222,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + This helper function is called by add_new_root(). + +*/ -+znode *reiser4_add_tree_root(znode * old_root /* existing tree root */ , ++znode *add_tree_root(znode * old_root /* existing tree root */ , + znode * fake /* "fake" znode */ ) +{ + reiser4_tree *tree = znode_get_tree(old_root); @@ -71008,7 +71260,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + flush can be going here. + */ + assert("nikita-1448", znode_is_root(old_root)); -+ new_root = reiser4_new_node(fake, tree->height + 1); ++ new_root = new_node(fake, tree->height + 1); + if (!IS_ERR(new_root) && (result = zload(new_root)) == 0) { + lock_handle rlh; + @@ -71047,8 +71299,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + WITH_DATA(new_root, + node_is_empty(new_root))); + write_lock_dk(tree); -+ znode_set_ld_key(new_root, reiser4_min_key()); -+ znode_set_rd_key(new_root, reiser4_max_key()); ++ znode_set_ld_key(new_root, min_key()); ++ znode_set_rd_key(new_root, max_key()); + write_unlock_dk(tree); + if (REISER4_DEBUG) { + ZF_CLR(old_root, JNODE_LEFT_CONNECTED); @@ -71133,14 +71385,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m +} + +/* actually remove tree root */ -+static int reiser4_kill_root(reiser4_tree * tree /* tree from which root is -+ * being removed */, -+ znode * old_root /* root node that is being -+ * removed */ , -+ znode * new_root /* new root---sole child of -+ * @old_root */, -+ const reiser4_block_nr * new_root_blk /* disk address of -+ * @new_root */) ++static int kill_root(reiser4_tree * tree /* tree from which root is being ++ * removed */ , ++ znode * old_root /* root node that is being removed */ , ++ znode * new_root /* new root---sole child of * ++ * @old_root */ , ++ const reiser4_block_nr * new_root_blk /* disk address of ++ * @new_root */ ) +{ + znode *uber; + int result; @@ -71206,17 +71457,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + at the entry. + + To remove tree root we need to take lock on special "fake" znode that -+ protects changes of tree height. See comments in reiser4_add_tree_root() for -+ more on this. ++ protects changes of tree height. See comments in add_tree_root() for more ++ on this. + + Also parent pointers have to be updated in + old and new root. To simplify code, function is split into two parts: outer -+ reiser4_kill_tree_root() collects all necessary arguments and calls -+ reiser4_kill_root() to do the actual job. ++ kill_tree_root() collects all necessary arguments and calls kill_root() ++ to do the actual job. + +*/ -+int reiser4_kill_tree_root(znode * old_root /* tree root that we are -+ removing*/) ++int kill_tree_root(znode * old_root /* tree root that we are removing */ ) +{ + int result; + coord_t down_link; @@ -71235,8 +71485,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + new_root = child_znode(&down_link, old_root, 0, 1); + if (!IS_ERR(new_root)) { + result = -+ reiser4_kill_root(tree, old_root, new_root, -+ znode_get_block(new_root)); ++ kill_root(tree, old_root, new_root, ++ znode_get_block(new_root)); + zput(new_root); + } else + result = PTR_ERR(new_root); @@ -71254,9 +71504,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.c linux-2.6.22/fs/reiser4/tree_m + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.h linux-2.6.22/fs/reiser4/tree_mod.h ---- linux-2.6.22.orig/fs/reiser4/tree_mod.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree_mod.h 2007-07-29 00:25:35.032736855 +0400 +Index: linux-2.6.16/fs/reiser4/tree_mod.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree_mod.h @@ -0,0 +1,29 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -71269,9 +71520,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.h linux-2.6.22/fs/reiser4/tree_m + +#include "forward.h" + -+znode *reiser4_new_node(znode * brother, tree_level level); -+znode *reiser4_add_tree_root(znode * old_root, znode * fake); -+int reiser4_kill_tree_root(znode * old_root); ++znode *new_node(znode * brother, tree_level level); ++znode *add_tree_root(znode * old_root, znode * fake); ++int kill_tree_root(znode * old_root); +void build_child_ptr_data(znode * child, reiser4_item_data * data); + +/* __REISER4_TREE_MOD_H__ */ @@ -71287,10 +71538,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_mod.h linux-2.6.22/fs/reiser4/tree_m + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.c linux-2.6.22/fs/reiser4/tree_walk.c ---- linux-2.6.22.orig/fs/reiser4/tree_walk.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree_walk.c 2007-07-29 00:25:35.032736855 +0400 -@@ -0,0 +1,927 @@ +Index: linux-2.6.16/fs/reiser4/tree_walk.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree_walk.c +@@ -0,0 +1,926 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -71716,8 +71968,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.c linux-2.6.22/fs/reiser4/tree_ + neighbor = zlook(tree, &da); + } else { + neighbor = -+ zget(tree, &da, side_parent, level, -+ reiser4_ctx_gfp_mask_get()); ++ zget(tree, &da, side_parent, level, get_gfp_mask()); + } + + if (IS_ERR(neighbor)) { @@ -72060,7 +72311,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.c linux-2.6.22/fs/reiser4/tree_ + /* there was lock request from hi-pri locker. if + it is possible we unlock last parent node and + re-lock it again. */ -+ for (; reiser4_check_deadlock(); h--) { ++ for (; check_deadlock(); h--) { + done_lh(&path[h]); + if (h == 0) + goto fail; @@ -72218,9 +72469,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.c linux-2.6.22/fs/reiser4/tree_ + fill-column: 80 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.h linux-2.6.22/fs/reiser4/tree_walk.h ---- linux-2.6.22.orig/fs/reiser4/tree_walk.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/tree_walk.h 2007-07-29 00:25:35.032736855 +0400 +Index: linux-2.6.16/fs/reiser4/tree_walk.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/tree_walk.h @@ -0,0 +1,125 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -72347,10 +72599,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/tree_walk.h linux-2.6.22/fs/reiser4/tree_ + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c ---- linux-2.6.22.orig/fs/reiser4/txnmgr.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/txnmgr.c 2007-07-29 00:25:35.040738926 +0400 -@@ -0,0 +1,3164 @@ +Index: linux-2.6.16/fs/reiser4/txnmgr.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/txnmgr.c +@@ -0,0 +1,3158 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -72393,7 +72646,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + +/* Thoughts on the external transaction interface: + -+ In the current code, a TRANSCRASH handle is created implicitly by reiser4_init_context() (which ++ In the current code, a TRANSCRASH handle is created implicitly by init_context() (which + creates state that lasts for the duration of a system call and is called at the start + of ReiserFS methods implementing VFS operations), and closed by reiser4_exit_context(), + occupying the scope of a single system call. We wish to give certain applications an @@ -72443,7 +72696,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + For actually implementing these out-of-system-call-scopped transcrashes, the + reiser4_context has a "txn_handle *trans" pointer that may be set to an open + transcrash. Currently there are no dynamically-allocated transcrashes, but there is a -+ "struct kmem_cache *_txnh_slab" created for that purpose in this file. ++ "kmem_cache_t *_txnh_slab" created for that purpose in this file. +*/ + +/* Extending the other system call interfaces for future transaction features: @@ -72531,8 +72784,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + * Steps (2) and (3) take place under long term lock on the twig node. + * + * When file is accessed through mmap(2) page is always created during -+ * page fault. -+ * After this (in reiser4_readpage()->reiser4_readpage_extent()): ++ * page fault. After this (in reiser4_readpage()->readpage_extent()): + * + * 1. if access is made to non-hole page new jnode is created, (if + * necessary) @@ -72616,7 +72868,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + +static void capture_fuse_into(txn_atom * small, txn_atom * large); + -+void reiser4_invalidate_list(struct list_head *); ++void invalidate_list(struct list_head *); + +/* GENERIC STRUCTURES */ + @@ -72632,9 +72884,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + +/* FIXME: In theory, we should be using the slab cache init & destructor + methods instead of, e.g., jnode_init, etc. */ -+static struct kmem_cache *_atom_slab = NULL; ++static kmem_cache_t *_atom_slab = NULL; +/* this is for user-visible, cross system-call transactions. */ -+static struct kmem_cache *_txnh_slab = NULL; ++static kmem_cache_t *_txnh_slab = NULL; + +/** + * init_txnmgr_static - create transaction manager slab caches @@ -72683,7 +72935,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + * + * This is called on mount. Makes necessary initializations. + */ -+void reiser4_init_txnmgr(txn_mgr *mgr) ++void init_txnmgr(txn_mgr *mgr) +{ + assert("umka-169", mgr != NULL); + @@ -72691,16 +72943,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + mgr->id_count = 1; + INIT_LIST_HEAD(&mgr->atoms_list); + spin_lock_init(&mgr->tmgr_lock); -+ mutex_init(&mgr->commit_mutex); ++ sema_init(&mgr->commit_semaphore, 1); +} + +/** -+ * reiser4_done_txnmgr - stop transaction manager ++ * done_txnmgr - stop transaction manager + * @mgr: pointer to transaction manager embedded in reiser4 super block + * + * This is called on umount. Does sanity checks. + */ -+void reiser4_done_txnmgr(txn_mgr *mgr) ++void done_txnmgr(txn_mgr *mgr) +{ + assert("umka-170", mgr != NULL); + assert("umka-1701", list_empty_careful(&mgr->atoms_list)); @@ -72715,7 +72967,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + + txnh->mode = mode; + txnh->atom = NULL; -+ reiser4_ctx_gfp_mask_set(); ++ set_gfp_mask(); + txnh->flags = 0; + spin_lock_init(&txnh->hlock); + INIT_LIST_HEAD(&txnh->txnh_link); @@ -72750,7 +73002,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + INIT_LIST_HEAD(ATOM_OVRWR_LIST(atom)); + INIT_LIST_HEAD(ATOM_WB_LIST(atom)); + INIT_LIST_HEAD(&atom->inodes); -+ spin_lock_init(&(atom->alock)); ++ spin_lock_init(&atom->alock); + /* list of transaction handles */ + INIT_LIST_HEAD(&atom->txnh_list); + /* link to transaction manager's list of atoms */ @@ -72797,7 +73049,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + trans_in_ctx, which means that transaction handles are stack-allocated. Eventually + this will be extended to allow transaction handles to span several contexts. */ +/* Audited by: umka (2002.06.13) */ -+void reiser4_txn_begin(reiser4_context * context) ++void txn_begin(reiser4_context * context) +{ + assert("jmacd-544", context->trans == NULL); + @@ -72812,13 +73064,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c +} + +/* Finish a transaction handle context. */ -+int reiser4_txn_end(reiser4_context * context) ++int txn_end(reiser4_context * context) +{ + long ret = 0; + txn_handle *txnh; + + assert("umka-283", context != NULL); -+ assert("nikita-3012", reiser4_schedulable()); ++ assert("nikita-3012", schedulable()); + assert("vs-24", context == get_current_context()); + assert("nikita-2967", lock_stack_isclean(get_current_lock_stack())); + @@ -72832,16 +73084,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + return ret; +} + -+void reiser4_txn_restart(reiser4_context * context) ++void txn_restart(reiser4_context * context) +{ -+ reiser4_txn_end(context); -+ reiser4_preempt_point(); -+ reiser4_txn_begin(context); ++ txn_end(context); ++ preempt_point(); ++ txn_begin(context); +} + -+void reiser4_txn_restart_current(void) ++void txn_restart_current(void) +{ -+ reiser4_txn_restart(get_current_context()); ++ txn_restart(get_current_context()); +} + +/* TXN_ATOM */ @@ -73053,8 +73305,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + } + + if (*atom_alloc == NULL) { -+ (*atom_alloc) = kmem_cache_alloc(_atom_slab, -+ reiser4_ctx_gfp_mask_get()); ++ (*atom_alloc) = kmem_cache_alloc(_atom_slab, get_gfp_mask()); + + if (*atom_alloc == NULL) + return RETERR(-ENOMEM); @@ -73069,7 +73320,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* Check whether new atom still needed */ + if (txnh->atom != NULL) { + /* NOTE-NIKITA probably it is rather better to free -+ * atom_alloc here than thread it up to reiser4_try_capture() */ ++ * atom_alloc here than thread it up to try_capture(). */ + + spin_unlock_txnh(txnh); + spin_unlock_txnmgr(mgr); @@ -73085,12 +73336,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("jmacd-17", atom_isclean(atom)); + + /* -+ * lock ordering is broken here. It is ok, as long as @atom is new -+ * and inaccessible for others. We can't use spin_lock_atom or -+ * spin_lock(&atom->alock) because they care about locking -+ * dependencies. spin_trylock_lock doesn't. ++ * do not use spin_lock_atom because we have broken lock ordering here ++ * which is ok, as long as @atom is new and inaccessible for others. + */ -+ check_me("", spin_trylock_atom(atom)); ++ spin_lock(&(atom->alock)); + + /* add atom to the end of transaction manager's list of atoms */ + list_add_tail(&atom->atom_link, &mgr->atoms_list); @@ -73106,7 +73355,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + atom->super = reiser4_get_current_sb(); + capture_assign_txnh_nolock(atom, txnh); + -+ spin_unlock_atom(atom); ++ spin_unlock(&(atom->alock)); + spin_unlock_txnh(txnh); + + return -E_REPEAT; @@ -73297,8 +73546,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + dispatch_wb_list(fq->atom, fq); + spin_unlock_atom(fq->atom); + -+ ret = reiser4_write_fq(fq, NULL, 1); -+ reiser4_fq_put(fq); ++ ret = write_fq(fq, NULL, 1); ++ fq_put(fq); + + return ret; +} @@ -73330,28 +73579,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + return current_atom_finish_all_fq(); +} + -+#if REISER4_DEBUG -+ -+static void reiser4_info_atom(const char *prefix, const txn_atom * atom) -+{ -+ if (atom == NULL) { -+ printk("%s: no atom\n", prefix); -+ return; -+ } -+ -+ printk("%s: refcount: %i id: %i flags: %x txnh_count: %i" -+ " capture_count: %i stage: %x start: %lu, flushed: %i\n", prefix, -+ atomic_read(&atom->refcount), atom->atom_id, atom->flags, -+ atom->txnh_count, atom->capture_count, atom->stage, -+ atom->start_time, atom->flushed); -+} -+ -+#else /* REISER4_DEBUG */ -+ -+static inline void reiser4_info_atom(const char *prefix, const txn_atom * atom) {} -+ -+#endif /* REISER4_DEBUG */ -+ +#define TOOMANYFLUSHES (1 << 13) + +/* Called with the atom locked and no open "active" transaction handlers except @@ -73379,8 +73606,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("zam-887", get_current_context()->trans->atom == *atom); + assert("jmacd-151", atom_isopen(*atom)); + ++ /* lock ordering: delete_sema and commit_sema are unordered */ + assert("nikita-3184", -+ get_current_super_private()->delete_mutex_owner != current); ++ get_current_super_private()->delete_sema_owner != current); + + for (flushiters = 0;; ++flushiters) { + ret = @@ -73394,13 +73622,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* if atom's dirty list contains one znode which is + HEARD_BANSHEE and is locked we have to allow lock owner to + continue and uncapture that znode */ -+ reiser4_preempt_point(); ++ preempt_point(); + + *atom = get_current_atom_locked(); + if (flushiters > TOOMANYFLUSHES && IS_POW(flushiters)) { + warning("nikita-3176", + "Flushing like mad: %i", flushiters); -+ reiser4_info_atom("atom", *atom); ++ info_atom("atom", *atom); + DEBUGON(flushiters > (1 << 20)); + } + } @@ -73421,7 +73649,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* Up to this point we have been flushing and after flush is called we + return -E_REPEAT. Now we can commit. We cannot return -E_REPEAT + at this point, commit should be successful. */ -+ reiser4_atom_set_stage(*atom, ASTAGE_PRE_COMMIT); ++ atom_set_stage(*atom, ASTAGE_PRE_COMMIT); + ON_DEBUG(((*atom)->committer = current)); + spin_unlock_atom(*atom); + @@ -73432,28 +73660,28 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("zam-906", list_empty(ATOM_WB_LIST(*atom))); + + /* isolate critical code path which should be executed by only one -+ * thread using tmgr mutex */ -+ mutex_lock(&sbinfo->tmgr.commit_mutex); ++ * thread using tmgr semaphore */ ++ down(&sbinfo->tmgr.commit_semaphore); + + ret = reiser4_write_logs(nr_submitted); + if (ret < 0) + reiser4_panic("zam-597", "write log failed (%ld)\n", ret); + -+ /* The atom->ovrwr_nodes list is processed under commit mutex held ++ /* The atom->ovrwr_nodes list is processed under commit semaphore held + because of bitmap nodes which are captured by special way in -+ reiser4_pre_commit_hook_bitmap(), that way does not include ++ bitmap_pre_commit_hook(), that way does not include + capture_fuse_wait() as a capturing of other nodes does -- the commit -+ mutex is used for transaction isolation instead. */ -+ reiser4_invalidate_list(ATOM_OVRWR_LIST(*atom)); -+ mutex_unlock(&sbinfo->tmgr.commit_mutex); ++ semaphore is used for transaction isolation instead. */ ++ invalidate_list(ATOM_OVRWR_LIST(*atom)); ++ up(&sbinfo->tmgr.commit_semaphore); + -+ reiser4_invalidate_list(ATOM_CLEAN_LIST(*atom)); -+ reiser4_invalidate_list(ATOM_WB_LIST(*atom)); ++ invalidate_list(ATOM_CLEAN_LIST(*atom)); ++ invalidate_list(ATOM_WB_LIST(*atom)); + assert("zam-927", list_empty(&(*atom)->inodes)); + + spin_lock_atom(*atom); + done: -+ reiser4_atom_set_stage(*atom, ASTAGE_DONE); ++ atom_set_stage(*atom, ASTAGE_DONE); + ON_DEBUG((*atom)->committer = NULL); + + /* Atom's state changes, so wake up everybody waiting for this @@ -73505,7 +73733,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + spin_unlock_atom(atom); + + /* commit is here */ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + return 0; +} + @@ -73522,9 +73750,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + reiser4_context *ctx = get_current_context(); + + assert("nikita-2965", lock_stack_isclean(get_current_lock_stack())); -+ assert("nikita-3058", reiser4_commit_check_locks()); ++ assert("nikita-3058", commit_check_locks()); + -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + + mgr = &get_super_private(super)->tmgr; + @@ -73554,7 +73782,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + return ret; + } else + /* wait atom commit */ -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + + goto again; + } @@ -73651,7 +73879,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + has to rescan atoms */ + mgr->daemon->rescan = 1; + spin_unlock(&mgr->daemon->guard); -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + return 0; +} + @@ -73782,7 +74010,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + * makes a progress in flushing or + * committing the atom + */ -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + goto repeat; + } + spin_unlock_atom(atom); @@ -73814,7 +74042,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + !(atom->flags & ATOM_CANCEL_FUSION)) { + ret = txn_try_to_fuse_small_atom(tmgr, atom); + if (ret == -E_REPEAT) { -+ reiser4_preempt_point(); ++ preempt_point(); + goto repeat; + } + } @@ -73832,7 +74060,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + if (*nr_submitted == 0) { + /* let others who hampers flushing (hold longterm locks, + for instance) to free the way for flush */ -+ reiser4_preempt_point(); ++ preempt_point(); + goto repeat; + } + ret = 0; @@ -73841,20 +74069,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + if (*nr_submitted > wbc->nr_to_write) + warning("", "asked for %ld, written %ld\n", wbc->nr_to_write, *nr_submitted); +*/ -+ reiser4_txn_restart(ctx); ++ txn_restart(ctx); + + return ret; +} + +/* Remove processed nodes from atom's clean list (thereby remove them from transaction). */ -+void reiser4_invalidate_list(struct list_head *head) ++void invalidate_list(struct list_head *head) +{ + while (!list_empty(head)) { + jnode *node; + + node = list_entry(head->next, jnode, capture_link); + spin_lock_jnode(node); -+ reiser4_uncapture_block(node); ++ uncapture_block(node); + jput(node); + } +} @@ -73869,7 +74097,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c +} + +/* Add atom to the atom's waitfor list and wait for somebody to wake us up; */ -+void reiser4_atom_wait_event(txn_atom * atom) ++void atom_wait_event(txn_atom * atom) +{ + txn_wait_links _wlinks; + @@ -73883,29 +74111,29 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + atomic_inc(&atom->refcount); + spin_unlock_atom(atom); + -+ reiser4_prepare_to_sleep(_wlinks._lock_stack); -+ reiser4_go_to_sleep(_wlinks._lock_stack); ++ prepare_to_sleep(_wlinks._lock_stack); ++ go_to_sleep(_wlinks._lock_stack); + + spin_lock_atom(atom); + list_del(&_wlinks._fwaitfor_link); + atom_dec_and_unlock(atom); +} + -+void reiser4_atom_set_stage(txn_atom * atom, txn_stage stage) ++void atom_set_stage(txn_atom * atom, txn_stage stage) +{ + assert("nikita-3535", atom != NULL); + assert_spin_locked(&(atom->alock)); -+ assert("nikita-3536", stage <= ASTAGE_INVALID); ++ assert("nikita-3536", ASTAGE_FREE <= stage && stage <= ASTAGE_INVALID); + /* Excelsior! */ + assert("nikita-3537", stage >= atom->stage); + if (atom->stage != stage) { + atom->stage = stage; -+ reiser4_atom_send_event(atom); ++ atom_send_event(atom); + } +} + +/* wake all threads which wait for an event */ -+void reiser4_atom_send_event(txn_atom * atom) ++void atom_send_event(txn_atom * atom) +{ + assert_spin_locked(&(atom->alock)); + wakeup_atom_waitfor_list(atom); @@ -73980,8 +74208,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + * increase monotonically), hence this check. + */ + if (cd->atom->stage < ASTAGE_CAPTURE_WAIT) -+ reiser4_atom_set_stage(cd->atom, -+ ASTAGE_CAPTURE_WAIT); ++ atom_set_stage(cd->atom, ASTAGE_CAPTURE_WAIT); + cd->atom->flags |= ATOM_FORCE_COMMIT; + } + if (cd->txnh->flags & TXNH_DONT_COMMIT) { @@ -74000,14 +74227,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + cd->wake_ktxnmgrd_up = + cd->atom->txnh_count == 1 && + cd->atom->nr_waiters == 0; -+ reiser4_atom_send_event(cd->atom); ++ atom_send_event(cd->atom); + result = 0; + } else if (!atom_can_be_committed(cd->atom)) { + if (should_wait_commit(cd->txnh)) { + /* sync(): wait for commit */ + cd->atom->nr_waiters++; + cd->wait = 1; -+ reiser4_atom_wait_event(cd->atom); ++ atom_wait_event(cd->atom); + result = RETERR(-E_REPEAT); + } else { + result = 0; @@ -74034,7 +74261,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* We change atom state to ASTAGE_CAPTURE_WAIT to + prevent atom fusion and count ourself as an active + flusher */ -+ reiser4_atom_set_stage(cd->atom, ASTAGE_CAPTURE_WAIT); ++ atom_set_stage(cd->atom, ASTAGE_CAPTURE_WAIT); + cd->atom->flags |= ATOM_FORCE_COMMIT; + + result = @@ -74073,7 +74300,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* calls try_commit_txnh() until either atom commits, or error + * happens */ + while (try_commit_txnh(&cd) != 0) -+ reiser4_preempt_point(); ++ preempt_point(); + + spin_lock_txnh(txnh); + @@ -74129,8 +74356,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + This function acquires and releases the handle's spinlock. This function is called + under the jnode lock and if the return value is 0, it returns with the jnode lock still + held. If the return is -E_REPEAT or some other error condition, the jnode lock is -+ released. The external interface (reiser4_try_capture) manages re-aquiring the jnode -+ lock in the failure case. ++ released. The external interface (try_capture) manages re-aquiring the jnode lock ++ in the failure case. +*/ +static int try_capture_block( + txn_handle * txnh, jnode * node, txn_capture mode, @@ -74139,7 +74366,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + txn_atom *block_atom; + txn_atom *txnh_atom; + -+ /* Should not call capture for READ_NONCOM requests, handled in reiser4_try_capture. */ ++ /* Should not call capture for READ_NONCOM requests, handled in try_capture. */ + assert("jmacd-567", CAPTURE_TYPE(mode) != TXN_CAPTURE_READ_NONCOM); + + /* FIXME-ZAM-HANS: FIXME_LATER_JMACD Should assert that atom->tree == @@ -74147,7 +74374,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("umka-194", txnh != NULL); + assert("umka-195", node != NULL); + -+ /* The jnode is already locked! Being called from reiser4_try_capture(). */ ++ /* The jnode is already locked! Being called from try_capture(). */ + assert_spin_locked(&(node->guard)); + block_atom = node->atom; + @@ -74310,8 +74537,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + cannot be processed immediately as it was requested in flags, + < 0 - other errors. +*/ -+int reiser4_try_capture(jnode *node, znode_lock_mode lock_mode, -+ txn_capture flags) ++int try_capture(jnode *node, znode_lock_mode lock_mode, ++ txn_capture flags) +{ + txn_atom *atom_alloc = NULL; + txn_capture cap_mode; @@ -74488,11 +74715,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + atomic_inc(&atomf->refcount); + spin_unlock_txnh(ctx->trans); + if (atomf > atomh) { -+ spin_lock_atom_nested(atomf); ++ spin_lock_atom(atomf); + } else { + spin_unlock_atom(atomh); + spin_lock_atom(atomf); -+ spin_lock_atom_nested(atomh); ++ spin_lock_atom(atomh); + } + if (atomh == atomf || !atom_isopen(atomh) || !atom_isopen(atomf)) { + release_two_atoms(atomf, atomh); @@ -74524,7 +74751,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + spin_lock_jnode(node); + unlock_page(pg); + -+ ret = reiser4_try_capture(node, ZNODE_WRITE_LOCK, 0); ++ ret = try_capture(node, ZNODE_WRITE_LOCK, 0); + spin_unlock_jnode(node); + jput(node); + lock_page(pg); @@ -74541,7 +74768,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + +VS-FIXME-HANS: can this code be at all streamlined? In particular, can you lock and unlock the jnode fewer times? + */ -+void reiser4_uncapture_page(struct page *pg) ++void uncapture_page(struct page *pg) +{ + jnode *node; + txn_atom *atom; @@ -74567,26 +74794,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + + /* We can remove jnode from transaction even if it is on flush queue + * prepped list, we only need to be sure that flush queue is not being -+ * written by reiser4_write_fq(). reiser4_write_fq() does not use atom -+ * spin lock for protection of the prepped nodes list, instead -+ * write_fq() increments atom's nr_running_queues counters for the time -+ * when prepped list is not protected by spin lock. Here we check this -+ * counter if we want to remove jnode from flush queue and, if the -+ * counter is not zero, wait all reiser4_write_fq() for this atom to -+ * complete. This is not significant overhead. */ ++ * written by write_fq(). write_fq() does not use atom spin lock for ++ * protection of the prepped nodes list, instead write_fq() increments ++ * atom's nr_running_queues counters for the time when prepped list is ++ * not protected by spin lock. Here we check this counter if we want ++ * to remove jnode from flush queue and, if the counter is not zero, ++ * wait all write_fq() for this atom to complete. This is not ++ * significant overhead. */ + while (JF_ISSET(node, JNODE_FLUSH_QUEUED) && atom->nr_running_queues) { + spin_unlock_jnode(node); + /* + * at this moment we want to wait for "atom event", viz. wait + * until @node can be removed from flush queue. But -+ * reiser4_atom_wait_event() cannot be called with page locked, -+ * because it deadlocks with jnode_extent_write(). Unlock page, -+ * after making sure (through page_cache_get()) that it cannot -+ * be released from memory. ++ * atom_wait_event() cannot be called with page locked, because ++ * it deadlocks with jnode_extent_write(). Unlock page, after ++ * making sure (through page_cache_get()) that it cannot be ++ * released from memory. + */ + page_cache_get(pg); + unlock_page(pg); -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + lock_page(pg); + /* + * page may has been detached by ->writepage()->releasepage(). @@ -74601,14 +74828,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + return; + } + } -+ reiser4_uncapture_block(node); ++ uncapture_block(node); + spin_unlock_atom(atom); + jput(node); +} + +/* this is used in extent's kill hook to uncapture and unhash jnodes attached to + * inode's tree of jnodes */ -+void reiser4_uncapture_jnode(jnode * node) ++void uncapture_jnode(jnode * node) +{ + txn_atom *atom; + @@ -74622,7 +74849,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + return; + } + -+ reiser4_uncapture_block(node); ++ uncapture_block(node); + spin_unlock_atom(atom); + jput(node); +} @@ -74642,7 +74869,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + + atomic_inc(&atom->refcount); + txnh->atom = atom; -+ reiser4_ctx_gfp_mask_set(); ++ set_gfp_mask(); + list_add_tail(&txnh->txnh_link, &atom->txnh_list); + atom->txnh_count += 1; +} @@ -74691,7 +74918,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + if (!JF_ISSET(node, JNODE_CREATED) && !JF_ISSET(node, JNODE_RELOC) + && !JF_ISSET(node, JNODE_OVRWR) && jnode_is_leaf(node) + && !jnode_is_cluster_page(node)) { -+ assert("vs-1093", !reiser4_blocknr_is_fake(&node->blocknr)); ++ assert("vs-1093", !blocknr_is_fake(&node->blocknr)); + assert("vs-1506", *jnode_get_block(node) != 0); + grabbed2flush_reserved_nolock(atom, (__u64) 1); + JF_SET(node, JNODE_FLUSH_RESERVED); @@ -74779,7 +75006,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + spin_unlock_jnode(node); + /* reiser4 file write code calls set_page_dirty for + * unformatted nodes, for formatted nodes we do it here. */ -+ reiser4_set_page_dirty_internal(page); ++ set_page_dirty_internal(page); + page_cache_release(page); + /* bump version counter in znode */ + z->version = znode_build_version(jnode_get_tree(node)); @@ -74792,7 +75019,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("jmacd-9777", node->atom != NULL); +} + -+int reiser4_sync_atom(txn_atom * atom) ++int sync_atom(txn_atom * atom) +{ + int result; + txn_handle *txnh; @@ -74807,7 +75034,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + result = force_commit_atom(txnh); + } else if (atom->stage < ASTAGE_POST_COMMIT) { + /* wait atom commit */ -+ reiser4_atom_wait_event(atom); ++ atom_wait_event(atom); + /* try once more */ + result = RETERR(-E_REPEAT); + } else @@ -74886,7 +75113,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + count = 0; + + /* flush queue list */ -+ /* reiser4_check_fq(atom); */ ++ /*check_fq(atom); */ + + /* dirty list */ + count = 0; @@ -74949,7 +75176,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("nikita-2432", !JF_ISSET(node, JNODE_RELOC)); + assert("nikita-3153", JF_ISSET(node, JNODE_DIRTY)); + assert("zam-897", !JF_ISSET(node, JNODE_FLUSH_QUEUED)); -+ assert("nikita-3367", !reiser4_blocknr_is_fake(jnode_get_block(node))); ++ assert("nikita-3367", !blocknr_is_fake(jnode_get_block(node))); + + atom = node->atom; + @@ -74986,7 +75213,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + assert("zam-917", !JF_ISSET(node, JNODE_RELOC)); + assert("zam-918", !JF_ISSET(node, JNODE_OVRWR)); + assert("zam-920", !JF_ISSET(node, JNODE_FLUSH_QUEUED)); -+ assert("nikita-3367", !reiser4_blocknr_is_fake(jnode_get_block(node))); ++ assert("nikita-3367", !blocknr_is_fake(jnode_get_block(node))); + jnode_set_reloc(node); +} + @@ -75019,14 +75246,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + queue_jnode(fq, node); +} + -+int reiser4_capture_super_block(struct super_block *s) ++int capture_super_block(struct super_block *s) +{ + int result; + znode *uber; + lock_handle lh; + + init_lh(&lh); -+ result = get_uber_znode(reiser4_get_tree(s), ++ result = get_uber_znode(get_tree(s), + ZNODE_WRITE_LOCK, ZNODE_LOCK_LOPRI, &lh); + if (result) + return result; @@ -75142,9 +75369,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* Go to sleep. */ + spin_unlock_txnh(txnh); + -+ ret = reiser4_prepare_to_sleep(wlinks._lock_stack); ++ ret = prepare_to_sleep(wlinks._lock_stack); + if (ret == 0) { -+ reiser4_go_to_sleep(wlinks._lock_stack); ++ go_to_sleep(wlinks._lock_stack); + ret = RETERR(-E_REPEAT); + } + @@ -75170,13 +75397,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + /* lock the atom with lesser address first */ + if (one < two) { + spin_lock_atom(one); -+ spin_lock_atom_nested(two); ++ spin_lock_atom(two); + } else { + spin_lock_atom(two); -+ spin_lock_atom_nested(one); ++ spin_lock_atom(one); + } +} + ++ +/* Perform the necessary work to prepare for fusing two atoms, which involves + * acquiring two atom locks in the proper order. If one of the node's atom is + * blocking fusion (i.e., it is in the CAPTURE_WAIT stage) and the handle's @@ -75331,7 +75559,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + small->nr_waiters = 0; + + /* splice flush queues */ -+ reiser4_fuse_fq(large, small); ++ fuse_fq(large, small); + + /* update counter of jnode on every atom' list */ + ON_DEBUG(large->dirty += small->dirty; @@ -75392,11 +75620,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + + if (large->stage < small->stage) { + /* Large only needs to notify if it has changed state. */ -+ reiser4_atom_set_stage(large, small->stage); ++ atom_set_stage(large, small->stage); + wakeup_atom_waiting_list(large); + } + -+ reiser4_atom_set_stage(small, ASTAGE_INVALID); ++ atom_set_stage(small, ASTAGE_INVALID); + + /* Notify any waiters--small needs to unload its wait lists. Waiters + actually remove themselves from the list before returning from the @@ -75416,8 +75644,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + + NOTE: this function does not release a (journal) reference to jnode + due to locking optimizations, you should call jput() somewhere after -+ calling reiser4_uncapture_block(). */ -+void reiser4_uncapture_block(jnode * node) ++ calling uncapture_block(). */ ++void uncapture_block(jnode * node) +{ + txn_atom *atom; + @@ -75469,6 +75697,25 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + ON_DEBUG(count_jnode(atom, node, NODE_LIST(node), OVRWR_LIST, 1)); +} + ++ ++#if REISER4_DEBUG ++ ++void info_atom(const char *prefix, const txn_atom * atom) ++{ ++ if (atom == NULL) { ++ printk("%s: no atom\n", prefix); ++ return; ++ } ++ ++ printk("%s: refcount: %i id: %i flags: %x txnh_count: %i" ++ " capture_count: %i stage: %x start: %lu, flushed: %i\n", prefix, ++ atomic_read(&atom->refcount), atom->atom_id, atom->flags, ++ atom->txnh_count, atom->capture_count, atom->stage, ++ atom->start_time, atom->flushed); ++} ++ ++#endif ++ +static int count_deleted_blocks_actor(txn_atom * atom, + const reiser4_block_nr * a, + const reiser4_block_nr * b, void *data) @@ -75515,10 +75762,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.c linux-2.6.22/fs/reiser4/txnmgr.c + * fill-column: 79 + * End: + */ -diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h ---- linux-2.6.22.orig/fs/reiser4/txnmgr.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/txnmgr.h 2007-07-29 00:25:35.044739961 +0400 -@@ -0,0 +1,701 @@ +Index: linux-2.6.16/fs/reiser4/txnmgr.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/txnmgr.h +@@ -0,0 +1,704 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -75536,11 +75784,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +#include +#include +#include -+#include ++#include + +/* TYPE DECLARATIONS */ + -+/* This enumeration describes the possible types of a capture request (reiser4_try_capture). ++/* This enumeration describes the possible types of a capture request (try_capture). + A capture request dynamically assigns a block to the calling thread's transaction + handle. */ +typedef enum { @@ -75574,12 +75822,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + indicate modification will occur. */ + TXN_CAPTURE_WTYPES = (TXN_CAPTURE_READ_MODIFY | TXN_CAPTURE_WRITE), + -+ /* An option to reiser4_try_capture, NONBLOCKING indicates that the caller would ++ /* An option to try_capture, NONBLOCKING indicates that the caller would + prefer not to sleep waiting for an aging atom to commit. */ + TXN_CAPTURE_NONBLOCKING = (1 << 4), + -+ /* An option to reiser4_try_capture to prevent atom fusion, just simple -+ capturing is allowed */ ++ /* An option to try_capture to prevent atom fusion, just simple capturing is allowed */ + TXN_CAPTURE_DONT_FUSE = (1 << 5) + + /* This macro selects only the exclusive capture request types, stripping out any @@ -75713,6 +75960,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + code above and proceed without restarting if they are still satisfied. +*/ + ++/* A block number set consists of only the list head. */ ++struct blocknr_set { ++ struct list_head entries; ++}; ++ +/* An atomic transaction: this is the underlying system representation + of a transaction, not the one seen by clients. + @@ -75768,10 +76020,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + + /* The atom's delete set. It collects block numbers of the nodes + which were deleted during the transaction. */ -+ struct list_head delete_set; ++ blocknr_set delete_set; + + /* The atom's wandered_block mapping. */ -+ struct list_head wandered_map; ++ blocknr_set wandered_map; + + /* The transaction's list of dirty captured nodes--per level. Index + by (level). dirty_nodes[0] is for znode-above-root */ @@ -75821,7 +76073,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + /* number of threads which do jnode_flush() over this atom */ + int nr_flushers; + /* number of flush queues which are IN_USE and jnodes from fq->prepped -+ are submitted to disk by the reiser4_write_fq() routine. */ ++ are submitted to disk by the write_fq() routine. */ + int nr_running_queues; + /* A counter of grabbed unformatted nodes, see a description of the + * reiser4 space reservation scheme at block_alloc.c */ @@ -75844,6 +76096,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + count_jnode(txn_atom *, jnode *, atom_list old_list, + atom_list new_list, int check_lists)); + ++typedef struct protected_jnodes { ++ struct list_head inatom; /* link to atom's list these structures */ ++ struct list_head nodes; /* head of list of protected nodes */ ++} protected_jnodes; ++ +/* A transaction handle: the client obtains and commits this handle which is assigned by + the system to a txn_atom. */ +struct txn_handle { @@ -75878,8 +76135,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + /* A counter used to assign atom->atom_id values. */ + __u32 id_count; + -+ /* a mutex object for commit serialization */ -+ struct mutex commit_mutex; ++ /* a semaphore object for commit serialization */ ++ struct semaphore commit_semaphore; + + /* a list of all txnmrgs served by particular daemon. */ + struct list_head linkage; @@ -75905,16 +76162,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +extern int init_txnmgr_static(void); +extern void done_txnmgr_static(void); + -+extern void reiser4_init_txnmgr(txn_mgr *); -+extern void reiser4_done_txnmgr(txn_mgr *); ++extern void init_txnmgr(txn_mgr *); ++extern void done_txnmgr(txn_mgr *); + -+extern int reiser4_txn_reserve(int reserved); ++extern int txn_reserve(int reserved); + -+extern void reiser4_txn_begin(reiser4_context * context); -+extern int reiser4_txn_end(reiser4_context * context); ++extern void txn_begin(reiser4_context * context); ++extern int txn_end(reiser4_context * context); + -+extern void reiser4_txn_restart(reiser4_context * context); -+extern void reiser4_txn_restart_current(void); ++extern void txn_restart(reiser4_context * context); ++extern void txn_restart_current(void); + +extern int txnmgr_force_commit_all(struct super_block *, int); +extern int current_atom_should_commit(void); @@ -75927,21 +76184,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + +extern int flush_some_atom(jnode *, long *, const struct writeback_control *, int); + -+extern void reiser4_atom_set_stage(txn_atom * atom, txn_stage stage); ++extern void atom_set_stage(txn_atom * atom, txn_stage stage); + +extern int same_slum_check(jnode * base, jnode * check, int alloc_check, + int alloc_value); +extern void atom_dec_and_unlock(txn_atom * atom); + -+extern int reiser4_try_capture(jnode * node, znode_lock_mode mode, txn_capture flags); ++extern int try_capture(jnode * node, znode_lock_mode mode, txn_capture flags); +extern int try_capture_page_to_invalidate(struct page *pg); + -+extern void reiser4_uncapture_page(struct page *pg); -+extern void reiser4_uncapture_block(jnode *); -+extern void reiser4_uncapture_jnode(jnode *); ++extern void uncapture_page(struct page *pg); ++extern void uncapture_block(jnode *); ++extern void uncapture_jnode(jnode *); + -+extern int reiser4_capture_inode(struct inode *); -+extern int reiser4_uncapture_inode(struct inode *); ++extern int capture_inode(struct inode *); ++extern int uncapture_inode(struct inode *); + +extern txn_atom *get_current_atom_locked_nocheck(void); + @@ -75977,24 +76234,24 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + +extern txn_atom *jnode_get_atom(jnode *); + -+extern void reiser4_atom_wait_event(txn_atom *); -+extern void reiser4_atom_send_event(txn_atom *); ++extern void atom_wait_event(txn_atom *); ++extern void atom_send_event(txn_atom *); + +extern void insert_into_atom_ovrwr_list(txn_atom * atom, jnode * node); -+extern int reiser4_capture_super_block(struct super_block *s); ++extern int capture_super_block(struct super_block *s); +int capture_bulk(jnode **, int count); + +/* See the comment on the function blocknrset.c:blocknr_set_add for the + calling convention of these three routines. */ -+extern void blocknr_set_init(struct list_head * bset); -+extern void blocknr_set_destroy(struct list_head * bset); -+extern void blocknr_set_merge(struct list_head * from, struct list_head * into); ++extern void blocknr_set_init(blocknr_set * bset); ++extern void blocknr_set_destroy(blocknr_set * bset); ++extern void blocknr_set_merge(blocknr_set * from, blocknr_set * into); +extern int blocknr_set_add_extent(txn_atom * atom, -+ struct list_head * bset, ++ blocknr_set * bset, + blocknr_set_entry ** new_bsep, + const reiser4_block_nr * start, + const reiser4_block_nr * len); -+extern int blocknr_set_add_pair(txn_atom * atom, struct list_head * bset, ++extern int blocknr_set_add_pair(txn_atom * atom, blocknr_set * bset, + blocknr_set_entry ** new_bsep, + const reiser4_block_nr * a, + const reiser4_block_nr * b); @@ -76002,7 +76259,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +typedef int (*blocknr_set_actor_f) (txn_atom *, const reiser4_block_nr *, + const reiser4_block_nr *, void *); + -+extern int blocknr_set_iterator(txn_atom * atom, struct list_head * bset, ++extern int blocknr_set_iterator(txn_atom * atom, blocknr_set * bset, + blocknr_set_actor_f actor, void *data, + int delete); + @@ -76014,7 +76271,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +{ + /* check that spinlocks of lower priorities are not held */ + assert("", (LOCK_CNT_NIL(spin_locked_txnh) && -+ LOCK_CNT_NIL(spin_locked_atom) && + LOCK_CNT_NIL(spin_locked_jnode) && + LOCK_CNT_NIL(spin_locked_zlock) && + LOCK_CNT_NIL(rw_locked_dk) && @@ -76026,20 +76282,6 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + LOCK_CNT_INC(spin_locked); +} + -+static inline void spin_lock_atom_nested(txn_atom *atom) -+{ -+ assert("", (LOCK_CNT_NIL(spin_locked_txnh) && -+ LOCK_CNT_NIL(spin_locked_jnode) && -+ LOCK_CNT_NIL(spin_locked_zlock) && -+ LOCK_CNT_NIL(rw_locked_dk) && -+ LOCK_CNT_NIL(rw_locked_tree))); -+ -+ spin_lock_nested(&(atom->alock), SINGLE_DEPTH_NESTING); -+ -+ LOCK_CNT_INC(spin_locked_atom); -+ LOCK_CNT_INC(spin_locked); -+} -+ +static inline int spin_trylock_atom(txn_atom *atom) +{ + if (spin_trylock(&(atom->alock))) { @@ -76174,8 +76416,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + atomic_t nr_errors; + /* An atom this flush queue is attached to */ + txn_atom *atom; -+ /* A wait queue head to wait on i/o completion */ -+ wait_queue_head_t wait; ++ /* A semaphore for waiting on i/o completion */ ++ struct semaphore io_sem; +#if REISER4_DEBUG + /* A thread which took this fq in exclusive use, NULL if fq is free, + * used for debugging. */ @@ -76183,13 +76425,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +#endif +}; + -+extern int reiser4_fq_by_atom(txn_atom *, flush_queue_t **); -+extern void reiser4_fq_put_nolock(flush_queue_t *); -+extern void reiser4_fq_put(flush_queue_t *); -+extern void reiser4_fuse_fq(txn_atom * to, txn_atom * from); ++extern int fq_by_atom(txn_atom *, flush_queue_t **); ++extern void fq_put_nolock(flush_queue_t *); ++extern void fq_put(flush_queue_t *); ++extern void fuse_fq(txn_atom * to, txn_atom * from); +extern void queue_jnode(flush_queue_t *, jnode *); ++extern void mark_jnode_queued(flush_queue_t *, jnode *); + -+extern int reiser4_write_fq(flush_queue_t *, long *, int); ++extern int write_fq(flush_queue_t *, long *, int); +extern int current_atom_finish_all_fq(void); +extern void init_atom_fq_parts(txn_atom *); + @@ -76198,7 +76441,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +extern void znode_make_dirty(znode * node); +extern void jnode_make_dirty_locked(jnode * node); + -+extern int reiser4_sync_atom(txn_atom * atom); ++extern int sync_atom(txn_atom * atom); + +#if REISER4_DEBUG +extern int atom_fq_parts_are_clean(txn_atom *); @@ -76207,7 +76450,15 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h +extern void add_fq_to_bio(flush_queue_t *, struct bio *); +extern flush_queue_t *get_fq_for_current_atom(void); + -+void reiser4_invalidate_list(struct list_head * head); ++void protected_jnodes_init(protected_jnodes * list); ++void protected_jnodes_done(protected_jnodes * list); ++void invalidate_list(struct list_head * head); ++ ++#if REISER4_DEBUG ++void info_atom(const char *prefix, const txn_atom * atom); ++#else ++#define info_atom(p,a) noop ++#endif + +# endif /* __REISER4_TXNMGR_H__ */ + @@ -76220,9 +76471,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/txnmgr.h linux-2.6.22/fs/reiser4/txnmgr.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/type_safe_hash.h linux-2.6.22/fs/reiser4/type_safe_hash.h ---- linux-2.6.22.orig/fs/reiser4/type_safe_hash.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/type_safe_hash.h 2007-07-29 00:25:35.044739961 +0400 +Index: linux-2.6.16/fs/reiser4/type_safe_hash.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/type_safe_hash.h @@ -0,0 +1,320 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -76544,10 +76796,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/type_safe_hash.h linux-2.6.22/fs/reiser4/ + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops.c ---- linux-2.6.22.orig/fs/reiser4/vfs_ops.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/vfs_ops.c 2007-07-29 00:25:35.044739961 +0400 -@@ -0,0 +1,259 @@ +Index: linux-2.6.16/fs/reiser4/vfs_ops.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/vfs_ops.c +@@ -0,0 +1,267 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -76601,6 +76854,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops +#include +#include + ++ +/* update inode stat-data by calling plugin */ +int reiser4_update_sd(struct inode *object) +{ @@ -76680,6 +76934,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + return result; +} + ++ ++ ++ +/* Release reiser4 dentry. This is d_op->d_release() method. */ +static void reiser4_d_release(struct dentry *dentry /* dentry released */ ) +{ @@ -76690,7 +76947,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + * Called by reiser4_sync_inodes(), during speculative write-back (through + * pdflush, or balance_dirty_pages()). + */ -+void reiser4_writeout(struct super_block *sb, struct writeback_control *wbc) ++void writeout(struct super_block *sb, struct writeback_control *wbc) +{ + long written = 0; + int repeats = 0; @@ -76709,8 +76966,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + return; + } + -+ BUG_ON(reiser4_get_super_fake(sb) == NULL); -+ mapping = reiser4_get_super_fake(sb)->i_mapping; ++ BUG_ON(get_super_fake(sb) == NULL); ++ mapping = get_super_fake(sb)->i_mapping; + do { + long nr_submitted = 0; + jnode *node = NULL; @@ -76751,9 +77008,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + } while (wbc->nr_to_write > 0); +} + ++ +void reiser4_throttle_write(struct inode *inode) +{ -+ reiser4_txn_restart_current(); ++ txn_restart_current(); + balance_dirty_pages_ratelimited(inode->i_mapping); +} + @@ -76761,6 +77019,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops +const int REISER4_MAGIC_OFFSET = 16 * 4096; /* offset to magic string from the + * beginning of device */ + ++ ++ +/* + * Reiser4 initialization/shutdown. + * @@ -76769,6 +77029,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + * during reiser4 module load (when compiled as module). + */ + ++ +void reiser4_handle_error(void) +{ + struct super_block *sb = reiser4_get_current_sb(); @@ -76807,10 +77068,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.c linux-2.6.22/fs/reiser4/vfs_ops + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.h linux-2.6.22/fs/reiser4/vfs_ops.h ---- linux-2.6.22.orig/fs/reiser4/vfs_ops.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/vfs_ops.h 2007-07-29 00:25:35.044739961 +0400 -@@ -0,0 +1,53 @@ +Index: linux-2.6.16/fs/reiser4/vfs_ops.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/vfs_ops.h +@@ -0,0 +1,58 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -76835,22 +77097,27 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.h linux-2.6.22/fs/reiser4/vfs_ops +/* address space operations */ +int reiser4_writepage(struct page *, struct writeback_control *); +int reiser4_set_page_dirty(struct page *); -+void reiser4_invalidatepage(struct page *, unsigned long offset); ++int reiser4_readpages(struct file *, struct address_space *, ++ struct list_head *pages, unsigned nr_pages); ++int reiser4_invalidatepage(struct page *, unsigned long offset); +int reiser4_releasepage(struct page *, gfp_t); + +extern int reiser4_update_sd(struct inode *); +extern int reiser4_add_nlink(struct inode *, struct inode *, int); +extern int reiser4_del_nlink(struct inode *, struct inode *, int); + ++ +extern int reiser4_start_up_io(struct page *page); +extern void reiser4_throttle_write(struct inode *); +extern int jnode_is_releasable(jnode *); + +#define CAPTURE_APAGE_BURST (1024l) -+void reiser4_writeout(struct super_block *, struct writeback_control *); ++void writeout(struct super_block *, struct writeback_control *); ++ + +extern void reiser4_handle_error(void); + ++ +/* __FS_REISER4_VFS_OPS_H__ */ +#endif + @@ -76864,10 +77131,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/vfs_ops.h linux-2.6.22/fs/reiser4/vfs_ops + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c ---- linux-2.6.22.orig/fs/reiser4/wander.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/wander.c 2007-07-29 00:25:35.048740996 +0400 -@@ -0,0 +1,1797 @@ +Index: linux-2.6.16/fs/reiser4/wander.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/wander.c +@@ -0,0 +1,1799 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ + @@ -77007,7 +77275,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + versions in the reiser4 in-memory super block. They get modified only at + atom commit time. The atom's commit thread has an exclusive access to those + "committed" fields because the log writer implementation supports only one -+ atom commit a time (there is a per-fs "commit" mutex). At ++ atom commit a time (there is a per-fs "commit" semaphore). At + that time "committed" counters are modified using per-atom information + collected during the transaction. These counters are stored on disk as a + part of tx head block when atom is committed. @@ -77105,6 +77373,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + set_bit((int)REISER4_NO_WRITE_BARRIER, &get_super_private(s)->fs_flags); +} + ++ +/* fill journal header block data */ +static void format_journal_header(struct commit_handle *ch) +{ @@ -77362,7 +77631,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + BA_FORMATTED); + + unpin_jnode_data(cur); -+ reiser4_drop_io_head(cur); ++ drop_io_head(cur); + } +} + @@ -77376,7 +77645,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + + assert("zam-499", b != NULL); + assert("zam-500", *b != 0); -+ assert("zam-501", !reiser4_blocknr_is_fake(b)); ++ assert("zam-501", !blocknr_is_fake(b)); + + reiser4_dealloc_block(b, BLOCK_NOT_COUNTED, BA_FORMATTED); + return 0; @@ -77405,7 +77674,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + ZAM-FIXME-HANS: yes, what happened to our discussion of using a fixed + reserved allocation area so as to get the best qualities of fixed + journals? */ -+ reiser4_blocknr_hint_init(&hint); ++ blocknr_hint_init(&hint); + hint.block_stage = BLOCK_GRABBED; + + ret = reiser4_alloc_blocks(&hint, start, &wide_len, @@ -77427,7 +77696,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + jnode *node; + + pg = bio->bi_io_vec[i].bv_page; -+ end_page_writeback(pg); ++ ClearPageWriteback(pg); + node = jprivate(pg); + spin_lock_jnode(node); + JF_CLR(node, JNODE_WRITEBACK); @@ -77503,18 +77772,18 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + spin_unlock_jnode(sj); + + /* jload it as the rest of overwrite set */ -+ jload_gfp(sj, reiser4_ctx_gfp_mask_get(), 0); ++ jload_gfp(sj, get_gfp_mask(), 0); + + ch->overwrite_set_size++; + } + spin_lock_jnode(cur); -+ reiser4_uncapture_block(cur); ++ uncapture_block(cur); + jput(cur); + + } else { + int ret; + ch->overwrite_set_size++; -+ ret = jload_gfp(cur, reiser4_ctx_gfp_mask_get(), 0); ++ ret = jload_gfp(cur, get_gfp_mask(), 0); + if (ret) + reiser4_panic("zam-783", + "cannot load e-flushed jnode back (ret = %d)\n", @@ -77782,7 +78051,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + do { + atom = get_current_atom_locked(); + assert("zam-536", -+ !reiser4_blocknr_is_fake(jnode_get_block(cur))); ++ !blocknr_is_fake(jnode_get_block(cur))); + ret = + blocknr_set_add_pair(atom, &atom->wandered_map, + &new_bsep, @@ -77878,7 +78147,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + while (allocated < (unsigned)ch->tx_size) { + len = (ch->tx_size - allocated); + -+ reiser4_blocknr_hint_init(&hint); ++ blocknr_hint_init(&hint); + + hint.block_stage = BLOCK_GRABBED; + @@ -77890,7 +78159,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + ret = reiser4_alloc_blocks(&hint, &first, &len, + BA_FORMATTED | BA_RESERVED | + BA_USE_DEFAULT_SEARCH_START); -+ reiser4_blocknr_hint_done(&hint); ++ blocknr_hint_done(&hint); + + if (ret) + return ret; @@ -77899,14 +78168,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + + /* create jnodes for all wander records */ + while (len--) { -+ cur = reiser4_alloc_io_head(&first); ++ cur = alloc_io_head(&first); + + if (cur == NULL) { + ret = RETERR(-ENOMEM); + goto free_not_assigned; + } + -+ ret = jinit_new(cur, reiser4_ctx_gfp_mask_get()); ++ ret = jinit_new(cur, get_gfp_mask()); + + if (ret != 0) { + jfree(cur); @@ -77995,7 +78264,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + break; + } while (0); + -+ reiser4_fq_put(fq); ++ fq_put(fq); + if (ret) + return ret; + repeat_wo_barrier: @@ -78019,20 +78288,21 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + return ret; +} + ++ +static int write_tx_back(struct commit_handle * ch) +{ + flush_queue_t *fq; + int ret; + int barrier; + -+ reiser4_post_commit_hook(); ++ post_commit_hook(); + fq = get_fq_for_current_atom(); + if (IS_ERR(fq)) + return PTR_ERR(fq); + spin_unlock_atom(fq->atom); + ret = write_jnode_list( + ch->overwrite_set, fq, NULL, WRITEOUT_FOR_PAGE_RECLAIM); -+ reiser4_fq_put(fq); ++ fq_put(fq); + if (ret) + return ret; + repeat_wo_barrier: @@ -78055,7 +78325,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + } + if (ret) + return ret; -+ reiser4_post_write_back_hook(); ++ post_write_back_hook(); + return 0; +} + @@ -78075,7 +78345,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + writeout_mode_enable(); + + /* block allocator may add j-nodes to the clean_list */ -+ ret = reiser4_pre_commit_hook(); ++ ret = pre_commit_hook(); + if (ret) + return ret; + @@ -78086,17 +78356,17 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + + /* relocate set is on the atom->clean_nodes list after + * current_atom_complete_writes() finishes. It can be safely -+ * uncaptured after commit_mutex is locked, because any atom that ++ * uncaptured after commit_semaphore is taken, because any atom that + * captures these nodes is guaranteed to commit after current one. + * -+ * This can only be done after reiser4_pre_commit_hook(), because it is where ++ * This can only be done after pre_commit_hook(), because it is where + * early flushed jnodes with CREATED bit are transferred to the + * overwrite list. */ -+ reiser4_invalidate_list(ATOM_CLEAN_LIST(atom)); ++ invalidate_list(ATOM_CLEAN_LIST(atom)); + spin_lock_atom(atom); + /* There might be waiters for the relocate nodes which we have + * released, wake them up. */ -+ reiser4_atom_send_event(atom); ++ atom_send_event(atom); + spin_unlock_atom(atom); + + if (REISER4_DEBUG) { @@ -78139,11 +78409,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + goto up_and_ret; + + spin_lock_atom(atom); -+ reiser4_atom_set_stage(atom, ASTAGE_POST_COMMIT); ++ atom_set_stage(atom, ASTAGE_POST_COMMIT); + spin_unlock_atom(atom); + + ret = write_tx_back(&ch); -+ reiser4_post_write_back_hook(); ++ post_write_back_hook(); + + up_and_ret: + if (ret) { @@ -78284,20 +78554,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + goto free_ow_set; + } + -+ log = reiser4_alloc_io_head(&log_rec_block); ++ log = alloc_io_head(&log_rec_block); + if (log == NULL) + return RETERR(-ENOMEM); + + ret = jload(log); + if (ret < 0) { -+ reiser4_drop_io_head(log); ++ drop_io_head(log); + return ret; + } + + ret = check_wander_record(log); + if (ret) { + jrelse(log); -+ reiser4_drop_io_head(log); ++ drop_io_head(log); + return ret; + } + @@ -78315,26 +78585,26 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + if (block == 0) + break; + -+ node = reiser4_alloc_io_head(&block); ++ node = alloc_io_head(&block); + if (node == NULL) { + ret = RETERR(-ENOMEM); + /* + * FIXME-VS:??? + */ + jrelse(log); -+ reiser4_drop_io_head(log); ++ drop_io_head(log); + goto free_ow_set; + } + + ret = jload(node); + + if (ret < 0) { -+ reiser4_drop_io_head(node); ++ drop_io_head(node); + /* + * FIXME-VS:??? + */ + jrelse(log); -+ reiser4_drop_io_head(log); ++ drop_io_head(log); + goto free_ow_set; + } + @@ -78350,7 +78620,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + } + + jrelse(log); -+ reiser4_drop_io_head(log); ++ drop_io_head(log); + + --nr_wander_records; + } @@ -78380,7 +78650,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + jnode *cur = list_entry(ch.overwrite_set->next, jnode, capture_link); + list_del_init(&cur->capture_link); + jrelse(cur); -+ reiser4_drop_io_head(cur); ++ drop_io_head(cur); + } + + list_del_init(&tx_head->capture_link); @@ -78430,20 +78700,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + + /* searching for oldest not flushed transaction */ + while (1) { -+ tx_head = reiser4_alloc_io_head(&prev_tx); ++ tx_head = alloc_io_head(&prev_tx); + if (!tx_head) + return RETERR(-ENOMEM); + + ret = jload(tx_head); + if (ret < 0) { -+ reiser4_drop_io_head(tx_head); ++ drop_io_head(tx_head); + return ret; + } + + ret = check_tx_head(tx_head); + if (ret) { + jrelse(tx_head); -+ reiser4_drop_io_head(tx_head); ++ drop_io_head(tx_head); + return ret; + } + @@ -78455,7 +78725,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + break; + + jrelse(tx_head); -+ reiser4_drop_io_head(tx_head); ++ drop_io_head(tx_head); + } + + total = le32_to_cpu(get_unaligned(&T->total)); @@ -78469,7 +78739,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + jnode_get_block(tx_head), total - 1); + + unpin_jnode_data(tx_head); -+ reiser4_drop_io_head(tx_head); ++ drop_io_head(tx_head); + + if (ret) + return ret; @@ -78589,14 +78859,14 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c +{ + int ret; + -+ *node = reiser4_alloc_io_head(block); ++ *node = alloc_io_head(block); + if (!(*node)) + return RETERR(-ENOMEM); + + ret = jload(*node); + + if (ret) { -+ reiser4_drop_io_head(*node); ++ drop_io_head(*node); + *node = NULL; + return ret; + } @@ -78612,13 +78882,13 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c +{ + if (*node) { + unpin_jnode_data(*node); -+ reiser4_drop_io_head(*node); ++ drop_io_head(*node); + *node = NULL; + } +} + +/* release journal control blocks */ -+void reiser4_done_journal_info(struct super_block *s) ++void done_journal_info(struct super_block *s) +{ + reiser4_super_info_data *sbinfo = get_super_private(s); + @@ -78630,7 +78900,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c +} + +/* load journal control blocks */ -+int reiser4_init_journal_info(struct super_block *s) ++int init_journal_info(struct super_block *s) +{ + reiser4_super_info_data *sbinfo = get_super_private(s); + journal_location *loc; @@ -78665,9 +78935,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.c linux-2.6.22/fs/reiser4/wander.c + fill-column: 80 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/wander.h linux-2.6.22/fs/reiser4/wander.h ---- linux-2.6.22.orig/fs/reiser4/wander.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/wander.h 2007-07-29 00:25:35.048740996 +0400 +Index: linux-2.6.16/fs/reiser4/wander.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/wander.h @@ -0,0 +1,135 @@ +/* Copyright 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */ + @@ -78787,8 +79058,8 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.h linux-2.6.22/fs/reiser4/wander.h +extern int reiser4_journal_replay(struct super_block *); +extern int reiser4_journal_recover_sb_data(struct super_block *); + -+extern int reiser4_init_journal_info(struct super_block *); -+extern void reiser4_done_journal_info(struct super_block *); ++extern int init_journal_info(struct super_block *); ++extern void done_journal_info(struct super_block *); + +extern int write_jnode_list(struct list_head *, flush_queue_t *, long *, int); + @@ -78804,9 +79075,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/wander.h linux-2.6.22/fs/reiser4/wander.h + scroll-step: 1 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/writeout.h linux-2.6.22/fs/reiser4/writeout.h ---- linux-2.6.22.orig/fs/reiser4/writeout.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/writeout.h 2007-07-29 00:25:35.052742032 +0400 +Index: linux-2.6.16/fs/reiser4/writeout.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/writeout.h @@ -0,0 +1,21 @@ +/* Copyright 2002, 2003, 2004 by Hans Reiser, licensing governed by reiser4/README */ + @@ -78816,7 +79088,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/writeout.h linux-2.6.22/fs/reiser4/writeo +#define WRITEOUT_FOR_PAGE_RECLAIM (0x2) +#define WRITEOUT_BARRIER (0x4) + -+extern int reiser4_get_writeout_flags(void); ++extern int get_writeout_flags(void); + +#endif /* __FS_REISER4_WRITEOUT_H__ */ + @@ -78829,10 +79101,11 @@ diff -urN linux-2.6.22.orig/fs/reiser4/writeout.h linux-2.6.22/fs/reiser4/writeo + fill-column: 80 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c ---- linux-2.6.22.orig/fs/reiser4/znode.c 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/znode.c 2007-07-29 00:25:35.052742032 +0400 -@@ -0,0 +1,1029 @@ +Index: linux-2.6.16/fs/reiser4/znode.c +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/znode.c +@@ -0,0 +1,1028 @@ +/* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by + * reiser4/README */ +/* Znode manipulation functions. */ @@ -78925,7 +79198,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + When we irrevocably commit ourselves to decision to remove node from the + tree, JNODE_HEARD_BANSHEE bit is set in zjnode.state of corresponding + znode. This is done either in ->kill_hook() of internal item or in -+ reiser4_kill_root() function when tree root is removed. ++ kill_root() function when tree root is removed. + + At this moment znode still has: + @@ -78943,9 +79216,9 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + parent node due to its nonexistence or proper parent node locking and + nobody uses parent pointers from children due to absence of them. Second we + invalidate all pending lock requests which still are on znode's lock -+ request queue, this is done by reiser4_invalidate_lock(). Another -+ JNODE_IS_DYING znode status bit is used to invalidate pending lock requests. -+ Once it set all requesters are forced to return -EINVAL from ++ request queue, this is done by invalidate_lock(). Another JNODE_IS_DYING ++ znode status bit is used to invalidate pending lock requests. Once it set ++ all requesters are forced to return -EINVAL from + longterm_lock_znode(). Future locking attempts are not possible because all + ways to get references to that znode are removed already. Last, node is + uncaptured from transaction. @@ -79023,7 +79296,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c +} + +/* The hash table definition */ -+#define KMALLOC(size) kmalloc((size), reiser4_ctx_gfp_mask_get()) ++#define KMALLOC(size) kmalloc((size), GFP_KERNEL) +#define KFREE(ptr, size) kfree(ptr) +TYPE_SAFE_HASH_DEFINE(z, znode, reiser4_block_nr, zjnode.key.z, zjnode.link.z, + blknrhashfn, blknreq); @@ -79031,7 +79304,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c +#undef KMALLOC + +/* slab for znodes */ -+static struct kmem_cache *znode_cache; ++static kmem_cache_t *znode_cache; + +int znode_shift_order; + @@ -79370,7 +79643,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + write_unlock_tree(tree); + } +#if REISER4_DEBUG -+ if (!reiser4_blocknr_is_fake(blocknr) && *blocknr != 0) ++ if (!blocknr_is_fake(blocknr) && *blocknr != 0) + reiser4_check_block(blocknr, 1); +#endif + /* Check for invalid tree level, return -EIO */ @@ -79458,7 +79731,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + assert("nikita-1377", znode_invariant(node)); + assert("jmacd-7771", !znode_above_root(node)); + assert("nikita-2125", atomic_read(&ZJNODE(node)->x_count) > 0); -+ assert("nikita-3016", reiser4_schedulable()); ++ assert("nikita-3016", schedulable()); + + if (info) + formatted_readahead(node, info); @@ -79530,7 +79803,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + znode_is_any_locked(node) || + znode_get_level(node) != LEAF_LEVEL || + keyge(key, &node->rd_key) || -+ keyeq(&node->rd_key, reiser4_min_key()) || ++ keyeq(&node->rd_key, min_key()) || + ZF_ISSET(node, JNODE_HEARD_BANSHEE)); + + node->rd_key = *key; @@ -79546,8 +79819,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + assert_rw_write_locked(&(znode_get_tree(node)->dk_lock)); + assert("nikita-3070", LOCK_CNT_GTZ(write_locked_dk)); + assert("nikita-2943", -+ znode_is_any_locked(node) || keyeq(&node->ld_key, -+ reiser4_min_key())); ++ znode_is_any_locked(node) || keyeq(&node->ld_key, min_key())); + + node->ld_key = *key; + ON_DEBUG(node->ld_key_version = atomic_inc_return(&delim_key_version)); @@ -79862,9 +80134,10 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.c linux-2.6.22/fs/reiser4/znode.c + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/fs/reiser4/znode.h linux-2.6.22/fs/reiser4/znode.h ---- linux-2.6.22.orig/fs/reiser4/znode.h 1970-01-01 03:00:00.000000000 +0300 -+++ linux-2.6.22/fs/reiser4/znode.h 2007-07-29 00:25:35.052742032 +0400 +Index: linux-2.6.16/fs/reiser4/znode.h +=================================================================== +--- /dev/null ++++ linux-2.6.16/fs/reiser4/znode.h @@ -0,0 +1,434 @@ +/* Copyright 2001, 2002, 2003, 2004 by Hans Reiser, licensing governed by + * reiser4/README */ @@ -80098,6 +80371,7 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.h linux-2.6.22/fs/reiser4/znode.h +extern void zinit(znode *, const znode * parent, reiser4_tree *); +extern int zparse(znode * node); + ++ +extern int znode_just_created(const znode * node); + +extern void zfree(znode * node); @@ -80270,17 +80544,16 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.h linux-2.6.22/fs/reiser4/znode.h + +#if REISER4_DEBUG +#define STORE_COUNTERS \ -+ reiser4_lock_cnt_info __entry_counters = \ -+ *reiser4_lock_counters() -+#define CHECK_COUNTERS \ -+ON_DEBUG_CONTEXT( \ -+({ \ -+ __entry_counters.x_refs = reiser4_lock_counters() -> x_refs; \ -+ __entry_counters.t_refs = reiser4_lock_counters() -> t_refs; \ -+ __entry_counters.d_refs = reiser4_lock_counters() -> d_refs; \ -+ assert("nikita-2159", \ -+ !memcmp(&__entry_counters, reiser4_lock_counters(), \ -+ sizeof __entry_counters)); \ ++ lock_counters_info __entry_counters = *lock_counters() ++#define CHECK_COUNTERS \ ++ON_DEBUG_CONTEXT( \ ++({ \ ++ __entry_counters.x_refs = lock_counters() -> x_refs; \ ++ __entry_counters.t_refs = lock_counters() -> t_refs; \ ++ __entry_counters.d_refs = lock_counters() -> d_refs; \ ++ assert("nikita-2159", \ ++ !memcmp(&__entry_counters, lock_counters(), \ ++ sizeof __entry_counters)); \ +}) ) + +#else @@ -80300,19 +80573,20 @@ diff -urN linux-2.6.22.orig/fs/reiser4/znode.h linux-2.6.22/fs/reiser4/znode.h + fill-column: 120 + End: +*/ -diff -urN linux-2.6.22.orig/include/linux/fs.h linux-2.6.22/include/linux/fs.h ---- linux-2.6.22.orig/include/linux/fs.h 2007-07-21 00:33:00.673389540 +0400 -+++ linux-2.6.22/include/linux/fs.h 2007-07-29 00:25:35.056743067 +0400 -@@ -1179,6 +1179,8 @@ +Index: linux-2.6.16/include/linux/fs.h +=================================================================== +--- linux-2.6.16.orig/include/linux/fs.h ++++ linux-2.6.16/include/linux/fs.h +@@ -1085,6 +1085,8 @@ struct super_operations { void (*clear_inode) (struct inode *); - void (*umount_begin) (struct vfsmount *, int); + void (*umount_begin) (struct super_block *); + void (*sync_inodes) (struct super_block *sb, + struct writeback_control *wbc); int (*show_options)(struct seq_file *, struct vfsmount *); - int (*show_stats)(struct seq_file *, struct vfsmount *); - #ifdef CONFIG_QUOTA -@@ -1630,6 +1632,7 @@ + + ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); +@@ -1449,6 +1451,7 @@ extern int invalidate_inode_pages2(struc extern int invalidate_inode_pages2_range(struct address_space *mapping, pgoff_t start, pgoff_t end); extern int write_inode_now(struct inode *, int); @@ -80320,29 +80594,31 @@ diff -urN linux-2.6.22.orig/include/linux/fs.h linux-2.6.22/include/linux/fs.h extern int filemap_fdatawrite(struct address_space *); extern int filemap_flush(struct address_space *); extern int filemap_fdatawait(struct address_space *); -diff -urN linux-2.6.22.orig/lib/radix-tree.c linux-2.6.22/lib/radix-tree.c ---- linux-2.6.22.orig/lib/radix-tree.c 2007-07-21 00:33:01.265543326 +0400 -+++ linux-2.6.22/lib/radix-tree.c 2007-07-29 00:25:35.060744102 +0400 -@@ -151,6 +151,7 @@ - out: - return ret; +Index: linux-2.6.16/lib/radix-tree.c +=================================================================== +--- linux-2.6.16.orig/lib/radix-tree.c ++++ linux-2.6.16/lib/radix-tree.c +@@ -139,6 +139,7 @@ static inline void tag_set(struct radix_ + { + __set_bit(offset, node->tags[tag]); } +EXPORT_SYMBOL(radix_tree_preload); - static inline void tag_set(struct radix_tree_node *node, unsigned int tag, - int offset) -diff -urN linux-2.6.22.orig/mm/filemap.c linux-2.6.22/mm/filemap.c ---- linux-2.6.22.orig/mm/filemap.c 2007-07-21 00:33:01.277546443 +0400 -+++ linux-2.6.22/mm/filemap.c 2007-07-29 00:25:35.064745138 +0400 -@@ -121,6 +121,7 @@ + static inline void tag_clear(struct radix_tree_node *node, int tag, int offset) + { +Index: linux-2.6.16/mm/filemap.c +=================================================================== +--- linux-2.6.16.orig/mm/filemap.c ++++ linux-2.6.16/mm/filemap.c +@@ -119,6 +119,7 @@ void __remove_from_page_cache(struct pag mapping->nrpages--; - __dec_zone_page_state(page, NR_FILE_PAGES); + pagecache_acct(-1); } +EXPORT_SYMBOL(__remove_from_page_cache); void remove_from_page_cache(struct page *page) { -@@ -132,6 +133,7 @@ +@@ -130,6 +131,7 @@ void remove_from_page_cache(struct page __remove_from_page_cache(page); write_unlock_irq(&mapping->tree_lock); } @@ -80350,26 +80626,72 @@ diff -urN linux-2.6.22.orig/mm/filemap.c linux-2.6.22/mm/filemap.c static int sync_page(void *word) { -@@ -719,6 +721,7 @@ - read_unlock_irq(&mapping->tree_lock); +@@ -272,6 +274,7 @@ static int wait_on_page_writeback_range( + return ret; } +EXPORT_SYMBOL(add_to_page_cache_lru); - /** - * find_get_pages_contig - gang contiguous pagecache lookup -@@ -838,6 +841,7 @@ + /* + * Write and wait upon all the pages in the passed range. This is a "data +@@ -632,7 +635,6 @@ repeat: + page_cache_release(cached_page); + return page; + } +- + EXPORT_SYMBOL(find_or_create_page); - ra->ra_pages /= 4; + /** +@@ -665,6 +667,7 @@ unsigned find_get_pages(struct address_s + read_unlock_irq(&mapping->tree_lock); + return ret; } +EXPORT_SYMBOL(find_get_pages); + /* + * Like find_get_pages, except we only return pages which are tagged with +@@ -686,6 +689,7 @@ unsigned find_get_pages_tag(struct addre + read_unlock_irq(&mapping->tree_lock); + return ret; + } ++EXPORT_SYMBOL(find_get_pages_tag); + + /* + * Same as grab_cache_page, but do not wait if the page is unavailable. +Index: linux-2.6.16/mm/page-writeback.c +=================================================================== +--- linux-2.6.16.orig/mm/page-writeback.c ++++ linux-2.6.16/mm/page-writeback.c +@@ -187,7 +187,7 @@ get_dirty_limits(struct writeback_state + * If we're over `background_thresh' then pdflush is woken to perform some + * writeout. + */ +-static void balance_dirty_pages(struct address_space *mapping) ++void balance_dirty_pages(struct address_space *mapping) + { + struct writeback_state wbs; + long nr_reclaimable; +@@ -253,6 +253,7 @@ static void balance_dirty_pages(struct a + (!laptop_mode && (nr_reclaimable > background_thresh))) + pdflush_operation(background_writeout, 0); + } ++EXPORT_SYMBOL(balance_dirty_pages); + /** - * do_generic_mapping_read - generic file read routine -diff -urN linux-2.6.22.orig/mm/readahead.c linux-2.6.22/mm/readahead.c ---- linux-2.6.22.orig/mm/readahead.c 2007-07-21 00:33:01.305553717 +0400 -+++ linux-2.6.22/mm/readahead.c 2007-07-29 00:25:35.064745138 +0400 -@@ -571,6 +571,7 @@ + * balance_dirty_pages_ratelimited - balance dirty memory state +Index: linux-2.6.16/mm/readahead.c +=================================================================== +--- linux-2.6.16.orig/mm/readahead.c ++++ linux-2.6.16/mm/readahead.c +@@ -541,6 +541,7 @@ page_cache_readahead(struct address_spac + out: + return ra->prev_page + 1; + } ++EXPORT_SYMBOL_GPL(page_cache_readahead); + + /* + * handle_ra_miss() is called when it is known that a page which should have +@@ -558,6 +559,7 @@ void handle_ra_miss(struct address_space ra->flags &= ~RA_FLAG_INCACHE; ra->cache_hit = 0; } -- 2.39.2