Skip to contentSkip to conversation

2.6.1-rc1-tiny1 tree for small systems

DISCUSSION Matt Mackall 5 participants 11 messages Jan 3, 2004 – Jan 10, 2004 1 message not in the archive

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

This is the third release of the -tiny kernel tree. The aim of this tree is to collect patches that reduce kernel disk and memory footprint as well as tools for working on small systems. Target users are things like embedded systems, small or legacy desktop folks, and handhelds.

Latest release includes:
- sync against 2.6.1-rc1
- latest netdrvr patchkit
- SLOB allocator
- Andi Kleen's bloat-o-meter
- configurable tcpdiag, inetpeer, dnotify, ptrace, sysenter/vsyscall
- configurable X86 CPU feature detection
- ability to override arch CFLAGS from Kconfig
- optional uninlining of current and thread_info
- other minor tweaks

The big bit here is SLOB, which optionally replaces the SLAB allocator and kmalloc wrappers with a traditional malloc arena and a SLAB emulation layer. SLOB is less than a tenth the size of the SLAB code and is considerably more space efficient with its allocations, but is not as fast and may prove less resistant to long-term fragmentation.

Thanks to Andi Kleen, Magnus Naeslund, and various others for their contributions and suggestions.

The patch can be found at:

http://selenic.com/tiny/2.6.1-rc1-tiny1.patch.bz2
http://selenic.com/tiny/2.6.1-rc1-tiny1-broken-out.tar.bz2

Contributions and suggestions are encouraged. In particular, it would be helpful if people with non-x86 hardware could take a stab at extending some of the stuff that's currently only been done for X86 to other architectures.

Signature · 1 line
Matt Mackall : http://www.selenic.com : Linux development and consulting
#1 lore raw
Quoted 4 lines · Matt Mackall

Contributions and suggestions are encouraged. In particular, it would be helpful if people with non-x86 hardware could take a stab at extending some of the stuff that's currently only been done for X86 to other architectures.

I just tried a kernel build with as much as possible turned off. This uncovered a couple of bugs, which I fixed with the attached diff. But it looks like there finally is a light at the end of the rainbow.

220K compressed and 371K uncompressed. This is a serious reduction from previous versions. There is still a huge amount of code I can't compile out but this is certainly progress. Thank you.

Eric

$ size vmlinux 
   text	   data	    bss	    dec	    hex	filename
 371813	  29914	  24620	 426347	  6816b	vmlinux
$ ls -l arch/i386/boot/bzImage 
-rw-r--r--    1 eric     eric       220348 Jan  4 00:22 arch/i386/boot/bzImage

gcc-3.3 --version
gcc-3.3 (GCC) 3.3.2 20030908 (Debian prerelease)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#
# Automatically generated make config: don't edit
#
CONFIG_X86=y
CONFIG_MMU=y
CONFIG_UID16=y
CONFIG_GENERIC_ISA_DMA=y

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
CONFIG_CLEAN_COMPILE=y
CONFIG_STANDALONE=y
CONFIG_BROKEN_ON_SMP=y

#
# General setup
#
# CONFIG_SWAP is not set
# CONFIG_SYSVIPC is not set
# CONFIG_BSD_PROCESS_ACCT is not set
# CONFIG_SYSCTL is not set
CONFIG_LOG_BUF_SHIFT=14
# CONFIG_IKCONFIG is not set
CONFIG_EMBEDDED=y
CONFIG_CORE_SMALL=y
CONFIG_NET_SMALL=y
CONFIG_CONSOLE_SMALL=y
CONFIG_PROCESSOR_SELECT=y
# CONFIG_CPU_SUP_INTEL is not set
# CONFIG_CPU_SUP_CYRIX is not set
# CONFIG_CPU_SUP_NSC is not set
# CONFIG_CPU_SUP_AMD is not set
# CONFIG_CPU_SUP_CENTAUR is not set
# CONFIG_CPU_SUP_TRANSMETA is not set
# CONFIG_CPU_SUP_RISE is not set
# CONFIG_CPU_SUP_NEXGEN is not set
# CONFIG_CPU_SUP_UMC is not set
# CONFIG_KALLSYMS is not set
# CONFIG_FUTEX is not set
# CONFIG_EPOLL is not set
CONFIG_IOSCHED_NOOP=y
# CONFIG_IOSCHED_AS is not set
# CONFIG_IOSCHED_DEADLINE is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_MEASURE_INLINES is not set
# CONFIG_IRQ_DEBUG is not set
# CONFIG_FULL_STACK is not set
# CONFIG_AUDIT_BOOTMEM is not set
# CONFIG_KMALLOC_ACCOUNTING is not set
CONFIG_HERTZ=1000
CONFIG_MAX_USER_RT_PRIO=5
# CONFIG_VM86 is not set
# CONFIG_AIO is not set
# CONFIG_DOUBLEFAULT is not set
# CONFIG_SYSFS is not set
# CONFIG_PRINTK is not set
# CONFIG_BUG is not set
CONFIG_PANIC=y
# CONFIG_FULL_PANIC is not set
# CONFIG_ELF_CORE is not set
# CONFIG_KCORE is not set
CONFIG_MAX_SWAPFILES_SHIFT=0
CONFIG_NR_LDISCS=0
# CONFIG_DMI_SCAN is not set
# CONFIG_CONSOLE_TRANSLATIONS is not set
# CONFIG_SLAB is not set
# CONFIG_TCP_DIAG is not set
# CONFIG_INETPEER is not set
# CONFIG_INLINE_THREADINFO is not set
# CONFIG_DNOTIFY is not set
# CONFIG_PTRACE is not set
# CONFIG_SYSENTER is not set
CONFIG_TINY_CFLAGS=y
CONFIG_TINY_CFLAGS_VAL="-march=i386"
CONFIG_SLOB=y

#
# Loadable module support
#
# CONFIG_MODULES is not set

#
# Processor type and features
#
CONFIG_X86_PC=y
# CONFIG_X86_VOYAGER is not set
# CONFIG_X86_NUMAQ is not set
# CONFIG_X86_SUMMIT is not set
# CONFIG_X86_BIGSMP is not set
# CONFIG_X86_VISWS is not set
# CONFIG_X86_GENERICARCH is not set
# CONFIG_X86_ES7000 is not set
# CONFIG_M386 is not set
CONFIG_M486=y
# CONFIG_M586 is not set
# CONFIG_M586TSC is not set
# CONFIG_M586MMX is not set
# CONFIG_M686 is not set
# CONFIG_MPENTIUMII is not set
# CONFIG_MPENTIUMIII is not set
# CONFIG_MPENTIUM4 is not set
# CONFIG_MK6 is not set
# CONFIG_MK7 is not set
# CONFIG_MK8 is not set
# CONFIG_MELAN is not set
# CONFIG_MCRUSOE is not set
# CONFIG_MWINCHIPC6 is not set
# CONFIG_MWINCHIP2 is not set
# CONFIG_MWINCHIP3D is not set
# CONFIG_MCYRIXIII is not set
# CONFIG_MVIAC3_2 is not set
# CONFIG_X86_GENERIC is not set
CONFIG_X86_CMPXCHG=y
CONFIG_X86_XADD=y
CONFIG_X86_L1_CACHE_SHIFT=4
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
CONFIG_X86_PPRO_FENCE=y
CONFIG_X86_F00F_BUG=y
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
CONFIG_X86_ALIGNMENT_16=y
# CONFIG_HPET_TIMER is not set
# CONFIG_HPET_EMULATE_RTC is not set
# CONFIG_SMP is not set
# CONFIG_PREEMPT is not set
# CONFIG_X86_UP_APIC is not set
# CONFIG_X86_MCE is not set
# CONFIG_TOSHIBA is not set
# CONFIG_I8K is not set
# CONFIG_MICROCODE is not set
# CONFIG_X86_MSR is not set
# CONFIG_X86_CPUID is not set
# CONFIG_EDD is not set
CONFIG_NOHIGHMEM=y
# CONFIG_HIGHMEM4G is not set
# CONFIG_HIGHMEM64G is not set
# CONFIG_MATH_EMULATION is not set
# CONFIG_MTRR is not set

#
# Power management options (ACPI, APM)
#
# CONFIG_PM is not set

#
# ACPI (Advanced Configuration and Power Interface) Support #
# CONFIG_ACPI is not set

#
# CPU Frequency scaling
#
# CONFIG_CPU_FREQ is not set

#
# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
#
# CONFIG_PCI is not set
# CONFIG_ISA is not set
# CONFIG_MCA is not set
# CONFIG_SCx200 is not set
# CONFIG_HOTPLUG is not set

#
# Executable file formats
#
# CONFIG_BINFMT_ELF is not set
# CONFIG_BINFMT_AOUT is not set
# CONFIG_BINFMT_MISC is not set

#
# Device Drivers
#

#
# Generic Driver Options
#

#
# Memory Technology Devices (MTD)
#
# CONFIG_MTD is not set

#
# Parallel port support
#
# CONFIG_PARPORT is not set

#
# Plug and Play support
#
# CONFIG_PNP is not set

#
# Block devices
#
# CONFIG_BLK_DEV_FD is not set
# CONFIG_BLK_DEV_LOOP is not set
# CONFIG_BLK_DEV_RAM is not set
# CONFIG_BLK_DEV_INITRD is not set
# CONFIG_LBD is not set

#
# ATA/ATAPI/MFM/RLL support
#
# CONFIG_IDE is not set

#
# SCSI device support
#
# CONFIG_SCSI is not set

#
# Multi-device support (RAID and LVM)
#
# CONFIG_MD is not set

#
# Fusion MPT device support
#

#
# IEEE 1394 (FireWire) support (EXPERIMENTAL)
#
# CONFIG_IEEE1394 is not set

#
# I2O device support
#

#
# Networking support
#
# CONFIG_NET is not set

#
# Amateur Radio support
#
# CONFIG_HAMRADIO is not set
# CONFIG_KGDBOE is not set
# CONFIG_NETPOLL is not set
# CONFIG_NETPOLL_RX is not set
# CONFIG_NETPOLL_TRAP is not set
# CONFIG_NET_POLL_CONTROLLER is not set

#
# ISDN subsystem
#

#
# Telephony Support
#
# CONFIG_PHONE is not set

#
# Input device support
#
# CONFIG_INPUT is not set

#
# Userland interfaces
#

#
# Input I/O drivers
#
# CONFIG_GAMEPORT is not set
CONFIG_SOUND_GAMEPORT=y
# CONFIG_SERIO is not set
# CONFIG_SERIO_I8042 is not set

#
# Input Device Drivers
#

#
# Character devices
#
# CONFIG_VT is not set
# CONFIG_SERIAL_NONSTANDARD is not set

#
# Serial drivers
#
# CONFIG_SERIAL_8250 is not set

