History log of /freebsd-current/sys/fs/ext2fs/ext2_vfsops.c
Revision Date Author Comments
# 56a8aca8 18-May-2024 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Stop treating size 0 as unknown size in vnode_create_vobject().

Whenever file is created, the vnode_create_vobject() function will
try to determine its size by calling vn_getsize_locked() as size 0
is ambigious: it means either the file size is 0 or the file size
is unknown.

Introduce special value for the size argument: VNODE_NO_SIZE.
Only when it is given, the vnode_create_vobject() will try to obtain
file's size on its own.

Introduce dedicated vnode_disk_create_vobject() for use by
g_vfs_open(), so we don't have to call vn_isdisk() in the common case
(for regular files).

Handle the case of mediasize==0 in g_vfs_open().

Reviewed by: alc, kib, markj, olce
Approved by: oshogbo (mentor), allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D45244


# 29363fb4 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove ancient SCCS tags.

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


# 2ff63af9 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .h pattern

Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/


# 50be18cc 08-May-2023 Fedor Uporov <fsu@FreeBSD.org>

ext2fs: Add large sectorsize disks support

The ext2fs does not support disks with sectorsize more 512 bytes.
The main issue is in reading/writing superblock, which is not aligned
with 4k value. Reimplement the superblock reading logic to make it
indifferent to disk logical sector size. The logical sector size
more then page size is not supported, like it is doing on Linux side.

PR: 271105
Reported by: k(at)vodka.home.kg
Reviewed by: pfg
MFC after: 2 week
Differential Revision: https://reviews.freebsd.org/D40047


# 1d9f3a37 06-Jan-2023 Konstantin Belousov <kib@FreeBSD.org>

Stop cleaning MNT_LOCAL on unmount

There is no point in clearing just this flag. Flags are reset on the
struct mount re-allocation for reuse anyway.

Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37966


# 829f0bcb 19-Dec-2022 Mateusz Guzik <mjg@FreeBSD.org>

vfs: add the concept of vnode state transitions

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


# b935e867 07-Nov-2022 Mateusz Guzik <mjg@FreeBSD.org>

Tree-wide replacement of VOP_UNLOCK + vrele combo with vput

No functional changes.


# bb92cd7b 24-Mar-2022 Mateusz Guzik <mjg@FreeBSD.org>

vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)


# 5034b445 24-Dec-2021 Fedor Uporov <fsu@FreeBSD.org>

Remove unnecessary e2fs_first_dblock value check

MFC after: 2 weeks


# 3dd3a395 16-Nov-2021 Neel Chauhan <nc@FreeBSD.org>

ext2: Check for e2fs_first_dblock in ext2_compute_sb_data()

This prevents a kernel panic on a damaged ext2 superblock.

PR: 259107
Reported by: Robert Morris <rtm@lcs.mit.edu>
Differential Revision: https://reviews.freebsd.org/D33029


# 7e1d3eef 25-Nov-2021 Mateusz Guzik <mjg@FreeBSD.org>

vfs: remove the unused thread argument from NDINIT*

See b4a58fbf640409a1 ("vfs: remove cn_thread")

Bump __FreeBSD_version to 1400043.


# 47f880eb 21-Aug-2021 Gordon Bergling <gbe@FreeBSD.org>

ext2fs(5): Correct a typo in an error message

- s/talbes/tables/

MFC after: 1 week


# f784da88 17-May-2021 Konstantin Belousov <kib@FreeBSD.org>

Move mnt_maxsymlinklen into appropriate fs mount data structures

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-Note: struct mount layout
Differential revision: https://reviews.freebsd.org/D30325


# 5679656e 18-Feb-2021 Fedor Uporov <fsu@FreeBSD.org>

Improve extents verification logic.

It is possible to walk thru inode extents if EXT2FS_PRINT_EXTENTS
macro is defined. The extents headers magics and physical blocks
ranges are checked during extents walk.

