aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/msdosfs/msdosfs_fileno.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2017-06-09 12:06:22 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2017-06-09 12:06:22 +0000
commit40373cf5b87fe5ac39830b31f28994b6729b3215 (patch)
tree5dbb82910e7d6504230eb0ad8e5bc7e4acae8c40 /sys/fs/msdosfs/msdosfs_fileno.c
parent7abe0df2233f76b0cd49e7ed1b1e70085f5f0cfb (diff)
downloadsrc-40373cf5b87fe5ac39830b31f28994b6729b3215.tar.gz
src-40373cf5b87fe5ac39830b31f28994b6729b3215.zip
Remove msdosfs -o large support.
Its purpose was to translate the values for msdosfs inode numbers, which is calculated from the msdosfs structures describing the file, into the range representable by 32bit ino_t. The translation acted for filesystems larger than 128Gb, it reserved the range 0xf0000000 (FILENO_FIRST_DYN) to UINT32_MAX and remembered some arbitrary translation of ino >= FILENO_FIRST_DYN into this range. It consumed memory that could be only freed by unmount, and the translation was not stable across remounts. With ino_t type extended to 64 bit, there is no such issue and values can be returned without compaction to 32bit. That is, for the native environments, the translation layer is not necessary and adds significant undeserved code complexity. For compat ABIs which use 32bit ino_t, the vfs.ino64_trunc_error sysctl provides some measures to soften the failure mode when inode numbers truncation is not safe. Discussed with: bde Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=319735
Diffstat (limited to 'sys/fs/msdosfs/msdosfs_fileno.c')
-rw-r--r--sys/fs/msdosfs/msdosfs_fileno.c152
1 files changed, 0 insertions, 152 deletions
diff --git a/sys/fs/msdosfs/msdosfs_fileno.c b/sys/fs/msdosfs/msdosfs_fileno.c
deleted file mode 100644
index f49e20f6e916..000000000000
--- a/sys/fs/msdosfs/msdosfs_fileno.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*-
- * Copyright (c) 2003-2004 Tim J. Robbins.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * Compress 64-bit file numbers into temporary, unique 32-bit file numbers.
- * This is needed because the algorithm we use to calculate these numbers
- * generates 64-bit quantities, but struct dirent's d_fileno member and
- * struct vnodeattr's va_fileid member only have space for 32 bits.
- *
- * 32-bit file numbers are generated sequentially, and stored in a
- * red-black tree, indexed on 64-bit file number. The mappings do not
- * persist across reboots (or unmounts); anything that relies on this
- * (e.g. NFS) will not work correctly. This scheme consumes 32 bytes
- * of kernel memory per file (on i386), and it may be possible for a user
- * to cause a panic by creating millions of tiny files.
- *
- * As an optimization, we split the file number space between statically
- * allocated and dynamically allocated. File numbers less than
- * FILENO_FIRST_DYN are left unchanged and do not have any tree nodes
- * allocated to them.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-
-#include <fs/msdosfs/bpb.h>
-#include <fs/msdosfs/direntry.h>
-#include <fs/msdosfs/msdosfsmount.h>
-
-static MALLOC_DEFINE(M_MSDOSFSFILENO, "msdosfs_fileno", "MSDOSFS fileno mapping node");
-
-RB_PROTOTYPE(msdosfs_filenotree, msdosfs_fileno, mf_tree,
- msdosfs_fileno_compare)
-
-static int msdosfs_fileno_compare(struct msdosfs_fileno *,
- struct msdosfs_fileno *);
-
-#define FILENO_FIRST_DYN 0xf0000000
-
-/* Initialize file number mapping structures. */
-void
-msdosfs_fileno_init(struct mount *mp)
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
-
- RB_INIT(&pmp->pm_filenos);
- pmp->pm_nfileno = FILENO_FIRST_DYN;
- if (pmp->pm_HugeSectors > 0xffffffff /
- (pmp->pm_BytesPerSec / sizeof(struct direntry)) + 1)
- pmp->pm_flags |= MSDOSFS_LARGEFS;
-}
-
-/* Free 32-bit file number generation structures. */
-void
-msdosfs_fileno_free(struct mount *mp)
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- struct msdosfs_fileno *mf, *next;
-
- for (mf = RB_MIN(msdosfs_filenotree, &pmp->pm_filenos); mf != NULL;
- mf = next) {
- next = RB_NEXT(msdosfs_filenotree, &pmp->pm_filenos, mf);
- RB_REMOVE(msdosfs_filenotree, &pmp->pm_filenos, mf);
- free(mf, M_MSDOSFSFILENO);
- }
-}
-
-/* Map a 64-bit file number into a 32-bit one. */
-uint32_t
-msdosfs_fileno_map(struct mount *mp, uint64_t fileno)
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- struct msdosfs_fileno key, *mf, *tmf;
- uint32_t mapped;
-
- if ((pmp->pm_flags & MSDOSFS_LARGEFS) == 0) {
- KASSERT((uint32_t)fileno == fileno,
- ("fileno >32 bits but not a large fs?"));
- return ((uint32_t)fileno);
- }
- if (fileno < FILENO_FIRST_DYN)
- return ((uint32_t)fileno);
- MSDOSFS_LOCK_MP(pmp);
- key.mf_fileno64 = fileno;
- mf = RB_FIND(msdosfs_filenotree, &pmp->pm_filenos, &key);
- if (mf != NULL) {
- mapped = mf->mf_fileno32;
- MSDOSFS_UNLOCK_MP(pmp);
- return (mapped);
- }
- if (pmp->pm_nfileno < FILENO_FIRST_DYN)
- panic("msdosfs_fileno_map: wraparound");
- MSDOSFS_UNLOCK_MP(pmp);
- mf = malloc(sizeof(*mf), M_MSDOSFSFILENO, M_WAITOK);
- MSDOSFS_LOCK_MP(pmp);
- tmf = RB_FIND(msdosfs_filenotree, &pmp->pm_filenos, &key);
- if (tmf != NULL) {
- mapped = tmf->mf_fileno32;
- MSDOSFS_UNLOCK_MP(pmp);
- free(mf, M_MSDOSFSFILENO);
- return (mapped);
- }
- mf->mf_fileno64 = fileno;
- mapped = mf->mf_fileno32 = pmp->pm_nfileno++;
- RB_INSERT(msdosfs_filenotree, &pmp->pm_filenos, mf);
- MSDOSFS_UNLOCK_MP(pmp);
- return (mapped);
-}
-
-/* Compare by 64-bit file number. */
-static int
-msdosfs_fileno_compare(struct msdosfs_fileno *fa, struct msdosfs_fileno *fb)
-{
-
- if (fa->mf_fileno64 > fb->mf_fileno64)
- return (1);
- else if (fa->mf_fileno64 < fb->mf_fileno64)
- return (-1);
- return (0);
-}
-
-RB_GENERATE(msdosfs_filenotree, msdosfs_fileno, mf_tree,
- msdosfs_fileno_compare)