#
# Non-8250 serial port support
#
# CONFIG_UNIX98_PTYS is not set

#
# I2C support
#
# CONFIG_I2C is not set

#
# I2C Algorithms
#

#
# I2C Hardware Bus support
#

#
# I2C Hardware Sensors Chip support
#
# CONFIG_I2C_SENSOR is not set

#
# Mice
#
# CONFIG_BUSMOUSE is not set
# CONFIG_QIC02_TAPE is not set

#
# IPMI
#
# CONFIG_IPMI_HANDLER is not set

#
# Watchdog Cards
#
# CONFIG_WATCHDOG is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
# CONFIG_GEN_RTC is not set
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
# CONFIG_APPLICOM 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 is not set
# CONFIG_RAW_DRIVER is not set
# CONFIG_HANGCHECK_TIMER is not set

#
# Multimedia devices
#
# CONFIG_VIDEO_DEV is not set

#
# Digital Video Broadcasting Devices
#

#
# Graphics support
#
# CONFIG_FB is not set

#
# Sound
#
# CONFIG_SOUND is not set

#
# USB support
#
# CONFIG_USB_GADGET is not set

#
# File systems
#
# CONFIG_EXT2_FS is not set
# CONFIG_EXT3_FS is not set
# CONFIG_JBD is not set
# CONFIG_REISERFS_FS is not set
# CONFIG_JFS_FS is not set
# CONFIG_XFS_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
# CONFIG_QUOTA is not set
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set

#
# CD-ROM/DVD Filesystems
#
# CONFIG_ISO9660_FS is not set
# CONFIG_UDF_FS is not set

#
# DOS/FAT/NT Filesystems
#
# CONFIG_FAT_FS is not set
# CONFIG_NTFS_FS is not set

#
# Pseudo filesystems
#
# CONFIG_PROC_FS is not set
# CONFIG_DEVFS_FS is not set
# CONFIG_TMPFS is not set
# CONFIG_HUGETLBFS is not set
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y

#
# Miscellaneous filesystems
#
# CONFIG_ADFS_FS is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
# CONFIG_BEFS_FS is not set
# CONFIG_BFS_FS is not set
# CONFIG_EFS_FS is not set
# CONFIG_CRAMFS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_HPFS_FS is not set
# CONFIG_QNX4FS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_UFS_FS is not set

#
# Partition Types
#
CONFIG_PARTITION_ADVANCED=y
# CONFIG_ACORN_PARTITION is not set
# CONFIG_OSF_PARTITION is not set
# CONFIG_AMIGA_PARTITION is not set
# CONFIG_ATARI_PARTITION is not set
# CONFIG_MAC_PARTITION is not set
# CONFIG_MSDOS_PARTITION is not set
# CONFIG_LDM_PARTITION is not set
# CONFIG_NEC98_PARTITION is not set
# CONFIG_SGI_PARTITION is not set
# CONFIG_ULTRIX_PARTITION is not set
# CONFIG_SUN_PARTITION is not set
# CONFIG_EFI_PARTITION is not set

#
# Native Language Support
#
# CONFIG_NLS is not set

#
# Profiling support
#
# CONFIG_PROFILING is not set

#
# Kernel hacking
#
# CONFIG_DEBUG_KERNEL is not set
# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
# CONFIG_FRAME_POINTER is not set

#
# Security options
#
# CONFIG_SECURITY is not set

#
# Cryptographic options
#
# CONFIG_CRYPTO is not set

#
# Library routines
#
# CONFIG_CRC32 is not set
CONFIG_X86_BIOS_REBOOT=y

arch/i386/kernel/cpu/common.c +28 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/arch/i386/kernel/cpu/common.c linux-2.6.1-rc1-tiny1.eb1/arch/i386/kernel/cpu/common.c
@@ -421,7 +421,6 @@
  * They will insert themselves into the cpu_devs structure.
  * Then, when cpu_init() is called, we can just iterate over that array.
  */
-
 extern int intel_cpu_init(void);
 extern int cyrix_init_cpu(void);
 extern int nsc_init_cpu(void);
@@ -431,6 +430,34 @@
 extern int rise_init_cpu(void);
 extern int nexgen_init_cpu(void);
 extern int umc_init_cpu(void);