Reviewed by: pfg
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29932


# 2bfd8992 14-Feb-2021 Konstantin Belousov <kib@FreeBSD.org>

vnode: move write cluster support data to inodes.

The data is only needed by filesystems that
1. use buffer cache
2. utilize clustering write support.

Requested by: mjg
Reviewed by: asomers (previous version), fsu (ext2 parts), mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28679


# cd853791 27-Nov-2020 Konstantin Belousov <kib@FreeBSD.org>

Make MAXPHYS tunable. Bump MAXPHYS to 1M.

Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*). Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys. Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight. Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27225


# 586ee69f 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

fs: clean up empty lines in .c and .h files


# 7ad2a82d 18-Aug-2020 Mateusz Guzik <mjg@FreeBSD.org>

vfs: drop the error parameter from vn_isdisk, introduce vn_isdisk_error

Most consumers pass NULL.


# a92a971b 16-Aug-2020 Mateusz Guzik <mjg@FreeBSD.org>

vfs: remove the thread argument from vget

It was already asserted to be curthread.

Semantic patch:

@@

expression arg1, arg2, arg3;

@@

- vget(arg1, arg2, arg3)
+ vget(arg1, arg2)


# cd3acfe7 17-May-2020 Fedor Uporov <fsu@FreeBSD.org>

Add BE architectures support.

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


# b249ce48 03-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

vfs: drop the mostly unused flags argument from VOP_UNLOCK

Filesystems which want to use it in limited capacity can employ the
VOP_UNLOCK_FLAGS macro.

Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D21427


# fe8b3456 06-Sep-2019 Conrad Meyer <cem@FreeBSD.org>

ext2fs: Remove redundant brelse() after r294954

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.


# 6ce04e59 07-Jul-2019 Fedor Uporov <fsu@FreeBSD.org>

Add additional check for 'blocks per group' and 'fragments per group' superblock fields.

These fields will not be equal only in case if bigalloc filesystem feature is turned on.
This feature is not supported for now.

Reported by: Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as: FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct)

MFC after: 2 weeks


# ebc94b66 16-Apr-2019 Fedor Uporov <fsu@FreeBSD.org>

ext2fs: Initial version of DTrace support.

Reviewed by: pfg, gnn
MFC after: 1 week

Differential Revision: https://reviews.freebsd.org/D19848


# 9441309a 04-Mar-2019 Fedor Uporov <fsu@FreeBSD.org>

Fix double free in case of mount error.

Reported by: Christopher Krah <krah@protonmail.com>
Reported as: FS-9-EXT3-2: Denial Of Service in nmount-5 (vm_fault_hold)
Reviewed by: pfg
MFC after: 1 week

Differential Revision: https://reviews.freebsd.org/D19385


# 736da517 04-Mar-2019 Fedor Uporov <fsu@FreeBSD.org>

Fix integer overflow possibility.

Reported by: Christopher Krah <krah@protonmail.com>
Reported as: FS-2-EXT2-1: Out-of-Bounds Write in nmount (ext2_vget)
Reviewed by: pfg
MFC after: 1 week

Differential Revision: https://reviews.freebsd.org/D19326


# daa2d62d 04-Mar-2019 Fedor Uporov <fsu@FreeBSD.org>

Add additional on-disk inode checks.

Reviewed by: pfg
MFC after: 1 week

Differential Revision: https://reviews.freebsd.org/D19323


# 6e38bf94 04-Mar-2019 Fedor Uporov <fsu@FreeBSD.org>

Make superblock reading logic more strict.

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


# 771ec59b 25-Jan-2019 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Add some extra consistency checks for the superblock.

Maliciously formed, or badly corrupted, filesystems can cause kernel
panics. In general, such acts of foot-shooting can only be accomplished
by root, but in a world with VM images that is moving towards automated
mounts it is important to have some form of prevention.

