original development tree for Linux kernel GTP module; now long in mainline.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

966 lines
23 KiB

[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
12 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
filesystem freeze: add error handling of write_super_lockfs/unlockfs Currently, ext3 in mainline Linux doesn't have the freeze feature which suspends write requests. So, we cannot take a backup which keeps the filesystem's consistency with the storage device's features (snapshot and replication) while it is mounted. In many case, a commercial filesystem (e.g. VxFS) has the freeze feature and it would be used to get the consistent backup. If Linux's standard filesystem ext3 has the freeze feature, we can do it without a commercial filesystem. So I have implemented the ioctls of the freeze feature. I think we can take the consistent backup with the following steps. 1. Freeze the filesystem with the freeze ioctl. 2. Separate the replication volume or create the snapshot with the storage device's feature. 3. Unfreeze the filesystem with the unfreeze ioctl. 4. Take the backup from the separated replication volume or the snapshot. This patch: VFS: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they can return an error. Rename write_super_lockfs and unlockfs of the super block operation freeze_fs and unfreeze_fs to avoid a confusion. ext3, ext4, xfs, gfs2, jfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that write_super_lockfs returns an error if needed, and unlockfs always returns 0. reiserfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they always return 0 (success) to keep a current behavior. Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com> Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com> Cc: <xfs-masters@oss.sgi.com> Cc: <linux-ext4@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Alasdair G Kergon <agk@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years ago
filesystem freeze: add error handling of write_super_lockfs/unlockfs Currently, ext3 in mainline Linux doesn't have the freeze feature which suspends write requests. So, we cannot take a backup which keeps the filesystem's consistency with the storage device's features (snapshot and replication) while it is mounted. In many case, a commercial filesystem (e.g. VxFS) has the freeze feature and it would be used to get the consistent backup. If Linux's standard filesystem ext3 has the freeze feature, we can do it without a commercial filesystem. So I have implemented the ioctls of the freeze feature. I think we can take the consistent backup with the following steps. 1. Freeze the filesystem with the freeze ioctl. 2. Separate the replication volume or create the snapshot with the storage device's feature. 3. Unfreeze the filesystem with the unfreeze ioctl. 4. Take the backup from the separated replication volume or the snapshot. This patch: VFS: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they can return an error. Rename write_super_lockfs and unlockfs of the super block operation freeze_fs and unfreeze_fs to avoid a confusion. ext3, ext4, xfs, gfs2, jfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that write_super_lockfs returns an error if needed, and unlockfs always returns 0. reiserfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they always return 0 (success) to keep a current behavior. Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com> Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com> Cc: <xfs-masters@oss.sgi.com> Cc: <linux-ext4@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Alasdair G Kergon <agk@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years ago
filesystem freeze: add error handling of write_super_lockfs/unlockfs Currently, ext3 in mainline Linux doesn't have the freeze feature which suspends write requests. So, we cannot take a backup which keeps the filesystem's consistency with the storage device's features (snapshot and replication) while it is mounted. In many case, a commercial filesystem (e.g. VxFS) has the freeze feature and it would be used to get the consistent backup. If Linux's standard filesystem ext3 has the freeze feature, we can do it without a commercial filesystem. So I have implemented the ioctls of the freeze feature. I think we can take the consistent backup with the following steps. 1. Freeze the filesystem with the freeze ioctl. 2. Separate the replication volume or create the snapshot with the storage device's feature. 3. Unfreeze the filesystem with the unfreeze ioctl. 4. Take the backup from the separated replication volume or the snapshot. This patch: VFS: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they can return an error. Rename write_super_lockfs and unlockfs of the super block operation freeze_fs and unfreeze_fs to avoid a confusion. ext3, ext4, xfs, gfs2, jfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that write_super_lockfs returns an error if needed, and unlockfs always returns 0. reiserfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they always return 0 (success) to keep a current behavior. Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com> Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com> Cc: <xfs-masters@oss.sgi.com> Cc: <linux-ext4@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Alasdair G Kergon <agk@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years ago
filesystem freeze: add error handling of write_super_lockfs/unlockfs Currently, ext3 in mainline Linux doesn't have the freeze feature which suspends write requests. So, we cannot take a backup which keeps the filesystem's consistency with the storage device's features (snapshot and replication) while it is mounted. In many case, a commercial filesystem (e.g. VxFS) has the freeze feature and it would be used to get the consistent backup. If Linux's standard filesystem ext3 has the freeze feature, we can do it without a commercial filesystem. So I have implemented the ioctls of the freeze feature. I think we can take the consistent backup with the following steps. 1. Freeze the filesystem with the freeze ioctl. 2. Separate the replication volume or create the snapshot with the storage device's feature. 3. Unfreeze the filesystem with the unfreeze ioctl. 4. Take the backup from the separated replication volume or the snapshot. This patch: VFS: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they can return an error. Rename write_super_lockfs and unlockfs of the super block operation freeze_fs and unfreeze_fs to avoid a confusion. ext3, ext4, xfs, gfs2, jfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that write_super_lockfs returns an error if needed, and unlockfs always returns 0. reiserfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they always return 0 (success) to keep a current behavior. Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com> Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com> Cc: <xfs-masters@oss.sgi.com> Cc: <linux-ext4@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Alasdair G Kergon <agk@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
[PATCH] disk quotas fail when /etc/mtab is symlinked to /proc/mounts If /etc/mtab is a regular file all of the mount options (of a file system) are written to /etc/mtab by the mount command. The quota tools look there for the quota strings for their operation. If, however, /etc/mtab is a symlink to /proc/mounts (a "good thing" in some environments) the tools don't write anything - they assume the kernel will take care of things. While the quota options are sent down to the kernel via the mount system call and the file system codes handle them properly unfortunately there is no code to echo the quota strings into /proc/mounts and the quota tools fail in the symlink case. The attached patchs modify the EXT[2|3] and JFS codes to add the necessary hooks. The show_options function of each file system in these patches currently deal with only those things that seemed related to quotas; especially in the EXT3 case more can be done (later?). Jan Kara also noted the difficulty in moving these changes above the FS codes responding similarly to myself to Andrew's comment about possible VFS migration. Issue summary: - FS codes have to process the entire string of options anyway. - Only FS codes that use quotas must have a show_options function (for quotas to work properly) however quotas are only used in a small number of FS. - Since most of the quota using FS support other options these FS codes should have the a show_options function to show those options - and the quota echoing becomes virtually negligible. Based on feedback I have modified my patches from the original: JFS a missing patch has been restored to the posting EXT[2|3] and JFS always use the show_options function - Each FS has at least one FS specific option displayed - QUOTA output is under a CONFIG_QUOTA ifdef - a follow-on patch will add a multitude of options for each FS EXT[2|3] and JFS "quota" is treated as "usrquota" EXT3 journalled data check for journalled quota removed EXT[2|3] mount when quota specified but not compiled in - no changes from my original patch. I tested the patch and the codes warn but - still mount. With all due respection I believe the comments otherwise were a - misread of the patch. Please reread/test and comment. XFS patch removed - the XFS team already made the necessary changes EXT3 mixing old and new quotas are handled differently (not purely exclusive) - if old and new quotas for the same type are used together the old type is silently depricated for compatability (e.g. usrquota and usrjquota) - mixing of old and new quotas is an error (e.g. usrjquota and grpquota) Signed-off-by: Mark Bellon <mbellon@mvista.com> Acked-by: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 years ago
filesystem freeze: add error handling of write_super_lockfs/unlockfs Currently, ext3 in mainline Linux doesn't have the freeze feature which suspends write requests. So, we cannot take a backup which keeps the filesystem's consistency with the storage device's features (snapshot and replication) while it is mounted. In many case, a commercial filesystem (e.g. VxFS) has the freeze feature and it would be used to get the consistent backup. If Linux's standard filesystem ext3 has the freeze feature, we can do it without a commercial filesystem. So I have implemented the ioctls of the freeze feature. I think we can take the consistent backup with the following steps. 1. Freeze the filesystem with the freeze ioctl. 2. Separate the replication volume or create the snapshot with the storage device's feature. 3. Unfreeze the filesystem with the unfreeze ioctl. 4. Take the backup from the separated replication volume or the snapshot. This patch: VFS: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they can return an error. Rename write_super_lockfs and unlockfs of the super block operation freeze_fs and unfreeze_fs to avoid a confusion. ext3, ext4, xfs, gfs2, jfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that write_super_lockfs returns an error if needed, and unlockfs always returns 0. reiserfs: Changed the type of write_super_lockfs and unlockfs from "void" to "int" so that they always return 0 (success) to keep a current behavior. Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com> Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com> Cc: <xfs-masters@oss.sgi.com> Cc: <linux-ext4@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Cc: Dave Chinner <david@fromorbit.com> Cc: Alasdair G Kergon <agk@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years ago
fs: Limit sys_mount to only request filesystem modules. Modify the request_module to prefix the file system type with "fs-" and add aliases to all of the filesystems that can be built as modules to match. A common practice is to build all of the kernel code and leave code that is not commonly needed as modules, with the result that many users are exposed to any bug anywhere in the kernel. Looking for filesystems with a fs- prefix limits the pool of possible modules that can be loaded by mount to just filesystems trivially making things safer with no real cost. Using aliases means user space can control the policy of which filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf with blacklist and alias directives. Allowing simple, safe, well understood work-arounds to known problematic software. This also addresses a rare but unfortunate problem where the filesystem name is not the same as it's module name and module auto-loading would not work. While writing this patch I saw a handful of such cases. The most significant being autofs that lives in the module autofs4. This is relevant to user namespaces because we can reach the request module in get_fs_type() without having any special permissions, and people get uncomfortable when a user specified string (in this case the filesystem type) goes all of the way to request_module. After having looked at this issue I don't think there is any particular reason to perform any filtering or permission checks beyond making it clear in the module request that we want a filesystem module. The common pattern in the kernel is to call request_module() without regards to the users permissions. In general all a filesystem module does once loaded is call register_filesystem() and go to sleep. Which means there is not much attack surface exposed by loading a filesytem module unless the filesystem is mounted. In a user namespace filesystems are not mounted unless .fs_flags = FS_USERNS_MOUNT, which most filesystems do not set today. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Acked-by: Kees Cook <keescook@chromium.org> Reported-by: Kees Cook <keescook@google.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
9 years ago
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2004
  3. * Portions Copyright (C) Christoph Hellwig, 2001-2002
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/fs.h>
  20. #include <linux/module.h>
  21. #include <linux/parser.h>
  22. #include <linux/completion.h>
  23. #include <linux/vfs.h>
  24. #include <linux/quotaops.h>
  25. #include <linux/mount.h>
  26. #include <linux/moduleparam.h>
  27. #include <linux/kthread.h>
  28. #include <linux/posix_acl.h>
  29. #include <linux/buffer_head.h>
  30. #include <linux/exportfs.h>
  31. #include <linux/crc32.h>
  32. #include <linux/slab.h>
  33. #include <asm/uaccess.h>
  34. #include <linux/seq_file.h>
  35. #include <linux/blkdev.h>
  36. #include "jfs_incore.h"
  37. #include "jfs_filsys.h"
  38. #include "jfs_inode.h"
  39. #include "jfs_metapage.h"
  40. #include "jfs_superblock.h"
  41. #include "jfs_dmap.h"
  42. #include "jfs_imap.h"
  43. #include "jfs_acl.h"
  44. #include "jfs_debug.h"
  45. MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
  46. MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
  47. MODULE_LICENSE("GPL");
  48. static struct kmem_cache * jfs_inode_cachep;
  49. static const struct super_operations jfs_super_operations;
  50. static const struct export_operations jfs_export_operations;
  51. static struct file_system_type jfs_fs_type;
  52. #define MAX_COMMIT_THREADS 64
  53. static int commit_threads = 0;
  54. module_param(commit_threads, int, 0);
  55. MODULE_PARM_DESC(commit_threads, "Number of commit threads");
  56. static struct task_struct *jfsCommitThread[MAX_COMMIT_THREADS];
  57. struct task_struct *jfsIOthread;
  58. struct task_struct *jfsSyncThread;
  59. #ifdef CONFIG_JFS_DEBUG
  60. int jfsloglevel = JFS_LOGLEVEL_WARN;
  61. module_param(jfsloglevel, int, 0644);
  62. MODULE_PARM_DESC(jfsloglevel, "Specify JFS loglevel (0, 1 or 2)");
  63. #endif
  64. static void jfs_handle_error(struct super_block *sb)
  65. {
  66. struct jfs_sb_info *sbi = JFS_SBI(sb);
  67. if (sb->s_flags & MS_RDONLY)
  68. return;
  69. updateSuper(sb, FM_DIRTY);
  70. if (sbi->flag & JFS_ERR_PANIC)
  71. panic("JFS (device %s): panic forced after error\n",
  72. sb->s_id);
  73. else if (sbi->flag & JFS_ERR_REMOUNT_RO) {
  74. jfs_err("ERROR: (device %s): remounting filesystem "
  75. "as read-only\n",
  76. sb->s_id);
  77. sb->s_flags |= MS_RDONLY;
  78. }
  79. /* nothing is done for continue beyond marking the superblock dirty */
  80. }
  81. void jfs_error(struct super_block *sb, const char * function, ...)
  82. {
  83. static char error_buf[256];
  84. va_list args;
  85. va_start(args, function);
  86. vsnprintf(error_buf, sizeof(error_buf), function, args);
  87. va_end(args);
  88. pr_err("ERROR: (device %s): %s\n", sb->s_id, error_buf);
  89. jfs_handle_error(sb);
  90. }
  91. static struct inode *jfs_alloc_inode(struct super_block *sb)
  92. {
  93. struct jfs_inode_info *jfs_inode;
  94. jfs_inode = kmem_cache_alloc(jfs_inode_cachep, GFP_NOFS);
  95. if (!jfs_inode)
  96. return NULL;
  97. return &jfs_inode->vfs_inode;
  98. }
  99. static void jfs_i_callback(struct rcu_head *head)
  100. {
  101. struct inode *inode = container_of(head, struct inode, i_rcu);
  102. struct jfs_inode_info *ji = JFS_IP(inode);
  103. kmem_cache_free(jfs_inode_cachep, ji);
  104. }
  105. static void jfs_destroy_inode(struct inode *inode)
  106. {
  107. struct jfs_inode_info *ji = JFS_IP(inode);
  108. BUG_ON(!list_empty(&ji->anon_inode_list));
  109. spin_lock_irq(&ji->ag_lock);
  110. if (ji->active_ag != -1) {
  111. struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
  112. atomic_dec(&bmap->db_active[ji->active_ag]);
  113. ji->active_ag = -1;
  114. }
  115. spin_unlock_irq(&ji->ag_lock);
  116. call_rcu(&inode->i_rcu, jfs_i_callback);
  117. }
  118. static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
  119. {
  120. struct jfs_sb_info *sbi = JFS_SBI(dentry->d_sb);
  121. s64 maxinodes;
  122. struct inomap *imap = JFS_IP(sbi->ipimap)->i_imap;
  123. jfs_info("In jfs_statfs");
  124. buf->f_type = JFS_SUPER_MAGIC;
  125. buf->f_bsize = sbi->bsize;
  126. buf->f_blocks = sbi->bmap->db_mapsize;
  127. buf->f_bfree = sbi->bmap->db_nfree;
  128. buf->f_bavail = sbi->bmap->db_nfree;
  129. /*
  130. * If we really return the number of allocated & free inodes, some
  131. * applications will fail because they won't see enough free inodes.
  132. * We'll try to calculate some guess as to how many inodes we can
  133. * really allocate
  134. *
  135. * buf->f_files = atomic_read(&imap->im_numinos);
  136. * buf->f_ffree = atomic_read(&imap->im_numfree);
  137. */
  138. maxinodes = min((s64) atomic_read(&imap->im_numinos) +
  139. ((sbi->bmap->db_nfree >> imap->im_l2nbperiext)
  140. << L2INOSPEREXT), (s64) 0xffffffffLL);
  141. buf->f_files = maxinodes;
  142. buf->f_ffree = maxinodes - (atomic_read(&imap->im_numinos) -
  143. atomic_read(&imap->im_numfree));
  144. buf->f_fsid.val[0] = (u32)crc32_le(0, sbi->uuid, sizeof(sbi->uuid)/2);
  145. buf->f_fsid.val[1] = (u32)crc32_le(0, sbi->uuid + sizeof(sbi->uuid)/2,
  146. sizeof(sbi->uuid)/2);
  147. buf->f_namelen = JFS_NAME_MAX;
  148. return 0;
  149. }
  150. static void jfs_put_super(struct super_block *sb)
  151. {
  152. struct jfs_sb_info *sbi = JFS_SBI(sb);
  153. int rc;
  154. jfs_info("In jfs_put_super");
  155. dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
  156. rc = jfs_umount(sb);
  157. if (rc)
  158. jfs_err("jfs_umount failed with return code %d", rc);
  159. unload_nls(sbi->nls_tab);
  160. truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
  161. iput(sbi->direct_inode);
  162. kfree(sbi);
  163. }
  164. enum {
  165. Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
  166. Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
  167. Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
  168. Opt_discard, Opt_nodiscard, Opt_discard_minblk
  169. };
  170. static const match_table_t tokens = {
  171. {Opt_integrity, "integrity"},
  172. {Opt_nointegrity, "nointegrity"},
  173. {Opt_iocharset, "iocharset=%s"},
  174. {Opt_resize, "resize=%u"},
  175. {Opt_resize_nosize, "resize"},
  176. {Opt_errors, "errors=%s"},
  177. {Opt_ignore, "noquota"},
  178. {Opt_ignore, "quota"},
  179. {Opt_usrquota, "usrquota"},
  180. {Opt_grpquota, "grpquota"},
  181. {Opt_uid, "uid=%u"},
  182. {Opt_gid, "gid=%u"},
  183. {Opt_umask, "umask=%u"},
  184. {Opt_discard, "discard"},
  185. {Opt_nodiscard, "nodiscard"},
  186. {Opt_discard_minblk, "discard=%u"},
  187. {Opt_err, NULL}
  188. };
  189. static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
  190. int *flag)
  191. {
  192. void *nls_map = (void *)-1; /* -1: no change; NULL: none */
  193. char *p;
  194. struct jfs_sb_info *sbi = JFS_SBI(sb);
  195. *newLVSize = 0;
  196. if (!options)
  197. return 1;
  198. while ((p = strsep(&options, ",")) != NULL) {
  199. substring_t args[MAX_OPT_ARGS];
  200. int token;
  201. if (!*p)
  202. continue;
  203. token = match_token(p, tokens, args);
  204. switch (token) {
  205. case Opt_integrity:
  206. *flag &= ~JFS_NOINTEGRITY;
  207. break;
  208. case Opt_nointegrity:
  209. *flag |= JFS_NOINTEGRITY;
  210. break;
  211. case Opt_ignore:
  212. /* Silently ignore the quota options */
  213. /* Don't do anything ;-) */
  214. break;
  215. case Opt_iocharset:
  216. if (nls_map && nls_map != (void *) -1)
  217. unload_nls(nls_map);
  218. if (!strcmp(args[0].from, "none"))
  219. nls_map = NULL;
  220. else {
  221. nls_map = load_nls(args[0].from);
  222. if (!nls_map) {
  223. pr_err("JFS: charset not found\n");
  224. goto cleanup;
  225. }
  226. }
  227. break;
  228. case Opt_resize:
  229. {
  230. char *resize = args[0].from;
  231. *newLVSize = simple_strtoull(resize, &resize, 0);
  232. break;
  233. }
  234. case Opt_resize_nosize:
  235. {
  236. *newLVSize = sb->s_bdev->bd_inode->i_size >>
  237. sb->s_blocksize_bits;
  238. if (*newLVSize == 0)
  239. pr_err("JFS: Cannot determine volume size\n");
  240. break;
  241. }
  242. case Opt_errors:
  243. {
  244. char *errors = args[0].from;
  245. if (!errors || !*errors)
  246. goto cleanup;
  247. if (!strcmp(errors, "continue")) {
  248. *flag &= ~JFS_ERR_REMOUNT_RO;
  249. *flag &= ~JFS_ERR_PANIC;
  250. *flag |= JFS_ERR_CONTINUE;
  251. } else if (!strcmp(errors, "remount-ro")) {
  252. *flag &= ~JFS_ERR_CONTINUE;
  253. *flag &= ~JFS_ERR_PANIC;
  254. *flag |= JFS_ERR_REMOUNT_RO;
  255. } else if (!strcmp(errors, "panic")) {
  256. *flag &= ~JFS_ERR_CONTINUE;
  257. *flag &= ~JFS_ERR_REMOUNT_RO;
  258. *flag |= JFS_ERR_PANIC;
  259. } else {
  260. pr_err("JFS: %s is an invalid error handler\n",
  261. errors);
  262. goto cleanup;
  263. }
  264. break;
  265. }
  266. #ifdef CONFIG_QUOTA
  267. case Opt_quota:
  268. case Opt_usrquota:
  269. *flag |= JFS_USRQUOTA;
  270. break;
  271. case Opt_grpquota:
  272. *flag |= JFS_GRPQUOTA;
  273. break;
  274. #else
  275. case Opt_usrquota:
  276. case Opt_grpquota:
  277. case Opt_quota:
  278. pr_err("JFS: quota operations not supported\n");
  279. break;
  280. #endif
  281. case Opt_uid:
  282. {
  283. char *uid = args[0].from;
  284. uid_t val = simple_strtoul(uid, &uid, 0);
  285. sbi->uid = make_kuid(current_user_ns(), val);
  286. if (!uid_valid(sbi->uid))
  287. goto cleanup;
  288. break;
  289. }
  290. case Opt_gid:
  291. {
  292. char *gid = args[0].from;
  293. gid_t val = simple_strtoul(gid, &gid, 0);
  294. sbi->gid = make_kgid(current_user_ns(), val);
  295. if (!gid_valid(sbi->gid))
  296. goto cleanup;
  297. break;
  298. }
  299. case Opt_umask:
  300. {
  301. char *umask = args[0].from;
  302. sbi->umask = simple_strtoul(umask, &umask, 8);
  303. if (sbi->umask & ~0777) {
  304. pr_err("JFS: Invalid value of umask\n");
  305. goto cleanup;
  306. }
  307. break;
  308. }
  309. case Opt_discard:
  310. {
  311. struct request_queue *q = bdev_get_queue(sb->s_bdev);
  312. /* if set to 1, even copying files will cause
  313. * trimming :O
  314. * -> user has more control over the online trimming
  315. */
  316. sbi->minblks_trim = 64;
  317. if (blk_queue_discard(q)) {
  318. *flag |= JFS_DISCARD;
  319. } else {
  320. pr_err("JFS: discard option " \
  321. "not supported on device\n");
  322. }
  323. break;
  324. }
  325. case Opt_nodiscard:
  326. *flag &= ~JFS_DISCARD;
  327. break;
  328. case Opt_discard_minblk:
  329. {
  330. struct request_queue *q = bdev_get_queue(sb->s_bdev);
  331. char *minblks_trim = args[0].from;
  332. if (blk_queue_discard(q)) {
  333. *flag |= JFS_DISCARD;
  334. sbi->minblks_trim = simple_strtoull(
  335. minblks_trim, &minblks_trim, 0);
  336. } else {
  337. pr_err("JFS: discard option " \
  338. "not supported on device\n");
  339. }
  340. break;
  341. }
  342. default:
  343. printk("jfs: Unrecognized mount option \"%s\" "
  344. " or missing value\n", p);
  345. goto cleanup;
  346. }
  347. }
  348. if (nls_map != (void *) -1) {
  349. /* Discard old (if remount) */
  350. unload_nls(sbi->nls_tab);
  351. sbi->nls_tab = nls_map;
  352. }
  353. return 1;
  354. cleanup:
  355. if (nls_map && nls_map != (void *) -1)
  356. unload_nls(nls_map);
  357. return 0;
  358. }
  359. static int jfs_remount(struct super_block *sb, int *flags, char *data)
  360. {
  361. s64 newLVSize = 0;
  362. int rc = 0;
  363. int flag = JFS_SBI(sb)->flag;
  364. int ret;
  365. if (!parse_options(data, sb, &newLVSize, &flag)) {
  366. return -EINVAL;
  367. }
  368. if (newLVSize) {
  369. if (sb->s_flags & MS_RDONLY) {
  370. pr_err("JFS: resize requires volume" \
  371. " to be mounted read-write\n");
  372. return -EROFS;
  373. }
  374. rc = jfs_extendfs(sb, newLVSize, 0);
  375. if (rc)
  376. return rc;
  377. }
  378. if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
  379. /*
  380. * Invalidate any previously read metadata. fsck may have
  381. * changed the on-disk data since we mounted r/o
  382. */
  383. truncate_inode_pages(JFS_SBI(sb)->direct_inode->i_mapping, 0);
  384. JFS_SBI(sb)->flag = flag;
  385. ret = jfs_mount_rw(sb, 1);
  386. /* mark the fs r/w for quota activity */
  387. sb->s_flags &= ~MS_RDONLY;
  388. dquot_resume(sb, -1);
  389. return ret;
  390. }
  391. if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) {
  392. rc = dquot_suspend(sb, -1);
  393. if (rc < 0) {
  394. return rc;
  395. }
  396. rc = jfs_umount_rw(sb);
  397. JFS_SBI(sb)->flag = flag;
  398. return rc;
  399. }
  400. if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY))
  401. if (!(sb->s_flags & MS_RDONLY)) {
  402. rc = jfs_umount_rw(sb);
  403. if (rc)
  404. return rc;
  405. JFS_SBI(sb)->flag = flag;
  406. ret = jfs_mount_rw(sb, 1);
  407. return ret;
  408. }
  409. JFS_SBI(sb)->flag = flag;
  410. return 0;
  411. }
  412. static int jfs_fill_super(struct super_block *sb, void *data, int silent)
  413. {
  414. struct jfs_sb_info *sbi;
  415. struct inode *inode;
  416. int rc;
  417. s64 newLVSize = 0;
  418. int flag, ret = -EINVAL;
  419. jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags);
  420. if (!new_valid_dev(sb->s_bdev->bd_dev))
  421. return -EOVERFLOW;
  422. sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL);
  423. if (!sbi)
  424. return -ENOMEM;
  425. sb->s_fs_info = sbi;
  426. sb->s_max_links = JFS_LINK_MAX;
  427. sbi->sb = sb;
  428. sbi->uid = INVALID_UID;
  429. sbi->gid = INVALID_GID;
  430. sbi->umask = -1;
  431. /* initialize the mount flag and determine the default error handler */
  432. flag = JFS_ERR_REMOUNT_RO;
  433. if (!parse_options((char *) data, sb, &newLVSize, &flag))
  434. goto out_kfree;
  435. sbi->flag = flag;
  436. #ifdef CONFIG_JFS_POSIX_ACL
  437. sb->s_flags |= MS_POSIXACL;
  438. #endif
  439. if (newLVSize) {
  440. pr_err("resize option for remount only\n");
  441. goto out_kfree;
  442. }
  443. /*
  444. * Initialize blocksize to 4K.
  445. */
  446. sb_set_blocksize(sb, PSIZE);
  447. /*
  448. * Set method vectors.
  449. */
  450. sb->s_op = &jfs_super_operations;
  451. sb->s_export_op = &jfs_export_operations;
  452. #ifdef CONFIG_QUOTA
  453. sb->dq_op = &dquot_operations;
  454. sb->s_qcop = &dquot_quotactl_ops;
  455. #endif
  456. /*
  457. * Initialize direct-mapping inode/address-space
  458. */
  459. inode = new_inode(sb);
  460. if (inode == NULL) {
  461. ret = -ENOMEM;
  462. goto out_unload;
  463. }
  464. inode->i_ino = 0;
  465. inode->i_size = sb->s_bdev->bd_inode->i_size;
  466. inode->i_mapping->a_ops = &jfs_metapage_aops;
  467. insert_inode_hash(inode);
  468. mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
  469. sbi->direct_inode = inode;
  470. rc = jfs_mount(sb);
  471. if (rc) {
  472. if (!silent) {
  473. jfs_err("jfs_mount failed w/return code = %d", rc);
  474. }
  475. goto out_mount_failed;
  476. }
  477. if (sb->s_flags & MS_RDONLY)
  478. sbi->log = NULL;
  479. else {
  480. rc = jfs_mount_rw(sb, 0);
  481. if (rc) {
  482. if (!silent) {
  483. jfs_err("jfs_mount_rw failed, return code = %d",
  484. rc);
  485. }
  486. goto out_no_rw;
  487. }
  488. }
  489. sb->s_magic = JFS_SUPER_MAGIC;
  490. if (sbi->mntflag & JFS_OS2)
  491. sb->s_d_op = &jfs_ci_dentry_operations;
  492. inode = jfs_iget(sb, ROOT_I);
  493. if (IS_ERR(inode)) {
  494. ret = PTR_ERR(inode);
  495. goto out_no_rw;
  496. }
  497. sb->s_root = d_make_root(inode);
  498. if (!sb->s_root)
  499. goto out_no_root;
  500. /* logical blocks are represented by 40 bits in pxd_t, etc. */
  501. sb->s_maxbytes = ((u64) sb->s_blocksize) << 40;
  502. #if BITS_PER_LONG == 32
  503. /*
  504. * Page cache is indexed by long.
  505. * I would use MAX_LFS_FILESIZE, but it's only half as big
  506. */
  507. sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, (u64)sb->s_maxbytes);
  508. #endif
  509. sb->s_time_gran = 1;
  510. return 0;
  511. out_no_root:
  512. jfs_err("jfs_read_super: get root dentry failed");
  513. out_no_rw:
  514. rc = jfs_umount(sb);
  515. if (rc) {
  516. jfs_err("jfs_umount failed with return code %d", rc);
  517. }
  518. out_mount_failed:
  519. filemap_write_and_wait(sbi->direct_inode->i_mapping);
  520. truncate_inode_pages(sbi->direct_inode->i_mapping, 0);
  521. make_bad_inode(sbi->direct_inode);
  522. iput(sbi->direct_inode);
  523. sbi->direct_inode = NULL;
  524. out_unload:
  525. if (sbi->nls_tab)
  526. unload_nls(sbi->nls_tab);
  527. out_kfree:
  528. kfree(sbi);
  529. return ret;
  530. }
  531. static int jfs_freeze(struct super_block *sb)
  532. {
  533. struct jfs_sb_info *sbi = JFS_SBI(sb);
  534. struct jfs_log *log = sbi->log;
  535. if (!(sb->s_flags & MS_RDONLY)) {
  536. txQuiesce(sb);
  537. lmLogShutdown(log);
  538. updateSuper(sb, FM_CLEAN);
  539. }
  540. return 0;
  541. }
  542. static int jfs_unfreeze(struct super_block *sb)
  543. {
  544. struct jfs_sb_info *sbi = JFS_SBI(sb);
  545. struct jfs_log *log = sbi->log;
  546. int rc = 0;
  547. if (!(sb->s_flags & MS_RDONLY)) {
  548. updateSuper(sb, FM_MOUNT);
  549. if ((rc = lmLogInit(log)))
  550. jfs_err("jfs_unlock failed with return code %d", rc);
  551. else
  552. txResume(sb);
  553. }
  554. return 0;
  555. }
  556. static struct dentry *jfs_do_mount(struct file_system_type *fs_type,
  557. int flags, const char *dev_name, void *data)
  558. {
  559. return mount_bdev(fs_type, flags, dev_name, data, jfs_fill_super);
  560. }
  561. static int jfs_sync_fs(struct super_block *sb, int wait)
  562. {
  563. struct jfs_log *log = JFS_SBI(sb)->log;
  564. /* log == NULL indicates read-only mount */
  565. if (log) {
  566. /*
  567. * Write quota structures to quota file, sync_blockdev() will
  568. * write them to disk later
  569. */
  570. dquot_writeback_dquots(sb, -1);
  571. jfs_flush_journal(log, wait);
  572. jfs_syncpt(log, 0);
  573. }
  574. return 0;
  575. }
  576. static int jfs_show_options(struct seq_file *seq, struct dentry *root)
  577. {
  578. struct jfs_sb_info *sbi = JFS_SBI(root->d_sb);
  579. if (uid_valid(sbi->uid))
  580. seq_printf(seq, ",uid=%d", from_kuid(&init_user_ns, sbi->uid));
  581. if (gid_valid(sbi->gid))
  582. seq_printf(seq, ",gid=%d", from_kgid(&init_user_ns, sbi->gid));
  583. if (sbi->umask != -1)
  584. seq_printf(seq, ",umask=%03o", sbi->umask);
  585. if (sbi->flag & JFS_NOINTEGRITY)
  586. seq_puts(seq, ",nointegrity");
  587. if (sbi->flag & JFS_DISCARD)
  588. seq_printf(seq, ",discard=%u", sbi->minblks_trim);
  589. if (sbi->nls_tab)
  590. seq_printf(seq, ",iocharset=%s", sbi->nls_tab->charset);
  591. if (sbi->flag & JFS_ERR_CONTINUE)
  592. seq_printf(seq, ",errors=continue");
  593. if (sbi->flag & JFS_ERR_PANIC)
  594. seq_printf(seq, ",errors=panic");
  595. #ifdef CONFIG_QUOTA
  596. if (sbi->flag & JFS_USRQUOTA)
  597. seq_puts(seq, ",usrquota");
  598. if (sbi->flag & JFS_GRPQUOTA)
  599. seq_puts(seq, ",grpquota");
  600. #endif
  601. return 0;
  602. }
  603. #ifdef CONFIG_QUOTA
  604. /* Read data from quotafile - avoid pagecache and such because we cannot afford
  605. * acquiring the locks... As quota files are never truncated and quota code
  606. * itself serializes the operations (and no one else should touch the files)
  607. * we don't have to be afraid of races */
  608. static ssize_t jfs_quota_read(struct super_block *sb, int type, char *data,
  609. size_t len, loff_t off)
  610. {
  611. struct inode *inode = sb_dqopt(sb)->files[type];
  612. sector_t blk = off >> sb->s_blocksize_bits;
  613. int err = 0;
  614. int offset = off & (sb->s_blocksize - 1);
  615. int tocopy;
  616. size_t toread;
  617. struct buffer_head tmp_bh;
  618. struct buffer_head *bh;
  619. loff_t i_size = i_size_read(inode);
  620. if (off > i_size)
  621. return 0;
  622. if (off+len > i_size)
  623. len = i_size-off;
  624. toread = len;
  625. while (toread > 0) {
  626. tocopy = sb->s_blocksize - offset < toread ?
  627. sb->s_blocksize - offset : toread;
  628. tmp_bh.b_state = 0;
  629. tmp_bh.b_size = 1 << inode->i_blkbits;
  630. err = jfs_get_block(inode, blk, &tmp_bh, 0);
  631. if (err)
  632. return err;
  633. if (!buffer_mapped(&tmp_bh)) /* A hole? */
  634. memset(data, 0, tocopy);
  635. else {
  636. bh = sb_bread(sb, tmp_bh.b_blocknr);
  637. if (!bh)
  638. return -EIO;
  639. memcpy(data, bh->b_data+offset, tocopy);
  640. brelse(bh);
  641. }
  642. offset = 0;
  643. toread -= tocopy;
  644. data += tocopy;
  645. blk++;
  646. }
  647. return len;
  648. }
  649. /* Write to quotafile */
  650. static ssize_t jfs_quota_write(struct super_block *sb, int type,
  651. const char *data, size_t len, loff_t off)
  652. {
  653. struct inode *inode = sb_dqopt(sb)->files[type];
  654. sector_t blk = off >> sb->s_blocksize_bits;
  655. int err = 0;
  656. int offset = off & (sb->s_blocksize - 1);
  657. int tocopy;
  658. size_t towrite = len;
  659. struct buffer_head tmp_bh;
  660. struct buffer_head *bh;
  661. mutex_lock(&inode->i_mutex);
  662. while (towrite > 0) {
  663. tocopy = sb->s_blocksize - offset < towrite ?
  664. sb->s_blocksize - offset : towrite;
  665. tmp_bh.b_state = 0;
  666. tmp_bh.b_size = 1 << inode->i_blkbits;
  667. err = jfs_get_block(inode, blk, &tmp_bh, 1);
  668. if (err)
  669. goto out;
  670. if (offset || tocopy != sb->s_blocksize)
  671. bh = sb_bread(sb, tmp_bh.b_blocknr);
  672. else
  673. bh = sb_getblk(sb, tmp_bh.b_blocknr);
  674. if (!bh) {
  675. err = -EIO;
  676. goto out;
  677. }
  678. lock_buffer(bh);
  679. memcpy(bh->b_data+offset, data, tocopy);
  680. flush_dcache_page(bh->b_page);
  681. set_buffer_uptodate(bh);
  682. mark_buffer_dirty(bh);
  683. unlock_buffer(bh);
  684. brelse(bh);
  685. offset = 0;
  686. towrite -= tocopy;
  687. data += tocopy;
  688. blk++;
  689. }
  690. out:
  691. if (len == towrite) {
  692. mutex_unlock(&inode->i_mutex);
  693. return err;
  694. }
  695. if (inode->i_size < off+len-towrite)
  696. i_size_write(inode, off+len-towrite);
  697. inode->i_version++;
  698. inode->i_mtime = inode->i_ctime = CURRENT_TIME;
  699. mark_inode_dirty(inode);
  700. mutex_unlock(&inode->i_mutex);
  701. return len - towrite;
  702. }
  703. #endif
  704. static const struct super_operations jfs_super_operations = {
  705. .alloc_inode = jfs_alloc_inode,
  706. .destroy_inode = jfs_destroy_inode,
  707. .dirty_inode = jfs_dirty_inode,
  708. .write_inode = jfs_write_inode,
  709. .evict_inode = jfs_evict_inode,
  710. .put_super = jfs_put_super,
  711. .sync_fs = jfs_sync_fs,
  712. .freeze_fs = jfs_freeze,
  713. .unfreeze_fs = jfs_unfreeze,
  714. .statfs = jfs_statfs,
  715. .remount_fs = jfs_remount,
  716. .show_options = jfs_show_options,
  717. #ifdef CONFIG_QUOTA
  718. .quota_read = jfs_quota_read,
  719. .quota_write = jfs_quota_write,
  720. #endif
  721. };
  722. static const struct export_operations jfs_export_operations = {
  723. .fh_to_dentry = jfs_fh_to_dentry,
  724. .fh_to_parent = jfs_fh_to_parent,
  725. .get_parent = jfs_get_parent,
  726. };
  727. static struct file_system_type jfs_fs_type = {
  728. .owner = THIS_MODULE,
  729. .name = "jfs",
  730. .mount = jfs_do_mount,
  731. .kill_sb = kill_block_super,
  732. .fs_flags = FS_REQUIRES_DEV,
  733. };
  734. MODULE_ALIAS_FS("jfs");
  735. static void init_once(void *foo)
  736. {
  737. struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
  738. memset(jfs_ip, 0, sizeof(struct jfs_inode_info));
  739. INIT_LIST_HEAD(&jfs_ip->anon_inode_list);
  740. init_rwsem(&jfs_ip->rdwrlock);
  741. mutex_init(&jfs_ip->commit_mutex);
  742. init_rwsem(&jfs_ip->xattr_sem);
  743. spin_lock_init(&jfs_ip->ag_lock);
  744. jfs_ip->active_ag = -1;
  745. inode_init_once(&jfs_ip->vfs_inode);
  746. }
  747. static int __init init_jfs_fs(void)
  748. {
  749. int i;
  750. int rc;
  751. jfs_inode_cachep =
  752. kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
  753. SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
  754. init_once);
  755. if (jfs_inode_cachep == NULL)
  756. return -ENOMEM;
  757. /*
  758. * Metapage initialization
  759. */
  760. rc = metapage_init();
  761. if (rc) {
  762. jfs_err("metapage_init failed w/rc = %d", rc);
  763. goto free_slab;
  764. }
  765. /*
  766. * Transaction Manager initialization
  767. */
  768. rc = txInit();
  769. if (rc) {
  770. jfs_err("txInit failed w/rc = %d", rc);
  771. goto free_metapage;
  772. }
  773. /*
  774. * I/O completion thread (endio)
  775. */
  776. jfsIOthread = kthread_run(jfsIOWait, NULL, "jfsIO");
  777. if (IS_ERR(jfsIOthread)) {
  778. rc = PTR_ERR(jfsIOthread);
  779. jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
  780. goto end_txmngr;
  781. }
  782. if (commit_threads < 1)
  783. commit_threads = num_online_cpus();
  784. if (commit_threads > MAX_COMMIT_THREADS)
  785. commit_threads = MAX_COMMIT_THREADS;
  786. for (i = 0; i < commit_threads; i++) {
  787. jfsCommitThread[i] = kthread_run(jfs_lazycommit, NULL, "jfsCommit");
  788. if (IS_ERR(jfsCommitThread[i])) {
  789. rc = PTR_ERR(jfsCommitThread[i]);
  790. jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
  791. commit_threads = i;
  792. goto kill_committask;
  793. }
  794. }
  795. jfsSyncThread = kthread_run(jfs_sync, NULL, "jfsSync");
  796. if (IS_ERR(jfsSyncThread)) {
  797. rc = PTR_ERR(jfsSyncThread);
  798. jfs_err("init_jfs_fs: fork failed w/rc = %d", rc);
  799. goto kill_committask;
  800. }
  801. #ifdef PROC_FS_JFS
  802. jfs_proc_init();
  803. #endif
  804. rc = register_filesystem(&jfs_fs_type);
  805. if (!rc)
  806. return 0;
  807. #ifdef PROC_FS_JFS
  808. jfs_proc_clean();
  809. #endif
  810. kthread_stop(jfsSyncThread);
  811. kill_committask:
  812. for (i = 0; i < commit_threads; i++)
  813. kthread_stop(jfsCommitThread[i]);
  814. kthread_stop(jfsIOthread);
  815. end_txmngr:
  816. txExit();
  817. free_metapage:
  818. metapage_exit();
  819. free_slab:
  820. kmem_cache_destroy(jfs_inode_cachep);
  821. return rc;
  822. }
  823. static void __exit exit_jfs_fs(void)
  824. {
  825. int i;
  826. jfs_info("exit_jfs_fs called");
  827. txExit();
  828. metapage_exit();
  829. kthread_stop(jfsIOthread);
  830. for (i = 0; i < commit_threads; i++)
  831. kthread_stop(jfsCommitThread[i]);
  832. kthread_stop(jfsSyncThread);
  833. #ifdef PROC_FS_JFS
  834. jfs_proc_clean();
  835. #endif
  836. unregister_filesystem(&jfs_fs_type);
  837. /*
  838. * Make sure all delayed rcu free inodes are flushed before we
  839. * destroy cache.
  840. */
  841. rcu_barrier();
  842. kmem_cache_destroy(jfs_inode_cachep);
  843. }
  844. module_init(init_jfs_fs)
  845. module_exit(exit_jfs_fs)