+
+#ifndef CONFIG_CPU_SUP_INTEL
+#define intel_cpu_init() 
+#endif
+#ifndef CONFIG_CPU_SUP_CYRIX
+#define cyrix_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_NSC
+#define nsc_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_AMD
+#define amd_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_CENTAUR
+#define centaur_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_TRANSMETA
+#define transmeta_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_RISE
+#define rise_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_NEXGEN
+#define nexgen_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_UMC
+#define umc_init_cpu() 
+#endif
 
 void __init early_cpu_init(void)
 {
arch/i386/mm/init.c +6 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/arch/i386/mm/init.c linux-2.6.1-rc1-tiny1.eb1/arch/i386/mm/init.c
@@ -444,9 +444,14 @@
 static struct kcore_list kcore_mem, kcore_vmalloc; 
 #endif
 
+#ifdef CNFIG_CPU_SUP_INTEL
+extern int ppro_with_ram_bug(void);
+#else
+static inline int ppro_with_ram_bug(void) { return 0; }
+#endif
+
 void __init mem_init(void)
 {
-	extern int ppro_with_ram_bug(void);
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 	int bad_ppro;
kernel/Makefile +2 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/kernel/Makefile linux-2.6.1-rc1-tiny1.eb1/kernel/Makefile
@@ -4,10 +4,11 @@
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    exit.o itimer.o time.o softirq.o resource.o \
-	    sysctl.o capability.o ptrace.o timer.o user.o \
+	    sysctl.o capability.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o
 
+obj-$(CONFIG_PTRACE) += ptrace.o
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
kernel/printk.c +2 -2
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/kernel/printk.c linux-2.6.1-rc1-tiny1.eb1/kernel/printk.c
@@ -101,10 +101,10 @@
 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
 static int preferred_console = -1;
 
-#ifdef CONFIG_PRINTK
-
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
+
+#ifdef CONFIG_PRINTK
 
 /*
  *	Setup a list of consoles. Called from init/main.c
#2 lore raw
Quoted 10 lines · Eric W. Biederman
Quoted 4 lines · Matt Mackall

Contributions and suggestions are encouraged. In particular, it would be helpful if people with non-x86 hardware could take a stab at extending some of the stuff that's currently only been done for X86 to other architectures.

I just tried a kernel build with as much as possible turned off. This uncovered a couple of bugs, which I fixed with the attached diff. But it looks like there finally is a light at the end of the rainbow.

Thanks. I actually cleaned up all this stuff earlier today, will probably do another release shortly.

Quoted 3 lines

220K compressed and 371K uncompressed. This is a serious reduction from previous versions. There is still a huge amount of code I can't compile out but this is certainly progress. Thank you.

Suggestions? I'm rapidly exhausting a lot of the obvious candidates. My target build at the moment is ide + ext2 + proc + ipv4 + console, and that's currently at around 800K uncompressed, booting in a little less than 2.5MB. Hoping to get that under 2.

Signature · 1 line
Matt Mackall : http://www.selenic.com : Linux development and consulting
#3 lore raw
Quoted 15 lines · Matt Mackall
Quoted 10 lines · Eric W. Biederman
Quoted 4 lines · Matt Mackall

Contributions and suggestions are encouraged. In particular, it would be helpful if people with non-x86 hardware could take a stab at extending some of the stuff that's currently only been done for X86 to other architectures.

I just tried a kernel build with as much as possible turned off. This uncovered a couple of bugs, which I fixed with the attached diff. But it looks like there finally is a light at the end of the rainbow.

Thanks. I actually cleaned up all this stuff earlier today, will probably do another release shortly.

Quoted 8 lines
Quoted 3 lines

220K compressed and 371K uncompressed. This is a serious reduction from previous versions. There is still a huge amount of code I can't compile out but this is certainly progress. Thank you.

Suggestions? I'm rapidly exhausting a lot of the obvious candidates. My target build at the moment is ide + ext2 + proc + ipv4 + console, and that's currently at around 800K uncompressed, booting in a little less than 2.5MB. Hoping to get that under 2.

Nice. I have a 386 I really should try this out on.

Of note IPv4 is about 90K compressed. And I know you can do a minimal IPv4 stack in about 8K compressed.

My target is a minimal kernel that can be used as a bootloader. But what I am looking for at first is to be able to turn as many things off as possible so that we can test to see how much individual pieces add.

If you look at ELKS or one of the old unix like kernels you can get those down to 64K and still be usable.

I'm currently looking at removing the buffer cache, since I most of the time I don't care about disks. This is complicated by the fact that many of the default paths in the kernel when they don't have a better implementation use buffer cache methods. But I'm making headway.

Proc is one of things that frequently has loads of crap that are not needed in a minimal setup.

Until I find more candidates to turn off I can't see any low hanging fruit for shrinking in size.

Eric

#4 lore raw
In reply to Matt Mackall
Quoted 10 lines · Matt Mackall
Quoted 4 lines · Eric W. Biederman

Matt Mackall <[email protected]> writes:
220K compressed and 371K uncompressed. This is a serious reduction from previous versions. There is still a huge amount of code I can't compile out but this is certainly progress. Thank you.

Suggestions? I'm rapidly exhausting a lot of the obvious candidates. My target build at the moment is ide + ext2 + proc + ipv4 + console, and that's currently at around 800K uncompressed, booting in a little less than 2.5MB. Hoping to get that under 2.

On the side of useless ugly. But interesting in what I had to touch the following patch is a first crude stab at removing block device support from the kernel.

With nothing selected this gets me down to a 191K bzImage and a 323K text segment. So for those who are not using it this is a significant drop.

I have a fairly static target of kernel and user space in 384K so I can fit it in a standard BIOS ROM chip. 192K would be even better, but I have other solutions I can use in that case if I need to.

Eric

$ ls -l arch/i386/boot/bzImage 
-rw-r--r--    2 eric     eric       191316 Jan  4 15:38 arch/i386/boot/bzImage
$ size vmlinux
   text	   data	    bss	    dec	    hex	filename
 323359	  28652	  24252	 376263	  5bdc7	vmlinux
arch/i386/mm/init.c +1 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/arch/i386/mm/init.c linux-2.6.1-rc1-tiny1.eb2/arch/i386/mm/init.c
@@ -444,7 +444,7 @@
 static struct kcore_list kcore_mem, kcore_vmalloc; 
 #endif
 
-#ifdef CNFIG_CPU_SUP_INTEL
+#ifdef CONFIG_CPU_SUP_INTEL
 extern int ppro_with_ram_bug(void);
 #else
 static inline int ppro_with_ram_bug(void) { return 0; }
drivers/block/Kconfig +22 -22

167 lines not on this page · raw message

drivers/block/Kconfig.embedded +5 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/drivers/block/Kconfig.embedded linux-2.6.1-rc1-tiny1.eb2/drivers/block/Kconfig.embedded
@@ -0,0 +1,5 @@
+config BLOCK_DEVICES
+	bool "Block device support" if EMBEDDED
+	default y
+	help
+	  Allow the complete removal of block device code
drivers/block/Kconfig.iosched +3 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/drivers/block/Kconfig.iosched linux-2.6.1-rc1-tiny1.eb2/drivers/block/Kconfig.iosched
@@ -1,5 +1,6 @@
 config IOSCHED_NOOP
 	bool "No-op I/O scheduler" if EMBEDDED
+	depends on BLOCK_DEVICES
 	default y
 	---help---
 	  The no-op I/O scheduler is a minimal scheduler that does basic merging
@@ -10,6 +11,7 @@
 
 config IOSCHED_AS
 	bool "Anticipatory I/O scheduler" if EMBEDDED
+	depends on BLOCK_DEVICES
 	default y
 	---help---
 	  The anticipatory I/O scheduler is the default disk scheduler. It is
@@ -19,6 +21,7 @@
 
 config IOSCHED_DEADLINE
 	bool "Deadline I/O scheduler" if EMBEDDED
+	depends on BLOCK_DEVICES
 	default y
 	---help---
 	  The deadline I/O scheduler is simple and compact, and is often as
drivers/block/Makefile +1 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/drivers/block/Makefile linux-2.6.1-rc1-tiny1.eb2/drivers/block/Makefile
@@ -13,7 +13,7 @@
 # kblockd threads
 #
 
-obj-y	:= elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
+obj-$(CONFIG_BLOCK_DEVICES)	:= elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
 
 obj-$(CONFIG_IOSCHED_NOOP)	+= noop-iosched.o
 obj-$(CONFIG_IOSCHED_AS)	+= as-iosched.o
drivers/md/Kconfig +1 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/drivers/md/Kconfig linux-2.6.1-rc1-tiny1.eb2/drivers/md/Kconfig
@@ -6,6 +6,7 @@
 
 config MD
 	bool "Multiple devices driver support (RAID and LVM)"
+	depends on BLOCK_DEVICES
 	help
 	  Support multiple physical spindles through a single logical device.
 	  Required for RAID and logical volume management.
fs/Kconfig.embedded +5 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/Kconfig.embedded linux-2.6.1-rc1-tiny1.eb2/fs/Kconfig.embedded
@@ -0,0 +1,11 @@
+config BINFMT_SCRIPT
+	bool "Kernel support for shell scripts" if EMBEDDED
+	default y
+	help
+	  Allow the removal of the code for executing shell scripts
fs/Makefile +6 -4
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/Makefile linux-2.6.1-rc1-tiny1.eb2/fs/Makefile
@@ -5,12 +5,14 @@
 # Rewritten to use lists instead of if-statements.
 # 
 
-obj-y :=	open.o read_write.o file_table.o buffer.o \
-		bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
+obj-y :=	open.o read_write.o file_table.o \
+		super.o char_dev.o stat.o exec.o pipe.o \
 		namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
 		dcache.o inode.o attr.o bad_inode.o file.o \
 		filesystems.o namespace.o seq_file.o xattr.o libfs.o \
-		fs-writeback.o mpage.o direct-io.o aio.o
+		fs-writeback.o aio.o
+
+obj-$(CONFIG_BLOCK_DEVICES) += buffer.o bio.o block_dev.o mpage.o direct-io.o
 
 obj-$(CONFIG_DNOTIFY)		+= dnotify.o
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
@@ -24,7 +26,7 @@
 obj-$(CONFIG_BINFMT_MISC)	+= binfmt_misc.o
 
 # binfmt_script is always there
-obj-y				+= binfmt_script.o
+obj-$(CONFIG_BINFMT_SCRIPT)	+= binfmt_script.o
 
 obj-$(CONFIG_BINFMT_ELF)	+= binfmt_elf.o
 obj-$(CONFIG_BINFMT_SOM)	+= binfmt_som.o
fs/buffer.c +0 -50

62 lines not on this page · raw message

fs/dcache.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/dcache.c linux-2.6.1-rc1-tiny1.eb2/fs/dcache.c
@@ -1619,7 +1619,9 @@
 	inode_init(mempages);
 	files_init(mempages); 
 	mnt_init(mempages);
+#ifdef CONFIG_BLOCK_DEVICES
 	bdev_cache_init();
+#endif
 	chrdev_init();
 }
 
fs/fs-writeback.c +39 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/fs-writeback.c linux-2.6.1-rc1-tiny1.eb2/fs/fs-writeback.c
@@ -22,8 +22,11 @@
 #include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
+#include <linux/quotaops.h>
 
+#ifdef CONFIG_BLOCK_DEVICES
 extern struct super_block *blockdev_superblock;
+#endif
 
 /**
  *	__mark_inode_dirty -	internal function
@@ -263,6 +266,7 @@
 		struct backing_dev_info *bdi = mapping->backing_dev_info;
 
 		if (bdi->memory_backed) {
+#ifdef CONFIG_BLOCK_DEVICES
 			if (sb == blockdev_superblock) {
 				/*
 				 * Dirty memory-backed blockdev: the ramdisk
@@ -271,6 +275,7 @@
 				list_move(&inode->i_list, &sb->s_dirty);
 				continue;
 			}
+#endif
 			/*
 			 * Assume that all inodes on this superblock are memory
 			 * backed.  Skip the superblock.
@@ -280,15 +285,19 @@
 
 		if (wbc->nonblocking && bdi_write_congested(bdi)) {
 			wbc->encountered_congestion = 1;
+#ifdef CONFIG_BLOCK_DEVICES
 			if (sb != blockdev_superblock)
 				break;		/* Skip a congested fs */
+#endif
 			list_move(&inode->i_list, &sb->s_dirty);
 			continue;		/* Skip a congested blockdev */
 		}
 
 		if (wbc->bdi && bdi != wbc->bdi) {
+#ifdef CONFIG_BLOCK_DEVICES
 			if (sb != blockdev_superblock)
 				break;		/* fs has the wrong queue */
+#endif
 			list_move(&inode->i_list, &sb->s_dirty);
 			continue;		/* blockdev has wrong queue */
 		}
@@ -523,11 +532,13 @@
 	current->flags |= PF_SYNCWRITE;
 	if (what & OSYNC_DATA)
 		err = filemap_fdatawrite(inode->i_mapping);
+#ifdef CONFIG_BLOCK_DEVICES
 	if (what & (OSYNC_METADATA|OSYNC_DATA)) {
 		err2 = sync_mapping_buffers(inode->i_mapping);
 		if (!err)
 			err = err2;
 	}
+#endif
 	if (what & OSYNC_DATA) {
 		err2 = filemap_fdatawait(inode->i_mapping);
 		if (!err)
@@ -586,4 +597,32 @@
 {
 	BUG_ON(!writeback_in_progress(bdi));
 	clear_bit(BDI_pdflush, &bdi->state);
+}
+
+
+/*
+ * Write out and wait upon all dirty data associated with this
+ * superblock.  Filesystem data as well as the underlying block
+ * device.  Takes the superblock lock.
+ */
+int fsync_super(struct super_block *sb)
+{
+	sync_inodes_sb(sb, 0);
+	DQUOT_SYNC(sb);
+	lock_super(sb);
+	if (sb->s_dirt && sb->s_op->write_super)
+		sb->s_op->write_super(sb);
+	unlock_super(sb);
+	if (sb->s_op->sync_fs)
+		sb->s_op->sync_fs(sb, 1);
+#ifdef CONFIG_BLOCK_DEVICES
+	sync_blockdev(sb->s_bdev);
+#endif
+	sync_inodes_sb(sb, 1);
+
+#ifdef CONFIG_BLOCK_DEVICES
+	return sync_blockdev(sb->s_bdev);
+#else
+	return 0;
+#endif
 }
fs/inode.c +13 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/inode.c linux-2.6.1-rc1-tiny1.eb2/fs/inode.c
@@ -233,7 +233,9 @@
  */
 void clear_inode(struct inode *inode)
 {
+#ifdef CONFIG_BLOCK_DEVICES
 	invalidate_inode_buffers(inode);
+#endif
        
 	if (inode->i_data.nrpages)
 		BUG();
@@ -245,8 +247,10 @@
 	DQUOT_DROP(inode);
 	if (inode->i_sb && inode->i_sb->s_op->clear_inode)
 		inode->i_sb->s_op->clear_inode(inode);
+#if CONFIG_BLOCK_DEVICES
 	if (inode->i_bdev)
 		bd_forget(inode);
+#endif
 	if (inode->i_cdev)
 		cd_forget(inode);
 	inode->i_state = I_CLEAR;
@@ -301,7 +305,9 @@
 		inode = list_entry(tmp, struct inode, i_list);
 		if (inode->i_sb != sb)
 			continue;
+#ifdef CONFIG_BLOCK_DEVICES
 		invalidate_inode_buffers(inode);
+#endif
 		if (!atomic_read(&inode->i_count)) {
 			hlist_del_init(&inode->i_hash);
 			list_del(&inode->i_list);
@@ -353,7 +359,8 @@
 }
 
 EXPORT_SYMBOL(invalidate_inodes);
- 
+
+#ifdef CONFIG_BLOCK_DEVICES 
 int __invalidate_device(struct block_device *bdev, int do_sync)
 {
 	struct super_block *sb;
@@ -380,6 +387,7 @@
 }
 
 EXPORT_SYMBOL(__invalidate_device);
+#endif
 
 static int can_unuse(struct inode *inode)
 {
@@ -431,8 +439,10 @@
 		if (inode_has_buffers(inode) || inode->i_data.nrpages) {
 			__iget(inode);
 			spin_unlock(&inode_lock);
+#ifdef CONFIG_BLOCK_DEVICES
 			if (remove_inode_buffers(inode))
 				reap += invalidate_inode_pages(&inode->i_data);
+#endif
 			iput(inode);
 			spin_lock(&inode_lock);
 
@@ -1391,9 +1401,11 @@
 	if (S_ISCHR(mode)) {
 		inode->i_fop = &def_chr_fops;
 		inode->i_rdev = rdev;
+#ifdef CONFIG_BLOCK_DEVICES
 	} else if (S_ISBLK(mode)) {
 		inode->i_fop = &def_blk_fops;
 		inode->i_rdev = rdev;
+#endif
 	} else if (S_ISFIFO(mode))
 		inode->i_fop = &def_fifo_fops;
 	else if (S_ISSOCK(mode))
fs/partitions/Makefile +1 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/partitions/Makefile linux-2.6.1-rc1-tiny1.eb2/fs/partitions/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y := check.o
+obj-$(CONFIG_BLOCK_DEVICES) := check.o
 
 obj-$(CONFIG_DEVFS_FS) += devfs.o
 obj-$(CONFIG_ACORN_PARTITION) += acorn.o
fs/super.c +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/fs/super.c linux-2.6.1-rc1-tiny1.eb2/fs/super.c
@@ -473,8 +473,10 @@
 {
 	int retval;
 	
+#ifdef CONFIG_BLOCK_DEVICES
 	if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
 		return -EACCES;
+#endif
 	if (flags & MS_RDONLY)
 		acct_auto_close(sb);
 	shrink_dcache_sb(sb);
@@ -588,6 +590,7 @@
 	return (void *)s->s_bdev == data;
 }
 
+#ifdef CONFIG_BLOCK_DEVICES
 struct super_block *get_sb_bdev(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data,
 	int (*fill_super)(struct super_block *, void *, int))
@@ -645,6 +648,7 @@
 }
 
 EXPORT_SYMBOL(kill_block_super);
+#endif
 
 struct super_block *get_sb_nodev(struct file_system_type *fs_type,
 	int flags, void *data,
include/linux/blkdev.h +9 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/include/linux/blkdev.h linux-2.6.1-rc1-tiny1.eb2/include/linux/blkdev.h
@@ -577,7 +577,11 @@
 extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
 extern void blk_dump_rq_flags(struct request *, char *);
 extern void generic_unplug_device(void *);
+#ifdef CONFIG_BLOCK_DEVICES
 extern long nr_blockdev_pages(void);
+#else
+static inline long nr_blockdev_pages(void) { return 0; }
+#endif
 
 int blk_get_queue(request_queue_t *);
 request_queue_t *blk_alloc_queue(int);
@@ -596,7 +600,12 @@
 extern void blk_queue_free_tags(request_queue_t *);
 extern int blk_queue_resize_tags(request_queue_t *, int);
 extern void blk_queue_invalidate_tags(request_queue_t *);
+
+#if defined(CONFIG_BLOCK_DEVICES)
 extern void blk_congestion_wait(int rw, long timeout);
+#else
+static inline void blk_congestion_wait(int rw, long timeout) {} 
+#endif
 
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern void blk_rq_prep_restart(struct request *);
include/linux/buffer_head.h +8 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/include/linux/buffer_head.h linux-2.6.1-rc1-tiny1.eb2/include/linux/buffer_head.h
@@ -150,7 +150,11 @@
 void buffer_insert_list(spinlock_t *lock,
 			struct buffer_head *, struct list_head *);
 void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode);
+#ifdef CONFIG_BLOCK_DEVICES
 int inode_has_buffers(struct inode *);
+#else
+static inline int inode_has_buffers(struct inode *inode) { return 0; }
+#endif
 void invalidate_inode_buffers(struct inode *);
 int remove_inode_buffers(struct inode *inode);
 int fsync_buffers_list(spinlock_t *lock, struct list_head *);
@@ -160,7 +164,11 @@
 void mark_buffer_async_read(struct buffer_head *bh);
 void mark_buffer_async_write(struct buffer_head *bh);
 void invalidate_bdev(struct block_device *, int);
+#if CONFIG_BLOCK_DEVICES
 int sync_blockdev(struct block_device *bdev);
+#else
+static inline int sync_blockdev(struct block_device *bdev) { return 0; }
+#endif
 void __wait_on_buffer(struct buffer_head *);
 wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
 void wake_up_buffer(struct buffer_head *bh);
include/linux/fs.h +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/include/linux/fs.h linux-2.6.1-rc1-tiny1.eb2/include/linux/fs.h
@@ -1145,7 +1145,11 @@
 extern int blkdev_put(struct block_device *, int);
 extern int bd_claim(struct block_device *, void *);
 extern void bd_release(struct block_device *);
+#ifdef CONFIG_BLOCK_DEVICE
 extern void blk_run_queues(void);
+#else
+static inline void blk_run_queues(void) {};
+#endif
 
 /* fs/char_dev.c */
 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, char *);
include/linux/mm.h +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/include/linux/mm.h linux-2.6.1-rc1-tiny1.eb2/include/linux/mm.h
@@ -486,7 +486,11 @@
 		if (spd)
 			return (*spd)(page);
 	}
+#if CONFIG_BLOCK_DEVICES
 	return __set_page_dirty_buffers(page);
+#else
+	return 0;
+#endif
 }
 
 /*
include/linux/mpage.h +10 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/include/linux/mpage.h linux-2.6.1-rc1-tiny1.eb2/include/linux/mpage.h
@@ -10,6 +10,7 @@
  * nested includes.  Get it right in the .c file).
  */
 
+#ifdef CONFIG_BLOCK_DEVICES
 struct writeback_control;
 
 int mpage_readpages(struct address_space *mapping, struct list_head *pages,
@@ -23,3 +24,12 @@
 {
 	return mpage_writepages(mapping, wbc, NULL);
 }
+#else
+
+static inline int
+generic_writepages(struct address_space *mapping, struct writeback_control *wbc)
+{
+	return 0;
+}
+
+#endif
init/Kconfig +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/init/Kconfig linux-2.6.1-rc1-tiny1.eb2/init/Kconfig
@@ -277,6 +277,8 @@
 	  support for epoll family of system calls.
 
 source "drivers/block/Kconfig.iosched"
+source "fs/Kconfig.embedded"
+source "drivers/block/Kconfig.embedded"
 
 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size" if EMBEDDED
init/do_mounts.c +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/init/do_mounts.c linux-2.6.1-rc1-tiny1.eb2/init/do_mounts.c
@@ -267,6 +267,7 @@
 	return 0;
 }
 
+#if CONFIG_BLOCK_DEVICES
 void __init mount_block_root(char *name, int flags)
 {
 	char *fs_names = __getname();
@@ -301,6 +302,7 @@
 out:
 	putname(fs_names);
 }
+#endif
  
 #ifdef CONFIG_ROOT_NFS
 static int __init mount_nfs_root(void)
@@ -368,8 +370,10 @@
 			change_floppy("root floppy");
 	}
 #endif