Reported by: Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert
of Fraunhofer FKIE.
Incidentaly this should also fix a memory corruption issue reported by
Dr Silvio Cesare of InfoSect.

Huge thanks to all reseachers for making us aware of the issue.

admbug: 872, 891
Reviewed by: fsu
Obtained from: NetBSD (with minor changes)
MFC after: 3 days


# e06e5241 13-May-2018 Fedor Uporov <fsu@FreeBSD.org>

Fix EXT2FS_DEBUG definition usage.

Reviewed by: pfg
MFC after: 3 months

Differential Revision: https://reviews.freebsd.org/D15394


# fdc154e4 05-Feb-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: remove EXT4F_RO_INCOMPAT_SUPP

This was a hack to be able to mount ext4 filesystems read-only while not
supporting all the features. We now support all those features so it
doesn't make sense to keep the undocumented hack.

Discussed with: fsu


# c0f16c65 29-Jan-2018 Fedor Uporov <fsu@FreeBSD.org>

Add flex_bg/meta_bg features RW support.

Reviewed by: pfg
MFC after: 6 months

Differential Revision: https://reviews.freebsd.org/D13964


# f9834d10 24-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

Revert r327781, r328093, r328056:
ufs|ext2fs: Revert uses of mallocarray(9).

These aren't really useful: drop them.
Variable unsigning will be brought again later.


# 9703326e 16-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: use mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). These
are not likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.


# 512f29d1 14-Jan-2018 Fedor Uporov <fsu@FreeBSD.org>

Add metadata_csum feature support.

Reviewed by: pfg (mentor)
Approved by: pfg (mentor)
MFC after: 6 months

Differential Revision: https://reviews.freebsd.org/D13810


# 3acd9182 05-Jan-2018 Fedor Uporov <fsu@FreeBSD.org>

Add 64bit feature support.

Reviewed by: kevlo, pfg (mentor)
Approved by: pfg (mentor)
MFC after: 6 months

Differential Revision: https://reviews.freebsd.org/D11530


# 51369649 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: further adoption of SPDX licensing ID tags.

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.


# b394cd1e 17-Oct-2017 Fedor Uporov <fsu@FreeBSD.org>

Add inital extents read-write support.

Approved by: pfg (mentor)
MFC after: 6 months
RelNotes: Yes

Differential Revision: https://reviews.freebsd.org/D12087


# 3d851dbe 02-Jul-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: be more verbose about unsupported ext2fs features.

It is useful to know exactly what features may be lacking when trying to
mount ext4 filesystems.

Submitted by: Fedor Uporov
Differential Revision: https://reviews.freebsd.org/D11208


# d23db91e 20-Jun-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Add uninit_bg feature support.

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


# bf9a211d 28-Dec-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

style(9) cleanups.

Just to reduce some of the issues found with indent(1).

MFC after: 1 week


# fca15474 02-Dec-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: renumber the license clauses to avoid skipping #3.

This is to keep consistency with other files, and help license-checking
utilities determine the number of clauses that apply.

No functional change.


# bb9535bb 25-Nov-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2: avoid possible overflow when calculating malloc size.

This is inspired on r308064 for case of reloading UFS.

MFC after: 1 week


# 63378528 07-Jun-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Stop dropping and reacquiring Giant around geom calls.

As in UFS r300366.


# 43ce40e8 07-Jun-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: cleanup generation number management.

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


# 57d2ac2f 22-May-2016 Kevin Lo <kevlo@FreeBSD.org>

arc4random() returns 0 to (2**32)−1, use an alternative to initialize
i_gen if it's zero rather than a divide by 2.

With inputs from delphij, mckusick, rmacklem

Reviewed by: mckusick


# ee7ae58a 25-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: make use of the howmany() macro when available.

We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.

MFC after: 2 weeks


# 2b3506d9 07-Apr-2016 Kevin Lo <kevlo@FreeBSD.org>

Fix comment.


# 9824e4ad 21-Jan-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Bring back the htree dir_index implementation.

