aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/ext2fs/ext2_alloc.c
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove ancient SCCS tags.Warner Losh2023-11-271-2/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Fix block bitmap end position computationFedor Uporov2023-01-291-1/+1
| | | | | | PR: 261850 Reported by: chenguang.wang MFC after: 2 weeks
* vfs: add the concept of vnode state transitionsMateusz Guzik2022-12-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | To quote from a comment above vput_final: <quote> * XXX Some filesystems pass in an exclusively locked vnode and strongly depend * on the lock being held all the way until VOP_INACTIVE. This in particular * happens with UFS which adds half-constructed vnodes to the hash, where they * can be found by other code. </quote> As is there is no mechanism which allows filesystems to denote that a vnode is fully initialized, consequently problems like the above are only found the hard way(tm). Add rudimentary support for state transitions, which in particular allow to assert the vnode is not legally unlocked until its fate is decided (either construction finishes or vgone is called to abort it). The new field lands in a 1-byte hole, thus it does not grow the struct. Bump __FreeBSD_version to 1400077 Reviewed by: kib (previous version) Tested by: pho Differential Revision: https://reviews.freebsd.org/D37759
* fs: fix a few common typos in source code commentsGordon Bergling2022-02-061-3/+3
| | | | | | | | - s/quadradically/quadratically/ - s/persistant/persistent/ Obtained from: NetBSD MFC after: 3 days
* ext2fs: minor typo.Pedro F. Giffuni2020-10-061-1/+1
| | | | | | | | Obtained from: Dragonfly MFC after: 3 days Notes: svn path=/head/; revision=366501
* fs: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-2/+0
| | | | Notes: svn path=/head/; revision=365070
* ext2fs: Stop checking for failures from malloc(M_WAITOK).Mark Johnston2020-07-201-3/+0
| | | | | | | | | | | PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> Reviewed by: fsu MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25707 Notes: svn path=/head/; revision=363367
* Add BE architectures support.Fedor Uporov2020-05-171-71/+84
| | | | | | | | | | | | Author of most initial version: pfg (https://reviews.freebsd.org/D23259) Reviewed by: pfg MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D24685 Notes: svn path=/head/; revision=361136
* Add inode bitmap tail initialization.Fedor Uporov2020-05-171-2/+15
| | | | | | | | | | Make ext2fs compatible with changes introduced in e2fsprogs v1.45.2. Now the tail of inode bitmap is filled with 0xff pattern explicitly during bitmap initialization phase to avoid e2fsck error like: "Padding at end of inode bitmap is not set." Notes: svn path=/head/; revision=361133
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* ext2fs: Remove redundant brelse() after r294954Conrad Meyer2019-09-061-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Coccinelle: @ rule1 @ identifier __error; @@ ... int __error; ... @ rule2 depends on rule1 @ identifier rule1.__error; identifier __bp; @@ __error = ( bread | bread_gb | breadn | breadn_flags ) (..., &__bp); if ( ( __error | __error != 0 ) ) { ... - brelse(__bp); ... } No functional change. Notes: svn path=/head/; revision=351926
* ext2fs: Initial version of DTrace support.Fedor Uporov2019-04-161-49/+41
| | | | | | | | | | Reviewed by: pfg, gnn MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19848 Notes: svn path=/head/; revision=346267
* Remove unneeded mount point unlock function calls.Fedor Uporov2019-03-151-7/+1
| | | | | | | | | | | | | The ext2_nodealloccg() function unlocks the mount point in case of successful node allocation. The additional unlocks are not required and should be removed. PR: 236452 Reported by: pho MFC after: 3 days Notes: svn path=/head/; revision=345179
* Do not read the on-disk inode in case of vnode allocation.Fedor Uporov2019-03-041-20/+58
| | | | | | | | | | | | Reported by: Christopher Krah <krah@protonmail.com> Reported as: FS-6-EXT2-4: Denial Of Service in mkdir-0 (ext2_mkdir/vn_rdwr) Reviewed by: pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19327 Notes: svn path=/head/; revision=344756
* Do not panic if inode bitmap is corrupted.Fedor Uporov2019-03-041-3/+5
| | | | | | | | | | | | admbug: 804 Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com> Reviewed by: pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19325 Notes: svn path=/head/; revision=344754
* Validate block bitmaps.Fedor Uporov2019-03-041-29/+75
| | | | | | | | | | Reviewed by: pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19324 Notes: svn path=/head/; revision=344753
* Make superblock reading logic more strict.Fedor Uporov2019-03-041-5/+5
| | | | | | | | | | | | | Add more on-disk superblock consistency checks to ext2_compute_sb_data() function. It should decrease the probability of mounting filesystems with corrupted superblock data. Reviewed by: pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19322 Notes: svn path=/head/; revision=344751
* Change unused inodes counters behavior in the cylinder groups.Fedor Uporov2018-08-211-8/+7
| | | | | | | Make it more close to native ext4 implementation to avoid fsck errors. Notes: svn path=/head/; revision=338151
* Fix EXT2FS_DEBUG definition usage.Fedor Uporov2018-05-131-2/+2
| | | | | | | | | | Reviewed by: pfg MFC after: 3 months Differential Revision: https://reviews.freebsd.org/D15394 Notes: svn path=/head/; revision=333584
* Revert r313780 (UFS_ prefix)Ed Maste2018-03-171-3/+3
| | | | Notes: svn path=/head/; revision=331095
* Prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2018-03-171-3/+3
| | | | | | | | | | | | | Followup to r313780. Also prefix ext2's and nandfs's versions with EXT2_ and NANDFS_. Reported by: kib Reviewed by: kib, mckusick Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9623 Notes: svn path=/head/; revision=331083
* Add flex_bg/meta_bg features RW support.Fedor Uporov2018-01-291-29/+62
| | | | | | | | | | Reviewed by: pfg MFC after: 6 months Differential Revision: https://reviews.freebsd.org/D13964 Notes: svn path=/head/; revision=328564
* Add metadata_csum feature support.Fedor Uporov2018-01-141-4/+26
| | | | | | | | | | | Reviewed by: pfg (mentor) Approved by: pfg (mentor) MFC after: 6 months Differential Revision: https://reviews.freebsd.org/D13810 Notes: svn path=/head/; revision=327977
* Add 64bit feature support.Fedor Uporov2018-01-051-73/+159
| | | | | | | | | | | Reviewed by: kevlo, pfg (mentor) Approved by: pfg (mentor) MFC after: 6 months Differential Revision: https://reviews.freebsd.org/D11530 Notes: svn path=/head/; revision=327584
* sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326023
* Fix physical block number overflow in different places.Fedor Uporov2017-10-241-7/+7
| | | | | | | | Approved by: pfg (mentor) MFC after: 6 months Notes: svn path=/head/; revision=324963
* Set doreallocblks sysctl value to zero by default because ofFedor Uporov2017-10-241-1/+1
| | | | | | | | | | possibility of filesystem corruption. Approved by: pfg (mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=324962
* Add inital extents read-write support.Fedor Uporov2017-10-171-15/+19
| | | | | | | | | | | Approved by: pfg (mentor) MFC after: 6 months RelNotes: Yes Differential Revision: https://reviews.freebsd.org/D12087 Notes: svn path=/head/; revision=324706
* Add check to avoid raw inode iblocks fields overflow in case of huge_file ↵Fedor Uporov2017-09-271-2/+1
| | | | | | | | | | | | | | feature. Use the Linux logic for now. Reviewed by: pfg (mentor) Approved by: pfg (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12131 Notes: svn path=/head/; revision=324064
* ext2fs: Add uninit_bg feature support.Pedro F. Giffuni2017-06-201-7/+211
| | | | | | | | | | | | | | | From the linux tune2fs(8) manpage: "Allow the kernel to initialize bitmaps and inode tables and keep a high watermark for the unused inodes in a filesystem, to reduce e2fsck(8) time. This first e2fsck run after enabling this feature will take the full time, but subsequent e2fsck runs will take only a fraction of the original time, depending on how full the file system is." Submitted by: Fedor Uporov Differential Revision: https://reviews.freebsd.org/D11211 Notes: svn path=/head/; revision=320145
* ext2fs: add read-write support for Extended Attributes.Pedro F. Giffuni2017-05-031-0/+19
| | | | | | | | | | | | | | | | | Extended attributes and their particular implementation in linux are different from FreeBSD so in this case we have started diverging from the UFS EA implementation, which would be the natural reference. Depending on future progress implementing ACLs this approach may change but for now bring to the tree an implementation that is consistent and can be tested. Submitted by: Fedor Uporov Differential Revision: https://reviews.freebsd.org/D10460 Notes: svn path=/head/; revision=317779
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-151-4/+4
| | | | | | | | | | | | | | | | | | | | | Specifically: ROOTINO -> UFS_ROOTINO WINO -> UFS_WINO NXADDR -> UFS_NXADDR NDADDR -> UFS_NDADDR NIADDR -> UFS_NIADDR MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency) Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_ Reviewed by: kib, mckusick Obtained from: NetBSD MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9536 Notes: svn path=/head/; revision=313780
* Undo small wrong style change.Pedro F. Giffuni2016-12-281-1/+1
| | | | | | | Reported by: kib Notes: svn path=/head/; revision=310706
* style(9) cleanups.Pedro F. Giffuni2016-12-281-65/+70
| | | | | | | | | Just to reduce some of the issues found with indent(1). MFC after: 1 week Notes: svn path=/head/; revision=310705
* ext2fs: renumber the license clauses to avoid skipping #3.Pedro F. Giffuni2016-12-021-1/+1
| | | | | | | | | | This is to keep consistency with other files, and help license-checking utilities determine the number of clauses that apply. No functional change. Notes: svn path=/head/; revision=309439
* ext2fs: cleanup generation number management.Pedro F. Giffuni2016-06-071-1/+3
| | | | | | | | | | | | | | | | | Ext2/3/4 manages generation numbers differently than UFS so adopt some rules that should work well. When allocating a new inode, make sure we generate a "good" random value specifically avoiding zero. Don't interfere with the numbers that are already generated in the filesystem: ext2fs doesn't have the backwards compatibility issues where there were no generation numbers. Reviewed by: kevlo MFC after: 1 week Notes: svn path=/head/; revision=301548
* arc4random() returns 0 to (2**32)−1, use an alternative to initializeKevin Lo2016-05-221-1/+2
| | | | | | | | | | | i_gen if it's zero rather than a divide by 2. With inputs from delphij, mckusick, rmacklem Reviewed by: mckusick Notes: svn path=/head/; revision=300423
* ext2fs: replace 0 with NULL for pointers.Pedro F. Giffuni2016-04-111-1/+2
| | | | | | | | | | | | While here do late initialization of ebap, similar as was done in UFS. Found with devel/coccinelle. MFC after: 2 weeks Notes: svn path=/head/; revision=297796
* Update comment: Linux does set a randomized generation number of an inodeKevin Lo2016-04-011-3/+1
| | | | | | | | | | | | on ext2/3/4. While here use arc4random() instead of random(). Reviewed by: pfg MFC after: 3 days Notes: svn path=/head/; revision=297479
* ext2: Initialize i_flag after allocation.Pedro F. Giffuni2016-01-241-0/+1
| | | | | | | | | | | | | | | | | We use i_flag to carry some flags like IN_E4INDEX which newer ext2fs variants uses internally. fsck.ext3 rightfully complains after our implementation tags non-directory inodes with INDEX_FL. Initializing i_flag during allocation removes the noise factor and quiets down fsck. Patch from: Damjan Jovanovic PR: 206530 Notes: svn path=/head/; revision=294652
* Remove dead code.Pedro F. Giffuni2015-01-181-6/+3
| | | | | | | | | | | | | | After the ext2 variant of the "orlov allocator" was implemented, the case for a negative or zero dirsize disappeared. Drop the dead code and unsign dirsize given that it can't be negative anyways. CID: 1008669 MFC after: 1 week Notes: svn path=/head/; revision=277340
* Adjust printf format specifiers for dev_t and ino_t in kernel.Gleb Kurtsou2014-12-171-4/+4
| | | | | | | | | ino_t and dev_t are about to become uint64_t. Reviewed by: kib, mckusick Notes: svn path=/head/; revision=275856
* Revert r263449;Pedro F. Giffuni2014-03-211-18/+2
| | | | | | | | | | | | ext2fs: minor update to the dirpref policy. The change in UFS r254996, reverted the change as the older code seems to work better. This was not visible in local testing but we can trust UFS is vastly more exercised in diferent environments. Notes: svn path=/head/; revision=263463
* ext2fs: minor update to the dirpref policy.Pedro F. Giffuni2014-03-201-2/+18
| | | | | | | | | | | | | Bring in a minor change to the dirpref policy based on r248623. This is pretty minimal change to keep the implementation in sync with UFS but other parts from the original change are not directly applicable so don't expect improvements in fsck times. MFC after: 2 weeks Notes: svn path=/head/; revision=263449
* ext2fs: small formatting fixes.Pedro F. Giffuni2014-03-011-1/+1
| | | | | | | | | | Remove some redundant spaces. No functional change. MFC after: 3 days Notes: svn path=/head/; revision=262667
* ext2fs: use of tab vs spaces.Pedro F. Giffuni2014-02-281-51/+51
| | | | | | | | | | | | | Consistently use a single tab after a #define as mentioned in style(9). Use tabs instead of space for indenting. Fix a typo: "hash_vesion". No functional change. MFC after: 3 days Notes: svn path=/head/; revision=262623
* ext2fs: Re-enable reallocblk.Pedro F. Giffuni2014-01-241-2/+2
| | | | | | | | | | The major corruption issues affecting this code have been fixed a while ago. MFC after: 1 week Notes: svn path=/head/; revision=261136
* Define ext2fs local types and use them.Pedro F. Giffuni2013-08-131-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | Add definitions for e2fs_daddr_t, e4fs_daddr_t in addition to the already existing e2fs_lbn_t and adjust them for ext4. Other than making the code more readable these changes should fix problems related to big filesystems. Setting the proper types can be tricky so the process was helped by looking at UFS. In our implementation, logical block numbers can be negative and the code depends on it. In ext2, block numbers are unsigned so it is convenient to keep e2fs_daddr_t unsigned and use the complete 32 bits. In the case of e4fs_daddr_t, while the value should be unsigned, for ext4 we only need to support 48 bits so preserving an extra bit from the sign is not an issue. While here also drop the ext2_setblock() prototype that was never used. Discussed with: mckusick, bde MFC after: 3 weeks Notes: svn path=/head/; revision=254283
* Define and use e2fs_lbn_t in ext2fs.Pedro F. Giffuni2013-06-231-2/+3
| | | | | | | | | | | | | | | | | | | | | In line to what is done in UFS, define an internal type e2fs_lbn_t for the logical block numbers. This change is basically a no-op as the new type is unchanged (int32_t) but it may be useful as bumping this may be required for ext4fs. Also, as pointed out by Bruce Evans: -Use daddr_t for daddr in ext2_bmaparray(). This seems to improve reliability with the reallocblks option. - Add a cast to the fsbtodb() macro as in UFS. Reviewed by: bde MFC after: 3 days Notes: svn path=/head/; revision=252103