+#if CONFIG_BLOCK_DEVICES
 	create_dev("/dev/root", ROOT_DEV, root_device_name);
 	mount_block_root("/dev/root", root_mountflags);
+#endif
 }
 
 /*
init/main.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/init/main.c linux-2.6.1-rc1-tiny1.eb2/init/main.c
@@ -447,7 +447,9 @@
 #endif
 	fork_init(num_physpages);
 	proc_caches_init();
+#if CONFIG_BLOCK_DEVICES
 	buffer_init();
+#endif
 	security_scaffolding_startup();
 	vfs_caches_init(max(1000, (int)num_physpages-16000));
 	radix_tree_init();
kernel/exit.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/kernel/exit.c linux-2.6.1-rc1-tiny1.eb2/kernel/exit.c
@@ -750,8 +750,10 @@
 		panic("Attempted to kill the idle task!");
 	if (unlikely(tsk->pid == 1))
 		panic("Attempted to kill init!");
+#ifdef CONFIG_BLOCK_DEVICES
 	if (tsk->io_context)
 		exit_io_context();
+#endif
 	tsk->flags |= PF_EXITING;
 	del_timer_sync(&tsk->real_timer);
 
kernel/sys.c +9 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/kernel/sys.c linux-2.6.1-rc1-tiny1.eb2/kernel/sys.c
@@ -251,6 +251,15 @@
 cond_syscall(sys_epoll_wait)
 cond_syscall(sys_pciconfig_read)
 cond_syscall(sys_pciconfig_write)
+cond_syscall(sys_io_setup)
+cond_syscall(sys_io_destroy)
+cond_syscall(sys_io_getevents)
+cond_syscall(sys_io_submit)
+cond_syscall(sys_io_cancel)
+cond_syscall(sys_bdflush)
+cond_syscall(sys_sync)
+cond_syscall(sys_fsync)
+cond_syscall(sys_fdatasync)
 
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {
mm/filemap.c +9 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/filemap.c linux-2.6.1-rc1-tiny1.eb2/mm/filemap.c
@@ -1640,6 +1640,11 @@
                 return err;
         }
 
+#if !defined(CONFIG_BLOCK_DEVICES)
+	if (unlikely(isblk)) {
+		return -EINVAL;
+	}
+#endif
 	if (!isblk) {
 		/* FIXME: this is for backwards compatibility with 2.4 */
 		if (file->f_flags & O_APPEND)
@@ -1688,7 +1693,9 @@
 
 		if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
 			*count = inode->i_sb->s_maxbytes - *pos;
-	} else {
+	} 
+#if defined(CONFIG_BLOCK_DEVICES)
+	else {
 		loff_t isize;
 		if (bdev_read_only(inode->i_bdev))
 			return -EPERM;
@@ -1701,6 +1708,7 @@
 		if (*pos + *count > isize)
 			*count = isize - *pos;
 	}
+#endif
 	return 0;
 }
 
mm/highmem.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/highmem.c linux-2.6.1-rc1-tiny1.eb2/mm/highmem.c
@@ -300,6 +300,7 @@
 	}
 }
 
+#ifdef CONFIG_BLOCK_DEVICES
 static void bounce_end_io(struct bio *bio, mempool_t *pool)
 {
 	struct bio *bio_orig = bio->bi_private;
@@ -479,6 +480,7 @@
 }
 
 EXPORT_SYMBOL(blk_queue_bounce);
+#endif /* CONFIG_BLOCK_DEVICES */
 
 #if defined(HASHED_PAGE_VIRTUAL)
 
mm/page-writeback.c +35 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/page-writeback.c linux-2.6.1-rc1-tiny1.eb2/mm/page-writeback.c
@@ -567,3 +567,38 @@
 	return 0;
 }
 EXPORT_SYMBOL(test_clear_page_dirty);
+
+
+/**
+ * try_to_release_page() - release old fs-specific metadata on a page
+ *
+ * @page: the page which the kernel is trying to free
+ * @gfp_mask: memory allocation flags (and I/O mode)
+ *
+ * The address_space is to try to release any data against the page
+ * (presumably at page->private).  If the release was successful, return `1'.
+ * Otherwise return zero.
+ *
+ * The @gfp_mask argument specifies whether I/O may be performed to release
+ * this page (__GFP_IO), and whether the call may block (__GFP_WAIT).
+ *
+ * NOTE: @gfp_mask may go away, and this function may become non-blocking.
+ */
+int try_to_release_page(struct page *page, int gfp_mask)
+{
+	struct address_space * const mapping = page->mapping;
+
+	if (!PageLocked(page))
+		BUG();
+	if (PageWriteback(page))
+		return 0;
+	
+	if (mapping && mapping->a_ops->releasepage)
+		return mapping->a_ops->releasepage(page, gfp_mask);
+#if CONFIG_BLOCK_DEVICES
+	return try_to_free_buffers(page);
+#else
+	BUG();
+	return 0;
+#endif
+}
mm/swap.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/swap.c linux-2.6.1-rc1-tiny1.eb2/mm/swap.c
@@ -317,6 +317,7 @@
 	pagevec_reinit(pvec);
 }
 