The htree dir_index is perhaps one of the most characteristic
features of the linux ext3 implementation. It was removed
in r281670, due to repeated bug reports.

Damjan Jovanic detected and fixed three bugs and did some
stress testing by building Apache OpenOffice on top of it
so it is now in good shape to bring back.

Differential Revision: https://reviews.freebsd.org/D5007

Submitted by: Damjan Jovanovic
Reviewed by: pfg
Tested by: pho
Relnotes: Yes
MFC after: 2 months (only 10.x)


# daf884fa 11-Jan-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

ext4: mount panic from freeing invalid pointers

Initialize the struct with those fields to zeroes on allocation,
preventing the panic.

Patch by: Damjan Jovanovic.

PR: 206056
MFC after: 3 days


# f738ee48 17-Apr-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

Drop experimental dir_index support.

The htree directory index is a highly desirable feature for research
purposes and was meant to improve performance in our ext2/3 driver.
Unfortunately our implementation has two problems:

- It never really delivered any performance improvement.
- It appears to corrupt the filesystem in undetermined circumstances.

Strictly speaking dir_index is not required for read/write support in
ext2/3 and our limited ext4 support still works fine without it.

Regain stability in the ext2 driver by removing it. We may need it back
(fixed) if we want to support encrypted ext4 support but thanks to the
wonders of version control we can always revert this change and bring it
back.

PR: 191895
PR: 198731
PR: 199309

MFC after: 5 days


# dda11d4a 15-Apr-2015 Rick Macklem <rmacklem@FreeBSD.org>

File systems that do not use the buffer cache (such as ZFS) must
use VOP_FSYNC() to perform the NFS server's Commit operation.
This patch adds a mnt_kern_flag called MNTK_USES_BCACHE which
is set by file systems that use the buffer cache. If this flag
is not set, the NFS server always does a VOP_FSYNC().
This should be ok for old file system modules that do not set
MNTK_USES_BCACHE, since calling VOP_FSYNC() is correct, although
it might not be optimal for file systems that use the buffer cache.

Reviewed by: kib
MFC after: 2 weeks


# e5c356b2 15-Feb-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Plug small memory leak

free() e2fs_contigdirs upon error.
Undo zeroing of e2fs_gd as this was actually a false positive.

X-MFC with: 278790


# f3ee91ed 14-Feb-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

Initialize the allocation of variables related to the ext2 allocator.

The e2fs_gd struct was not being initialized and garbage was
being used for hinting the ext2 allocator variant.
Use malloc to clear the values and also initialize e2fs_contigdirs
during allocation to keep consistency.

While here clean up small style issues.

Reported by: Clang static analyser
MFC after: 1 week


# 9a53618a 18-Jan-2015 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2: Garbage-collect some unused variables

Reported by: clang static analysis
MFC after: 2 weeks


# 33587684 12-Nov-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

ifdef ext2_print_inode which is not really used.

ext2_print_inode is not really used but it was nice to
have for initial development work. #ifdef it under a
new EXT2FS_DEBUG knob so that we don't spend time
compiling it.

MFC after: 3 days


# 3a54024d 28-Feb-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: use of tab vs spaces.

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


# 67da48a1 22-Feb-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: fully enable ext4 read-only support.

The ext4 developers tend to tag Ext4-specific flags as
"incompatible" even when such features are not relevant for
read-only support. This is a consequence of the process
though which this filesystem is implemented without design
and the fact that some new features are not extensible to
ext2/3.

Organize the features according to what we support and sort
them so that we can now read-only mount filesystems with
some features that may be found in newly formatted ext4 fs.

Submitted by: Zheng Liu
Reviewed by: pfg
MFC after: 5 days


# ad3d96a7 28-Jan-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Use i_flag instead of i_flags for Ext4 inode flags.

