* [patch 1/4] Configure out AIO support [not found] <20080729154520.728594017@free-electrons.com> @ 2008-07-29 15:45 ` Thomas Petazzoni [not found] ` <20080729154747.574989775@free-electrons.com> [not found] ` <20080729154747.872888047@free-electrons.com> 2 siblings, 0 replies; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-29 15:45 UTC (permalink / raw) To: linux-kernel, linux-embedded; +Cc: thomas.petazzoni, bcrl, linux-aio, mpm, akpm [-- Attachment #1: configure-out-aio-support --] [-- Type: text/plain, Size: 4841 bytes --] This patchs adds the CONFIG_AIO option which allows to remove support for asynchronous I/O operations, that are not necessarly used by applications, particularly on embedded devices. As this is a size-reduction option, it depends on CONFIG_EMBEDDED. It allows to save ~7 kilobytes of kernel code/data: text data bss dec hex filename 1115067 119180 217088 1451335 162547 vmlinux 1108025 119048 217088 1444161 160941 vmlinux.new -7042 -132 0 -7174 -1C06 +/- This patch has been originally written by Matt Mackall <mpm@selenic.com>, and is part of the Linux Tiny project. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: bcrl@kvack.org Cc: linux-aio@kvack.org Cc: mpm@selenic.com Cc: akpm@linux-foundation.org --- fs/Makefile | 3 ++- include/linux/aio.h | 9 +++++++++ init/Kconfig | 8 ++++++++ kernel/sys_ni.c | 5 +++++ kernel/sysctl.c | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) Index: linuxdev/fs/Makefile =================================================================== --- linuxdev.orig/fs/Makefile +++ linuxdev/fs/Makefile @@ -8,7 +8,7 @@ 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 aio.o \ + attr.o bad_inode.o file.o filesystems.o namespace.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ pnode.o drop_caches.o splice.o sync.o utimes.o \ stack.o @@ -27,6 +27,7 @@ obj-$(CONFIG_SIGNALFD) += signalfd.o obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o +obj-$(CONFIG_AIO) += aio.o obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o nfsd-$(CONFIG_NFSD) := nfsctl.o Index: linuxdev/include/linux/aio.h =================================================================== --- linuxdev.orig/include/linux/aio.h +++ linuxdev/include/linux/aio.h @@ -204,12 +204,21 @@ /* prototypes */ extern unsigned aio_max_size; +#ifdef CONFIG_AIO extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb); extern int aio_put_req(struct kiocb *iocb); extern void kick_iocb(struct kiocb *iocb); extern int aio_complete(struct kiocb *iocb, long res, long res2); struct mm_struct; extern void exit_aio(struct mm_struct *mm); +#else +static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; } +static inline int aio_put_req(struct kiocb *iocb) { return 0; } +static inline void kick_iocb(struct kiocb *iocb) { } +static inline int aio_complete(struct kiocb *iocb, long res, long res2) { return 0; } +struct mm_struct; +static inline void exit_aio(struct mm_struct *mm) { } +#endif /* CONFIG_AIO */ #define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) Index: linuxdev/init/Kconfig =================================================================== --- linuxdev.orig/init/Kconfig +++ linuxdev/init/Kconfig @@ -724,6 +724,14 @@ option replaces shmem and tmpfs with the much simpler ramfs code, which may be appropriate on small systems without swap. +config AIO + bool "Enable AIO support" if EMBEDDED + default y + help + This option enables POSIX asynchronous I/O which may by used + by some high performance threaded applications. Disabling + this option saves about 7k. + config VM_EVENT_COUNTERS default y bool "Enable VM event counters for /proc/vmstat" if EMBEDDED Index: linuxdev/kernel/sys_ni.c =================================================================== --- linuxdev.orig/kernel/sys_ni.c +++ linuxdev/kernel/sys_ni.c @@ -125,6 +125,11 @@ cond_syscall(sys_vm86); cond_syscall(compat_sys_ipc); cond_syscall(compat_sys_sysctl); +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); /* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read); Index: linuxdev/kernel/sysctl.c =================================================================== --- linuxdev.orig/kernel/sysctl.c +++ linuxdev/kernel/sysctl.c @@ -1290,6 +1290,7 @@ .extra1 = &zero, .extra2 = &two, }, +#ifdef CONFIG_AIO { .procname = "aio-nr", .data = &aio_nr, @@ -1304,6 +1305,7 @@ .mode = 0644, .proc_handler = &proc_doulongvec_minmax, }, +#endif /* CONFIG_AIO */ #ifdef CONFIG_INOTIFY_USER { .ctl_name = FS_INOTIFY, -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: <a href=mailto:"aart@kvack.org">aart@kvack.org</a> ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <20080729154747.574989775@free-electrons.com>]
* Re: [patch 1/4] Configure out AIO support [not found] ` <20080729154747.574989775@free-electrons.com> @ 2008-07-29 16:27 ` Matt Mackall 0 siblings, 0 replies; 31+ messages in thread From: Matt Mackall @ 2008-07-29 16:27 UTC (permalink / raw) To: Thomas Petazzoni; +Cc: linux-kernel, linux-embedded, bcrl, linux-aio, akpm On Tue, 2008-07-29 at 17:45 +0200, Thomas Petazzoni wrote: > plain text document attachment (configure-out-aio-support) > This patchs adds the CONFIG_AIO option which allows to remove support > for asynchronous I/O operations, that are not necessarly used by > applications, particularly on embedded devices. As this is a > size-reduction option, it depends on CONFIG_EMBEDDED. It allows to > save ~7 kilobytes of kernel code/data: > > text data bss dec hex filename > 1115067 119180 217088 1451335 162547 vmlinux > 1108025 119048 217088 1444161 160941 vmlinux.new > -7042 -132 0 -7174 -1C06 +/- > > This patch has been originally written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Cc: bcrl@kvack.org > Cc: linux-aio@kvack.org > Cc: mpm@selenic.com > Cc: akpm@linux-foundation.org These all look good to me, naturally. Signed-off-by: Matt Mackall <mpm@selenic.com> -- Mathematics is the supreme nostalgia of our time. ^ permalink raw reply [flat|nested] 31+ messages in thread
[parent not found: <20080729154747.872888047@free-electrons.com>]
* Re: [patch 2/4] Configure out file locking features [not found] ` <20080729154747.872888047@free-electrons.com> @ 2008-07-29 18:17 ` Matthew Wilcox 2008-07-29 18:57 ` Matt Mackall 2008-07-30 14:27 ` Adrian Bunk 0 siblings, 2 replies; 31+ messages in thread From: Matthew Wilcox @ 2008-07-29 18:17 UTC (permalink / raw) To: Thomas Petazzoni; +Cc: linux-kernel, linux-embedded, linux-fsdevel, mpm, akpm On Tue, Jul 29, 2008 at 05:45:22PM +0200, Thomas Petazzoni wrote: > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > support for advisory locks. With this patch enabled, the flock() > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > and NFS support are disabled. These features are not necessarly needed > on embedded systems. It allows to save ~11 Kb of kernel code and data: > > text data bss dec hex filename > 1125436 118764 212992 1457192 163c28 vmlinux.old > 1114299 118564 212992 1445855 160fdf vmlinux > -11137 -200 0 -11337 -2C49 +/- > > This patch has originally been written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> In principle, I think this is a great idea. > config NFS_FS > tristate "NFS client support" > - depends on INET > + depends on INET && FILE_LOCKING > select LOCKD > select SUNRPC > select NFS_ACL_SUPPORT if NFS_V3_ACL I think this part is a little lazy. It should be possible to support NFS without file locking. I suspect that's really not in-scope for the linux-tiny tree as currently envisaged with the focus on embedded devices that probably don't use NFS anyway. Do we want to care about the situation of a machine with fixed workload, that doesn't need file locking, but does use NFS? -- Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step." ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-29 18:17 ` [patch 2/4] Configure out file locking features Matthew Wilcox @ 2008-07-29 18:57 ` Matt Mackall 2008-07-29 20:00 ` Jamie Lokier 2008-07-30 14:27 ` Adrian Bunk 1 sibling, 1 reply; 31+ messages in thread From: Matt Mackall @ 2008-07-29 18:57 UTC (permalink / raw) To: Matthew Wilcox Cc: Thomas Petazzoni, linux-kernel, linux-embedded, linux-fsdevel, akpm On Tue, 2008-07-29 at 12:17 -0600, Matthew Wilcox wrote: > On Tue, Jul 29, 2008 at 05:45:22PM +0200, Thomas Petazzoni wrote: > > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > > support for advisory locks. With this patch enabled, the flock() > > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > > and NFS support are disabled. These features are not necessarly needed > > on embedded systems. It allows to save ~11 Kb of kernel code and data: > > > > text data bss dec hex filename > > 1125436 118764 212992 1457192 163c28 vmlinux.old > > 1114299 118564 212992 1445855 160fdf vmlinux > > -11137 -200 0 -11337 -2C49 +/- > > > > This patch has originally been written by Matt Mackall > > <mpm@selenic.com>, and is part of the Linux Tiny project. > > > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > > In principle, I think this is a great idea. > > > config NFS_FS > > tristate "NFS client support" > > - depends on INET > > + depends on INET && FILE_LOCKING > > select LOCKD > > select SUNRPC > > select NFS_ACL_SUPPORT if NFS_V3_ACL > > I think this part is a little lazy. It should be possible to support > NFS without file locking. I suspect that's really not in-scope for the > linux-tiny tree as currently envisaged with the focus on embedded > devices that probably don't use NFS anyway. Do we want to care about > the situation of a machine with fixed workload, that doesn't need file > locking, but does use NFS? I would lean towards no, but if someone comes along who cares, they're welcome to try it. This stuff all has to strike a balance between savings and effort/complexity/maintainability, so any time the submitter is too lazy to cover a less common use case, it's probably a good sign they're approaching that tipping point. On the other hand, if you think it's trivial to do a locking-ectomy on NFS, I'd be happy to see it. The typical embedded NFS-based devices are NAS servers and media players and are going to be more concerned about things like page cache balancing. -- Mathematics is the supreme nostalgia of our time. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-29 18:57 ` Matt Mackall @ 2008-07-29 20:00 ` Jamie Lokier 0 siblings, 0 replies; 31+ messages in thread From: Jamie Lokier @ 2008-07-29 20:00 UTC (permalink / raw) To: Matt Mackall Cc: Matthew Wilcox, Thomas Petazzoni, linux-kernel, linux-embedded, linux-fsdevel, akpm Matt Mackall wrote: > The typical embedded NFS-based devices are NAS servers and media players > and are going to be more concerned about things like page cache > balancing. Oh, those. It would be really annoying to buy a home NAS and find it doesn't support NFS locks or SMB oplocks. NASes are vaguely useful for more than one computer in the house at the same time. That said, I bought a big, expensive one, found it far too slow for my needs, send it back for a refund and bought a portable cheap USB disk which had *so* much higher performance. The convenience of serving multiple machines just wasn't worth the lousy performance. -- Jamie ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-29 18:17 ` [patch 2/4] Configure out file locking features Matthew Wilcox 2008-07-29 18:57 ` Matt Mackall @ 2008-07-30 14:27 ` Adrian Bunk 2008-07-30 15:40 ` Thomas Petazzoni 1 sibling, 1 reply; 31+ messages in thread From: Adrian Bunk @ 2008-07-30 14:27 UTC (permalink / raw) To: Matthew Wilcox Cc: Thomas Petazzoni, linux-kernel, linux-embedded, linux-fsdevel, mpm, akpm It seems the emails containing the patches never made it to the vger lists, which makes it a bit hard to comment on them. Thomas, can you try to figure out what went wrong and resend them then? cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-30 14:27 ` Adrian Bunk @ 2008-07-30 15:40 ` Thomas Petazzoni 2008-07-31 6:27 ` Uwe Kleine-König 0 siblings, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-30 15:40 UTC (permalink / raw) To: Adrian Bunk Cc: Matthew Wilcox, linux-kernel, linux-embedded, linux-fsdevel, mpm, akpm [-- Attachment #1: Type: text/plain, Size: 2070 bytes --] Le Wed, 30 Jul 2008 17:27:54 +0300, Adrian Bunk <bunk@kernel.org> a écrit : > It seems the emails containing the patches never made it to the vger > lists, which makes it a bit hard to comment on them. Yes, they didn't make it to the lists, for some reason. Maybe it's because I sent them using "quilt mail --send", which uses my local exim4 mail server, and for some reason, vger doesn't like that kind of e-mails. However, my exim4 is configured to sent the e-mails through by ISP SMTP. From my exim4 mainlog: 2008-07-29 17:47:57 1KNrQS-0007kt-Kg => linux-kernel@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> linux-embedded@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> netdev@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> davem@davemloft.net R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> mpm@selenic.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> akpm@linux-foundation.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> thomas.petazzoni@free-electrons.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> michael@free-electrons.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* 2008-07-29 17:47:57 1KNrQS-0007kt-Kg Completed So from my side, everything seemed to work well. Does anybody has a clue ? > Thomas, can you try to figure out what went wrong and resend them > then? I will send them again through my normal MUA, using quilt mail --mbox. Hopefully it'll work. Sincerly, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-30 15:40 ` Thomas Petazzoni @ 2008-07-31 6:27 ` Uwe Kleine-König 0 siblings, 0 replies; 31+ messages in thread From: Uwe Kleine-König @ 2008-07-31 6:27 UTC (permalink / raw) To: Thomas Petazzoni Cc: Adrian Bunk, Matthew Wilcox, linux-kernel@vger.kernel.org, linux-embedded@vger.kernel.org, linux-fsdevel@vger.kernel.org, mpm@selenic.com, akpm@linux-foundation.org Hello Thomas, Thomas Petazzoni wrote: > Le Wed, 30 Jul 2008 17:27:54 +0300, > Adrian Bunk <bunk@kernel.org> a écrit : > > > It seems the emails containing the patches never made it to the vger > > lists, which makes it a bit hard to comment on them. > > Yes, they didn't make it to the lists, for some reason. Maybe it's > because I sent them using "quilt mail --send", which uses my local > exim4 mail server, and for some reason, vger doesn't like that kind of > e-mails. However, my exim4 is configured to sent the e-mails through by > ISP SMTP. From my exim4 mainlog: > > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg => linux-kernel@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> linux-embedded@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> netdev@vger.kernel.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> davem@davemloft.net R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> mpm@selenic.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> akpm@linux-foundation.org R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> thomas.petazzoni@free-electrons.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg -> michael@free-electrons.com R=smarthost T=remote_smtp_smarthost H=smtp.free.fr [212.27.48.4]* > 2008-07-29 17:47:57 1KNrQS-0007kt-Kg Completed > > So from my side, everything seemed to work well. Does anybody has a > clue ? Don't know if this is the problem, but I had problems getting mails through some time ago, too. For me the problem was that the source address was myusername@mymachine.intranet.$mycompany.$tld and vger.kernel.org didn't want to take these because the host name had no DNS entry. I fixed that by rewriting the From line in outgoing mails on my host. I'm using postfix (from Debian) so I had to add an entry to /etc/postfix/sender_canonical. Best regards Uwe -- Uwe Kleine-König, Software Engineer Digi International GmbH Branch Breisach, Küferstrasse 8, 79206 Breisach, Germany Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* [patch 0/4] [resend] Add configuration options to disable features not needed on embedded devices @ 2008-07-31 9:27 Thomas Petazzoni 2008-07-31 9:27 ` [patch 2/4] Configure out file locking features Thomas Petazzoni 0 siblings, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-31 9:27 UTC (permalink / raw) To: linux-kernel, linux-embedded; +Cc: michael Hi, This is a resend of the small patch list I sent on July, 29th. I'm resending the patches because they didn't make it to vger lists for some setup problem on my side, and because I've been asked by Adrian Bunk to resend them in order to get proper review. However, please note that the patches removing ethtool and IGMP have both been nack-ed by David Miller. The resend of these patches is not an intent to workaround these NACKs in any way: I'm resending because I've been asked to do so. I apologize for the mess, and hope that this time, the mails will reach vger lists. Changes since previous post: * Add Matt Mackall's Signed-off-by on all patches * Make bonding and bridging select ethtool in the ethtool-related patch. Sincerly, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 31+ messages in thread
* [patch 2/4] Configure out file locking features 2008-07-31 9:27 [patch 0/4] [resend] Add configuration options to disable features not needed on embedded devices Thomas Petazzoni @ 2008-07-31 9:27 ` Thomas Petazzoni 2008-07-31 13:53 ` Adrian Bunk 2008-08-02 16:38 ` J. Bruce Fields 0 siblings, 2 replies; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-31 9:27 UTC (permalink / raw) To: linux-kernel, linux-embedded Cc: michael, Thomas Petazzoni, Matt Mackall, matthew, linux-fsdevel, akpm [-- Attachment #1: configure-out-fs-locks-support.patch --] [-- Type: text/plain, Size: 8797 bytes --] This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data: text data bss dec hex filename 1125436 118764 212992 1457192 163c28 vmlinux.old 1114299 118564 212992 1445855 160fdf vmlinux -11137 -200 0 -11337 -2C49 +/- This patch has originally been written by Matt Mackall <mpm@selenic.com>, and is part of the Linux Tiny project. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: matthew@wil.cx Cc: linux-fsdevel@vger.kernel.org Cc: mpm@selenic.com Cc: akpm@linux-foundation.org --- fs/Kconfig | 2 +- fs/Makefile | 3 ++- fs/proc/proc_misc.c | 4 ++++ include/linux/fs.h | 52 +++++++++++++++++++++++++++++++++++++++++++++------- init/Kconfig | 8 ++++++++ kernel/sys_ni.c | 1 + kernel/sysctl.c | 6 +++++- 7 files changed, 66 insertions(+), 10 deletions(-) Index: linuxdev/fs/Kconfig =================================================================== --- linuxdev.orig/fs/Kconfig +++ linuxdev/fs/Kconfig @@ -1559,7 +1559,7 @@ config NFS_FS tristate "NFS client support" - depends on INET + depends on INET && FILE_LOCKING select LOCKD select SUNRPC select NFS_ACL_SUPPORT if NFS_V3_ACL Index: linuxdev/fs/Makefile =================================================================== --- linuxdev.orig/fs/Makefile +++ linuxdev/fs/Makefile @@ -7,7 +7,7 @@ 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 \ + ioctl.o readdir.o select.o fifo.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 \ pnode.o drop_caches.o splice.o sync.o utimes.o \ @@ -28,6 +28,7 @@ obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o obj-$(CONFIG_AIO) += aio.o +obj-$(CONFIG_FILE_LOCKING) += locks.o obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o nfsd-$(CONFIG_NFSD) := nfsctl.o Index: linuxdev/fs/proc/proc_misc.c =================================================================== --- linuxdev.orig/fs/proc/proc_misc.c +++ linuxdev/fs/proc/proc_misc.c @@ -677,6 +677,7 @@ return proc_calc_metrics(page, start, off, count, eof, len); } +#ifdef CONFIG_FILE_LOCKING static int locks_open(struct inode *inode, struct file *filp) { return seq_open(filp, &locks_seq_operations); @@ -688,6 +689,7 @@ .llseek = seq_lseek, .release = seq_release, }; +#endif /* CONFIG_FILE_LOCKING */ static int execdomains_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -881,7 +883,9 @@ #ifdef CONFIG_PRINTK proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); #endif +#ifdef CONFIG_FILE_LOCKING proc_create("locks", 0, NULL, &proc_locks_operations); +#endif proc_create("devices", 0, NULL, &proc_devinfo_operations); proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); #ifdef CONFIG_BLOCK Index: linuxdev/include/linux/fs.h =================================================================== --- linuxdev.orig/include/linux/fs.h +++ linuxdev/include/linux/fs.h @@ -983,6 +983,13 @@ #include <linux/fcntl.h> +extern void send_sigio(struct fown_struct *fown, int fd, int band); + +/* fs/sync.c */ +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, + loff_t endbyte, unsigned int flags); + +#ifdef CONFIG_FILE_LOCKING extern int fcntl_getlk(struct file *, struct flock __user *); extern int fcntl_setlk(unsigned int, struct file *, unsigned int, struct flock __user *); @@ -993,14 +1000,9 @@ struct flock64 __user *); #endif -extern void send_sigio(struct fown_struct *fown, int fd, int band); extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); extern int fcntl_getlease(struct file *filp); -/* fs/sync.c */ -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, - loff_t endbyte, unsigned int flags); - /* fs/locks.c */ extern void locks_init_lock(struct file_lock *); extern void locks_copy_lock(struct file_lock *, struct file_lock *); @@ -1023,6 +1025,33 @@ extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count); extern struct seq_operations locks_seq_operations; +#else /* !CONFIG_FILE_LOCKING */ +#define fcntl_getlk(a, b) (-EINVAL) +#define fcntl_setlk(a, b, c, d) (-EACCES) +#if BITS_PER_LONG == 32 +#define fcntl_getlk64(a, b) (-EINVAL) +#define fcntl_setlk64(a, b, c, d) (-EACCES) +#endif +#define fcntl_setlease(a, b, c) (0) +#define fcntl_getlease(a) (0) +#define locks_init_lock(a) +#define locks_copy_lock(a, b) +#define locks_remove_posix(a, b) +#define locks_remove_flock(a) +#define posix_test_lock(a, b) (0) +#define posix_lock_file(a, b) (-ENOLCK) +#define posix_lock_file_wait(a, b) (-ENOLCK) +#define posix_unblock_lock(a, b) (-ENOENT) +#define vfs_test_lock(a, b) (0) +#define vfs_lock_file(a, b, c, d) (-ENOLCK) +#define vfs_cancel_lock(a, b) (0) +#define flock_lock_file_wait(a, b) (-ENOLCK) +#define __break_lease(a, b) (0) +#define lease_get_mtime(a, b) +#define lock_may_read(a, b, c) (1) +#define lock_may_write(a, b, c) (1) +#endif /* !CONFIG_FILE_LOCKING */ + struct fasync_struct { int magic; @@ -1554,9 +1583,12 @@ /* /sys/fs */ extern struct kobject *fs_kobj; +extern int rw_verify_area(int, struct file *, loff_t *, size_t); + #define FLOCK_VERIFY_READ 1 #define FLOCK_VERIFY_WRITE 2 +#ifdef CONFIG_FILE_LOCKING extern int locks_mandatory_locked(struct inode *); extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); @@ -1587,8 +1619,6 @@ return 0; } -extern int rw_verify_area(int, struct file *, loff_t *, size_t); - static inline int locks_verify_truncate(struct inode *inode, struct file *filp, loff_t size) @@ -1609,6 +1639,14 @@ return __break_lease(inode, mode); return 0; } +#else /* !CONFIG_FILE_LOCKING */ +#define locks_mandatory_locked(a) (0) +#define locks_mandatory_area(a, b, c, d, e) (0) +#define mandatory_lock(a) (0) +#define locks_verify_locked(a) (0) +#define locks_verify_truncate(a, b, c) (0) +#define break_lease(a, b) (0) +#endif /* CONFIG_FILE_LOCKING */ /* fs/open.c */ Index: linuxdev/init/Kconfig =================================================================== --- linuxdev.orig/init/Kconfig +++ linuxdev/init/Kconfig @@ -732,6 +732,14 @@ by some high performance threaded applications. Disabling this option saves about 7k. +config FILE_LOCKING + bool "Enable POSIX file locking API" if EMBEDDED + default y + help + This option enables standard file locking support, required + for filesystems like NFS and for the flock() system + call. Disabling this option saves about 11k. + config VM_EVENT_COUNTERS default y bool "Enable VM event counters for /proc/vmstat" if EMBEDDED Index: linuxdev/kernel/sys_ni.c =================================================================== --- linuxdev.orig/kernel/sys_ni.c +++ linuxdev/kernel/sys_ni.c @@ -130,6 +130,7 @@ cond_syscall(sys_io_submit); cond_syscall(sys_io_cancel); cond_syscall(sys_io_getevents); +cond_syscall(sys_flock); /* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read); Index: linuxdev/kernel/sysctl.c =================================================================== --- linuxdev.orig/kernel/sysctl.c +++ linuxdev/kernel/sysctl.c @@ -97,7 +97,7 @@ static int neg_one = -1; #endif -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) static int two = 2; #endif @@ -1260,6 +1260,7 @@ .extra1 = &minolduid, .extra2 = &maxolduid, }, +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASES, .procname = "leases-enable", @@ -1268,6 +1269,7 @@ .mode = 0644, .proc_handler = &proc_dointvec, }, +#endif #ifdef CONFIG_DNOTIFY { .ctl_name = FS_DIR_NOTIFY, @@ -1279,6 +1281,7 @@ }, #endif #ifdef CONFIG_MMU +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASE_TIME, .procname = "lease-break-time", @@ -1290,6 +1293,7 @@ .extra1 = &zero, .extra2 = &two, }, +#endif /* CONFIG_FILE_LOCKING */ #ifdef CONFIG_AIO { .procname = "aio-nr", -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 9:27 ` [patch 2/4] Configure out file locking features Thomas Petazzoni @ 2008-07-31 13:53 ` Adrian Bunk 2008-07-31 14:20 ` Thomas Petazzoni 2008-08-02 16:38 ` J. Bruce Fields 1 sibling, 1 reply; 31+ messages in thread From: Adrian Bunk @ 2008-07-31 13:53 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 11:27:05AM +0200, Thomas Petazzoni wrote: > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > support for advisory locks. With this patch enabled, the flock() > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > and NFS support are disabled. These features are not necessarly needed > on embedded systems. It allows to save ~11 Kb of kernel code and data: > > text data bss dec hex filename > 1125436 118764 212992 1457192 163c28 vmlinux.old > 1114299 118564 212992 1445855 160fdf vmlinux > -11137 -200 0 -11337 -2C49 +/- > > This patch has originally been written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. >... As I've already said in the past I'm personally not a huge fan of these patches, but if it brings advantages in real-life situations it's hard to argue against it. In which use cases can users safely disable this option, and on what devices have you verified that CONFIG_FILE_LOCKING=n kernels actually work in practice? cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 13:53 ` Adrian Bunk @ 2008-07-31 14:20 ` Thomas Petazzoni 2008-07-31 15:37 ` Adrian Bunk 0 siblings, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-31 14:20 UTC (permalink / raw) To: Adrian Bunk Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Le Thu, 31 Jul 2008 16:53:19 +0300, Adrian Bunk <bunk@kernel.org> a écrit : > As I've already said in the past I'm personally not a huge fan of > these patches, but if it brings advantages in real-life situations > it's hard to argue against it. Yes, I've seen your points about that kind of patches on linux-embedded, and I understand them. I agree that adding dozens and dozens of configuration items for small features doesn't look like something sustainable on the long run. However, the kernel keeps growing and this isn't sustainable either on the long run for *some* embedded users. So, what should we do ? (That's a real question) Some numbers about a bootable x86 allnoconfig kernel with ELF, ext2 and IDE support : text data bss dec hex filename 1110389 119468 217088 1446945 161421 vmlinux.2.6.26 1134606 118840 212992 1466438 166046 vmlinux.2.6.27-rc1 24217 -628 -4096 19493 4C25 +/- (The only configuration change between the two kernels is CONFIG_FW_LOADER n->y, which pulls drivers/base/firmware_class.o, 3k). > In which use cases can users safely disable this option, and on what > devices have you verified that CONFIG_FILE_LOCKING=n kernels actually > work in practice? As long as they don't use NFS (realistic in many production environments) and that the applications do not rely on advisory locking (flock() and fnctl() F_GETLK and F_SETLK), file locking can be disabled. In practice, I only tested a CONFIG_FILE_LOCKING=n kernel with a basic Busybox under Qemu. Sincerly, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 14:20 ` Thomas Petazzoni @ 2008-07-31 15:37 ` Adrian Bunk 2008-07-31 16:26 ` Thomas Petazzoni 0 siblings, 1 reply; 31+ messages in thread From: Adrian Bunk @ 2008-07-31 15:37 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 04:20:07PM +0200, Thomas Petazzoni wrote: > Le Thu, 31 Jul 2008 16:53:19 +0300, > Adrian Bunk <bunk@kernel.org> a écrit : > > > As I've already said in the past I'm personally not a huge fan of > > these patches, but if it brings advantages in real-life situations > > it's hard to argue against it. > > Yes, I've seen your points about that kind of patches on > linux-embedded, and I understand them. I agree that adding dozens and > dozens of configuration items for small features doesn't look like > something sustainable on the long run. However, the kernel keeps > growing and this isn't sustainable either on the long run for *some* > embedded users. So, what should we do ? (That's a real question) I'm not against making the kernel smaller. I'm just not a fan of adding config options for each few kB of code - we have to maintain them and the more complex the configuration becomes the more often it breaks. > Some numbers about a bootable x86 allnoconfig kernel with ELF, ext2 and > IDE support : > > text data bss dec hex filename > 1110389 119468 217088 1446945 161421 vmlinux.2.6.26 > 1134606 118840 212992 1466438 166046 vmlinux.2.6.27-rc1 > 24217 -628 -4096 19493 4C25 +/- What became bigger was most likely not related to the patches you sent. Where and why did the kernel become bigger? > (The only configuration change between the two kernels is > CONFIG_FW_LOADER n->y, which pulls drivers/base/firmware_class.o, 3k). Why did CONFIG_FW_LOADER get enabled? Due to alnoconfig disabling CONFIG_EMBEDDED? > > In which use cases can users safely disable this option, and on what > > devices have you verified that CONFIG_FILE_LOCKING=n kernels actually > > work in practice? > > As long as they don't use NFS (realistic in many production > environments) and that the applications do not rely on advisory locking > (flock() and fnctl() F_GETLK and F_SETLK), file locking can be > disabled. But what does that mean in practice? A user will ask: I'm using $applications with $libraries, can I safely disable this option? And e.g. according to a quick grep through the sources uClibc's updwtmp() seems to cease working without flock(). It costs us maintainance of the option and the #ifdef's and gives users one way more to shoot themselves into the foot in nontrivial to detect ways. > In practice, I only tested a CONFIG_FILE_LOCKING=n kernel > with a basic Busybox under Qemu. > > Sincerly, > > Thomas cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 15:37 ` Adrian Bunk @ 2008-07-31 16:26 ` Thomas Petazzoni 2008-07-31 16:49 ` Adrian Bunk 0 siblings, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-07-31 16:26 UTC (permalink / raw) To: Adrian Bunk Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Le Thu, 31 Jul 2008 18:37:57 +0300, Adrian Bunk <bunk@kernel.org> a écrit : > I'm just not a fan of adding config options for each few kB of code - > we have to maintain them and the more complex the configuration > becomes the more often it breaks. I'm not a fan of these too, but are there other solutions ? > What became bigger was most likely not related to the patches you > sent. No, it is not. > Where and why did the kernel become bigger? It's not up-to-date with 2.6.26 and 2.6.27-rc1, but Bloatwatch <http://www.selenic.com/bloatwatch/>, by Matt Mackall, is here to answer these questions. I haven't made the analysis for 2.6.26->2.6.27-rc1. > Why did CONFIG_FW_LOADER get enabled? > Due to alnoconfig disabling CONFIG_EMBEDDED? I don't know. Haven't made the analysis for now. > A user will ask: > I'm using $applications with $libraries, can I safely disable this > option? Hard to tell in the general case. > And e.g. according to a quick grep through the sources uClibc's > updwtmp() seems to cease working without flock(). Correct. But on many embedded systems, we don't care about logging past user logins. We might even not care about logins at all. > It costs us maintainance of the option and the #ifdef's and gives > users one way more to shoot themselves into the foot in nontrivial to > detect ways. That's correct, and as I said previously, I fully understand the maintainance problem of all these new configuration options. I must admit that I do not really have more objective technical arguments that would help us deciding whether the code size reduction vs. code maintainance choice should be made in one direction or the other. Sincerly, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 16:26 ` Thomas Petazzoni @ 2008-07-31 16:49 ` Adrian Bunk 2008-07-31 16:57 ` David Woodhouse 2008-07-31 17:32 ` Tim Bird 0 siblings, 2 replies; 31+ messages in thread From: Adrian Bunk @ 2008-07-31 16:49 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 06:26:16PM +0200, Thomas Petazzoni wrote: > Le Thu, 31 Jul 2008 18:37:57 +0300, > Adrian Bunk <bunk@kernel.org> a écrit : > > > I'm just not a fan of adding config options for each few kB of code - > > we have to maintain them and the more complex the configuration > > becomes the more often it breaks. > > I'm not a fan of these too, but are there other solutions ? There are many things that can be done to reduce the kernel size or try to minimize the growth of the kernel. E.g. working on --combine -fwhole-program (where David once had preliminary patches for the per-module approach) might be better. > > What became bigger was most likely not related to the patches you > > sent. > > No, it is not. > > > Where and why did the kernel become bigger? > > It's not up-to-date with 2.6.26 and 2.6.27-rc1, but Bloatwatch > <http://www.selenic.com/bloatwatch/>, by Matt Mackall, is here to > answer these questions. I haven't made the analysis for > 2.6.26->2.6.27-rc1. It can only give some hints where to start searching. But it tracks a defconfig, and e.g. the nearly doubled size between 2.6.18 and 2.6.19 is both expected and not a problem for embedded systems. The real work is to figure out in which areas that are relevant for embedded systems the kernel became bigger. > > Why did CONFIG_FW_LOADER get enabled? > > Due to alnoconfig disabling CONFIG_EMBEDDED? > > I don't know. Haven't made the analysis for now. > > > A user will ask: > > I'm using $applications with $libraries, can I safely disable this > > option? > > Hard to tell in the general case. > > > And e.g. according to a quick grep through the sources uClibc's > > updwtmp() seems to cease working without flock(). > > Correct. But on many embedded systems, we don't care about logging past > user logins. We might even not care about logins at all. And for embedded systems with which applications is it 100% safe to disable this option? And don't answer "doesn't use flock()", I want a real-life example of a device where you could guarantee a developer that disabling this option in his product would be safe. > > It costs us maintainance of the option and the #ifdef's and gives > > users one way more to shoot themselves into the foot in nontrivial to > > detect ways. > > That's correct, and as I said previously, I fully understand the > maintainance problem of all these new configuration options. I must > admit that I do not really have more objective technical arguments that > would help us deciding whether the code size reduction vs. code > maintainance choice should be made in one direction or the other. My personal criteron for this patch is still how many real-life systems can safely disable it. > Sincerly, > > Thomas cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 16:49 ` Adrian Bunk @ 2008-07-31 16:57 ` David Woodhouse 2008-07-31 17:32 ` Tim Bird 1 sibling, 0 replies; 31+ messages in thread From: David Woodhouse @ 2008-07-31 16:57 UTC (permalink / raw) To: Adrian Bunk Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, 2008-07-31 at 19:49 +0300, Adrian Bunk wrote: > On Thu, Jul 31, 2008 at 06:26:16PM +0200, Thomas Petazzoni wrote: > > Le Thu, 31 Jul 2008 18:37:57 +0300, > > Adrian Bunk <bunk@kernel.org> a écrit : > > > > > I'm just not a fan of adding config options for each few kB of code - > > > we have to maintain them and the more complex the configuration > > > becomes the more often it breaks. > > > > I'm not a fan of these too, but are there other solutions ? > > There are many things that can be done to reduce the kernel size or try > to minimize the growth of the kernel. > > E.g. working on --combine -fwhole-program (where David once had > preliminary patches for the per-module approach) might be better. Yeah, I'm planning to dig that out again and play with it some time soon. The Kbuild issues were too scary at the time, but I'm less frightened of it these days... Segher has also been looking at it, and reported quite a useful win when he used it to combine arch/$ARCH/mm and mm/, and arch/$ARCH/kernel and kernel/. -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 16:49 ` Adrian Bunk 2008-07-31 16:57 ` David Woodhouse @ 2008-07-31 17:32 ` Tim Bird 2008-07-31 18:12 ` Robert Schwebel 2008-07-31 19:16 ` Adrian Bunk 1 sibling, 2 replies; 31+ messages in thread From: Tim Bird @ 2008-07-31 17:32 UTC (permalink / raw) To: Adrian Bunk Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Adrian Bunk wrote: > And for embedded systems with which applications is it 100% safe to > disable this option? Sony's digital cameras. This option *is* disabled in the kernel for (most) Sony digital cameras. Those digital cameras have the kernel, busybox, a custom C library, and one proprietary application. The application does not use flock() (or AIO, or ethtool or multi-cast) These cameras were heavily tested, and are shipping now. I can't make any guarantees for other developers, but those of us who are careful about our application development would like the option to eliminate completely unused features from the kernel. (And the C library, but that's a different issue.) > And don't answer "doesn't use flock()", I want a real-life example of a > device where you could guarantee a developer that disabling this option > in his product would be safe. I'm not sure why a guarantee is required that other developers use this option safely. Maybe this is a point of disconnect between embedded folks and non-embedded folks. We're accustomed to making tradeoff decisions that only affect our product, and which we take full responsibility for testing. If warnings or support avoidance for the general population using such config options is the issue, I think that David Woodhouse's suggestion that such things could taint the kernel is an interesting idea. Maybe have we could have an "unsafe-config" taint flag? I should add that I am sympathetic with the larger issue you raise about nibbling at the bottom with patches that only address a few KB of the problem, while the size continues to build (to an even greater degree) with each release. My response is that I agree with you on the nibbling bit, but probably just at a different level of KB savings. That is, I presume you'd be OK with something that saved 100K or even 20K, but balk at bit at these patches, which save 10k or less. My threshold is lower (probably down to about 5K, so these are pretty close to the bubble), but even I wouldn't recommend applying anything much below that. We've already started considering to drop some linux-tiny patches that just don't save enough to warrant continued maintenance. -- Tim ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America ============================= ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 17:32 ` Tim Bird @ 2008-07-31 18:12 ` Robert Schwebel 2008-07-31 19:31 ` Adrian Bunk 2008-07-31 19:16 ` Adrian Bunk 1 sibling, 1 reply; 31+ messages in thread From: Robert Schwebel @ 2008-07-31 18:12 UTC (permalink / raw) To: Tim Bird Cc: Adrian Bunk, Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 10:32:20AM -0700, Tim Bird wrote: > > And for embedded systems with which applications is it 100% safe to > > disable this option? > > Sony's digital cameras. We have also several very small automation & measurement devices in the field which run a very dedicated more or less single application which can be carefully audited. In the OSADL safety working group, people are discussing about Linux for safety critical applications. If we want to achieve such scenarios, stripped-down systems are an absolute must. Although increasing processor power even in embedded applications lead to more and more standard-line kernels plus normal userspace components (i.e. glibc instead of uclibc), there are still applications where the final product consists only of the kernel plus the app, whereas during development time, the system has a full-blown configuration. rsc -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Handelsregister: Amtsgericht Hildesheim, HRA 2686 Hannoversche Str. 2, 31134 Hildesheim, Germany Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9 ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 18:12 ` Robert Schwebel @ 2008-07-31 19:31 ` Adrian Bunk 2008-08-01 7:28 ` Robert Schwebel 0 siblings, 1 reply; 31+ messages in thread From: Adrian Bunk @ 2008-07-31 19:31 UTC (permalink / raw) To: Robert Schwebel Cc: Tim Bird, Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 08:12:14PM +0200, Robert Schwebel wrote: > On Thu, Jul 31, 2008 at 10:32:20AM -0700, Tim Bird wrote: > > > And for embedded systems with which applications is it 100% safe to > > > disable this option? > > > > Sony's digital cameras. > > We have also several very small automation & measurement devices in the > field which run a very dedicated more or less single application which > can be carefully audited. > > In the OSADL safety working group, people are discussing about Linux for > safety critical applications. If we want to achieve such scenarios, > stripped-down systems are an absolute must. >... My first reaction is that as soon as you enable CONFIG_EMBEDDED you can easily enter codepaths noone else has used for a while and that got unnoticed broken. > rsc cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 19:31 ` Adrian Bunk @ 2008-08-01 7:28 ` Robert Schwebel 0 siblings, 0 replies; 31+ messages in thread From: Robert Schwebel @ 2008-08-01 7:28 UTC (permalink / raw) To: Adrian Bunk Cc: Robert Schwebel, Tim Bird, Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 10:31:26PM +0300, Adrian Bunk wrote: > > In the OSADL safety working group, people are discussing about Linux > > for safety critical applications. If we want to achieve such > > scenarios, stripped-down systems are an absolute must. > >... > > My first reaction is that as soon as you enable CONFIG_EMBEDDED you > can easily enter codepaths noone else has used for a while and that > got unnoticed broken. That may be no problem; if we ever come to a safety kernel, it will have to be audited and carefully tested anyway. rsc -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Handelsregister: Amtsgericht Hildesheim, HRA 2686 Hannoversche Str. 2, 31134 Hildesheim, Germany Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9 ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 17:32 ` Tim Bird 2008-07-31 18:12 ` Robert Schwebel @ 2008-07-31 19:16 ` Adrian Bunk 2008-07-31 20:37 ` Tim Bird 1 sibling, 1 reply; 31+ messages in thread From: Adrian Bunk @ 2008-07-31 19:16 UTC (permalink / raw) To: Tim Bird Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 10:32:20AM -0700, Tim Bird wrote: > Adrian Bunk wrote: > > And for embedded systems with which applications is it 100% safe to > > disable this option? > > Sony's digital cameras. > > This option *is* disabled in the kernel for (most) Sony digital cameras. > Those digital cameras have the kernel, busybox, a custom C library, > and one proprietary application. The application does not use > flock() (or AIO, or ethtool or multi-cast) > > These cameras were heavily tested, and are shipping now. I can't > make any guarantees for other developers, but those of us who > are careful about our application development would like the option > to eliminate completely unused features from the kernel. (And > the C library, but that's a different issue.) > > > And don't answer "doesn't use flock()", I want a real-life example of a > > device where you could guarantee a developer that disabling this option > > in his product would be safe. > > I'm not sure why a guarantee is required that other developers > use this option safely. Maybe this is a point of disconnect between > embedded folks and non-embedded folks. We're accustomed to making > tradeoff decisions that only affect our product, and which > we take full responsibility for testing. Thanks. That's quite different from Thomas' "In practice, I only tested a CONFIG_FILE_LOCKING=n kernel with a basic Busybox under Qemu." and addresses my concerns. In case I didn't express myself clearly: I was not interested in guarantees for random developers but in seeing some reasonable use case for a real device. > If warnings or support avoidance for the general population using > such config options is the issue, I think that David Woodhouse's > suggestion that such things could taint the kernel is an interesting > idea. Maybe have we could have an "unsafe-config" taint flag? A CONFIG_EMBEDDED=y flag? > I should add that I am sympathetic with the larger issue you raise > about nibbling at the bottom with patches that only address a > few KB of the problem, while the size continues to build (to an > even greater degree) with each release. My response is that I agree > with you on the nibbling bit, but probably just at a different > level of KB savings. > > That is, I presume you'd be OK with something that saved 100K or > even 20K, but balk at bit at these patches, which save 10k or less. > My threshold is lower (probably down to about 5K, so these are > pretty close to the bubble), but even I wouldn't recommend > applying anything much below that. We've already started > considering to drop some linux-tiny patches that just don't save > enough to warrant continued maintenance. It's not only about limits, I also have a general dislike for the "add more config options" approach. I get your point why it brings advantages in some cases, but if you are looking for a cheerleader it won't be me. ;-) > -- Tim cu Adrian -- "Is there not promise of rain?" Ling Tan asked suddenly out of the darkness. There had been need of rain for many days. "Only a promise," Lao Er said. Pearl S. Buck - Dragon Seed ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 19:16 ` Adrian Bunk @ 2008-07-31 20:37 ` Tim Bird 0 siblings, 0 replies; 31+ messages in thread From: Tim Bird @ 2008-07-31 20:37 UTC (permalink / raw) To: Adrian Bunk Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Adrian Bunk wrote: > On Thu, Jul 31, 2008 at 10:32:20AM -0700, Tim Bird wrote: >> If warnings or support avoidance for the general population using >> such config options is the issue, I think that David Woodhouse's >> suggestion that such things could taint the kernel is an interesting >> idea. Maybe have we could have an "unsafe-config" taint flag? > > A CONFIG_EMBEDDED=y flag? If this is sufficient, it works for me! > It's not only about limits, I also have a general dislike for the > "add more config options" approach. > > I get your point why it brings advantages in some cases, but if you are > looking for a cheerleader it won't be me. ;-) Understood. I promise not to send you any pom-poms. ;-) -- Tim ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America ============================= ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-07-31 9:27 ` [patch 2/4] Configure out file locking features Thomas Petazzoni 2008-07-31 13:53 ` Adrian Bunk @ 2008-08-02 16:38 ` J. Bruce Fields 2008-08-04 13:52 ` Thomas Petazzoni 1 sibling, 1 reply; 31+ messages in thread From: J. Bruce Fields @ 2008-08-02 16:38 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Thu, Jul 31, 2008 at 11:27:05AM +0200, Thomas Petazzoni wrote: > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > support for advisory locks. With this patch enabled, the flock() > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > and NFS support are disabled. These features are not necessarly needed > on embedded systems. It allows to save ~11 Kb of kernel code and data: Out of curiosity, why does the nfs client need disabling, but not nfsd, gfs2, fuse, etc.? --b. > > text data bss dec hex filename > 1125436 118764 212992 1457192 163c28 vmlinux.old > 1114299 118564 212992 1445855 160fdf vmlinux > -11137 -200 0 -11337 -2C49 +/- > > This patch has originally been written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Signed-off-by: Matt Mackall <mpm@selenic.com> > Cc: matthew@wil.cx > Cc: linux-fsdevel@vger.kernel.org > Cc: mpm@selenic.com > Cc: akpm@linux-foundation.org > > --- > fs/Kconfig | 2 +- > fs/Makefile | 3 ++- > fs/proc/proc_misc.c | 4 ++++ > include/linux/fs.h | 52 +++++++++++++++++++++++++++++++++++++++++++++------- > init/Kconfig | 8 ++++++++ > kernel/sys_ni.c | 1 + > kernel/sysctl.c | 6 +++++- > 7 files changed, 66 insertions(+), 10 deletions(-) > > Index: linuxdev/fs/Kconfig > =================================================================== > --- linuxdev.orig/fs/Kconfig > +++ linuxdev/fs/Kconfig > @@ -1559,7 +1559,7 @@ > > config NFS_FS > tristate "NFS client support" > - depends on INET > + depends on INET && FILE_LOCKING > select LOCKD > select SUNRPC > select NFS_ACL_SUPPORT if NFS_V3_ACL > Index: linuxdev/fs/Makefile > =================================================================== > --- linuxdev.orig/fs/Makefile > +++ linuxdev/fs/Makefile > @@ -7,7 +7,7 @@ > > 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 \ > + ioctl.o readdir.o select.o fifo.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 \ > pnode.o drop_caches.o splice.o sync.o utimes.o \ > @@ -28,6 +28,7 @@ > obj-$(CONFIG_TIMERFD) += timerfd.o > obj-$(CONFIG_EVENTFD) += eventfd.o > obj-$(CONFIG_AIO) += aio.o > +obj-$(CONFIG_FILE_LOCKING) += locks.o > obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o > > nfsd-$(CONFIG_NFSD) := nfsctl.o > Index: linuxdev/fs/proc/proc_misc.c > =================================================================== > --- linuxdev.orig/fs/proc/proc_misc.c > +++ linuxdev/fs/proc/proc_misc.c > @@ -677,6 +677,7 @@ > return proc_calc_metrics(page, start, off, count, eof, len); > } > > +#ifdef CONFIG_FILE_LOCKING > static int locks_open(struct inode *inode, struct file *filp) > { > return seq_open(filp, &locks_seq_operations); > @@ -688,6 +689,7 @@ > .llseek = seq_lseek, > .release = seq_release, > }; > +#endif /* CONFIG_FILE_LOCKING */ > > static int execdomains_read_proc(char *page, char **start, off_t off, > int count, int *eof, void *data) > @@ -881,7 +883,9 @@ > #ifdef CONFIG_PRINTK > proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); > #endif > +#ifdef CONFIG_FILE_LOCKING > proc_create("locks", 0, NULL, &proc_locks_operations); > +#endif > proc_create("devices", 0, NULL, &proc_devinfo_operations); > proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); > #ifdef CONFIG_BLOCK > Index: linuxdev/include/linux/fs.h > =================================================================== > --- linuxdev.orig/include/linux/fs.h > +++ linuxdev/include/linux/fs.h > @@ -983,6 +983,13 @@ > > #include <linux/fcntl.h> > > +extern void send_sigio(struct fown_struct *fown, int fd, int band); > + > +/* fs/sync.c */ > +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > + loff_t endbyte, unsigned int flags); > + > +#ifdef CONFIG_FILE_LOCKING > extern int fcntl_getlk(struct file *, struct flock __user *); > extern int fcntl_setlk(unsigned int, struct file *, unsigned int, > struct flock __user *); > @@ -993,14 +1000,9 @@ > struct flock64 __user *); > #endif > > -extern void send_sigio(struct fown_struct *fown, int fd, int band); > extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); > extern int fcntl_getlease(struct file *filp); > > -/* fs/sync.c */ > -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > - loff_t endbyte, unsigned int flags); > - > /* fs/locks.c */ > extern void locks_init_lock(struct file_lock *); > extern void locks_copy_lock(struct file_lock *, struct file_lock *); > @@ -1023,6 +1025,33 @@ > extern int lock_may_read(struct inode *, loff_t start, unsigned long count); > extern int lock_may_write(struct inode *, loff_t start, unsigned long count); > extern struct seq_operations locks_seq_operations; > +#else /* !CONFIG_FILE_LOCKING */ > +#define fcntl_getlk(a, b) (-EINVAL) > +#define fcntl_setlk(a, b, c, d) (-EACCES) > +#if BITS_PER_LONG == 32 > +#define fcntl_getlk64(a, b) (-EINVAL) > +#define fcntl_setlk64(a, b, c, d) (-EACCES) > +#endif > +#define fcntl_setlease(a, b, c) (0) > +#define fcntl_getlease(a) (0) > +#define locks_init_lock(a) > +#define locks_copy_lock(a, b) > +#define locks_remove_posix(a, b) > +#define locks_remove_flock(a) > +#define posix_test_lock(a, b) (0) > +#define posix_lock_file(a, b) (-ENOLCK) > +#define posix_lock_file_wait(a, b) (-ENOLCK) > +#define posix_unblock_lock(a, b) (-ENOENT) > +#define vfs_test_lock(a, b) (0) > +#define vfs_lock_file(a, b, c, d) (-ENOLCK) > +#define vfs_cancel_lock(a, b) (0) > +#define flock_lock_file_wait(a, b) (-ENOLCK) > +#define __break_lease(a, b) (0) > +#define lease_get_mtime(a, b) > +#define lock_may_read(a, b, c) (1) > +#define lock_may_write(a, b, c) (1) > +#endif /* !CONFIG_FILE_LOCKING */ > + > > struct fasync_struct { > int magic; > @@ -1554,9 +1583,12 @@ > /* /sys/fs */ > extern struct kobject *fs_kobj; > > +extern int rw_verify_area(int, struct file *, loff_t *, size_t); > + > #define FLOCK_VERIFY_READ 1 > #define FLOCK_VERIFY_WRITE 2 > > +#ifdef CONFIG_FILE_LOCKING > extern int locks_mandatory_locked(struct inode *); > extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); > > @@ -1587,8 +1619,6 @@ > return 0; > } > > -extern int rw_verify_area(int, struct file *, loff_t *, size_t); > - > static inline int locks_verify_truncate(struct inode *inode, > struct file *filp, > loff_t size) > @@ -1609,6 +1639,14 @@ > return __break_lease(inode, mode); > return 0; > } > +#else /* !CONFIG_FILE_LOCKING */ > +#define locks_mandatory_locked(a) (0) > +#define locks_mandatory_area(a, b, c, d, e) (0) > +#define mandatory_lock(a) (0) > +#define locks_verify_locked(a) (0) > +#define locks_verify_truncate(a, b, c) (0) > +#define break_lease(a, b) (0) > +#endif /* CONFIG_FILE_LOCKING */ > > /* fs/open.c */ > > Index: linuxdev/init/Kconfig > =================================================================== > --- linuxdev.orig/init/Kconfig > +++ linuxdev/init/Kconfig > @@ -732,6 +732,14 @@ > by some high performance threaded applications. Disabling > this option saves about 7k. > > +config FILE_LOCKING > + bool "Enable POSIX file locking API" if EMBEDDED > + default y > + help > + This option enables standard file locking support, required > + for filesystems like NFS and for the flock() system > + call. Disabling this option saves about 11k. > + > config VM_EVENT_COUNTERS > default y > bool "Enable VM event counters for /proc/vmstat" if EMBEDDED > Index: linuxdev/kernel/sys_ni.c > =================================================================== > --- linuxdev.orig/kernel/sys_ni.c > +++ linuxdev/kernel/sys_ni.c > @@ -130,6 +130,7 @@ > cond_syscall(sys_io_submit); > cond_syscall(sys_io_cancel); > cond_syscall(sys_io_getevents); > +cond_syscall(sys_flock); > > /* arch-specific weak syscall entries */ > cond_syscall(sys_pciconfig_read); > Index: linuxdev/kernel/sysctl.c > =================================================================== > --- linuxdev.orig/kernel/sysctl.c > +++ linuxdev/kernel/sysctl.c > @@ -97,7 +97,7 @@ > static int neg_one = -1; > #endif > > -#ifdef CONFIG_MMU > +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) > static int two = 2; > #endif > > @@ -1260,6 +1260,7 @@ > .extra1 = &minolduid, > .extra2 = &maxolduid, > }, > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASES, > .procname = "leases-enable", > @@ -1268,6 +1269,7 @@ > .mode = 0644, > .proc_handler = &proc_dointvec, > }, > +#endif > #ifdef CONFIG_DNOTIFY > { > .ctl_name = FS_DIR_NOTIFY, > @@ -1279,6 +1281,7 @@ > }, > #endif > #ifdef CONFIG_MMU > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASE_TIME, > .procname = "lease-break-time", > @@ -1290,6 +1293,7 @@ > .extra1 = &zero, > .extra2 = &two, > }, > +#endif /* CONFIG_FILE_LOCKING */ > #ifdef CONFIG_AIO > { > .procname = "aio-nr", > > -- > Thomas Petazzoni, Free Electrons > Kernel, drivers and embedded Linux development, > consulting, training and support. > http://free-electrons.com > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-02 16:38 ` J. Bruce Fields @ 2008-08-04 13:52 ` Thomas Petazzoni 2008-08-04 18:16 ` J. Bruce Fields 0 siblings, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-08-04 13:52 UTC (permalink / raw) To: J. Bruce Fields Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Le Sat, 2 Aug 2008 12:38:48 -0400, "J. Bruce Fields" <bfields@fieldses.org> a écrit : > Out of curiosity, why does the nfs client need disabling, but not > nfsd, gfs2, fuse, etc.? Then also need disabling. Updated patch below. Thanks! Thomas --- Configure out file locking features This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data: text data bss dec hex filename 1125436 118764 212992 1457192 163c28 vmlinux.old 1114299 118564 212992 1445855 160fdf vmlinux -11137 -200 0 -11337 -2C49 +/- This patch has originally been written by Matt Mackall <mpm@selenic.com>, and is part of the Linux Tiny project. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: matthew@wil.cx Cc: linux-fsdevel@vger.kernel.org Cc: mpm@selenic.com Cc: akpm@linux-foundation.org --- fs/Kconfig | 15 ++++++++++++++- fs/Makefile | 3 ++- fs/dlm/Kconfig | 1 + fs/gfs2/Kconfig | 1 + fs/proc/proc_misc.c | 4 ++++ include/linux/fs.h | 52 +++++++++++++++++++++++++++++++++++++++++++++------- kernel/sys_ni.c | 1 + kernel/sysctl.c | 6 +++++- 8 files changed, 73 insertions(+), 10 deletions(-) Index: linuxdev/fs/Kconfig =================================================================== --- linuxdev.orig/fs/Kconfig +++ linuxdev/fs/Kconfig @@ -427,12 +427,21 @@ bool default n +config FILE_LOCKING + bool "Enable POSIX file locking API" if EMBEDDED + default y + help + This option enables standard file locking support, required + for filesystems like NFS and for the flock() system + call. Disabling this option saves about 11k. + source "fs/xfs/Kconfig" source "fs/gfs2/Kconfig" config OCFS2_FS tristate "OCFS2 file system support" depends on NET && SYSFS + depends on FILE_LOCKING select CONFIGFS_FS select JBD select CRC32 @@ -642,6 +651,7 @@ config FUSE_FS tristate "Filesystem in Userspace support" + depends on FILE_LOCKING help With FUSE it is possible to implement a fully functional filesystem in a userspace program. @@ -1567,7 +1577,7 @@ config NFS_FS tristate "NFS client support" - depends on INET + depends on INET && FILE_LOCKING select LOCKD select SUNRPC select NFS_ACL_SUPPORT if NFS_V3_ACL @@ -1735,6 +1745,7 @@ config LOCKD tristate + depends on FILE_LOCKING config LOCKD_V4 bool @@ -1870,6 +1881,7 @@ config CIFS tristate "CIFS support (advanced network filesystem, SMBFS successor)" depends on INET + depends on FILE_LOCKING select NLS help This is the client VFS module for the Common Internet File System @@ -2059,6 +2071,7 @@ config AFS_FS tristate "Andrew File System support (AFS) (EXPERIMENTAL)" depends on INET && EXPERIMENTAL + depends on FILE_LOCKING select AF_RXRPC help If you say Y here, you will get an experimental Andrew File System Index: linuxdev/fs/Makefile =================================================================== --- linuxdev.orig/fs/Makefile +++ linuxdev/fs/Makefile @@ -7,7 +7,7 @@ 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 \ + ioctl.o readdir.o select.o fifo.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 \ pnode.o drop_caches.o splice.o sync.o utimes.o \ @@ -28,6 +28,7 @@ obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o obj-$(CONFIG_AIO) += aio.o +obj-$(CONFIG_FILE_LOCKING) += locks.o obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o nfsd-$(CONFIG_NFSD) := nfsctl.o Index: linuxdev/fs/dlm/Kconfig =================================================================== --- linuxdev.orig/fs/dlm/Kconfig +++ linuxdev/fs/dlm/Kconfig @@ -2,6 +2,7 @@ tristate "Distributed Lock Manager (DLM)" depends on EXPERIMENTAL && INET depends on SYSFS && (IPV6 || IPV6=n) + depends on FILE_LOCKING select CONFIGFS_FS select IP_SCTP help Index: linuxdev/fs/gfs2/Kconfig =================================================================== --- linuxdev.orig/fs/gfs2/Kconfig +++ linuxdev/fs/gfs2/Kconfig @@ -1,6 +1,7 @@ config GFS2_FS tristate "GFS2 file system support" depends on EXPERIMENTAL && (64BIT || (LSF && LBD)) + depends on FILE_LOCKING select FS_POSIX_ACL select CRC32 help Index: linuxdev/fs/proc/proc_misc.c =================================================================== --- linuxdev.orig/fs/proc/proc_misc.c +++ linuxdev/fs/proc/proc_misc.c @@ -677,6 +677,7 @@ return proc_calc_metrics(page, start, off, count, eof, len); } +#ifdef CONFIG_FILE_LOCKING static int locks_open(struct inode *inode, struct file *filp) { return seq_open(filp, &locks_seq_operations); @@ -688,6 +689,7 @@ .llseek = seq_lseek, .release = seq_release, }; +#endif /* CONFIG_FILE_LOCKING */ static int execdomains_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -881,7 +883,9 @@ #ifdef CONFIG_PRINTK proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); #endif +#ifdef CONFIG_FILE_LOCKING proc_create("locks", 0, NULL, &proc_locks_operations); +#endif proc_create("devices", 0, NULL, &proc_devinfo_operations); proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); #ifdef CONFIG_BLOCK Index: linuxdev/include/linux/fs.h =================================================================== --- linuxdev.orig/include/linux/fs.h +++ linuxdev/include/linux/fs.h @@ -983,6 +983,13 @@ #include <linux/fcntl.h> +extern void send_sigio(struct fown_struct *fown, int fd, int band); + +/* fs/sync.c */ +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, + loff_t endbyte, unsigned int flags); + +#ifdef CONFIG_FILE_LOCKING extern int fcntl_getlk(struct file *, struct flock __user *); extern int fcntl_setlk(unsigned int, struct file *, unsigned int, struct flock __user *); @@ -993,14 +1000,9 @@ struct flock64 __user *); #endif -extern void send_sigio(struct fown_struct *fown, int fd, int band); extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); extern int fcntl_getlease(struct file *filp); -/* fs/sync.c */ -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, - loff_t endbyte, unsigned int flags); - /* fs/locks.c */ extern void locks_init_lock(struct file_lock *); extern void locks_copy_lock(struct file_lock *, struct file_lock *); @@ -1023,6 +1025,33 @@ extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count); extern struct seq_operations locks_seq_operations; +#else /* !CONFIG_FILE_LOCKING */ +#define fcntl_getlk(a, b) (-EINVAL) +#define fcntl_setlk(a, b, c, d) (-EACCES) +#if BITS_PER_LONG == 32 +#define fcntl_getlk64(a, b) (-EINVAL) +#define fcntl_setlk64(a, b, c, d) (-EACCES) +#endif +#define fcntl_setlease(a, b, c) (0) +#define fcntl_getlease(a) (0) +#define locks_init_lock(a) +#define locks_copy_lock(a, b) +#define locks_remove_posix(a, b) +#define locks_remove_flock(a) +#define posix_test_lock(a, b) (0) +#define posix_lock_file(a, b) (-ENOLCK) +#define posix_lock_file_wait(a, b) (-ENOLCK) +#define posix_unblock_lock(a, b) (-ENOENT) +#define vfs_test_lock(a, b) (0) +#define vfs_lock_file(a, b, c, d) (-ENOLCK) +#define vfs_cancel_lock(a, b) (0) +#define flock_lock_file_wait(a, b) (-ENOLCK) +#define __break_lease(a, b) (0) +#define lease_get_mtime(a, b) +#define lock_may_read(a, b, c) (1) +#define lock_may_write(a, b, c) (1) +#endif /* !CONFIG_FILE_LOCKING */ + struct fasync_struct { int magic; @@ -1554,9 +1583,12 @@ /* /sys/fs */ extern struct kobject *fs_kobj; +extern int rw_verify_area(int, struct file *, loff_t *, size_t); + #define FLOCK_VERIFY_READ 1 #define FLOCK_VERIFY_WRITE 2 +#ifdef CONFIG_FILE_LOCKING extern int locks_mandatory_locked(struct inode *); extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); @@ -1587,8 +1619,6 @@ return 0; } -extern int rw_verify_area(int, struct file *, loff_t *, size_t); - static inline int locks_verify_truncate(struct inode *inode, struct file *filp, loff_t size) @@ -1609,6 +1639,14 @@ return __break_lease(inode, mode); return 0; } +#else /* !CONFIG_FILE_LOCKING */ +#define locks_mandatory_locked(a) (0) +#define locks_mandatory_area(a, b, c, d, e) (0) +#define mandatory_lock(a) (0) +#define locks_verify_locked(a) (0) +#define locks_verify_truncate(a, b, c) (0) +#define break_lease(a, b) (0) +#endif /* CONFIG_FILE_LOCKING */ /* fs/open.c */ Index: linuxdev/kernel/sys_ni.c =================================================================== --- linuxdev.orig/kernel/sys_ni.c +++ linuxdev/kernel/sys_ni.c @@ -130,6 +130,7 @@ cond_syscall(sys_io_submit); cond_syscall(sys_io_cancel); cond_syscall(sys_io_getevents); +cond_syscall(sys_flock); /* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read); Index: linuxdev/kernel/sysctl.c =================================================================== --- linuxdev.orig/kernel/sysctl.c +++ linuxdev/kernel/sysctl.c @@ -97,7 +97,7 @@ static int neg_one = -1; #endif -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) static int two = 2; #endif @@ -1260,6 +1260,7 @@ .extra1 = &minolduid, .extra2 = &maxolduid, }, +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASES, .procname = "leases-enable", @@ -1268,6 +1269,7 @@ .mode = 0644, .proc_handler = &proc_dointvec, }, +#endif #ifdef CONFIG_DNOTIFY { .ctl_name = FS_DIR_NOTIFY, @@ -1279,6 +1281,7 @@ }, #endif #ifdef CONFIG_MMU +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASE_TIME, .procname = "lease-break-time", @@ -1290,6 +1293,7 @@ .extra1 = &zero, .extra2 = &two, }, +#endif /* CONFIG_FILE_LOCKING */ #ifdef CONFIG_AIO { .procname = "aio-nr", -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 13:52 ` Thomas Petazzoni @ 2008-08-04 18:16 ` J. Bruce Fields 2008-08-04 18:24 ` Tim Bird 2008-08-06 13:12 ` Thomas Petazzoni 0 siblings, 2 replies; 31+ messages in thread From: J. Bruce Fields @ 2008-08-04 18:16 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: > Le Sat, 2 Aug 2008 12:38:48 -0400, > "J. Bruce Fields" <bfields@fieldses.org> a écrit : > > > Out of curiosity, why does the nfs client need disabling, but not > > nfsd, gfs2, fuse, etc.? > > Then also need disabling. OK by me, but again, why exactly? Since you're replacing the locking calls they used by stubs that just return errors, in theory nfs, nfsd, gfs2, and the rest should still compile and run, just without locking support, right? I don't have a strong opinion either way, just curious. --b. > Updated patch below. > > Thanks! > > Thomas > > --- > > Configure out file locking features > > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > support for advisory locks. With this patch enabled, the flock() > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > and NFS support are disabled. These features are not necessarly needed > on embedded systems. It allows to save ~11 Kb of kernel code and data: > > text data bss dec hex filename > 1125436 118764 212992 1457192 163c28 vmlinux.old > 1114299 118564 212992 1445855 160fdf vmlinux > -11137 -200 0 -11337 -2C49 +/- > > This patch has originally been written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Signed-off-by: Matt Mackall <mpm@selenic.com> > Cc: matthew@wil.cx > Cc: linux-fsdevel@vger.kernel.org > Cc: mpm@selenic.com > Cc: akpm@linux-foundation.org > > --- > fs/Kconfig | 15 ++++++++++++++- > fs/Makefile | 3 ++- > fs/dlm/Kconfig | 1 + > fs/gfs2/Kconfig | 1 + > fs/proc/proc_misc.c | 4 ++++ > include/linux/fs.h | 52 +++++++++++++++++++++++++++++++++++++++++++++------- > kernel/sys_ni.c | 1 + > kernel/sysctl.c | 6 +++++- > 8 files changed, 73 insertions(+), 10 deletions(-) > > Index: linuxdev/fs/Kconfig > =================================================================== > --- linuxdev.orig/fs/Kconfig > +++ linuxdev/fs/Kconfig > @@ -427,12 +427,21 @@ > bool > default n > > +config FILE_LOCKING > + bool "Enable POSIX file locking API" if EMBEDDED > + default y > + help > + This option enables standard file locking support, required > + for filesystems like NFS and for the flock() system > + call. Disabling this option saves about 11k. > + > source "fs/xfs/Kconfig" > source "fs/gfs2/Kconfig" > > config OCFS2_FS > tristate "OCFS2 file system support" > depends on NET && SYSFS > + depends on FILE_LOCKING > select CONFIGFS_FS > select JBD > select CRC32 > @@ -642,6 +651,7 @@ > > config FUSE_FS > tristate "Filesystem in Userspace support" > + depends on FILE_LOCKING > help > With FUSE it is possible to implement a fully functional filesystem > in a userspace program. > @@ -1567,7 +1577,7 @@ > > config NFS_FS > tristate "NFS client support" > - depends on INET > + depends on INET && FILE_LOCKING > select LOCKD > select SUNRPC > select NFS_ACL_SUPPORT if NFS_V3_ACL > @@ -1735,6 +1745,7 @@ > > config LOCKD > tristate > + depends on FILE_LOCKING > > config LOCKD_V4 > bool > @@ -1870,6 +1881,7 @@ > config CIFS > tristate "CIFS support (advanced network filesystem, SMBFS successor)" > depends on INET > + depends on FILE_LOCKING > select NLS > help > This is the client VFS module for the Common Internet File System > @@ -2059,6 +2071,7 @@ > config AFS_FS > tristate "Andrew File System support (AFS) (EXPERIMENTAL)" > depends on INET && EXPERIMENTAL > + depends on FILE_LOCKING > select AF_RXRPC > help > If you say Y here, you will get an experimental Andrew File System > Index: linuxdev/fs/Makefile > =================================================================== > --- linuxdev.orig/fs/Makefile > +++ linuxdev/fs/Makefile > @@ -7,7 +7,7 @@ > > 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 \ > + ioctl.o readdir.o select.o fifo.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 \ > pnode.o drop_caches.o splice.o sync.o utimes.o \ > @@ -28,6 +28,7 @@ > obj-$(CONFIG_TIMERFD) += timerfd.o > obj-$(CONFIG_EVENTFD) += eventfd.o > obj-$(CONFIG_AIO) += aio.o > +obj-$(CONFIG_FILE_LOCKING) += locks.o > obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o > > nfsd-$(CONFIG_NFSD) := nfsctl.o > Index: linuxdev/fs/dlm/Kconfig > =================================================================== > --- linuxdev.orig/fs/dlm/Kconfig > +++ linuxdev/fs/dlm/Kconfig > @@ -2,6 +2,7 @@ > tristate "Distributed Lock Manager (DLM)" > depends on EXPERIMENTAL && INET > depends on SYSFS && (IPV6 || IPV6=n) > + depends on FILE_LOCKING > select CONFIGFS_FS > select IP_SCTP > help > Index: linuxdev/fs/gfs2/Kconfig > =================================================================== > --- linuxdev.orig/fs/gfs2/Kconfig > +++ linuxdev/fs/gfs2/Kconfig > @@ -1,6 +1,7 @@ > config GFS2_FS > tristate "GFS2 file system support" > depends on EXPERIMENTAL && (64BIT || (LSF && LBD)) > + depends on FILE_LOCKING > select FS_POSIX_ACL > select CRC32 > help > Index: linuxdev/fs/proc/proc_misc.c > =================================================================== > --- linuxdev.orig/fs/proc/proc_misc.c > +++ linuxdev/fs/proc/proc_misc.c > @@ -677,6 +677,7 @@ > return proc_calc_metrics(page, start, off, count, eof, len); > } > > +#ifdef CONFIG_FILE_LOCKING > static int locks_open(struct inode *inode, struct file *filp) > { > return seq_open(filp, &locks_seq_operations); > @@ -688,6 +689,7 @@ > .llseek = seq_lseek, > .release = seq_release, > }; > +#endif /* CONFIG_FILE_LOCKING */ > > static int execdomains_read_proc(char *page, char **start, off_t off, > int count, int *eof, void *data) > @@ -881,7 +883,9 @@ > #ifdef CONFIG_PRINTK > proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); > #endif > +#ifdef CONFIG_FILE_LOCKING > proc_create("locks", 0, NULL, &proc_locks_operations); > +#endif > proc_create("devices", 0, NULL, &proc_devinfo_operations); > proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); > #ifdef CONFIG_BLOCK > Index: linuxdev/include/linux/fs.h > =================================================================== > --- linuxdev.orig/include/linux/fs.h > +++ linuxdev/include/linux/fs.h > @@ -983,6 +983,13 @@ > > #include <linux/fcntl.h> > > +extern void send_sigio(struct fown_struct *fown, int fd, int band); > + > +/* fs/sync.c */ > +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > + loff_t endbyte, unsigned int flags); > + > +#ifdef CONFIG_FILE_LOCKING > extern int fcntl_getlk(struct file *, struct flock __user *); > extern int fcntl_setlk(unsigned int, struct file *, unsigned int, > struct flock __user *); > @@ -993,14 +1000,9 @@ > struct flock64 __user *); > #endif > > -extern void send_sigio(struct fown_struct *fown, int fd, int band); > extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); > extern int fcntl_getlease(struct file *filp); > > -/* fs/sync.c */ > -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > - loff_t endbyte, unsigned int flags); > - > /* fs/locks.c */ > extern void locks_init_lock(struct file_lock *); > extern void locks_copy_lock(struct file_lock *, struct file_lock *); > @@ -1023,6 +1025,33 @@ > extern int lock_may_read(struct inode *, loff_t start, unsigned long count); > extern int lock_may_write(struct inode *, loff_t start, unsigned long count); > extern struct seq_operations locks_seq_operations; > +#else /* !CONFIG_FILE_LOCKING */ > +#define fcntl_getlk(a, b) (-EINVAL) > +#define fcntl_setlk(a, b, c, d) (-EACCES) > +#if BITS_PER_LONG == 32 > +#define fcntl_getlk64(a, b) (-EINVAL) > +#define fcntl_setlk64(a, b, c, d) (-EACCES) > +#endif > +#define fcntl_setlease(a, b, c) (0) > +#define fcntl_getlease(a) (0) > +#define locks_init_lock(a) > +#define locks_copy_lock(a, b) > +#define locks_remove_posix(a, b) > +#define locks_remove_flock(a) > +#define posix_test_lock(a, b) (0) > +#define posix_lock_file(a, b) (-ENOLCK) > +#define posix_lock_file_wait(a, b) (-ENOLCK) > +#define posix_unblock_lock(a, b) (-ENOENT) > +#define vfs_test_lock(a, b) (0) > +#define vfs_lock_file(a, b, c, d) (-ENOLCK) > +#define vfs_cancel_lock(a, b) (0) > +#define flock_lock_file_wait(a, b) (-ENOLCK) > +#define __break_lease(a, b) (0) > +#define lease_get_mtime(a, b) > +#define lock_may_read(a, b, c) (1) > +#define lock_may_write(a, b, c) (1) > +#endif /* !CONFIG_FILE_LOCKING */ > + > > struct fasync_struct { > int magic; > @@ -1554,9 +1583,12 @@ > /* /sys/fs */ > extern struct kobject *fs_kobj; > > +extern int rw_verify_area(int, struct file *, loff_t *, size_t); > + > #define FLOCK_VERIFY_READ 1 > #define FLOCK_VERIFY_WRITE 2 > > +#ifdef CONFIG_FILE_LOCKING > extern int locks_mandatory_locked(struct inode *); > extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); > > @@ -1587,8 +1619,6 @@ > return 0; > } > > -extern int rw_verify_area(int, struct file *, loff_t *, size_t); > - > static inline int locks_verify_truncate(struct inode *inode, > struct file *filp, > loff_t size) > @@ -1609,6 +1639,14 @@ > return __break_lease(inode, mode); > return 0; > } > +#else /* !CONFIG_FILE_LOCKING */ > +#define locks_mandatory_locked(a) (0) > +#define locks_mandatory_area(a, b, c, d, e) (0) > +#define mandatory_lock(a) (0) > +#define locks_verify_locked(a) (0) > +#define locks_verify_truncate(a, b, c) (0) > +#define break_lease(a, b) (0) > +#endif /* CONFIG_FILE_LOCKING */ > > /* fs/open.c */ > > Index: linuxdev/kernel/sys_ni.c > =================================================================== > --- linuxdev.orig/kernel/sys_ni.c > +++ linuxdev/kernel/sys_ni.c > @@ -130,6 +130,7 @@ > cond_syscall(sys_io_submit); > cond_syscall(sys_io_cancel); > cond_syscall(sys_io_getevents); > +cond_syscall(sys_flock); > > /* arch-specific weak syscall entries */ > cond_syscall(sys_pciconfig_read); > Index: linuxdev/kernel/sysctl.c > =================================================================== > --- linuxdev.orig/kernel/sysctl.c > +++ linuxdev/kernel/sysctl.c > @@ -97,7 +97,7 @@ > static int neg_one = -1; > #endif > > -#ifdef CONFIG_MMU > +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) > static int two = 2; > #endif > > @@ -1260,6 +1260,7 @@ > .extra1 = &minolduid, > .extra2 = &maxolduid, > }, > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASES, > .procname = "leases-enable", > @@ -1268,6 +1269,7 @@ > .mode = 0644, > .proc_handler = &proc_dointvec, > }, > +#endif > #ifdef CONFIG_DNOTIFY > { > .ctl_name = FS_DIR_NOTIFY, > @@ -1279,6 +1281,7 @@ > }, > #endif > #ifdef CONFIG_MMU > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASE_TIME, > .procname = "lease-break-time", > @@ -1290,6 +1293,7 @@ > .extra1 = &zero, > .extra2 = &two, > }, > +#endif /* CONFIG_FILE_LOCKING */ > #ifdef CONFIG_AIO > { > .procname = "aio-nr", > > > -- > Thomas Petazzoni, Free Electrons > Kernel, drivers and embedded Linux development, > consulting, training and support. > http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:16 ` J. Bruce Fields @ 2008-08-04 18:24 ` Tim Bird 2008-08-04 18:25 ` J. Bruce Fields 2008-08-06 13:12 ` Thomas Petazzoni 1 sibling, 1 reply; 31+ messages in thread From: Tim Bird @ 2008-08-04 18:24 UTC (permalink / raw) To: J. Bruce Fields Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm J. Bruce Fields wrote: > On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: >> Le Sat, 2 Aug 2008 12:38:48 -0400, >> "J. Bruce Fields" <bfields@fieldses.org> a écrit : >> >>> Out of curiosity, why does the nfs client need disabling, but not >>> nfsd, gfs2, fuse, etc.? >> Then also need disabling. > > OK by me, but again, why exactly? Since you're replacing the locking > calls they used by stubs that just return errors, in theory nfs, nfsd, > gfs2, and the rest should still compile and run, just without locking > support, right? I think so, but haven't tested this myself. However, I would still be inclined to NOT add the extra config dependencies. Just my 2 cents. -- Tim ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America ============================= -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:24 ` Tim Bird @ 2008-08-04 18:25 ` J. Bruce Fields 2008-08-04 18:54 ` Matt Mackall 2008-08-04 22:32 ` Tim Bird 0 siblings, 2 replies; 31+ messages in thread From: J. Bruce Fields @ 2008-08-04 18:25 UTC (permalink / raw) To: Tim Bird Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Mon, Aug 04, 2008 at 11:24:51AM -0700, Tim Bird wrote: > J. Bruce Fields wrote: > > On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: > >> Le Sat, 2 Aug 2008 12:38:48 -0400, > >> "J. Bruce Fields" <bfields@fieldses.org> a écrit : > >> > >>> Out of curiosity, why does the nfs client need disabling, but not > >>> nfsd, gfs2, fuse, etc.? > >> Then also need disabling. > > > > OK by me, but again, why exactly? Since you're replacing the locking > > calls they used by stubs that just return errors, in theory nfs, nfsd, > > gfs2, and the rest should still compile and run, just without locking > > support, right? > > I think so, but haven't tested this myself. > > However, I would still be inclined to NOT add the extra config > dependencies. Just my 2 cents. OK. My fear was that there was some good reason that the nfs dependency was added in the first place, and that it's since been lost.... --b. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:25 ` J. Bruce Fields @ 2008-08-04 18:54 ` Matt Mackall 2008-08-04 19:42 ` J. Bruce Fields 2008-08-04 22:32 ` Tim Bird 1 sibling, 1 reply; 31+ messages in thread From: Matt Mackall @ 2008-08-04 18:54 UTC (permalink / raw) To: J. Bruce Fields Cc: Tim Bird, Thomas Petazzoni, linux-kernel, linux-embedded, michael, matthew, linux-fsdevel, akpm On Mon, 2008-08-04 at 14:25 -0400, J. Bruce Fields wrote: > On Mon, Aug 04, 2008 at 11:24:51AM -0700, Tim Bird wrote: > > J. Bruce Fields wrote: > > > On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: > > >> Le Sat, 2 Aug 2008 12:38:48 -0400, > > >> "J. Bruce Fields" <bfields@fieldses.org> a écrit : > > >> > > >>> Out of curiosity, why does the nfs client need disabling, but not > > >>> nfsd, gfs2, fuse, etc.? > > >> Then also need disabling. > > > > > > OK by me, but again, why exactly? Since you're replacing the locking > > > calls they used by stubs that just return errors, in theory nfs, nfsd, > > > gfs2, and the rest should still compile and run, just without locking > > > support, right? > > > > I think so, but haven't tested this myself. > > > > However, I would still be inclined to NOT add the extra config > > dependencies. Just my 2 cents. > > OK. My fear was that there was some good reason that the nfs dependency > was added in the first place, and that it's since been lost.... I vaguely remember there was some compile issue here, but that would have been back in the 2.6.10 era. -- Mathematics is the supreme nostalgia of our time. ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:54 ` Matt Mackall @ 2008-08-04 19:42 ` J. Bruce Fields 0 siblings, 0 replies; 31+ messages in thread From: J. Bruce Fields @ 2008-08-04 19:42 UTC (permalink / raw) To: Matt Mackall Cc: Tim Bird, Thomas Petazzoni, linux-kernel, linux-embedded, michael, matthew, linux-fsdevel, akpm On Mon, Aug 04, 2008 at 01:54:01PM -0500, Matt Mackall wrote: > > On Mon, 2008-08-04 at 14:25 -0400, J. Bruce Fields wrote: > > On Mon, Aug 04, 2008 at 11:24:51AM -0700, Tim Bird wrote: > > > J. Bruce Fields wrote: > > > > On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: > > > >> Le Sat, 2 Aug 2008 12:38:48 -0400, > > > >> "J. Bruce Fields" <bfields@fieldses.org> a écrit : > > > >> > > > >>> Out of curiosity, why does the nfs client need disabling, but not > > > >>> nfsd, gfs2, fuse, etc.? > > > >> Then also need disabling. > > > > > > > > OK by me, but again, why exactly? Since you're replacing the locking > > > > calls they used by stubs that just return errors, in theory nfs, nfsd, > > > > gfs2, and the rest should still compile and run, just without locking > > > > support, right? > > > > > > I think so, but haven't tested this myself. > > > > > > However, I would still be inclined to NOT add the extra config > > > dependencies. Just my 2 cents. > > > > OK. My fear was that there was some good reason that the nfs dependency > > was added in the first place, and that it's since been lost.... > > I vaguely remember there was some compile issue here, but that would > have been back in the 2.6.10 era. Sounds plausible. I've got no objection to the patch either way, but if we could at least just add a comment documenting the issue (if it exists), that might be helpful. --b. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:25 ` J. Bruce Fields 2008-08-04 18:54 ` Matt Mackall @ 2008-08-04 22:32 ` Tim Bird 1 sibling, 0 replies; 31+ messages in thread From: Tim Bird @ 2008-08-04 22:32 UTC (permalink / raw) To: J. Bruce Fields Cc: Thomas Petazzoni, linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm J. Bruce Fields wrote: > On Mon, Aug 04, 2008 at 11:24:51AM -0700, Tim Bird wrote: >> J. Bruce Fields wrote: >>> On Mon, Aug 04, 2008 at 03:52:37PM +0200, Thomas Petazzoni wrote: >>>> Le Sat, 2 Aug 2008 12:38:48 -0400, >>>> "J. Bruce Fields" <bfields@fieldses.org> a écrit : >>>> >>>>> Out of curiosity, why does the nfs client need disabling, but not >>>>> nfsd, gfs2, fuse, etc.? >>>> Then also need disabling. >>> OK by me, but again, why exactly? Since you're replacing the locking >>> calls they used by stubs that just return errors, in theory nfs, nfsd, >>> gfs2, and the rest should still compile and run, just without locking >>> support, right? >> I think so, but haven't tested this myself. >> >> However, I would still be inclined to NOT add the extra config >> dependencies. Just my 2 cents. > > OK. My fear was that there was some good reason that the nfs dependency > was added in the first place, and that it's since been lost.... For general information, I just ran a test with the NFS dependency on file locking turned off, and with the NFS auto-enable of CONFIG_LOCKD removed. It got me about a 16K savings, and I was able to successfully boot a target with an NFS-mounted root file system. I haven't run extensive tests, so I don't know what apps might break in this configuration, but at least in this test, it ran well enough to boot the machine. Below is the patch I used, which is only provided for information. This should NOT be applied - it consists of quick hacks to test this configuration only (that is, to test NFS with CONFIG_FILE_LOCKING=n). BTW - this is on a 2.6.23 kernel, so even the regular FILE_LOCKING bits may be different from the current no-file-locking patch. --- fs/Kconfig | 3 +-- fs/nfs/client.c | 6 ++++++ fs/nfs/nfs3proc.c | 4 ++++ fs/nfs/proc.c | 4 ++++ fs/read_write.c | 2 ++ include/linux/fs.h | 13 +++++++------ 6 files changed, 24 insertions(+), 8 deletions(-) --- a/fs/Kconfig +++ b/fs/Kconfig @@ -1701,8 +1701,7 @@ menu "Network File Systems" config NFS_FS tristate "NFS file system support" - depends on INET && FILE_LOCKING - select LOCKD + depends on INET select SUNRPC select NFS_ACL_SUPPORT if NFS_V3_ACL help --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -414,6 +414,7 @@ static void nfs_destroy_server(struct nf lockd_down(); /* release rpc.lockd */ } +#ifdef LOCKD /* * Version 2 or 3 lockd setup */ @@ -434,6 +435,7 @@ static int nfs_start_lockd(struct nfs_se out: return error; } +#endif /* * Initialise an NFSv3 ACL client connection @@ -577,9 +579,11 @@ static int nfs_init_server(struct nfs_se server->acdirmax = data->acdirmax * HZ; /* Start lockd here, before we might error out */ +#ifdef LOCKD error = nfs_start_lockd(server); if (error < 0) goto error; +#endif error = nfs_init_server_rpcclient(server, data->pseudoflavor); if (error < 0) @@ -1128,9 +1132,11 @@ struct nfs_server *nfs_clone_server(stru (unsigned long long) server->fsid.major, (unsigned long long) server->fsid.minor); +#ifdef LOCKD error = nfs_start_lockd(server); if (error < 0) goto out_free_server; +#endif spin_lock(&nfs_client_lock); list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -795,7 +795,11 @@ static void nfs3_proc_commit_setup(struc static int nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) { +#ifdef LOCKD return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl); +#else + return -ENOLCK; +#endif } const struct nfs_rpc_ops nfs_v3_clientops = { --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -605,7 +605,11 @@ nfs_proc_commit_setup(struct nfs_write_d static int nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) { +#ifdef LOCKD return nlmclnt_proc(filp->f_path.dentry->d_inode, cmd, fl); +#else + return -ENOLCK; +#endif } --- a/fs/read_write.c +++ b/fs/read_write.c @@ -211,6 +211,7 @@ int rw_verify_area(int read_write, struc if (unlikely((pos < 0) || (loff_t) (pos + count) < 0)) goto Einval; +#ifdef FILE_LOCKING if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) { int retval = locks_mandatory_area( read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, @@ -218,6 +219,7 @@ int rw_verify_area(int read_write, struc if (retval < 0) return retval; } +#endif return count > MAX_RW_COUNT ? MAX_RW_COUNT : count; Einval: --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -863,10 +863,6 @@ extern int fcntl_setlk64(unsigned int, s extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); extern int fcntl_getlease(struct file *filp); -/* fs/sync.c */ -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, - loff_t endbyte, unsigned int flags); - /* fs/locks.c */ extern void locks_init_lock(struct file_lock *); extern void locks_copy_lock(struct file_lock *, struct file_lock *); @@ -918,6 +914,10 @@ extern int lock_may_write(struct inode * #define steal_locks(a) #endif /* !CONFIG_FILE_LOCKING */ +/* fs/sync.c */ +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, + loff_t endbyte, unsigned int flags); + struct fasync_struct { int magic; int fa_fd; @@ -1424,8 +1424,6 @@ static inline int locks_verify_locked(st return 0; } -extern int rw_verify_area(int, struct file *, loff_t *, size_t); - static inline int locks_verify_truncate(struct inode *inode, struct file *filp, loff_t size) @@ -1459,6 +1457,9 @@ static inline int break_lease(struct ino #endif /* !CONFIG_FILE_LOCKING */ +extern int rw_verify_area(int, struct file *, loff_t *, size_t); + + /* fs/open.c */ extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America ============================= ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-04 18:16 ` J. Bruce Fields 2008-08-04 18:24 ` Tim Bird @ 2008-08-06 13:12 ` Thomas Petazzoni 2008-08-07 22:55 ` J. Bruce Fields 1 sibling, 1 reply; 31+ messages in thread From: Thomas Petazzoni @ 2008-08-06 13:12 UTC (permalink / raw) To: J. Bruce Fields Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm Le Mon, 4 Aug 2008 14:16:41 -0400, "J. Bruce Fields" <bfields@fieldses.org> a écrit : > OK by me, but again, why exactly? Since you're replacing the locking > calls they used by stubs that just return errors, in theory nfs, nfsd, > gfs2, and the rest should still compile and run, just without locking > support, right? You're right, that was stupid. Either should I add the Kconfig dependencies *OR* add the function stubs, not both. The following patch implements the second solution. I've checked that NFS, CIFS, GFS2, OCFS2, AFS and FUSE compile correctly. I've tested NFS only, though. Here is the new patch. Comments and suggestions welcome. Sincerly, Thomas --- Configure out file locking features This patch adds the CONFIG_FILE_LOCKING option which allows to remove support for advisory locks. With this patch enabled, the flock() system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() and NFS support are disabled. These features are not necessarly needed on embedded systems. It allows to save ~11 Kb of kernel code and data: text data bss dec hex filename 1125436 118764 212992 1457192 163c28 vmlinux.old 1114299 118564 212992 1445855 160fdf vmlinux -11137 -200 0 -11337 -2C49 +/- This patch has originally been written by Matt Mackall <mpm@selenic.com>, and is part of the Linux Tiny project. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Matt Mackall <mpm@selenic.com> Cc: matthew@wil.cx Cc: linux-fsdevel@vger.kernel.org Cc: mpm@selenic.com Cc: akpm@linux-foundation.org --- fs/Kconfig | 8 +++++++ fs/Makefile | 3 +- fs/proc/proc_misc.c | 4 +++ include/linux/fs.h | 55 +++++++++++++++++++++++++++++++++++++++++++++------- kernel/sys_ni.c | 1 kernel/sysctl.c | 6 ++++- 6 files changed, 68 insertions(+), 9 deletions(-) Index: linuxdev/fs/Kconfig =================================================================== --- linuxdev.orig/fs/Kconfig +++ linuxdev/fs/Kconfig @@ -419,6 +419,14 @@ bool default n +config FILE_LOCKING + bool "Enable POSIX file locking API" if EMBEDDED + default y + help + This option enables standard file locking support, required + for filesystems like NFS and for the flock() system + call. Disabling this option saves about 11k. + source "fs/xfs/Kconfig" source "fs/gfs2/Kconfig" Index: linuxdev/fs/Makefile =================================================================== --- linuxdev.orig/fs/Makefile +++ linuxdev/fs/Makefile @@ -7,7 +7,7 @@ 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 \ + ioctl.o readdir.o select.o fifo.o dcache.o inode.o \ attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ seq_file.o xattr.o libfs.o fs-writeback.o \ pnode.o drop_caches.o splice.o sync.o utimes.o \ @@ -27,6 +27,7 @@ obj-$(CONFIG_SIGNALFD) += signalfd.o obj-$(CONFIG_TIMERFD) += timerfd.o obj-$(CONFIG_EVENTFD) += eventfd.o +obj-$(CONFIG_FILE_LOCKING) += locks.o obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o nfsd-$(CONFIG_NFSD) := nfsctl.o Index: linuxdev/fs/proc/proc_misc.c =================================================================== --- linuxdev.orig/fs/proc/proc_misc.c +++ linuxdev/fs/proc/proc_misc.c @@ -677,6 +677,7 @@ return proc_calc_metrics(page, start, off, count, eof, len); } +#ifdef CONFIG_FILE_LOCKING static int locks_open(struct inode *inode, struct file *filp) { return seq_open(filp, &locks_seq_operations); @@ -688,6 +689,7 @@ .llseek = seq_lseek, .release = seq_release, }; +#endif /* CONFIG_FILE_LOCKING */ static int execdomains_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data) @@ -881,7 +883,9 @@ #ifdef CONFIG_PRINTK proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); #endif +#ifdef CONFIG_FILE_LOCKING proc_create("locks", 0, NULL, &proc_locks_operations); +#endif proc_create("devices", 0, NULL, &proc_devinfo_operations); proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); #ifdef CONFIG_BLOCK Index: linuxdev/include/linux/fs.h =================================================================== --- linuxdev.orig/include/linux/fs.h +++ linuxdev/include/linux/fs.h @@ -983,6 +983,13 @@ #include <linux/fcntl.h> +extern void send_sigio(struct fown_struct *fown, int fd, int band); + +/* fs/sync.c */ +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, + loff_t endbyte, unsigned int flags); + +#ifdef CONFIG_FILE_LOCKING extern int fcntl_getlk(struct file *, struct flock __user *); extern int fcntl_setlk(unsigned int, struct file *, unsigned int, struct flock __user *); @@ -993,14 +1000,9 @@ struct flock64 __user *); #endif -extern void send_sigio(struct fown_struct *fown, int fd, int band); extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); extern int fcntl_getlease(struct file *filp); -/* fs/sync.c */ -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, - loff_t endbyte, unsigned int flags); - /* fs/locks.c */ extern void locks_init_lock(struct file_lock *); extern void locks_copy_lock(struct file_lock *, struct file_lock *); @@ -1023,6 +1025,35 @@ extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count); extern struct seq_operations locks_seq_operations; +#else /* !CONFIG_FILE_LOCKING */ +#define fcntl_getlk(a, b) ({ -EINVAL; }) +#define fcntl_setlk(a, b, c, d) ({ -EACCES; }) +#if BITS_PER_LONG == 32 +#define fcntl_getlk64(a, b) ({ -EINVAL; }) +#define fcntl_setlk64(a, b, c, d) ({ -EACCES; }) +#endif +#define fcntl_setlease(a, b, c) ({ 0; }) +#define fcntl_getlease(a) ({ 0; }) +#define locks_init_lock(a) ({ }) +#define __locks_copy_lock(a, b) ({ }) +#define locks_copy_lock(a, b) ({ }) +#define locks_remove_posix(a, b) ({ }) +#define locks_remove_flock(a) ({ }) +#define posix_test_lock(a, b) ({ 0; }) +#define posix_lock_file(a, b, c) ({ -ENOLCK; }) +#define posix_lock_file_wait(a, b) ({ -ENOLCK; }) +#define posix_unblock_lock(a, b) (-ENOENT) +#define vfs_test_lock(a, b) ({ 0; }) +#define vfs_lock_file(a, b, c, d) (-ENOLCK) +#define vfs_cancel_lock(a, b) ({ 0; }) +#define flock_lock_file_wait(a, b) ({ -ENOLCK; }) +#define __break_lease(a, b) ({ 0; }) +#define lease_get_mtime(a, b) ({ }) +#define generic_setlease(a, b, c) ({ -EINVAL; }) +#define lock_may_read(a, b, c) ({ 1; }) +#define lock_may_write(a, b, c) ({ 1; }) +#endif /* !CONFIG_FILE_LOCKING */ + struct fasync_struct { int magic; @@ -1554,9 +1585,12 @@ /* /sys/fs */ extern struct kobject *fs_kobj; +extern int rw_verify_area(int, struct file *, loff_t *, size_t); + #define FLOCK_VERIFY_READ 1 #define FLOCK_VERIFY_WRITE 2 +#ifdef CONFIG_FILE_LOCKING extern int locks_mandatory_locked(struct inode *); extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); @@ -1587,8 +1621,6 @@ return 0; } -extern int rw_verify_area(int, struct file *, loff_t *, size_t); - static inline int locks_verify_truncate(struct inode *inode, struct file *filp, loff_t size) @@ -1609,6 +1641,15 @@ return __break_lease(inode, mode); return 0; } +#else /* !CONFIG_FILE_LOCKING */ +#define locks_mandatory_locked(a) ({ 0; }) +#define locks_mandatory_area(a, b, c, d, e) ({ 0; }) +#define __mandatory_lock(a) ({ 0; }) +#define mandatory_lock(a) ({ 0; }) +#define locks_verify_locked(a) ({ 0; }) +#define locks_verify_truncate(a, b, c) ({ 0; }) +#define break_lease(a, b) ({ 0; }) +#endif /* CONFIG_FILE_LOCKING */ /* fs/open.c */ Index: linuxdev/kernel/sys_ni.c =================================================================== --- linuxdev.orig/kernel/sys_ni.c +++ linuxdev/kernel/sys_ni.c @@ -125,6 +125,7 @@ cond_syscall(sys_vm86); cond_syscall(compat_sys_ipc); cond_syscall(compat_sys_sysctl); +cond_syscall(sys_flock); /* arch-specific weak syscall entries */ cond_syscall(sys_pciconfig_read); Index: linuxdev/kernel/sysctl.c =================================================================== --- linuxdev.orig/kernel/sysctl.c +++ linuxdev/kernel/sysctl.c @@ -97,7 +97,7 @@ static int neg_one = -1; #endif -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) static int two = 2; #endif @@ -1260,6 +1260,7 @@ .extra1 = &minolduid, .extra2 = &maxolduid, }, +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASES, .procname = "leases-enable", @@ -1268,6 +1269,7 @@ .mode = 0644, .proc_handler = &proc_dointvec, }, +#endif #ifdef CONFIG_DNOTIFY { .ctl_name = FS_DIR_NOTIFY, @@ -1279,6 +1281,7 @@ }, #endif #ifdef CONFIG_MMU +#ifdef CONFIG_FILE_LOCKING { .ctl_name = FS_LEASE_TIME, .procname = "lease-break-time", @@ -1290,6 +1293,7 @@ .extra1 = &zero, .extra2 = &two, }, +#endif { .procname = "aio-nr", .data = &aio_nr, -- Thomas Petazzoni, Free Electrons Kernel, drivers and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [patch 2/4] Configure out file locking features 2008-08-06 13:12 ` Thomas Petazzoni @ 2008-08-07 22:55 ` J. Bruce Fields 0 siblings, 0 replies; 31+ messages in thread From: J. Bruce Fields @ 2008-08-07 22:55 UTC (permalink / raw) To: Thomas Petazzoni Cc: linux-kernel, linux-embedded, michael, Matt Mackall, matthew, linux-fsdevel, akpm On Wed, Aug 06, 2008 at 03:12:22PM +0200, Thomas Petazzoni wrote: > Le Mon, 4 Aug 2008 14:16:41 -0400, > "J. Bruce Fields" <bfields@fieldses.org> a écrit : > > > OK by me, but again, why exactly? Since you're replacing the locking > > calls they used by stubs that just return errors, in theory nfs, nfsd, > > gfs2, and the rest should still compile and run, just without locking > > support, right? > > You're right, that was stupid. Either should I add the Kconfig > dependencies *OR* add the function stubs, not both. The following patch > implements the second solution. I've checked that NFS, CIFS, GFS2, > OCFS2, AFS and FUSE compile correctly. I've tested NFS only, though. > > Here is the new patch. Comments and suggestions welcome. Seems fine to me, thanks! I can queue it up in my tree for 2.6.28 if there's no objections. (But, basic mail question: so I give this message to git-am and it complains because of all this =3D=20 stuff, which google tells me is quoted-printable encoding. Fine, I fixed it up by hand, but a) there must be some less boring way to deal with it, and b) there must have been some easy way to avoid it in the first place, either on my side or yours? Enlightenment welcome.) --b. > > Sincerly, > > Thomas > > --- > > Configure out file locking features > > This patch adds the CONFIG_FILE_LOCKING option which allows to remove > support for advisory locks. With this patch enabled, the flock() > system call, the F_GETLK, F_SETLK and F_SETLKW operations of fcntl() > and NFS support are disabled. These features are not necessarly needed > on embedded systems. It allows to save ~11 Kb of kernel code and data: > > text data bss dec hex filename > 1125436 118764 212992 1457192 163c28 vmlinux.old > 1114299 118564 212992 1445855 160fdf vmlinux > -11137 -200 0 -11337 -2C49 +/- > > This patch has originally been written by Matt Mackall > <mpm@selenic.com>, and is part of the Linux Tiny project. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Signed-off-by: Matt Mackall <mpm@selenic.com> > Cc: matthew@wil.cx > Cc: linux-fsdevel@vger.kernel.org > Cc: mpm@selenic.com > Cc: akpm@linux-foundation.org > > --- > fs/Kconfig | 8 +++++++ > fs/Makefile | 3 +- > fs/proc/proc_misc.c | 4 +++ > include/linux/fs.h | 55 +++++++++++++++++++++++++++++++++++++++++++++------- > kernel/sys_ni.c | 1 > kernel/sysctl.c | 6 ++++- > 6 files changed, 68 insertions(+), 9 deletions(-) > > Index: linuxdev/fs/Kconfig > =================================================================== > --- linuxdev.orig/fs/Kconfig > +++ linuxdev/fs/Kconfig > @@ -419,6 +419,14 @@ > bool > default n > > +config FILE_LOCKING > + bool "Enable POSIX file locking API" if EMBEDDED > + default y > + help > + This option enables standard file locking support, required > + for filesystems like NFS and for the flock() system > + call. Disabling this option saves about 11k. > + > source "fs/xfs/Kconfig" > source "fs/gfs2/Kconfig" > > Index: linuxdev/fs/Makefile > =================================================================== > --- linuxdev.orig/fs/Makefile > +++ linuxdev/fs/Makefile > @@ -7,7 +7,7 @@ > > 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 \ > + ioctl.o readdir.o select.o fifo.o dcache.o inode.o \ > attr.o bad_inode.o file.o filesystems.o namespace.o aio.o \ > seq_file.o xattr.o libfs.o fs-writeback.o \ > pnode.o drop_caches.o splice.o sync.o utimes.o \ > @@ -27,6 +27,7 @@ > obj-$(CONFIG_SIGNALFD) += signalfd.o > obj-$(CONFIG_TIMERFD) += timerfd.o > obj-$(CONFIG_EVENTFD) += eventfd.o > +obj-$(CONFIG_FILE_LOCKING) += locks.o > obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o > > nfsd-$(CONFIG_NFSD) := nfsctl.o > Index: linuxdev/fs/proc/proc_misc.c > =================================================================== > --- linuxdev.orig/fs/proc/proc_misc.c > +++ linuxdev/fs/proc/proc_misc.c > @@ -677,6 +677,7 @@ > return proc_calc_metrics(page, start, off, count, eof, len); > } > > +#ifdef CONFIG_FILE_LOCKING > static int locks_open(struct inode *inode, struct file *filp) > { > return seq_open(filp, &locks_seq_operations); > @@ -688,6 +689,7 @@ > .llseek = seq_lseek, > .release = seq_release, > }; > +#endif /* CONFIG_FILE_LOCKING */ > > static int execdomains_read_proc(char *page, char **start, off_t off, > int count, int *eof, void *data) > @@ -881,7 +883,9 @@ > #ifdef CONFIG_PRINTK > proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); > #endif > +#ifdef CONFIG_FILE_LOCKING > proc_create("locks", 0, NULL, &proc_locks_operations); > +#endif > proc_create("devices", 0, NULL, &proc_devinfo_operations); > proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations); > #ifdef CONFIG_BLOCK > Index: linuxdev/include/linux/fs.h > =================================================================== > --- linuxdev.orig/include/linux/fs.h > +++ linuxdev/include/linux/fs.h > @@ -983,6 +983,13 @@ > > #include <linux/fcntl.h> > > +extern void send_sigio(struct fown_struct *fown, int fd, int band); > + > +/* fs/sync.c */ > +extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > + loff_t endbyte, unsigned int flags); > + > +#ifdef CONFIG_FILE_LOCKING > extern int fcntl_getlk(struct file *, struct flock __user *); > extern int fcntl_setlk(unsigned int, struct file *, unsigned int, > struct flock __user *); > @@ -993,14 +1000,9 @@ > struct flock64 __user *); > #endif > > -extern void send_sigio(struct fown_struct *fown, int fd, int band); > extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); > extern int fcntl_getlease(struct file *filp); > > -/* fs/sync.c */ > -extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset, > - loff_t endbyte, unsigned int flags); > - > /* fs/locks.c */ > extern void locks_init_lock(struct file_lock *); > extern void locks_copy_lock(struct file_lock *, struct file_lock *); > @@ -1023,6 +1025,35 @@ > extern int lock_may_read(struct inode *, loff_t start, unsigned long count); > extern int lock_may_write(struct inode *, loff_t start, unsigned long count); > extern struct seq_operations locks_seq_operations; > +#else /* !CONFIG_FILE_LOCKING */ > +#define fcntl_getlk(a, b) ({ -EINVAL; }) > +#define fcntl_setlk(a, b, c, d) ({ -EACCES; }) > +#if BITS_PER_LONG == 32 > +#define fcntl_getlk64(a, b) ({ -EINVAL; }) > +#define fcntl_setlk64(a, b, c, d) ({ -EACCES; }) > +#endif > +#define fcntl_setlease(a, b, c) ({ 0; }) > +#define fcntl_getlease(a) ({ 0; }) > +#define locks_init_lock(a) ({ }) > +#define __locks_copy_lock(a, b) ({ }) > +#define locks_copy_lock(a, b) ({ }) > +#define locks_remove_posix(a, b) ({ }) > +#define locks_remove_flock(a) ({ }) > +#define posix_test_lock(a, b) ({ 0; }) > +#define posix_lock_file(a, b, c) ({ -ENOLCK; }) > +#define posix_lock_file_wait(a, b) ({ -ENOLCK; }) > +#define posix_unblock_lock(a, b) (-ENOENT) > +#define vfs_test_lock(a, b) ({ 0; }) > +#define vfs_lock_file(a, b, c, d) (-ENOLCK) > +#define vfs_cancel_lock(a, b) ({ 0; }) > +#define flock_lock_file_wait(a, b) ({ -ENOLCK; }) > +#define __break_lease(a, b) ({ 0; }) > +#define lease_get_mtime(a, b) ({ }) > +#define generic_setlease(a, b, c) ({ -EINVAL; }) > +#define lock_may_read(a, b, c) ({ 1; }) > +#define lock_may_write(a, b, c) ({ 1; }) > +#endif /* !CONFIG_FILE_LOCKING */ > + > > struct fasync_struct { > int magic; > @@ -1554,9 +1585,12 @@ > /* /sys/fs */ > extern struct kobject *fs_kobj; > > +extern int rw_verify_area(int, struct file *, loff_t *, size_t); > + > #define FLOCK_VERIFY_READ 1 > #define FLOCK_VERIFY_WRITE 2 > > +#ifdef CONFIG_FILE_LOCKING > extern int locks_mandatory_locked(struct inode *); > extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t); > > @@ -1587,8 +1621,6 @@ > return 0; > } > > -extern int rw_verify_area(int, struct file *, loff_t *, size_t); > - > static inline int locks_verify_truncate(struct inode *inode, > struct file *filp, > loff_t size) > @@ -1609,6 +1641,15 @@ > return __break_lease(inode, mode); > return 0; > } > +#else /* !CONFIG_FILE_LOCKING */ > +#define locks_mandatory_locked(a) ({ 0; }) > +#define locks_mandatory_area(a, b, c, d, e) ({ 0; }) > +#define __mandatory_lock(a) ({ 0; }) > +#define mandatory_lock(a) ({ 0; }) > +#define locks_verify_locked(a) ({ 0; }) > +#define locks_verify_truncate(a, b, c) ({ 0; }) > +#define break_lease(a, b) ({ 0; }) > +#endif /* CONFIG_FILE_LOCKING */ > > /* fs/open.c */ > > Index: linuxdev/kernel/sys_ni.c > =================================================================== > --- linuxdev.orig/kernel/sys_ni.c > +++ linuxdev/kernel/sys_ni.c > @@ -125,6 +125,7 @@ > cond_syscall(sys_vm86); > cond_syscall(compat_sys_ipc); > cond_syscall(compat_sys_sysctl); > +cond_syscall(sys_flock); > > /* arch-specific weak syscall entries */ > cond_syscall(sys_pciconfig_read); > Index: linuxdev/kernel/sysctl.c > =================================================================== > --- linuxdev.orig/kernel/sysctl.c > +++ linuxdev/kernel/sysctl.c > @@ -97,7 +97,7 @@ > static int neg_one = -1; > #endif > > -#ifdef CONFIG_MMU > +#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING) > static int two = 2; > #endif > > @@ -1260,6 +1260,7 @@ > .extra1 = &minolduid, > .extra2 = &maxolduid, > }, > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASES, > .procname = "leases-enable", > @@ -1268,6 +1269,7 @@ > .mode = 0644, > .proc_handler = &proc_dointvec, > }, > +#endif > #ifdef CONFIG_DNOTIFY > { > .ctl_name = FS_DIR_NOTIFY, > @@ -1279,6 +1281,7 @@ > }, > #endif > #ifdef CONFIG_MMU > +#ifdef CONFIG_FILE_LOCKING > { > .ctl_name = FS_LEASE_TIME, > .procname = "lease-break-time", > @@ -1290,6 +1293,7 @@ > .extra1 = &zero, > .extra2 = &two, > }, > +#endif > { > .procname = "aio-nr", > .data = &aio_nr, > > > -- > Thomas Petazzoni, Free Electrons > Kernel, drivers and embedded Linux development, > consulting, training and support. > http://free-electrons.com ^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2008-08-07 22:55 UTC | newest] Thread overview: 31+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20080729154520.728594017@free-electrons.com> 2008-07-29 15:45 ` [patch 1/4] Configure out AIO support Thomas Petazzoni [not found] ` <20080729154747.574989775@free-electrons.com> 2008-07-29 16:27 ` Matt Mackall [not found] ` <20080729154747.872888047@free-electrons.com> 2008-07-29 18:17 ` [patch 2/4] Configure out file locking features Matthew Wilcox 2008-07-29 18:57 ` Matt Mackall 2008-07-29 20:00 ` Jamie Lokier 2008-07-30 14:27 ` Adrian Bunk 2008-07-30 15:40 ` Thomas Petazzoni 2008-07-31 6:27 ` Uwe Kleine-König 2008-07-31 9:27 [patch 0/4] [resend] Add configuration options to disable features not needed on embedded devices Thomas Petazzoni 2008-07-31 9:27 ` [patch 2/4] Configure out file locking features Thomas Petazzoni 2008-07-31 13:53 ` Adrian Bunk 2008-07-31 14:20 ` Thomas Petazzoni 2008-07-31 15:37 ` Adrian Bunk 2008-07-31 16:26 ` Thomas Petazzoni 2008-07-31 16:49 ` Adrian Bunk 2008-07-31 16:57 ` David Woodhouse 2008-07-31 17:32 ` Tim Bird 2008-07-31 18:12 ` Robert Schwebel 2008-07-31 19:31 ` Adrian Bunk 2008-08-01 7:28 ` Robert Schwebel 2008-07-31 19:16 ` Adrian Bunk 2008-07-31 20:37 ` Tim Bird 2008-08-02 16:38 ` J. Bruce Fields 2008-08-04 13:52 ` Thomas Petazzoni 2008-08-04 18:16 ` J. Bruce Fields 2008-08-04 18:24 ` Tim Bird 2008-08-04 18:25 ` J. Bruce Fields 2008-08-04 18:54 ` Matt Mackall 2008-08-04 19:42 ` J. Bruce Fields 2008-08-04 22:32 ` Tim Bird 2008-08-06 13:12 ` Thomas Petazzoni 2008-08-07 22:55 ` J. Bruce Fields
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).