+#if CONFIG_BLOCK_DEVICES
 /*
  * Try to drop buffers from the pages in a pagevec
  */
@@ -333,6 +334,7 @@
 		}
 	}
 }
+#endif
 
 /**
  * pagevec_lookup - gang pagecache lookup
mm/truncate.c +8 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/truncate.c linux-2.6.1-rc1-tiny1.eb2/mm/truncate.c
@@ -18,11 +18,18 @@
 
 static int do_invalidatepage(struct page *page, unsigned long offset)
 {
+	int ret;
 	int (*invalidatepage)(struct page *, unsigned long);
 	invalidatepage = page->mapping->a_ops->invalidatepage;
+#if CONFIG_BLOCK_DEVICE
 	if (invalidatepage == NULL)
 		invalidatepage = block_invalidatepage;
-	return (*invalidatepage)(page, offset);
+#endif
+	ret = 1;
+	if (invalidatepage) {
+		ret = (*invalidatepage)(page, offset);
+	}
+	return ret;
 }
 
 static inline void truncate_partial_page(struct page *page, unsigned partial)
mm/vmscan.c +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.eb1/mm/vmscan.c linux-2.6.1-rc1-tiny1.eb2/mm/vmscan.c
@@ -704,19 +704,23 @@
 			spin_unlock_irq(&zone->lru_lock);
 			pgdeactivate += pgmoved;
 			pgmoved = 0;
+#ifdef CONFIG_BLOCK_DEVICES
 			if (buffer_heads_over_limit)
 				pagevec_strip(&pvec);
+#endif
 			__pagevec_release(&pvec);
 			spin_lock_irq(&zone->lru_lock);
 		}
 	}
 	zone->nr_inactive += pgmoved;
 	pgdeactivate += pgmoved;
+#ifdef CONFIG_BLOCK_DEVICES
 	if (buffer_heads_over_limit) {
 		spin_unlock_irq(&zone->lru_lock);
 		pagevec_strip(&pvec);
 		spin_lock_irq(&zone->lru_lock);
 	}
+#endif
 
 	pgmoved = 0;
 	while (!list_empty(&l_active)) {
#5 lore raw

On Sun, Jan 04, 2004 at 05:00:49PM -0700, Eric W. Biederman wrote:

1) make block-based filesystems dependent on CONFIG_BLOCK

Quoted 14 lines
fs/super.c +2 -0
@@ -473,8 +473,10 @@
 {
 	int retval;
 
+#ifdef CONFIG_BLOCK_DEVICES
 	if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
 		return -EACCES;
+#endif
 	if (flags & MS_RDONLY)
 		acct_auto_close(sb);
 	shrink_dcache_sb(sb);

fs/super.c line 591

Quoted 2 lines
fs/super.c +0 -0
@@ -588,6 +590,7 @@
 	return (void *)s->s_bdev == data;
 }

Tons of stuff here make sense only for block-based filesystems (e.g. the function immediately above ;-). Ifdef, or, better yet, move to fs/block_dev.c

fs/super.c line 593

Quoted 2 lines
fs/super.c +2 -0
+cond_syscall(sys_fsync)
+cond_syscall(sys_fdatasync)

Huh? They should work for network filesystems.

#6 lore raw

First thanks for the review.

Quoted 3 lines · [email protected] writes:

On Sun, Jan 04, 2004 at 05:00:49PM -0700, Eric W. Biederman wrote:

1) make block-based filesystems dependent on CONFIG_BLOCK

Yep that sounds better and is easier to type.

Quoted 6 lines
Quoted 6 lines
fs/super.c +0 -0
@@ -473,8 +473,10 @@
 {
 	int retval;
 
Quoted 13 lines

fs/super.c line 591

Quoted 10 lines
fs/super.c +2 -0
+#ifdef CONFIG_BLOCK_DEVICES
 	if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev))
 		return -EACCES;
+#endif
 	if (flags & MS_RDONLY)
 		acct_auto_close(sb);
 	shrink_dcache_sb(sb);
@@ -588,6 +590,7 @@
 	return (void *)s->s_bdev == data;
 }

Tons of stuff here make sense only for block-based filesystems (e.g. the function immediately above ;-). Ifdef, or, better yet, move to fs/block_dev.c

remounting only makes sense for block based filesystems? That does not sound right.

Definitely something to look into next time I get the chance.

Quoted 4 lines

fs/super.c line 593

Quoted 2 lines
fs/super.c +2 -0
+cond_syscall(sys_fsync)
+cond_syscall(sys_fdatasync)

Huh? They should work for network filesystems.

Good catch. I did say this was a first cut that was too ugly to use. The problem is those functions need to move out of buffer.c

I have moved them into fs-writeback.c and things still appear to work.

My method of exacting the dependencies was to remove the obvious files from the build and then to fixup whatever linker problems were left.

Eric

#8 lore raw
In reply to a message not in the archive
Quoted 7 lines · Matt Mackall
Quoted 3 lines · Eric W. Biederman

On the side of useless ugly. But interesting in what I had to touch the following patch is a first crude stab at removing block device support from the kernel.

This looks good. If you can send me a version with /BLOCK_DEVICE/BLOCK/, etc., I'll put it in.

Ok. I have just had a chance to clean some things up. Attached is my latest and hopefully clean set up diffs against 2.6.1-rc1-tiny1

I am bouncing this off of linux-kernel as well since I got such good feedback last time.

- First the compile fixes, so I can compile test this code.
- Then the CONFIG_BLOCK patch.
* I have reviewed the code and it looks correct, beyond just the fact that the code compiles.
* I have added a sync.c for the sync functions that used to live in buffer.c.
* I have removed most instances of CONFIG_BLOCK from the mainline code to improve maintenance. Now there are just a few ugly parts where the block layer is not cleanly separated from the rest of the code.
* I have updated where I put the depends so fewer things need a CONFIG_BLOCK.
* I have added a CONFIG_BLOCK to all of the likely looking filesystems.
- Then a new patch that was sort of in my tree to make BINFMT_SCRIPT configurable.
- And another new patch to use cond_syscall instead of explicit dummies when we don't have the AIO code compiled in.

The last two patches really don't really appear to save anything but they are clean, and you can't have too many CONFIG_EMBEDDED options :)

Eric

arch/i386/kernel/cpu/common.c +28 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/arch/i386/kernel/cpu/common.c linux-2.6.1-rc1-tiny1.compile-fixes/arch/i386/kernel/cpu/common.c
@@ -421,7 +421,6 @@
  * They will insert themselves into the cpu_devs structure.
  * Then, when cpu_init() is called, we can just iterate over that array.
  */
-
 extern int intel_cpu_init(void);
 extern int cyrix_init_cpu(void);
 extern int nsc_init_cpu(void);
@@ -431,6 +430,34 @@
 extern int rise_init_cpu(void);
 extern int nexgen_init_cpu(void);
 extern int umc_init_cpu(void);