The ext4 inode flags do not have equivalents for chflags (1)
and hold information that is private to the implementation.
The i_flag field in the inode is a better place to hold the Ext4
inode flags as it saves us from masking flags while setting or
getting attributes. It should also make things cleaner if we
implement write support for Ext4.

Suggested by: bde
Tested by: Mike Ma
MFC after: 3 days


# a7710d51 21-Jan-2014 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Translate the EXT4_EXTENTS and EXT4_INDEX to the inode flags.

r260545 cleared the inode flags to fix corruption problems but
we still need to pass some EXT4 flags for the ext4 read-only
mode. None of these attributes has an equivalent in FreeBSD and
are uninteresting for the system utilities so they should be
innaccessible in ext2_getattrib().

Note: we also use EXT4_HUGE_FILE but we use it directly from the
dinode structure so it is not necessary to translate it,

Suggested by: bde
MFC after: 3 days


# d7511a40 12-Aug-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

Add read-only support for extents in ext2fs.

Basic support for extents was implemented by Zheng Liu as part
of his Google Summer of Code in 2010. This support is read-only
at this time.

In addition to extents we also support the huge_file extension
for read-only purposes. This works nicely with the additional
support for birthtime/nanosec timestamps and dir_index that
have been added lately.

The implementation may not work for all ext4 filesystems as
it doesn't support some features that are being enabled by
default on recent linux like flex_bg. Nevertheless, the feature
should be very useful for migration or simple access in
filesystems that have been converted from ext2/3 or don't use
incompatible features.

Special thanks to Zheng Liu for his dedication and continued
work to support ext2 in FreeBSD.

Submitted by: Zheng Liu (lz@)
Reviewed by: Mike Ma, Christoph Mallon (previous version)
Sponsored by: Google Inc.
MFC after: 3 weeks


# 91f5a467 06-Jul-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

Initial implementation of the HTree directory index.

This is a port of NetBSD's GSoC 2012 Ext3 HTree directory indexing
by Vyacheslav Matyushin. It was cleaned up and enhanced for FreeBSD
by Zheng Liu (lz@).

This is an excellent example of work shared among different projects:
Vyacheslav was able to look at an early prototype from Zheng Liu who
was also able to check the code from Haiku (with permission).

As in linux, the feature is not available by default and must be
enabled explicitly with tune2fs. We still do not support the
workarounds required in readdir for NFS.

Submitted by: Zheng Liu
Tested by: Mike Ma
Sponsored by: Google Inc.
MFC after: 1 week


# e2bc2cce 29-Jun-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Use the complete random() range in i_gen.

i_gen is unsigned in ext2fs so we can handle the complete
32 bits.

MFC after: 1 week


# abe38ac7 10-Jun-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

s/file system/filesystem/g

Based on r96755 from UFS.

MFC after: 3 days


# 4e1e0e25 08-Feb-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: Replace redundant EXT2_MIN_BLOCK with EXT2_MIN_BLOCK_SIZE.

Submitted by: Christoph Mallon
MFC after: 2 weeks


# 1a125d6d 08-Feb-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: make e2fs_maxcontig local and remove tautological check.

e2fs_maxcontig was modelled after UFS when bringing the
"Orlov allocator" to ext2. On UFS fs_maxcontig is kept in the
superblock and is used by userland tools (fsck and growfs),

In ext2 this information is volatile so it is not available
for userland tools, so in this case it doesn't have sense
to carry it in the in-memory superblock.

Also remove a pointless check for MAX(1, x) > 0.

Submitted by: Christoph Mallon
MFC after: 2 weeks


# 757224cb 02-Feb-2013 Pedro F. Giffuni <pfg@FreeBSD.org>

ext2fs: general cleanup.