+
+#ifndef CONFIG_CPU_SUP_INTEL
+#define intel_cpu_init() 
+#endif
+#ifndef CONFIG_CPU_SUP_CYRIX
+#define cyrix_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_NSC
+#define nsc_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_AMD
+#define amd_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_CENTAUR
+#define centaur_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_TRANSMETA
+#define transmeta_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_RISE
+#define rise_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_NEXGEN
+#define nexgen_init_cpu() 
+#endif
+#ifndef CONFIG_CPU_SUP_UMC
+#define umc_init_cpu() 
+#endif
 
 void __init early_cpu_init(void)
 {
arch/i386/mm/init.c +6 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/arch/i386/mm/init.c linux-2.6.1-rc1-tiny1.compile-fixes/arch/i386/mm/init.c
@@ -444,9 +444,14 @@
 static struct kcore_list kcore_mem, kcore_vmalloc; 
 #endif
 
+#ifdef CONFIG_CPU_SUP_INTEL
+extern int ppro_with_ram_bug(void);
+#else
+static inline int ppro_with_ram_bug(void) { return 0; }
+#endif
+
 void __init mem_init(void)
 {
-	extern int ppro_with_ram_bug(void);
 	int codesize, reservedpages, datasize, initsize;
 	int tmp;
 	int bad_ppro;
kernel/Makefile +2 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/kernel/Makefile linux-2.6.1-rc1-tiny1.compile-fixes/kernel/Makefile
@@ -4,10 +4,11 @@
 
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
 	    exit.o itimer.o time.o softirq.o resource.o \
-	    sysctl.o capability.o ptrace.o timer.o user.o \
+	    sysctl.o capability.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o
 
+obj-$(CONFIG_PTRACE) += ptrace.o
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
 obj-$(CONFIG_SMP) += cpu.o
kernel/printk.c +2 -2
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1/kernel/printk.c linux-2.6.1-rc1-tiny1.compile-fixes/kernel/printk.c
@@ -101,10 +101,10 @@
 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
 static int preferred_console = -1;
 
-#ifdef CONFIG_PRINTK
-
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
+
+#ifdef CONFIG_PRINTK
 
 /*
  *	Setup a list of consoles. Called from init/main.c
drivers/block/Kconfig +1 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/drivers/block/Kconfig linux-2.6.1-rc1-tiny1.config-block/drivers/block/Kconfig
@@ -3,6 +3,7 @@
 #
 
 menu "Block devices"
+	depends BLOCK
 
 config BLK_DEV_FD
 	tristate "Normal floppy disk support"
drivers/block/Kconfig.embedded +5 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/drivers/block/Kconfig.embedded linux-2.6.1-rc1-tiny1.config-block/drivers/block/Kconfig.embedded
@@ -0,0 +1,5 @@
+config BLOCK
+	bool "Block device support" if EMBEDDED
+	default y
+	help
+	  Allow the complete removal of block device code
drivers/block/Kconfig.iosched +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/drivers/block/Kconfig.iosched linux-2.6.1-rc1-tiny1.config-block/drivers/block/Kconfig.iosched
@@ -1,3 +1,5 @@
+if BLOCK
+
 config IOSCHED_NOOP
 	bool "No-op I/O scheduler" if EMBEDDED
 	default y
@@ -26,4 +28,6 @@
 	  workloads, better. In the case of a single process performing I/O to
 	  a disk at any one time, its behaviour is almost identical to the
 	  anticipatory I/O scheduler and so is a good choice.
+
+endif
 
drivers/block/Makefile +1 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/drivers/block/Makefile linux-2.6.1-rc1-tiny1.config-block/drivers/block/Makefile
@@ -13,7 +13,7 @@
 # kblockd threads
 #
 
-obj-y	:= elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
+obj-$(CONFIG_BLOCK)	:= elevator.o ll_rw_blk.o ioctl.o genhd.o scsi_ioctl.o
 
 obj-$(CONFIG_IOSCHED_NOOP)	+= noop-iosched.o
 obj-$(CONFIG_IOSCHED_AS)	+= as-iosched.o
drivers/md/Kconfig +1 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/drivers/md/Kconfig linux-2.6.1-rc1-tiny1.config-block/drivers/md/Kconfig
@@ -3,6 +3,7 @@
 #
 
 menu "Multi-device support (RAID and LVM)"
+	depends on BLOCK
 
 config MD
 	bool "Multiple devices driver support (RAID and LVM)"
fs/Kconfig +24 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/Kconfig linux-2.6.1-rc1-tiny1.config-block/fs/Kconfig
@@ -6,6 +6,7 @@
 
 config EXT2_FS
 	tristate "Second extended fs support"
+	depends on BLOCK
 	help
 	  This is the de facto standard Linux file system (method to organize
 	  files on a storage device) for hard disks.
@@ -85,6 +86,7 @@
 
 config EXT3_FS
 	tristate "Ext3 journalling file system support"
+	depends on BLOCK
 	help
 	  This is the journaling version of the Second extended file system
 	  (often called ext3), the de facto standard Linux file system
@@ -157,6 +159,7 @@
 # dep_tristate '  Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS
 	tristate
 	default EXT3_FS
+	depends on BLOCK
 	help
 	  This is a generic journaling layer for block devices.  It is
 	  currently used by the ext3 file system, but it could also be used to
@@ -195,6 +198,7 @@
 
 config REISERFS_FS
 	tristate "Reiserfs support"
+	depends on BLOCK
 	help
 	  Stores not just filenames but the files themselves in a balanced
 	  tree.  Uses journaling.
@@ -246,6 +250,7 @@
 
 config JFS_FS
 	tristate "JFS filesystem support"
+	depends on BLOCK
 	select NLS
 	help
 	  This is a port of IBM's Journaled Filesystem .  More information is
@@ -293,6 +298,7 @@
 
 config XFS_FS
 	tristate "XFS filesystem support"
+	depends on BLOCK
 	help
 	  XFS is a high performance journaling filesystem which originated
 	  on the SGI IRIX platform.  It is completely multi-threaded, can
@@ -358,6 +364,7 @@
 
 config MINIX_FS
 	tristate "Minix fs support"
+	depends on BLOCK
 	help
 	  Minix is a simple operating system used in many classes about OS's.
 	  The minix file system (method to organize files on a hard disk
@@ -375,6 +382,7 @@
 
 config ROMFS_FS
 	tristate "ROM file system support"
+	depends on BLOCK
 	---help---
 	  This is a very small read-only file system mainly intended for
 	  initial ram disks of installation disks, but it could be used for
@@ -466,6 +474,8 @@
 	  N here.
 
 menu "CD-ROM/DVD Filesystems"
+	depends on BLOCK
+
 
 config ISO9660_FS
 	tristate "ISO 9660 CDROM file system support"
@@ -529,6 +539,7 @@
 endmenu
 
 menu "DOS/FAT/NT Filesystems"
+	depends on BLOCK
 
 config FAT_FS
 	tristate "DOS FAT fs support"
@@ -900,6 +911,7 @@
 config ADFS_FS
 	tristate "ADFS file system support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	help
 	  The Acorn Disc Filing System is the standard file system of the
 	  RiscOS operating system which runs on Acorn's ARM-based Risc PC
@@ -928,6 +940,7 @@
 config AFFS_FS
 	tristate "Amiga FFS file system support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	help
 	  The Fast File System (FFS) is the common file system used on hard
 	  disks by Amiga(tm) systems since AmigaOS Version 1.3 (34.20).  Say Y
@@ -950,6 +963,7 @@
 config HFS_FS
 	tristate "Apple Macintosh file system support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	help
 	  If you say Y here, you will be able to mount Macintosh-formatted
 	  floppy disks and hard drive partitions with full read-write access.
@@ -962,6 +976,7 @@
 config BEFS_FS
 	tristate "BeOS file systemv(BeFS) support (read only) (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	select NLS
 	help
 	  The BeOS File System (BeFS) is the native file system of Be, Inc's
@@ -989,6 +1004,7 @@
 config BFS_FS
 	tristate "BFS file system support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	help
 	  Boot File System (BFS) is a file system used under SCO UnixWare to
 	  allow the bootloader access to the kernel image and other important
@@ -1011,6 +1027,7 @@
 config EFS_FS
 	tristate "EFS file system support (read only) (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
+	depends on BLOCK
 	help
 	  EFS is an older file system used for non-ISO9660 CD-ROMs and hard
 	  disk partitions by SGI's IRIX operating system (IRIX 6.0 and newer
@@ -1097,6 +1114,7 @@
 
 config CRAMFS
 	tristate "Compressed ROM file system support"
+	depends on BLOCK
 	select ZLIB_INFLATE
 	help
 	  Saying Y here includes support for CramFs (Compressed ROM File
@@ -1116,6 +1134,7 @@
 
 config VXFS_FS
 	tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
+	depends on BLOCK
 	help
 	  FreeVxFS is a file system driver that support the VERITAS VxFS(TM)
 	  file system format.  VERITAS VxFS(TM) is the standard file system
@@ -1133,6 +1152,7 @@
 
 config HPFS_FS
 	tristate "OS/2 HPFS file system support"
+	depends on BLOCK
 	help
 	  OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
 	  is the file system used for organizing files on OS/2 hard disk
@@ -1149,6 +1169,7 @@
 
 config QNX4FS_FS
 	tristate "QNX4 file system support (read only)"
+	depends on BLOCK
 	help
 	  This is the file system used by the real-time operating systems
 	  QNX 4 and QNX 6 (the latter is also called QNX RTP).
@@ -1176,6 +1197,7 @@
 
 config SYSV_FS
 	tristate "System V/Xenix/V7/Coherent file system support"
+	depends on BLOCK
 	help
 	  SCO, Xenix and Coherent are commercial Unix systems for Intel
 	  machines, and Version 7 was used on the DEC PDP-11. Saying Y
@@ -1214,6 +1236,7 @@
 
 config UFS_FS
 	tristate "UFS file system support (read only)"
+	depends on BLOCK
 	help
 	  BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD,
 	  OpenBSD and NeXTstep) use a file system called UFS. Some System V
@@ -1608,6 +1631,7 @@
 endmenu
 
 menu "Partition Types"
+	depends on BLOCK
 
 source "fs/partitions/Kconfig"
 
fs/Makefile +4 -3
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/Makefile linux-2.6.1-rc1-tiny1.config-block/fs/Makefile
@@ -5,13 +5,14 @@
 # Rewritten to use lists instead of if-statements.
 # 
 
-obj-y :=	open.o read_write.o file_table.o buffer.o \
-		bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
+obj-y :=	open.o read_write.o file_table.o \
+		super.o char_dev.o stat.o exec.o pipe.o \
 		namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
 		dcache.o inode.o attr.o bad_inode.o file.o \
 		filesystems.o namespace.o seq_file.o xattr.o libfs.o \
-		fs-writeback.o mpage.o direct-io.o aio.o
+		fs-writeback.o mpage.o aio.o sync.o
 
+obj-$(CONFIG_BLOCK)		+= buffer.o bio.o block_dev.o direct-io.o
 obj-$(CONFIG_DNOTIFY)		+= dnotify.o
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-$(CONFIG_COMPAT)		+= compat.o
fs/block_dev.c +101 -0

104 lines not on this page · raw message

fs/buffer.c +4 -208

249 lines not on this page · raw message

fs/dcache.c +5 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/dcache.c linux-2.6.1-rc1-tiny1.config-block/fs/dcache.c
@@ -1598,7 +1598,12 @@
 
 EXPORT_SYMBOL(d_genocide);
 
+#ifdef CONFIG_BLOCK
 extern void bdev_cache_init(void);
+#else
+static inline void bdev_cache_init(void) {}
+#endif
+
 extern void chrdev_init(void);
 
 void __init vfs_caches_init(unsigned long mempages)
fs/fs-writeback.c +8 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/fs-writeback.c linux-2.6.1-rc1-tiny1.config-block/fs/fs-writeback.c
@@ -23,7 +23,9 @@
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 
+#ifdef CONFIG_BLOCK
 extern struct super_block *blockdev_superblock;
+#endif
 
 /**
  *	__mark_inode_dirty -	internal function
@@ -263,6 +265,7 @@
 		struct backing_dev_info *bdi = mapping->backing_dev_info;
 
 		if (bdi->memory_backed) {
+#ifdef CONFIG_BLOCK
 			if (sb == blockdev_superblock) {
 				/*
 				 * Dirty memory-backed blockdev: the ramdisk
@@ -271,6 +274,7 @@
 				list_move(&inode->i_list, &sb->s_dirty);
 				continue;
 			}
+#endif
 			/*
 			 * Assume that all inodes on this superblock are memory
 			 * backed.  Skip the superblock.
@@ -280,15 +284,19 @@
 
 		if (wbc->nonblocking && bdi_write_congested(bdi)) {
 			wbc->encountered_congestion = 1;
+#ifdef CONFIG_BLOCK
 			if (sb != blockdev_superblock)
 				break;		/* Skip a congested fs */
+#endif
 			list_move(&inode->i_list, &sb->s_dirty);
 			continue;		/* Skip a congested blockdev */
 		}
 
 		if (wbc->bdi && bdi != wbc->bdi) {
+#ifdef CONFIG_BLOCK
 			if (sb != blockdev_superblock)
 				break;		/* fs has the wrong queue */
+#endif
 			list_move(&inode->i_list, &sb->s_dirty);
 			continue;		/* blockdev has wrong queue */
 		}
fs/inode.c +15 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/inode.c linux-2.6.1-rc1-tiny1.config-block/fs/inode.c
@@ -245,8 +245,10 @@
 	DQUOT_DROP(inode);
 	if (inode->i_sb && inode->i_sb->s_op->clear_inode)
 		inode->i_sb->s_op->clear_inode(inode);
+#ifdef CONFIG_BLOCK
 	if (inode->i_bdev)
 		bd_forget(inode);
+#endif
 	if (inode->i_cdev)
 		cd_forget(inode);
 	inode->i_state = I_CLEAR;
@@ -354,6 +356,7 @@
 
 EXPORT_SYMBOL(invalidate_inodes);
  
+#ifdef CONFIG_BLOCK
 int __invalidate_device(struct block_device *bdev, int do_sync)
 {
 	struct super_block *sb;
@@ -380,6 +383,7 @@
 }
 
 EXPORT_SYMBOL(__invalidate_device);
+#endif
 
 static int can_unuse(struct inode *inode)
 {
@@ -1384,6 +1388,17 @@
 
 	set_shrinker(DEFAULT_SEEKS, shrink_icache_memory);
 }
+
+#ifndef CONFIG_BLOCK
+static int no_bdev_open(struct inode *inode, struct file *file)
+{
+	return -ENXIO;
+};
+
+struct file_operations def_blk_fops = {
+	.open	= no_bdev_open,
+};
+#endif
 
 void init_special_inode(struct inode *inode, umode_t mode, dev_t rdev)
 {
fs/mpage.c +15 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/mpage.c linux-2.6.1-rc1-tiny1.config-block/fs/mpage.c
@@ -27,6 +27,7 @@
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
 
+#ifdef CONFIG_BLOCK
 /*
  * I/O completion handler for multipage BIOs.
  *
@@ -576,6 +577,8 @@
 	return bio;
 }
 
+#endif /* CONFIG_BLOCK */
+
 /**
  * mpage_writepages - walk the list of dirty pages of the given
  * address space and writepage() all of them.
@@ -620,8 +623,10 @@
 		struct writeback_control *wbc, get_block_t get_block)
 {
 	struct backing_dev_info *bdi = mapping->backing_dev_info;
+#ifdef CONFIG_BLOCK
 	struct bio *bio = NULL;
 	sector_t last_block_in_bio = 0;
+#endif
 	int ret = 0;
 	int done = 0;
 	int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -631,8 +636,10 @@
 		return 0;
 	}
 
+#ifdef CONFIG_BLOCK
 	writepage = NULL;
 	if (get_block == NULL)
+#endif
 		writepage = mapping->a_ops->writepage;
 
 	spin_lock(&mapping->page_lock);
@@ -671,7 +678,9 @@
 
 		if (page->mapping == mapping && !PageWriteback(page) &&
 					test_clear_page_dirty(page)) {
+#ifdef CONFIG_BLOCK
 			if (writepage) {
+#endif
 				ret = (*writepage)(page, wbc);
 				if (ret) {
 					if (ret == -ENOSPC)
@@ -681,10 +690,13 @@
 						set_bit(AS_EIO,
 							&mapping->flags);
 				}
-			} else {
+#ifdef CONFIG_BLOCK
+			} 
+			else {
 				bio = mpage_writepage(bio, page, get_block,
 					&last_block_in_bio, &ret, wbc);
 			}
+#endif
 			if (ret || (--(wbc->nr_to_write) <= 0))
 				done = 1;
 			if (wbc->nonblocking && bdi_write_congested(bdi)) {
@@ -701,8 +713,10 @@
 	 * Leave any remaining dirty pages on ->io_pages
 	 */
 	spin_unlock(&mapping->page_lock);
+#ifdef CONFIG_BLOCK
 	if (bio)
 		mpage_bio_submit(WRITE, bio);
+#endif
 	return ret;
 }
 EXPORT_SYMBOL(mpage_writepages);
fs/partitions/Makefile +1 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/fs/partitions/Makefile linux-2.6.1-rc1-tiny1.config-block/fs/partitions/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y := check.o
+obj-$(CONFIG_BLOCK) := check.o
 
 obj-$(CONFIG_DEVFS_FS) += devfs.o
 obj-$(CONFIG_ACORN_PARTITION) += acorn.o
fs/super.c +2 -101

121 lines not on this page · raw message

fs/sync.c +201 -0

201 lines not on this page · raw message

include/linux/blkdev.h +9 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/include/linux/blkdev.h linux-2.6.1-rc1-tiny1.config-block/include/linux/blkdev.h
@@ -577,7 +577,11 @@
 extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
 extern void blk_dump_rq_flags(struct request *, char *);
 extern void generic_unplug_device(void *);
+#ifdef CONFIG_BLOCK
 extern long nr_blockdev_pages(void);
+#else
+static inline long nr_blockdev_pages(void) { return 0; }
+#endif
 
 int blk_get_queue(request_queue_t *);
 request_queue_t *blk_alloc_queue(int);
@@ -596,7 +600,12 @@
 extern void blk_queue_free_tags(request_queue_t *);
 extern int blk_queue_resize_tags(request_queue_t *, int);
 extern void blk_queue_invalidate_tags(request_queue_t *);
+
+#ifdef CONFIG_BLOCK
 extern void blk_congestion_wait(int rw, long timeout);
+#else
+static inline void blk_congestion_wait(int rw, long timeout) {} 
+#endif
 
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern void blk_rq_prep_restart(struct request *);
include/linux/buffer_head.h +11 -2
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/include/linux/buffer_head.h linux-2.6.1-rc1-tiny1.config-block/include/linux/buffer_head.h
@@ -150,17 +150,26 @@
 void buffer_insert_list(spinlock_t *lock,
 			struct buffer_head *, struct list_head *);
 void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode);