- Remove unused extern declarations in fs.h
- Correct comments in ext2_dir.h
- Several panic() messages showed wrong function names.
- Remove commented out stray line in ext2_alloc.c.
- Remove the unused macro EXT2_BLOCK_SIZE_BITS() and the then
write-only member e2fs_blocksize_bits from struct m_ext2fs.
- Remove the unused macro EXT2_FIRST_INO() and the then write-only
member e2fs_first_inode from struct m_ext2fs.
- Remove EXT2_DESC_PER_BLOCK() and the member e2fs_descpb from
struct m_ext2fs.
- Remove the unused members e2fs_bmask, e2fs_dbpg and
e2fs_mount_opt from struct m_ext2fs
- Correct harmless off-by-one error for fspath in ext2_vfsops.c.
- Remove the unused and broken macros EXT2_ADDR_PER_BLOCK_BITS()
and EXT2_DESC_PER_BLOCK_BITS().
- Remove the !_KERNEL versions of the EXT2_* macros.

Submitted by: Christoph Mallon
MFC after: 2 weeks


# e28f5d52 19-Dec-2012 Pedro F. Giffuni <pfg@FreeBSD.org>

More constant renaming in preparation for newer features.

We also try to make better use of the fs flags instead of
trying adapt the code according to the fs structures. In
the case of subsecond timestamps and birthtime we now
check that the feature is explicitly enabled: previously
we only checked that the reserved space was available and
silently wrote them.

This approach is much safer, especially if the filesystem
happens to use embedded inodes or support EAs.

Discussed with: Zheng Liu
MFC after: 5 days


# c6e0355c 19-Nov-2012 Attilio Rao <attilio@FreeBSD.org>

r16312 is not any longer real since many years (likely since when VFS
received granular locking) but the comment present in UFS has been
copied all over other filesystems code incorrectly for several times.

Removes comments that makes no sense now.

Reviewed by: kib
MFC after: 3 days


# bc2258da 09-Nov-2012 Attilio Rao <attilio@FreeBSD.org>

Complete MPSAFE VFS interface and remove MNTK_MPSAFE flag.
Porters should refer to __FreeBSD_version 1000021 for this change as
it may have happened at the same timeframe.


# f7a3729c 22-Jul-2012 Kevin Lo <kevlo@FreeBSD.org>

Use NULL instead of 0 for pointers


# d6cc34a1 03-Jul-2012 Kevin Lo <kevlo@FreeBSD.org>

Fix a typo


# 7d5f5d83 10-May-2012 Sergey Kandaurov <pluknet@FreeBSD.org>

Fix mount interlock oversights from the previous change in r234386.

Reported by: dougb
Submitted by: Mateusz Guzik <mjguzik at gmail com>
Reviewed by: Kirk McKusick
Tested by: pho


# 71469bb3 17-Apr-2012 Kirk McKusick <mckusick@FreeBSD.org>

Replace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL.
The primary changes are that the user of the interface no longer
needs to manage the mount-mutex locking and that the vnode that
is returned has its mutex locked (thus avoiding the need to check
to see if its is DOOMED or other possible end of life senarios).

To minimize compatibility issues for third-party developers, the
old MNT_VNODE_FOREACH interface will remain available so that this
change can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH
will be removed in head.

The reason for this update is to prepare for the addition of the
MNT_VNODE_FOREACH_ACTIVE interface that will loop over just the
active vnodes associated with a mount point (typically less than
1% of the vnodes associated with the mount point).

Reviewed by: kib
Tested by: Peter Holm
MFC after: 2 weeks


# 035e4e04 08-Mar-2012 Pedro F. Giffuni <pfg@FreeBSD.org>

Add support for ns timestamps and birthtime to the ext2/3 driver.

When using big inodes there is sufficient space in ext3 to
keep extra resolution and birthtime (creation) timestamps.
The appropriate fields in the on-disk inode have been approved
for a long time but support for this in ext3 has not been
widely distributed.

In preparation for ext4 most linux distributions have enabled
by default such bigger inodes and some people use nanosecond
timestamps in ext3. We now support those when the inode is big
enough and while we do recognize the EXT4F_ROCOMPAT_EXTRA_ISIZE,
we maintain the extra timestamps even when they are not used.

An additional note by Bruce Evans:
We blindly accept unrepresentable tv_nsec in VOP_SETATTR(), but
all file systems have always done that. When POSIX gets around
to specifying the behaviour, it will probably require certain
rounding to the fs's resolution and not rejecting the request.
This unfortunately means that syscalls that set times can't
really tell if they succeeded without reading back the times
using stat() or similar and checking that they were set close
enough.

Reviewed by: bde
Approved by: jhb (mentor)
MFC after: 2 weeks


# 5ed5554f 16-Dec-2011 Pedro F. Giffuni <pfg@FreeBSD.org>

Style cleanups by jh@.
Fix a comment from the previous commit.
Use M_ZERO instead of bzero() in ext2_vfsops.c
Add include guards from PR.

PR: 162564
Approved by: jhb (mentor)
MFC after: 2 weeks


# 5b63c125 15-Dec-2011 Pedro F. Giffuni <pfg@FreeBSD.org>

Bring in reallocblk to ext2fs.

The feature has been standard for a while in UFS as a means to reduce
fragmentation, therefore maintaining consistent performance with
filesystem aging. This is also very similar to what ext4 calls
"delayed allocation".

In his 2010 GSoC, Zheng Liu ported and benchmarked the missing
FANCY_REALLOC code to find more consistent performance improvements than
with the preallocation approach.

PR: 159233
Author: Zheng Liu <gnehzuil AT SPAMFREE gmail DOT com>
Sponsored by: Google Inc.
Approved by: jhb (mentor)
MFC after: 2 weeks


# 694a586a 21-May-2011 Rick Macklem <rmacklem@FreeBSD.org>

Add a lock flags argument to the VFS_FHTOVP() file system
method, so that callers can indicate the minimum vnode
locking requirement. This will allow some file systems to choose
to return a LK_SHARED locked vnode when LK_SHARED is specified
for the flags argument. This patch only adds the flag. It
does not change any file system to use it and all callers
specify LK_EXCLUSIVE, so file system semantics are not changed.

Reviewed by: kib


# bbfe24fb 27-Apr-2011 John Baldwin <jhb@FreeBSD.org>

Use a private EXT2_ROOTINO constant instead of redefining ROOTINO.

Submitted by: Pedro F. Giffuni giffunip at yahoo


# 45641afb 01-Feb-2011 John Baldwin <jhb@FreeBSD.org>

Some cosmetic fixes and remove a duplicate constant.

Submitted by: Pedro F. Giffuni giffunip at yahoo


# 84edda0a 21-Jan-2011 John Baldwin <jhb@FreeBSD.org>

Restore support for the 'async' and 'sync' mount options lost when
switching to nmount(2). While here, sort the options.

PR: kern/153584
Submitted by: Pedro F. Giffuni giffunip at yahoo
MFC after: 1 week


# 007c6207 19-Jan-2011 John Baldwin <jhb@FreeBSD.org>

Merge 118969 from UFS:
Eliminate the i_devvp field from the incore inodes, we can get the same
value from ip->i_ump->um_devvp.

Submitted by: Pedro F. Giffuni giffunip at yahoo
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# e09c00ca 14-Jan-2010 Ulf Lilleengen <lulf@FreeBSD.org>

Bring in the ext2fs work done by Aditya Sarawgi during and after Google Summer
of Code 2009:

- BSDL block and inode allocation policies for ext2fs. This involves the use
FFS1 style block and inode allocation for ext2fs. Preallocation was removed
since it was GPL'd.
- Make ext2fs MPSAFE by introducing locks to per-mount datastructures.
- Fixes for kern/122047 PR.
- Various small bugfixes.
- Move out of gnu/ directory.

Sponsored by: Google Inc.
Submitted by: Aditya Sarawgi <sarawgi.aditya AT SPAMFREE gmail DOT com>