+#ifdef CONFIG_BLOCK
 int inode_has_buffers(struct inode *);
 void invalidate_inode_buffers(struct inode *);
 int remove_inode_buffers(struct inode *inode);
-int fsync_buffers_list(spinlock_t *lock, struct list_head *);
 int sync_mapping_buffers(struct address_space *mapping);
+int sync_blockdev(struct block_device *bdev);
+#else
+static inline int inode_has_buffers(struct inode *inode) { return 0; }
+static inline void invalidate_inode_buffers(struct inode *inode) { }
+static inline int remove_inode_buffers(struct inode *inode) { return 1; }
+static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; }
+static inline int sync_blockdev(struct block_device *bdev) { return 0; }
+#endif
+int fsync_buffers_list(spinlock_t *lock, struct list_head *);
+
 void unmap_underlying_metadata(struct block_device *bdev, sector_t block);
 
 void mark_buffer_async_read(struct buffer_head *bh);
 void mark_buffer_async_write(struct buffer_head *bh);
 void invalidate_bdev(struct block_device *, int);
-int sync_blockdev(struct block_device *bdev);
 void __wait_on_buffer(struct buffer_head *);
 wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
 void wake_up_buffer(struct buffer_head *bh);
include/linux/fs.h +12 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/include/linux/fs.h linux-2.6.1-rc1-tiny1.config-block/include/linux/fs.h
@@ -1145,7 +1145,11 @@
 extern int blkdev_put(struct block_device *, int);
 extern int bd_claim(struct block_device *, void *);
 extern void bd_release(struct block_device *);
+#ifdef CONFIG_BLOCK
 extern void blk_run_queues(void);
+#else
+static inline void blk_run_queues(void) {};
+#endif
 
 /* fs/char_dev.c */
 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, char *);
@@ -1210,7 +1214,11 @@
 extern void sync_supers(void);
 extern void sync_filesystems(int wait);
 extern void emergency_sync(void);
+#ifdef CONFIG_bLOCK
 extern void emergency_remount(void);
+#else
+static inline void emergency_remount(void) {}
+#endif
 extern int do_remount_sb(struct super_block *sb, int flags,
 			 void *data, int force);
 extern sector_t bmap(struct inode *, sector_t);
@@ -1290,7 +1298,11 @@
 extern void file_kill(struct file *f);
 struct bio;
 extern int submit_bio(int, struct bio *);
+#ifdef CONFIG_BLOCK
 extern int bdev_read_only(struct block_device *);
+#else
+static inline int bdev_read_only(struct block_device *bdev) { return 0; }
+#endif
 extern int set_blocksize(struct block_device *, int);
 extern int sb_set_blocksize(struct super_block *, int);
 extern int sb_min_blocksize(struct super_block *, int);
include/linux/mm.h +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/include/linux/mm.h linux-2.6.1-rc1-tiny1.config-block/include/linux/mm.h
@@ -486,7 +486,11 @@
 		if (spd)
 			return (*spd)(page);
 	}
+#if CONFIG_BLOCK
 	return __set_page_dirty_buffers(page);
+#else
+	return 0;
+#endif
 }
 
 /*
init/Kconfig +1 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/init/Kconfig linux-2.6.1-rc1-tiny1.config-block/init/Kconfig
@@ -276,6 +276,7 @@
 	  Disabling this option will cause the kernel to be built without
 	  support for epoll family of system calls.
 
+source "drivers/block/Kconfig.embedded"
 source "drivers/block/Kconfig.iosched"
 
 config CC_OPTIMIZE_FOR_SIZE
init/do_mounts.c +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/init/do_mounts.c linux-2.6.1-rc1-tiny1.config-block/init/do_mounts.c
@@ -267,6 +267,7 @@
 	return 0;
 }
 
+#ifdef CONFIG_BLOCK
 void __init mount_block_root(char *name, int flags)
 {
 	char *fs_names = __getname();
@@ -301,6 +302,7 @@
 out:
 	putname(fs_names);
 }
+#endif /* CONFIG_BLOCK */
  
 #ifdef CONFIG_ROOT_NFS
 static int __init mount_nfs_root(void)
@@ -368,8 +370,10 @@
 			change_floppy("root floppy");
 	}
 #endif
+#ifdef CONFIG_BLOCK
 	create_dev("/dev/root", ROOT_DEV, root_device_name);
 	mount_block_root("/dev/root", root_mountflags);
+#endif
 }
 
 /*
init/main.c +6 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/init/main.c linux-2.6.1-rc1-tiny1.config-block/init/main.c
@@ -78,7 +78,6 @@
 extern void sbus_init(void);
 extern void sysctl_init(void);
 extern void signals_init(void);
-extern void buffer_init(void);
 extern void pidhash_init(void);
 extern void pidmap_init(void);
 extern void pte_chain_init(void);
@@ -89,6 +88,12 @@
 
 #ifdef CONFIG_TC
 extern void tc_init(void);
+#endif
+
+#ifdef CONFIG_BLOCK
+extern void buffer_init(void);
+#else
+static inline void buffer_init(void) {}
 #endif
 
 /*
kernel/exit.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/kernel/exit.c linux-2.6.1-rc1-tiny1.config-block/kernel/exit.c
@@ -750,8 +750,10 @@
 		panic("Attempted to kill the idle task!");
 	if (unlikely(tsk->pid == 1))
 		panic("Attempted to kill init!");
+#ifdef CONFIG_BLOCK
 	if (tsk->io_context)
 		exit_io_context();
+#endif
 	tsk->flags |= PF_EXITING;
 	del_timer_sync(&tsk->real_timer);
 
mm/filemap.c +9 -2
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/filemap.c linux-2.6.1-rc1-tiny1.config-block/mm/filemap.c
@@ -1639,7 +1639,11 @@
                 file->f_error = 0;
                 return err;
         }
-
+#ifndef CONFIG_BLOCK
+	if (unlikely(isblk)) {
+		return -EINVAL;
+	}
+#endif
 	if (!isblk) {
 		/* FIXME: this is for backwards compatibility with 2.4 */
 		if (file->f_flags & O_APPEND)
@@ -1688,7 +1692,9 @@
 
 		if (unlikely(*pos + *count > inode->i_sb->s_maxbytes))
 			*count = inode->i_sb->s_maxbytes - *pos;
-	} else {
+	} 
+#ifdef CONFIG_BLOCK
+	else {
 		loff_t isize;
 		if (bdev_read_only(inode->i_bdev))
 			return -EPERM;
@@ -1701,6 +1707,7 @@
 		if (*pos + *count > isize)
 			*count = isize - *pos;
 	}
+#endif
 	return 0;
 }
 
mm/highmem.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/highmem.c linux-2.6.1-rc1-tiny1.config-block/mm/highmem.c
@@ -300,6 +300,7 @@
 	}
 }
 
+#ifdef CONFIG_BLOCK
 static void bounce_end_io(struct bio *bio, mempool_t *pool)
 {
 	struct bio *bio_orig = bio->bi_private;
@@ -479,6 +480,7 @@
 }
 
 EXPORT_SYMBOL(blk_queue_bounce);
+#endif /* CONFIG_BLOCK */
 
 #if defined(HASHED_PAGE_VIRTUAL)
 
mm/page-writeback.c +34 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/page-writeback.c linux-2.6.1-rc1-tiny1.config-block/mm/page-writeback.c
@@ -567,3 +567,37 @@
 	return 0;
 }
 EXPORT_SYMBOL(test_clear_page_dirty);
+
+/**
+ * try_to_release_page() - release old fs-specific metadata on a page
+ *
+ * @page: the page which the kernel is trying to free
+ * @gfp_mask: memory allocation flags (and I/O mode)
+ *
+ * The address_space is to try to release any data against the page
+ * (presumably at page->private).  If the release was successful, return `1'.
+ * Otherwise return zero.
+ *
+ * The @gfp_mask argument specifies whether I/O may be performed to release
+ * this page (__GFP_IO), and whether the call may block (__GFP_WAIT).
+ *
+ * NOTE: @gfp_mask may go away, and this function may become non-blocking.
+ */
+int try_to_release_page(struct page *page, int gfp_mask)
+{
+	struct address_space * const mapping = page->mapping;
+
+	if (!PageLocked(page))
+		BUG();
+	if (PageWriteback(page))
+		return 0;
+	
+	if (mapping && mapping->a_ops->releasepage)
+		return mapping->a_ops->releasepage(page, gfp_mask);
+#ifdef CONFIG_BLOCK
+	return try_to_free_buffers(page);
+#else
+	BUG();
+	return 0;
+#endif
+}
mm/swap.c +2 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/swap.c linux-2.6.1-rc1-tiny1.config-block/mm/swap.c
@@ -317,6 +317,7 @@
 	pagevec_reinit(pvec);
 }
 
+#ifdef CONFIG_BLOCK
 /*
  * Try to drop buffers from the pages in a pagevec
  */
@@ -333,6 +334,7 @@
 		}
 	}
 }
+#endif /* CONFIG_BLOCK */
 
 /**
  * pagevec_lookup - gang pagecache lookup
mm/truncate.c +3 -1
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/truncate.c linux-2.6.1-rc1-tiny1.config-block/mm/truncate.c
@@ -20,9 +20,11 @@
 {
 	int (*invalidatepage)(struct page *, unsigned long);
 	invalidatepage = page->mapping->a_ops->invalidatepage;
+#ifdef CONFIG_BLOCK
 	if (invalidatepage == NULL)
 		invalidatepage = block_invalidatepage;
-	return (*invalidatepage)(page, offset);
+#endif
+	return (invalidatepage) ? (*invalidatepage)(page, offset) : 1;
 }
 
 static inline void truncate_partial_page(struct page *page, unsigned partial)
mm/vmscan.c +4 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/mm/vmscan.c linux-2.6.1-rc1-tiny1.config-block/mm/vmscan.c
@@ -704,19 +704,23 @@
 			spin_unlock_irq(&zone->lru_lock);
 			pgdeactivate += pgmoved;
 			pgmoved = 0;
+#ifdef CONFIG_BLOCK
 			if (buffer_heads_over_limit)
 				pagevec_strip(&pvec);
+#endif
 			__pagevec_release(&pvec);
 			spin_lock_irq(&zone->lru_lock);
 		}
 	}
 	zone->nr_inactive += pgmoved;
 	pgdeactivate += pgmoved;
+#ifdef CONFIG_BLOCK
 	if (buffer_heads_over_limit) {
 		spin_unlock_irq(&zone->lru_lock);
 		pagevec_strip(&pvec);
 		spin_lock_irq(&zone->lru_lock);
 	}
+#endif
 
 	pgmoved = 0;
 	while (!list_empty(&l_active)) {
fs/Kconfig.embedded +6 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.config-block/fs/Kconfig.embedded linux-2.6.1-rc1-tiny1.config-binfmt-script/fs/Kconfig.embedded
@@ -0,0 +1,6 @@
+config BINFMT_SCRIPT
+	bool "Kernel support for shell scripts" if EMBEDDED
+	default y
+	help
+	  Allow the removal of the code for executing shell scripts
+
fs/Makefile +1 -2
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.config-block/fs/Makefile linux-2.6.1-rc1-tiny1.config-binfmt-script/fs/Makefile
@@ -24,8 +24,7 @@
 obj-$(CONFIG_BINFMT_EM86)	+= binfmt_em86.o
 obj-$(CONFIG_BINFMT_MISC)	+= binfmt_misc.o
 
-# binfmt_script is always there
-obj-y				+= binfmt_script.o
+obj-$(CONFIG_BINFMT_SCRIPT)	+= binfmt_script.o
 
 obj-$(CONFIG_BINFMT_ELF)	+= binfmt_elf.o
 obj-$(CONFIG_BINFMT_SOM)	+= binfmt_som.o
init/Kconfig +1 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.config-block/init/Kconfig linux-2.6.1-rc1-tiny1.config-binfmt-script/init/Kconfig
@@ -278,6 +278,7 @@
 
 source "drivers/block/Kconfig.embedded"
 source "drivers/block/Kconfig.iosched"
+source "fs/Kconfig.embedded"
 
 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size" if EMBEDDED
fs/aio.c +0 -31
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.config-binfmt-script/fs/aio.c linux-2.6.1-rc1-tiny1.reduce-aio/fs/aio.c
@@ -1293,46 +1293,15 @@
 	return 0;
 }
 
-asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t *ctxp)
-{
-	return -ENOSYS;
-}
-
-asmlinkage long sys_io_destroy(aio_context_t ctx)
-{
-	return -ENOSYS;
-}
-
 int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
 			 struct iocb *iocb)
 {
 	return -EINVAL;
 }
 
-asmlinkage long sys_io_submit(aio_context_t ctx_id, long nr,
-			      struct iocb __user **iocbpp)
-{
-	return -ENOSYS;
-}
-
 struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb *iocb, u32 key)
 {
 	return 0;
-}
-
-asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb *iocb,
-			      struct io_event *result)
-{
-	return -ENOSYS;
-}
-
-asmlinkage long sys_io_getevents(aio_context_t ctx_id,
-				 long min_nr,
-				 long nr,
-				 struct io_event *events,
-				 struct timespec *timeout)
-{
-	return -ENOSYS;
 }
 
 EXPORT_SYMBOL(aio_complete);
kernel/sys.c +5 -0
diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.config-binfmt-script/kernel/sys.c linux-2.6.1-rc1-tiny1.reduce-aio/kernel/sys.c
@@ -251,6 +251,11 @@
 cond_syscall(sys_epoll_wait)
 cond_syscall(sys_pciconfig_read)
 cond_syscall(sys_pciconfig_write)
+cond_syscall(sys_io_setup)
+cond_syscall(sys_io_destroy)
+cond_syscall(sys_io_submit)
+cond_syscall(sys_io_cancel)
+cond_syscall(sys_io_getevents)
 
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {
#11 lore raw
In reply to Matt Mackall

In article <[email protected]>,
Matt Mackall <[email protected]> wrote:

| Suggestions? I'm rapidly exhausting a lot of the obvious candidates.
| My target build at the moment is ide + ext2 + proc + ipv4 + console, and
| that's currently at around 800K uncompressed, booting in a little less
| than 2.5MB. Hoping to get that under 2.

Suggestion: keep picking the low-hanging fruit a bit longer, you have been making a lot of improvement with minimal code changes! Much appreciated!

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#9 lore raw
In reply to Eric W. Biederman

Em Thu, Jan 08, 2004 at 12:22:29PM -0700, Eric W. Biederman escreveu:

Quoted 17 lines
Quoted 7 lines · Matt Mackall
Quoted 3 lines · Eric W. Biederman

On the side of useless ugly. But interesting in what I had to touch the following patch is a first crude stab at removing block device support from the kernel.

This looks good. If you can send me a version with /BLOCK_DEVICE/BLOCK/, etc., I'll put it in.

Ok. I have just had a chance to clean some things up. Attached is my latest and hopefully clean set up diffs against 2.6.1-rc1-tiny1

diff -uNr -X linux-ignore-files linux-2.6.1-rc1-tiny1.compile-fixes/include/linux/fs.h linux-2.6.1-rc1-tiny1.config-block/include/linux/fs.h

include/linux/fs.h line 1217

Quoted 4 lines
include/linux/fs.h +1 -0
@@ -1210,7 +1214,11 @@
 extern void sync_supers(void);
 extern void sync_filesystems(int wait);
 extern void emergency_sync(void);
+#ifdef CONFIG_bLOCK
                 ^
                 |
                 |
                 |
                 |

oops :)

#10 lore raw
In reply to Eric W. Biederman
Quoted 10 lines · Eric W. Biederman
Quoted 7 lines · Matt Mackall
Quoted 3 lines · Eric W. Biederman

On the side of useless ugly. But interesting in what I had to touch the following patch is a first crude stab at removing block device support from the kernel.

This looks good. If you can send me a version with /BLOCK_DEVICE/BLOCK/, etc., I'll put it in.

Quoted 7 lines

Ok. I have just had a chance to clean some things up. Attached is my latest and hopefully clean set up diffs against 2.6.1-rc1-tiny1

I am bouncing this off of linux-kernel as well since I got such good feedback last time.

- First the compile fixes, so I can compile test this code.

Ok, had this stuff in my last release.

Quoted 1 line

- Then the CONFIG_BLOCK patch.

Merged with some minor tweaks in 2.6.1-tiny1.

Quoted 2 lines

- Then a new patch that was sort of in my tree to make BINFMT_SCRIPT configurable.

Merged.

Quoted 2 lines

- And another new patch to use cond_syscall instead of explicit dummies when we don't have the AIO code compiled in.

I went back and cleaned up all my syscall changes to use the cond_syscall approach, thanks for pointing it out.

Signature · 1 line
Matt Mackall : http://www.selenic.com : Linux development and consulting