2005-01-07 02:29:27 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1982, 1986, 1989, 1993
|
|
|
|
* The Regents of the University of California. 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.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-24 10:09:53 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-11 06:34:30 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1996-01-05 18:31:58 +00:00
|
|
|
#include "opt_quota.h"
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/malloc.h>
|
Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
random(4) device in the kernel, and the KERN_ARND sysctl will
return nothing. With RANDOM_DUMMY there will be a random(4) that
always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
(direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
when the dust settles.
- Use macros for locks.
- Fix comments.
* src/share/man/...
- Update the man pages.
* src/etc/...
- The startup/shutdown work is done in D2924.
* src/UPDATING
- Add UPDATING announcement.
* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.
* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.
* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.
* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
selection is the way to go.
* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.
* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.
* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
that instead. All that is needed here is N=0, N++, N==0, and some
localised trickery is used to manufacture a 128-bit 0ULLL.
* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
now the test will do a basic check of compressibility. Clairvoyant
talent is still a good idea.
- This is still a long way off a proper unit test.
* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.
Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/proc.h>
|
2016-04-07 04:23:25 +00:00
|
|
|
#include <sys/racct.h>
|
Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
random(4) device in the kernel, and the KERN_ARND sysctl will
return nothing. With RANDOM_DUMMY there will be a random(4) that
always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
(direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
when the dust settles.
- Use macros for locks.
- Fix comments.
* src/share/man/...
- Update the man pages.
* src/etc/...
- The startup/shutdown work is done in D2924.
* src/UPDATING
- Add UPDATING announcement.
* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.
* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.
* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.
* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
selection is the way to go.
* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.
* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.
* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
that instead. All that is needed here is N=0, N++, N==0, and some
localised trickery is used to manufacture a 128-bit 0ULLL.
* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
now the test will do a basic check of compressibility. Clairvoyant
talent is still a good idea.
- This is still a long way off a proper unit test.
* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.
Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
|
|
|
#include <sys/random.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/resourcevar.h>
|
2013-05-31 00:43:41 +00:00
|
|
|
#include <sys/rwlock.h>
|
2000-07-26 23:07:01 +00:00
|
|
|
#include <sys/stat.h>
|
Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
random(4) device in the kernel, and the KERN_ARND sysctl will
return nothing. With RANDOM_DUMMY there will be a random(4) that
always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
(direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
when the dust settles.
- Use macros for locks.
- Fix comments.
* src/share/man/...
- Update the man pages.
* src/etc/...
- The startup/shutdown work is done in D2924.
* src/UPDATING
- Add UPDATING announcement.
* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.
* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.
* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.
* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
selection is the way to go.
* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.
* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.
* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
that instead. All that is needed here is N=0, N++, N==0, and some
localised trickery is used to manufacture a 128-bit 0ULLL.
* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
now the test will do a basic check of compressibility. Clairvoyant
talent is still a good idea.
- This is still a long way off a proper unit test.
* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.
Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
|
|
|
#include <sys/vmmeter.h>
|
|
|
|
#include <sys/vnode.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_extern.h>
|
2009-01-20 11:27:45 +00:00
|
|
|
#include <vm/vm_object.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
Introduce extended attribute support for FFS, allowing arbitrary
(name, value) pairs to be associated with inodes. This support is
used for ACLs, MAC labels, and Capabilities in the TrustedBSD
security extensions, which are currently under development.
In this implementation, attributes are backed to data vnodes in the
style of the quota support in FFS. Support for FFS extended
attributes may be enabled using the FFS_EXTATTR kernel option
(disabled by default). Userland utilities and man pages will be
committed in the next batch. VFS interfaces and man pages have
been in the repo since 4.0-RELEASE and are unchanged.
o ufs/ufs/extattr.h: UFS-specific extattr defines
o ufs/ufs/ufs_extattr.c: bulk of support routines
o ufs/{ufs,ffs,mfs}/*.[ch]: hooks and extattr.h includes
o contrib/softupdates/ffs_softdep.c: extattr.h includes
o conf/options, conf/files, i386/conf/LINT: added FFS_EXTATTR
o coda/coda_vfsops.c: XXX required extattr.h due to ufsmount.h
(This should not be the case, and will be fixed in a future commit)
Currently attributes are not supported in MFS. This will be fixed.
Reviewed by: adrian, bp, freebsd-fs, other unthanked souls
Obtained from: TrustedBSD Project
2000-04-15 03:34:27 +00:00
|
|
|
#include <ufs/ufs/extattr.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <ufs/ufs/quota.h>
|
1997-10-16 20:32:40 +00:00
|
|
|
#include <ufs/ufs/ufsmount.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <ufs/ufs/inode.h>
|
1998-07-03 18:46:52 +00:00
|
|
|
#include <ufs/ufs/ufs_extern.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <ufs/ffs/fs.h>
|
|
|
|
#include <ufs/ffs/ffs_extern.h>
|
|
|
|
|
2002-06-21 06:18:05 +00:00
|
|
|
static int ffs_indirtrunc(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
|
|
|
|
ufs2_daddr_t, int, ufs2_daddr_t *);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the access, modified, and inode change times as specified by the
|
1998-07-03 22:17:03 +00:00
|
|
|
* IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode
|
|
|
|
* to disk if the IN_MODIFIED flag is set (it may be set initially, or by
|
|
|
|
* the timestamp update). The IN_LAZYMOD flag is set to force a write
|
2006-10-10 09:20:54 +00:00
|
|
|
* later if not now. The IN_LAZYACCESS is set instead of IN_MODIFIED if the fs
|
|
|
|
* is currently being suspended (or is suspended) and vnode has been accessed.
|
|
|
|
* If we write now, then clear IN_MODIFIED, IN_LAZYACCESS and IN_LAZYMOD to
|
|
|
|
* reflect the presumably successful write, and if waitfor is set, then wait
|
|
|
|
* for the write to complete.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
int
|
1999-01-07 16:14:19 +00:00
|
|
|
ffs_update(vp, waitfor)
|
1997-10-16 20:32:40 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
int waitfor;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2002-05-13 09:22:31 +00:00
|
|
|
struct fs *fs;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct buf *bp;
|
|
|
|
struct inode *ip;
|
This commit enables a UFS filesystem to do a forcible unmount when
the underlying media fails or becomes inaccessible. For example
when a USB flash memory card hosting a UFS filesystem is unplugged.
The strategy for handling disk I/O errors when soft updates are
enabled is to stop writing to the disk of the affected file system
but continue to accept I/O requests and report that all future
writes by the file system to that disk actually succeed. Then
initiate an asynchronous forced unmount of the affected file system.
There are two cases for disk I/O errors:
- ENXIO, which means that this disk is gone and the lower layers
of the storage stack already guarantee that no future I/O to
this disk will succeed.
- EIO (or most other errors), which means that this particular
I/O request has failed but subsequent I/O requests to this
disk might still succeed.
For ENXIO, we can just clear the error and continue, because we
know that the file system cannot affect the on-disk state after we
see this error. For EIO or other errors, we arrange for the geom_vfs
layer to reject all future I/O requests with ENXIO just like is
done when the geom_vfs is orphaned. In both cases, the file system
code can just clear the error and proceed with the forcible unmount.
This new treatment of I/O errors is needed for writes of any buffer
that is involved in a dependency. Most dependencies are described
by a structure attached to the buffer's b_dep field. But some are
created and processed as a result of the completion of the dependencies
attached to the buffer.
Clearing of some dependencies require a read. For example if there
is a dependency that requires an inode to be written, the disk block
containing that inode must be read, the updated inode copied into
place in that buffer, and the buffer then written back to disk.
Often the needed buffer is already in memory and can be used. But
if it needs to be read from the disk, the read will fail, so we
fabricate a buffer full of zeroes and pretend that the read succeeded.
This zero'ed buffer can be updated and written back to disk.
The only case where a buffer full of zeros causes the code to do
the wrong thing is when reading an inode buffer containing an inode
that still has an inode dependency in memory that will reinitialize
the effective link count (i_effnlink) based on the actual link count
(i_nlink) that we read. To handle this case we now store the i_nlink
value that we wrote in the inode dependency so that it can be
restored into the zero'ed buffer thus keeping the tracking of the
inode link count consistent.
Because applications depend on knowing when an attempt to write
their data to stable storage has failed, the fsync(2) and msync(2)
system calls need to return errors if data fails to be written to
stable storage. So these operations return ENXIO for every call
made on files in a file system where we have otherwise been ignoring
I/O errors.
Coauthered by: mckusick
Reviewed by: kib
Tested by: Peter Holm
Approved by: mckusick (mentor)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24088
2020-05-25 23:47:31 +00:00
|
|
|
daddr_t bn;
|
2012-03-01 18:45:25 +00:00
|
|
|
int flags, error;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2006-10-10 09:20:54 +00:00
|
|
|
ASSERT_VOP_ELOCKED(vp, "ffs_update");
|
1999-01-06 16:52:38 +00:00
|
|
|
ufs_itimes(vp);
|
1997-10-16 20:32:40 +00:00
|
|
|
ip = VTOI(vp);
|
1999-01-06 18:18:06 +00:00
|
|
|
if ((ip->i_flag & IN_MODIFIED) == 0 && waitfor == 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
2020-06-04 12:23:15 +00:00
|
|
|
ip->i_flag &= ~(IN_LAZYACCESS | IN_LAZYMOD | IN_MODIFIED | IN_IBLKDATA);
|
2016-09-17 16:47:34 +00:00
|
|
|
fs = ITOFS(ip);
|
|
|
|
if (fs->fs_ronly && ITOUMP(ip)->um_fsckpid == 0)
|
2002-01-15 07:17:12 +00:00
|
|
|
return (0);
|
2012-03-01 18:45:25 +00:00
|
|
|
/*
|
|
|
|
* If we are updating a snapshot and another process is currently
|
|
|
|
* writing the buffer containing the inode for this snapshot then
|
|
|
|
* a deadlock can occur when it tries to check the snapshot to see
|
|
|
|
* if that block needs to be copied. Thus when updating a snapshot
|
|
|
|
* we check to see if the buffer is already locked, and if it is
|
|
|
|
* we drop the snapshot lock until the buffer has been written
|
|
|
|
* and is available to us. We have to grab a reference to the
|
|
|
|
* snapshot vnode to prevent it from being removed while we are
|
|
|
|
* waiting for the buffer.
|
|
|
|
*/
|
|
|
|
flags = 0;
|
|
|
|
if (IS_SNAPSHOT(ip))
|
|
|
|
flags = GB_LOCK_NOWAIT;
|
2012-03-28 21:21:19 +00:00
|
|
|
loop:
|
This commit enables a UFS filesystem to do a forcible unmount when
the underlying media fails or becomes inaccessible. For example
when a USB flash memory card hosting a UFS filesystem is unplugged.
The strategy for handling disk I/O errors when soft updates are
enabled is to stop writing to the disk of the affected file system
but continue to accept I/O requests and report that all future
writes by the file system to that disk actually succeed. Then
initiate an asynchronous forced unmount of the affected file system.
There are two cases for disk I/O errors:
- ENXIO, which means that this disk is gone and the lower layers
of the storage stack already guarantee that no future I/O to
this disk will succeed.
- EIO (or most other errors), which means that this particular
I/O request has failed but subsequent I/O requests to this
disk might still succeed.
For ENXIO, we can just clear the error and continue, because we
know that the file system cannot affect the on-disk state after we
see this error. For EIO or other errors, we arrange for the geom_vfs
layer to reject all future I/O requests with ENXIO just like is
done when the geom_vfs is orphaned. In both cases, the file system
code can just clear the error and proceed with the forcible unmount.
This new treatment of I/O errors is needed for writes of any buffer
that is involved in a dependency. Most dependencies are described
by a structure attached to the buffer's b_dep field. But some are
created and processed as a result of the completion of the dependencies
attached to the buffer.
Clearing of some dependencies require a read. For example if there
is a dependency that requires an inode to be written, the disk block
containing that inode must be read, the updated inode copied into
place in that buffer, and the buffer then written back to disk.
Often the needed buffer is already in memory and can be used. But
if it needs to be read from the disk, the read will fail, so we
fabricate a buffer full of zeroes and pretend that the read succeeded.
This zero'ed buffer can be updated and written back to disk.
The only case where a buffer full of zeros causes the code to do
the wrong thing is when reading an inode buffer containing an inode
that still has an inode dependency in memory that will reinitialize
the effective link count (i_effnlink) based on the actual link count
(i_nlink) that we read. To handle this case we now store the i_nlink
value that we wrote in the inode dependency so that it can be
restored into the zero'ed buffer thus keeping the tracking of the
inode link count consistent.
Because applications depend on knowing when an attempt to write
their data to stable storage has failed, the fsync(2) and msync(2)
system calls need to return errors if data fails to be written to
stable storage. So these operations return ENXIO for every call
made on files in a file system where we have otherwise been ignoring
I/O errors.
Coauthered by: mckusick
Reviewed by: kib
Tested by: Peter Holm
Approved by: mckusick (mentor)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24088
2020-05-25 23:47:31 +00:00
|
|
|
bn = fsbtodb(fs, ino_to_fsba(fs, ip->i_number));
|
|
|
|
error = ffs_breadz(VFSTOUFS(vp->v_mount), ITODEVVP(ip), bn, bn,
|
|
|
|
(int) fs->fs_bsize, NULL, NULL, 0, NOCRED, flags, NULL, &bp);
|
2012-03-01 18:45:25 +00:00
|
|
|
if (error != 0) {
|
2016-01-27 21:23:01 +00:00
|
|
|
if (error != EBUSY)
|
2012-03-01 18:45:25 +00:00
|
|
|
return (error);
|
|
|
|
KASSERT((IS_SNAPSHOT(ip)), ("EBUSY from non-snapshot"));
|
2012-03-28 21:21:19 +00:00
|
|
|
/*
|
|
|
|
* Wait for our inode block to become available.
|
|
|
|
*
|
|
|
|
* Hold a reference to the vnode to protect against
|
|
|
|
* ffs_snapgone(). Since we hold a reference, it can only
|
2019-12-08 21:30:04 +00:00
|
|
|
* get reclaimed (VIRF_DOOMED flag) in a forcible downgrade
|
2012-03-28 21:21:19 +00:00
|
|
|
* or unmount. For an unmount, the entire filesystem will be
|
|
|
|
* gone, so we cannot attempt to touch anything associated
|
|
|
|
* with it while the vnode is unlocked; all we can do is
|
|
|
|
* pause briefly and try again. If when we relock the vnode
|
|
|
|
* we discover that it has been reclaimed, updating it is no
|
|
|
|
* longer necessary and we can just return an error.
|
|
|
|
*/
|
|
|
|
vref(vp);
|
2020-01-03 22:29:58 +00:00
|
|
|
VOP_UNLOCK(vp);
|
2012-03-28 21:21:19 +00:00
|
|
|
pause("ffsupd", 1);
|
2012-03-01 18:45:25 +00:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
|
|
|
vrele(vp);
|
2019-12-08 21:30:04 +00:00
|
|
|
if (VN_IS_DOOMED(vp))
|
2012-03-28 21:21:19 +00:00
|
|
|
return (ENOENT);
|
|
|
|
goto loop;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1998-03-08 09:59:44 +00:00
|
|
|
if (DOINGSOFTDEP(vp))
|
|
|
|
softdep_update_inodeblock(ip, bp, waitfor);
|
|
|
|
else if (ip->i_effnlink != ip->i_nlink)
|
|
|
|
panic("ffs_update: bad link cnt");
|
2016-09-17 16:47:34 +00:00
|
|
|
if (I_IS_UFS1(ip)) {
|
2002-06-21 06:18:05 +00:00
|
|
|
*((struct ufs1_dinode *)bp->b_data +
|
|
|
|
ino_to_fsbo(fs, ip->i_number)) = *ip->i_din1;
|
2018-11-13 21:40:56 +00:00
|
|
|
/*
|
|
|
|
* XXX: FIX? The entropy here is desirable,
|
|
|
|
* but the harvesting may be expensive
|
|
|
|
*/
|
2018-08-26 12:51:46 +00:00
|
|
|
random_harvest_queue(&(ip->i_din1), sizeof(ip->i_din1), RANDOM_FS_ATIME);
|
Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
random(4) device in the kernel, and the KERN_ARND sysctl will
return nothing. With RANDOM_DUMMY there will be a random(4) that
always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
(direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
when the dust settles.
- Use macros for locks.
- Fix comments.
* src/share/man/...
- Update the man pages.
* src/etc/...
- The startup/shutdown work is done in D2924.
* src/UPDATING
- Add UPDATING announcement.
* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.
* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.
* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.
* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
selection is the way to go.
* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.
* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.
* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
that instead. All that is needed here is N=0, N++, N==0, and some
localised trickery is used to manufacture a 128-bit 0ULLL.
* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
now the test will do a basic check of compressibility. Clairvoyant
talent is still a good idea.
- This is still a long way off a proper unit test.
* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.
Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
|
|
|
} else {
|
2018-12-11 22:14:37 +00:00
|
|
|
ffs_update_dinode_ckhash(fs, ip->i_din2);
|
2002-06-21 06:18:05 +00:00
|
|
|
*((struct ufs2_dinode *)bp->b_data +
|
|
|
|
ino_to_fsbo(fs, ip->i_number)) = *ip->i_din2;
|
2018-11-13 21:40:56 +00:00
|
|
|
/*
|
|
|
|
* XXX: FIX? The entropy here is desirable,
|
|
|
|
* but the harvesting may be expensive
|
|
|
|
*/
|
2018-08-26 12:51:46 +00:00
|
|
|
random_harvest_queue(&(ip->i_din2), sizeof(ip->i_din2), RANDOM_FS_ATIME);
|
Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
random(4) device in the kernel, and the KERN_ARND sysctl will
return nothing. With RANDOM_DUMMY there will be a random(4) that
always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
(direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
when the dust settles.
- Use macros for locks.
- Fix comments.
* src/share/man/...
- Update the man pages.
* src/etc/...
- The startup/shutdown work is done in D2924.
* src/UPDATING
- Add UPDATING announcement.
* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.
* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.
* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.
* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
selection is the way to go.
* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.
* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.
* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
that instead. All that is needed here is N=0, N++, N==0, and some
localised trickery is used to manufacture a 128-bit 0ULLL.
* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
now the test will do a basic check of compressibility. Clairvoyant
talent is still a good idea.
- This is still a long way off a proper unit test.
* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.
Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
|
|
|
}
|
This commit enables a UFS filesystem to do a forcible unmount when
the underlying media fails or becomes inaccessible. For example
when a USB flash memory card hosting a UFS filesystem is unplugged.
The strategy for handling disk I/O errors when soft updates are
enabled is to stop writing to the disk of the affected file system
but continue to accept I/O requests and report that all future
writes by the file system to that disk actually succeed. Then
initiate an asynchronous forced unmount of the affected file system.
There are two cases for disk I/O errors:
- ENXIO, which means that this disk is gone and the lower layers
of the storage stack already guarantee that no future I/O to
this disk will succeed.
- EIO (or most other errors), which means that this particular
I/O request has failed but subsequent I/O requests to this
disk might still succeed.
For ENXIO, we can just clear the error and continue, because we
know that the file system cannot affect the on-disk state after we
see this error. For EIO or other errors, we arrange for the geom_vfs
layer to reject all future I/O requests with ENXIO just like is
done when the geom_vfs is orphaned. In both cases, the file system
code can just clear the error and proceed with the forcible unmount.
This new treatment of I/O errors is needed for writes of any buffer
that is involved in a dependency. Most dependencies are described
by a structure attached to the buffer's b_dep field. But some are
created and processed as a result of the completion of the dependencies
attached to the buffer.
Clearing of some dependencies require a read. For example if there
is a dependency that requires an inode to be written, the disk block
containing that inode must be read, the updated inode copied into
place in that buffer, and the buffer then written back to disk.
Often the needed buffer is already in memory and can be used. But
if it needs to be read from the disk, the read will fail, so we
fabricate a buffer full of zeroes and pretend that the read succeeded.
This zero'ed buffer can be updated and written back to disk.
The only case where a buffer full of zeros causes the code to do
the wrong thing is when reading an inode buffer containing an inode
that still has an inode dependency in memory that will reinitialize
the effective link count (i_effnlink) based on the actual link count
(i_nlink) that we read. To handle this case we now store the i_nlink
value that we wrote in the inode dependency so that it can be
restored into the zero'ed buffer thus keeping the tracking of the
inode link count consistent.
Because applications depend on knowing when an attempt to write
their data to stable storage has failed, the fsync(2) and msync(2)
system calls need to return errors if data fails to be written to
stable storage. So these operations return ENXIO for every call
made on files in a file system where we have otherwise been ignoring
I/O errors.
Coauthered by: mckusick
Reviewed by: kib
Tested by: Peter Holm
Approved by: mckusick (mentor)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24088
2020-05-25 23:47:31 +00:00
|
|
|
if (waitfor) {
|
2012-03-01 18:45:25 +00:00
|
|
|
error = bwrite(bp);
|
This commit enables a UFS filesystem to do a forcible unmount when
the underlying media fails or becomes inaccessible. For example
when a USB flash memory card hosting a UFS filesystem is unplugged.
The strategy for handling disk I/O errors when soft updates are
enabled is to stop writing to the disk of the affected file system
but continue to accept I/O requests and report that all future
writes by the file system to that disk actually succeed. Then
initiate an asynchronous forced unmount of the affected file system.
There are two cases for disk I/O errors:
- ENXIO, which means that this disk is gone and the lower layers
of the storage stack already guarantee that no future I/O to
this disk will succeed.
- EIO (or most other errors), which means that this particular
I/O request has failed but subsequent I/O requests to this
disk might still succeed.
For ENXIO, we can just clear the error and continue, because we
know that the file system cannot affect the on-disk state after we
see this error. For EIO or other errors, we arrange for the geom_vfs
layer to reject all future I/O requests with ENXIO just like is
done when the geom_vfs is orphaned. In both cases, the file system
code can just clear the error and proceed with the forcible unmount.
This new treatment of I/O errors is needed for writes of any buffer
that is involved in a dependency. Most dependencies are described
by a structure attached to the buffer's b_dep field. But some are
created and processed as a result of the completion of the dependencies
attached to the buffer.
Clearing of some dependencies require a read. For example if there
is a dependency that requires an inode to be written, the disk block
containing that inode must be read, the updated inode copied into
place in that buffer, and the buffer then written back to disk.
Often the needed buffer is already in memory and can be used. But
if it needs to be read from the disk, the read will fail, so we
fabricate a buffer full of zeroes and pretend that the read succeeded.
This zero'ed buffer can be updated and written back to disk.
The only case where a buffer full of zeros causes the code to do
the wrong thing is when reading an inode buffer containing an inode
that still has an inode dependency in memory that will reinitialize
the effective link count (i_effnlink) based on the actual link count
(i_nlink) that we read. To handle this case we now store the i_nlink
value that we wrote in the inode dependency so that it can be
restored into the zero'ed buffer thus keeping the tracking of the
inode link count consistent.
Because applications depend on knowing when an attempt to write
their data to stable storage has failed, the fsync(2) and msync(2)
system calls need to return errors if data fails to be written to
stable storage. So these operations return ENXIO for every call
made on files in a file system where we have otherwise been ignoring
I/O errors.
Coauthered by: mckusick
Reviewed by: kib
Tested by: Peter Holm
Approved by: mckusick (mentor)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24088
2020-05-25 23:47:31 +00:00
|
|
|
if (ffs_fsfail_cleanup(VFSTOUFS(vp->v_mount), error))
|
|
|
|
error = 0;
|
|
|
|
} else if (vm_page_count_severe() || buf_dirty_count_severe()) {
|
2012-03-11 20:23:46 +00:00
|
|
|
bawrite(bp);
|
|
|
|
error = 0;
|
1998-03-08 09:59:44 +00:00
|
|
|
} else {
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (bp->b_bufsize == fs->fs_bsize)
|
|
|
|
bp->b_flags |= B_CLUSTEROK;
|
1994-05-24 10:09:53 +00:00
|
|
|
bdwrite(bp);
|
2012-03-01 18:45:25 +00:00
|
|
|
error = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2012-03-01 18:45:25 +00:00
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define SINGLE 0 /* index of single indirect block */
|
|
|
|
#define DOUBLE 1 /* index of double indirect block */
|
|
|
|
#define TRIPLE 2 /* index of triple indirect block */
|
|
|
|
/*
|
2005-04-05 08:49:41 +00:00
|
|
|
* Truncate the inode ip to at most length size, freeing the
|
1994-05-24 10:09:53 +00:00
|
|
|
* disk blocks.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
2012-04-23 13:21:28 +00:00
|
|
|
ffs_truncate(vp, length, flags, cred)
|
VFS mega cleanup commit (x/N)
1. Add new file "sys/kern/vfs_default.c" where default actions for
VOPs go. Implement proper defaults for ABORTOP, BWRITE, LEASE,
POLL, REVOKE and STRATEGY. Various stuff spread over the entire
tree belongs here.
2. Change VOP_BLKATOFF to a normal function in cd9660.
3. Kill VOP_BLKATOFF, VOP_TRUNCATE, VOP_VFREE, VOP_VALLOC. These
are private interface functions between UFS and the underlying
storage manager layer (FFS/LFS/MFS/EXT2FS). The functions now
live in struct ufsmount instead.
4. Remove a kludge of VOP_ functions in all filesystems, that did
nothing but obscure the simplicity and break the expandability.
If a filesystem doesn't implement VOP_FOO, it shouldn't have an
entry for it in its vnops table. The system will try to DTRT
if it is not implemented. There are still some cruft left, but
the bulk of it is done.
5. Fix another VCALL in vfs_cache.c (thanks Bruce!)
1997-10-16 10:50:27 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
off_t length;
|
|
|
|
int flags;
|
|
|
|
struct ucred *cred;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2005-04-05 08:49:41 +00:00
|
|
|
struct inode *ip;
|
2017-02-15 19:50:26 +00:00
|
|
|
ufs2_daddr_t bn, lbn, lastblock, lastiblock[UFS_NIADDR];
|
|
|
|
ufs2_daddr_t indir_lbn[UFS_NIADDR], oldblks[UFS_NDADDR + UFS_NIADDR];
|
|
|
|
ufs2_daddr_t newblks[UFS_NDADDR + UFS_NIADDR];
|
2016-02-24 01:58:40 +00:00
|
|
|
ufs2_daddr_t count, blocksreleased = 0, datablocks, blkno;
|
2008-03-22 09:15:16 +00:00
|
|
|
struct bufobj *bo;
|
2002-05-13 09:22:31 +00:00
|
|
|
struct fs *fs;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct buf *bp;
|
2005-01-24 10:04:22 +00:00
|
|
|
struct ufsmount *ump;
|
2011-06-10 22:48:35 +00:00
|
|
|
int softdeptrunc, journaltrunc;
|
|
|
|
int needextclean, extblocks;
|
2018-08-18 21:21:06 +00:00
|
|
|
int offset, size, level, nblocks;
|
2016-09-08 17:40:40 +00:00
|
|
|
int i, error, allerror, indiroff, waitforupdate;
|
2018-08-18 22:21:59 +00:00
|
|
|
u_long key;
|
1994-05-24 10:09:53 +00:00
|
|
|
off_t osize;
|
|
|
|
|
2005-04-05 08:49:41 +00:00
|
|
|
ip = VTOI(vp);
|
2016-09-17 16:47:34 +00:00
|
|
|
ump = VFSTOUFS(vp->v_mount);
|
|
|
|
fs = ump->um_fs;
|
2008-03-22 09:15:16 +00:00
|
|
|
bo = &vp->v_bufobj;
|
2005-01-24 10:04:22 +00:00
|
|
|
|
2005-02-22 23:56:42 +00:00
|
|
|
ASSERT_VOP_LOCKED(vp, "ffs_truncate");
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (length < 0)
|
1994-10-22 02:27:35 +00:00
|
|
|
return (EINVAL);
|
2010-04-24 07:05:35 +00:00
|
|
|
if (length > fs->fs_maxfilesize)
|
|
|
|
return (EFBIG);
|
2011-06-10 22:48:35 +00:00
|
|
|
#ifdef QUOTA
|
|
|
|
error = getinoquota(ip);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
#endif
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
/*
|
|
|
|
* Historically clients did not have to specify which data
|
|
|
|
* they were truncating. So, if not specified, we assume
|
|
|
|
* traditional behavior, e.g., just the normal data.
|
|
|
|
*/
|
|
|
|
if ((flags & (IO_EXT | IO_NORMAL)) == 0)
|
|
|
|
flags |= IO_NORMAL;
|
2010-07-06 07:11:04 +00:00
|
|
|
if (!DOINGSOFTDEP(vp) && !DOINGASYNC(vp))
|
|
|
|
flags |= IO_SYNC;
|
2016-09-08 17:40:40 +00:00
|
|
|
waitforupdate = (flags & IO_SYNC) != 0 || !DOINGASYNC(vp);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
/*
|
|
|
|
* If we are truncating the extended-attributes, and cannot
|
|
|
|
* do it with soft updates, then do it slowly here. If we are
|
|
|
|
* truncating both the extended attributes and the file contents
|
|
|
|
* (e.g., the file is being unlinked), then pick it off with
|
|
|
|
* soft updates below.
|
|
|
|
*/
|
2010-04-24 07:05:35 +00:00
|
|
|
allerror = 0;
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
needextclean = 0;
|
2011-06-10 22:48:35 +00:00
|
|
|
softdeptrunc = 0;
|
|
|
|
journaltrunc = DOINGSUJ(vp);
|
2020-04-09 23:51:18 +00:00
|
|
|
journaltrunc = 0; /* XXX temp patch until bug found */
|
2011-06-10 22:48:35 +00:00
|
|
|
if (journaltrunc == 0 && DOINGSOFTDEP(vp) && length == 0)
|
|
|
|
softdeptrunc = !softdep_slowdown(vp);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
extblocks = 0;
|
2005-04-05 08:49:41 +00:00
|
|
|
datablocks = DIP(ip, i_blocks);
|
|
|
|
if (fs->fs_magic == FS_UFS2_MAGIC && ip->i_din2->di_extsize > 0) {
|
|
|
|
extblocks = btodb(fragroundup(fs, ip->i_din2->di_extsize));
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
datablocks -= extblocks;
|
|
|
|
}
|
|
|
|
if ((flags & IO_EXT) && extblocks > 0) {
|
2011-06-10 22:48:35 +00:00
|
|
|
if (length != 0)
|
|
|
|
panic("ffs_truncate: partial trunc of extdata");
|
|
|
|
if (softdeptrunc || journaltrunc) {
|
|
|
|
if ((flags & IO_NORMAL) == 0)
|
|
|
|
goto extclean;
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
needextclean = 1;
|
|
|
|
} else {
|
2012-03-25 00:02:37 +00:00
|
|
|
if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
return (error);
|
|
|
|
#ifdef QUOTA
|
2019-07-31 22:44:58 +00:00
|
|
|
(void) chkdq(ip, -extblocks, NOCRED, FORCE);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
#endif
|
2008-10-10 21:23:50 +00:00
|
|
|
vinvalbuf(vp, V_ALT, 0, 0);
|
2011-08-25 08:17:39 +00:00
|
|
|
vn_pages_remove(vp,
|
2009-01-20 22:00:19 +00:00
|
|
|
OFF_TO_IDX(lblktosize(fs, -extblocks)), 0);
|
2011-06-10 22:48:35 +00:00
|
|
|
osize = ip->i_din2->di_extsize;
|
|
|
|
ip->i_din2->di_blocks -= extblocks;
|
2005-04-05 08:49:41 +00:00
|
|
|
ip->i_din2->di_extsize = 0;
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NXADDR; i++) {
|
2005-04-05 08:49:41 +00:00
|
|
|
oldblks[i] = ip->i_din2->di_extb[i];
|
|
|
|
ip->i_din2->di_extb[i] = 0;
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
}
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE);
|
2016-09-08 17:40:40 +00:00
|
|
|
if ((error = ffs_update(vp, waitforupdate)))
|
2011-06-10 22:48:35 +00:00
|
|
|
return (error);
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NXADDR; i++) {
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
if (oldblks[i] == 0)
|
|
|
|
continue;
|
2016-09-17 16:47:34 +00:00
|
|
|
ffs_blkfree(ump, fs, ITODEVVP(ip), oldblks[i],
|
2011-06-15 23:19:09 +00:00
|
|
|
sblksize(fs, osize, i), ip->i_number,
|
2018-08-18 22:21:59 +00:00
|
|
|
vp->v_type, NULL, SINGLETON_KEY);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-10 22:48:35 +00:00
|
|
|
if ((flags & IO_NORMAL) == 0)
|
|
|
|
return (0);
|
2005-04-05 08:49:41 +00:00
|
|
|
if (vp->v_type == VLNK &&
|
|
|
|
(ip->i_size < vp->v_mount->mnt_maxsymlinklen ||
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
datablocks == 0)) {
|
2007-11-08 17:21:51 +00:00
|
|
|
#ifdef INVARIANTS
|
1994-05-24 10:09:53 +00:00
|
|
|
if (length != 0)
|
|
|
|
panic("ffs_truncate: partial truncate of symlink");
|
|
|
|
#endif
|
2005-04-05 08:49:41 +00:00
|
|
|
bzero(SHORTLINK(ip), (u_int)ip->i_size);
|
|
|
|
ip->i_size = 0;
|
|
|
|
DIP_SET(ip, i_size, 0);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
if (needextclean)
|
2011-06-10 22:48:35 +00:00
|
|
|
goto extclean;
|
2016-09-08 17:40:40 +00:00
|
|
|
return (ffs_update(vp, waitforupdate));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2005-04-05 08:49:41 +00:00
|
|
|
if (ip->i_size == length) {
|
2020-01-13 02:31:51 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE);
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
if (needextclean)
|
2011-06-10 22:48:35 +00:00
|
|
|
goto extclean;
|
2012-03-11 20:26:19 +00:00
|
|
|
return (ffs_update(vp, 0));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2002-01-16 04:59:09 +00:00
|
|
|
if (fs->fs_ronly)
|
|
|
|
panic("ffs_truncate: read-only filesystem");
|
2012-03-01 18:45:25 +00:00
|
|
|
if (IS_SNAPSHOT(ip))
|
2005-04-05 08:49:41 +00:00
|
|
|
ffs_snapremove(vp);
|
|
|
|
vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0;
|
2010-04-24 07:05:35 +00:00
|
|
|
osize = ip->i_size;
|
|
|
|
/*
|
|
|
|
* Lengthen the size of the file. We must ensure that the
|
|
|
|
* last byte of the file is allocated. Since the smallest
|
|
|
|
* value of osize is 0, length will be at least 1.
|
|
|
|
*/
|
|
|
|
if (osize < length) {
|
|
|
|
vnode_pager_setsize(vp, length);
|
|
|
|
flags |= BA_CLRBUF;
|
|
|
|
error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp);
|
|
|
|
if (error) {
|
|
|
|
vnode_pager_setsize(vp, osize);
|
2011-06-10 22:48:35 +00:00
|
|
|
return (error);
|
2010-04-24 07:05:35 +00:00
|
|
|
}
|
|
|
|
ip->i_size = length;
|
|
|
|
DIP_SET(ip, i_size, length);
|
|
|
|
if (bp->b_bufsize == fs->fs_bsize)
|
|
|
|
bp->b_flags |= B_CLUSTEROK;
|
|
|
|
if (flags & IO_SYNC)
|
|
|
|
bwrite(bp);
|
2012-03-11 20:26:19 +00:00
|
|
|
else if (DOINGASYNC(vp))
|
|
|
|
bdwrite(bp);
|
2010-04-24 07:05:35 +00:00
|
|
|
else
|
|
|
|
bawrite(bp);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
2016-09-08 17:40:40 +00:00
|
|
|
return (ffs_update(vp, waitforupdate));
|
2010-04-24 07:05:35 +00:00
|
|
|
}
|
2016-02-24 01:58:40 +00:00
|
|
|
/*
|
|
|
|
* Lookup block number for a given offset. Zero length files
|
|
|
|
* have no blocks, so return a blkno of -1.
|
|
|
|
*/
|
|
|
|
lbn = lblkno(fs, length - 1);
|
|
|
|
if (length == 0) {
|
|
|
|
blkno = -1;
|
2017-02-15 19:50:26 +00:00
|
|
|
} else if (lbn < UFS_NDADDR) {
|
2016-02-24 01:58:40 +00:00
|
|
|
blkno = DIP(ip, i_db[lbn]);
|
|
|
|
} else {
|
|
|
|
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn), fs->fs_bsize,
|
|
|
|
cred, BA_METAONLY, &bp);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2017-02-15 19:50:26 +00:00
|
|
|
indiroff = (lbn - UFS_NDADDR) % NINDIR(fs);
|
2016-09-17 16:47:34 +00:00
|
|
|
if (I_IS_UFS1(ip))
|
2016-02-24 01:58:40 +00:00
|
|
|
blkno = ((ufs1_daddr_t *)(bp->b_data))[indiroff];
|
|
|
|
else
|
|
|
|
blkno = ((ufs2_daddr_t *)(bp->b_data))[indiroff];
|
|
|
|
/*
|
|
|
|
* If the block number is non-zero, then the indirect block
|
|
|
|
* must have been previously allocated and need not be written.
|
|
|
|
* If the block number is zero, then we may have allocated
|
|
|
|
* the indirect block and hence need to write it out.
|
|
|
|
*/
|
|
|
|
if (blkno != 0)
|
|
|
|
brelse(bp);
|
2016-09-08 17:40:40 +00:00
|
|
|
else if (flags & IO_SYNC)
|
2016-02-24 01:58:40 +00:00
|
|
|
bwrite(bp);
|
2016-09-08 17:40:40 +00:00
|
|
|
else
|
|
|
|
bdwrite(bp);
|
2016-02-24 01:58:40 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If the block number at the new end of the file is zero,
|
|
|
|
* then we must allocate it to ensure that the last block of
|
|
|
|
* the file is allocated. Soft updates does not handle this
|
|
|
|
* case, so here we have to clean up the soft updates data
|
|
|
|
* structures describing the allocation past the truncation
|
|
|
|
* point. Finding and deallocating those structures is a lot of
|
|
|
|
* work. Since partial truncation with a hole at the end occurs
|
|
|
|
* rarely, we solve the problem by syncing the file so that it
|
|
|
|
* will have no soft updates data structures left.
|
|
|
|
*/
|
|
|
|
if (blkno == 0 && (error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
|
|
|
|
return (error);
|
|
|
|
if (blkno != 0 && DOINGSOFTDEP(vp)) {
|
2011-06-10 22:48:35 +00:00
|
|
|
if (softdeptrunc == 0 && journaltrunc == 0) {
|
1998-03-08 09:59:44 +00:00
|
|
|
/*
|
2016-02-24 01:58:40 +00:00
|
|
|
* If soft updates cannot handle this truncation,
|
|
|
|
* clean up soft dependency data structures and
|
|
|
|
* fall through to the synchronous truncation.
|
1998-03-08 09:59:44 +00:00
|
|
|
*/
|
2012-03-25 00:02:37 +00:00
|
|
|
if ((error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
|
2011-06-10 22:48:35 +00:00
|
|
|
return (error);
|
1998-03-08 09:59:44 +00:00
|
|
|
} else {
|
2011-06-10 22:48:35 +00:00
|
|
|
flags = IO_NORMAL | (needextclean ? IO_EXT: 0);
|
|
|
|
if (journaltrunc)
|
|
|
|
softdep_journal_freeblocks(ip, cred, length,
|
|
|
|
flags);
|
|
|
|
else
|
|
|
|
softdep_setup_freeblocks(ip, length, flags);
|
2005-02-22 23:56:42 +00:00
|
|
|
ASSERT_VOP_LOCKED(vp, "ffs_truncate1");
|
2011-06-10 22:48:35 +00:00
|
|
|
if (journaltrunc == 0) {
|
2020-01-13 02:31:51 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE);
|
2011-06-10 22:48:35 +00:00
|
|
|
error = ffs_update(vp, 0);
|
|
|
|
}
|
|
|
|
return (error);
|
2009-01-20 11:30:22 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
/*
|
2016-02-24 01:58:40 +00:00
|
|
|
* Shorten the size of the file. If the last block of the
|
|
|
|
* shortened file is unallocated, we must allocate it.
|
|
|
|
* Additionally, if the file is not being truncated to a
|
|
|
|
* block boundary, the contents of the partial block
|
|
|
|
* following the end of the file must be zero'ed in
|
|
|
|
* case it ever becomes accessible again because of
|
|
|
|
* subsequent file growth. Directories however are not
|
1998-06-14 19:31:28 +00:00
|
|
|
* zero'ed as they should grow back initialized to empty.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
offset = blkoff(fs, length);
|
2016-02-24 01:58:40 +00:00
|
|
|
if (blkno != 0 && offset == 0) {
|
2005-04-05 08:49:41 +00:00
|
|
|
ip->i_size = length;
|
|
|
|
DIP_SET(ip, i_size, length);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
1994-05-24 10:09:53 +00:00
|
|
|
} else {
|
2020-04-06 20:23:47 +00:00
|
|
|
lbn = lblkno(fs, length);
|
|
|
|
flags |= BA_CLRBUF;
|
|
|
|
error = UFS_BALLOC(vp, length - 1, 1, cred, flags, &bp);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2001-12-13 05:07:48 +00:00
|
|
|
/*
|
|
|
|
* When we are doing soft updates and the UFS_BALLOC
|
|
|
|
* above fills in a direct block hole with a full sized
|
|
|
|
* block that will be truncated down to a fragment below,
|
|
|
|
* we must flush out the block dependency with an FSYNC
|
|
|
|
* so that we do not get a soft updates inconsistency
|
|
|
|
* when we create the fragment below.
|
|
|
|
*/
|
2017-02-15 19:50:26 +00:00
|
|
|
if (DOINGSOFTDEP(vp) && lbn < UFS_NDADDR &&
|
2001-12-13 05:07:48 +00:00
|
|
|
fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize &&
|
2012-03-25 00:02:37 +00:00
|
|
|
(error = ffs_syncvnode(vp, MNT_WAIT, 0)) != 0)
|
2011-06-10 22:48:35 +00:00
|
|
|
return (error);
|
2005-04-05 08:49:41 +00:00
|
|
|
ip->i_size = length;
|
|
|
|
DIP_SET(ip, i_size, length);
|
|
|
|
size = blksize(fs, ip, lbn);
|
2016-02-24 01:58:40 +00:00
|
|
|
if (vp->v_type != VDIR && offset != 0)
|
1998-06-14 19:31:28 +00:00
|
|
|
bzero((char *)bp->b_data + offset,
|
|
|
|
(u_int)(size - offset));
|
|
|
|
/* Kirk's code has reallocbuf(bp, size, 1) here */
|
1995-03-26 23:29:13 +00:00
|
|
|
allocbuf(bp, size);
|
Make our v_usecount vnode reference count work identically to the
original BSD code. The association between the vnode and the vm_object
no longer includes reference counts. The major difference is that
vm_object's are no longer freed gratuitiously from the vnode, and so
once an object is created for the vnode, it will last as long as the
vnode does.
When a vnode object reference count is incremented, then the underlying
vnode reference count is incremented also. The two "objects" are now
more intimately related, and so the interactions are now much less
complex.
When vnodes are now normally placed onto the free queue with an object still
attached. The rundown of the object happens at vnode rundown time, and
happens with exactly the same filesystem semantics of the original VFS
code. There is absolutely no need for vnode_pager_uncache and other
travesties like that anymore.
A side-effect of these changes is that SMP locking should be much simpler,
the I/O copyin/copyout optimizations work, NFS should be more ponderable,
and further work on layered filesystems should be less frustrating, because
of the totally coherent management of the vnode objects and vnodes.
Please be careful with your system while running this code, but I would
greatly appreciate feedback as soon a reasonably possible.
1998-01-06 05:26:17 +00:00
|
|
|
if (bp->b_bufsize == fs->fs_bsize)
|
|
|
|
bp->b_flags |= B_CLUSTEROK;
|
Add support to UFS2 to provide storage for extended attributes.
As this code is not actually used by any of the existing
interfaces, it seems unlikely to break anything (famous
last words).
The internal kernel interface to manipulate these attributes
is invoked using two new IO_ flags: IO_NORMAL and IO_EXT.
These flags may be specified in the ioflags word of VOP_READ,
VOP_WRITE, and VOP_TRUNCATE. Specifying IO_NORMAL means that
you want to do I/O to the normal data part of the file and
IO_EXT means that you want to do I/O to the extended attributes
part of the file. IO_NORMAL and IO_EXT are mutually exclusive
for VOP_READ and VOP_WRITE, but may be specified individually
or together in the case of VOP_TRUNCATE. For example, when
removing a file, VOP_TRUNCATE is called with both IO_NORMAL
and IO_EXT set. For backward compatibility, if neither IO_NORMAL
nor IO_EXT is set, then IO_NORMAL is assumed.
Note that the BA_ and IO_ flags have been `merged' so that they
may both be used in the same flags word. This merger is possible
by assigning the IO_ flags to the low sixteen bits and the BA_
flags the high sixteen bits. This works because the high sixteen
bits of the IO_ word is reserved for read-ahead and help with
write clustering so will never be used for flags. This merge
lets us get away from code of the form:
if (ioflags & IO_SYNC)
flags |= BA_SYNC;
For the future, I have considered adding a new field to the
vattr structure, va_extsize. This addition could then be
exported through the stat structure to allow applications to
find out the size of the extended attribute storage and also
would provide a more standard interface for truncating them
(via VOP_SETATTR rather than VOP_TRUNCATE).
I am also contemplating adding a pathconf parameter (for
concreteness, lets call it _PC_MAX_EXTSIZE) which would
let an application determine the maximum size of the extended
atribute storage.
Sponsored by: DARPA & NAI Labs.
2002-07-19 07:29:39 +00:00
|
|
|
if (flags & IO_SYNC)
|
1994-05-24 10:09:53 +00:00
|
|
|
bwrite(bp);
|
2012-03-11 20:26:19 +00:00
|
|
|
else if (DOINGASYNC(vp))
|
|
|
|
bdwrite(bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
else
|
|
|
|
bawrite(bp);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Calculate index into inode's block list of
|
|
|
|
* last direct and indirect blocks (if any)
|
|
|
|
* which we want to keep. Lastblock is -1 when
|
|
|
|
* the file is truncated to 0.
|
|
|
|
*/
|
|
|
|
lastblock = lblkno(fs, length + fs->fs_bsize - 1) - 1;
|
2017-02-15 19:50:26 +00:00
|
|
|
lastiblock[SINGLE] = lastblock - UFS_NDADDR;
|
1994-05-24 10:09:53 +00:00
|
|
|
lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
|
|
|
|
lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
|
|
|
|
nblocks = btodb(fs->fs_bsize);
|
|
|
|
/*
|
|
|
|
* Update file and block pointers on disk before we start freeing
|
|
|
|
* blocks. If we crash before free'ing blocks below, the blocks
|
|
|
|
* will be returned to the free list. lastiblock values are also
|
|
|
|
* normalized to -1 for calls to ffs_indirtrunc below.
|
|
|
|
*/
|
2002-06-21 06:18:05 +00:00
|
|
|
for (level = TRIPLE; level >= SINGLE; level--) {
|
2017-02-15 19:50:26 +00:00
|
|
|
oldblks[UFS_NDADDR + level] = DIP(ip, i_ib[level]);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (lastiblock[level] < 0) {
|
2005-04-05 08:49:41 +00:00
|
|
|
DIP_SET(ip, i_ib[level], 0);
|
1994-05-24 10:09:53 +00:00
|
|
|
lastiblock[level] = -1;
|
|
|
|
}
|
2002-06-21 06:18:05 +00:00
|
|
|
}
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NDADDR; i++) {
|
2005-04-05 08:49:41 +00:00
|
|
|
oldblks[i] = DIP(ip, i_db[i]);
|
2002-06-21 06:18:05 +00:00
|
|
|
if (i > lastblock)
|
2005-04-05 08:49:41 +00:00
|
|
|
DIP_SET(ip, i_db[i], 0);
|
2002-06-21 06:18:05 +00:00
|
|
|
}
|
2020-01-13 02:31:51 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_CHANGE | IN_UPDATE);
|
2016-09-08 17:40:40 +00:00
|
|
|
allerror = ffs_update(vp, waitforupdate);
|
1998-03-19 22:49:44 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Having written the new inode to disk, save its new configuration
|
|
|
|
* and put back the old block pointers long enough to process them.
|
|
|
|
* Note that we save the new block configuration so we can check it
|
|
|
|
* when we are done.
|
|
|
|
*/
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NDADDR; i++) {
|
2005-04-05 08:49:41 +00:00
|
|
|
newblks[i] = DIP(ip, i_db[i]);
|
|
|
|
DIP_SET(ip, i_db[i], oldblks[i]);
|
2002-06-21 06:18:05 +00:00
|
|
|
}
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NIADDR; i++) {
|
|
|
|
newblks[UFS_NDADDR + i] = DIP(ip, i_ib[i]);
|
|
|
|
DIP_SET(ip, i_ib[i], oldblks[UFS_NDADDR + i]);
|
2002-06-21 06:18:05 +00:00
|
|
|
}
|
2005-04-05 08:49:41 +00:00
|
|
|
ip->i_size = osize;
|
|
|
|
DIP_SET(ip, i_size, osize);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
1998-03-19 22:49:44 +00:00
|
|
|
|
2019-05-24 20:27:50 +00:00
|
|
|
error = vtruncbuf(vp, length, fs->fs_bsize);
|
1998-03-19 22:49:44 +00:00
|
|
|
if (error && (allerror == 0))
|
|
|
|
allerror = error;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Indirect blocks first.
|
|
|
|
*/
|
2017-02-15 19:50:26 +00:00
|
|
|
indir_lbn[SINGLE] = -UFS_NDADDR;
|
1994-05-24 10:09:53 +00:00
|
|
|
indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
|
|
|
|
indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
|
|
|
|
for (level = TRIPLE; level >= SINGLE; level--) {
|
2005-04-05 08:49:41 +00:00
|
|
|
bn = DIP(ip, i_ib[level]);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bn != 0) {
|
2005-04-05 08:49:41 +00:00
|
|
|
error = ffs_indirtrunc(ip, indir_lbn[level],
|
1994-05-24 10:09:53 +00:00
|
|
|
fsbtodb(fs, bn), lastiblock[level], level, &count);
|
|
|
|
if (error)
|
|
|
|
allerror = error;
|
|
|
|
blocksreleased += count;
|
|
|
|
if (lastiblock[level] < 0) {
|
2005-04-05 08:49:41 +00:00
|
|
|
DIP_SET(ip, i_ib[level], 0);
|
2016-09-17 16:47:34 +00:00
|
|
|
ffs_blkfree(ump, fs, ump->um_devvp, bn,
|
2011-06-15 23:19:09 +00:00
|
|
|
fs->fs_bsize, ip->i_number,
|
2018-08-18 22:21:59 +00:00
|
|
|
vp->v_type, NULL, SINGLETON_KEY);
|
1994-05-24 10:09:53 +00:00
|
|
|
blocksreleased += nblocks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (lastiblock[level] >= 0)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All whole direct blocks or frags.
|
|
|
|
*/
|
2018-08-18 22:21:59 +00:00
|
|
|
key = ffs_blkrelease_start(ump, ump->um_devvp, ip->i_number);
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = UFS_NDADDR - 1; i > lastblock; i--) {
|
2002-05-13 09:22:31 +00:00
|
|
|
long bsize;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2005-04-05 08:49:41 +00:00
|
|
|
bn = DIP(ip, i_db[i]);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bn == 0)
|
|
|
|
continue;
|
2005-04-05 08:49:41 +00:00
|
|
|
DIP_SET(ip, i_db[i], 0);
|
|
|
|
bsize = blksize(fs, ip, i);
|
2016-09-17 16:47:34 +00:00
|
|
|
ffs_blkfree(ump, fs, ump->um_devvp, bn, bsize, ip->i_number,
|
2018-08-18 22:21:59 +00:00
|
|
|
vp->v_type, NULL, key);
|
1994-05-24 10:09:53 +00:00
|
|
|
blocksreleased += btodb(bsize);
|
|
|
|
}
|
2018-08-18 22:21:59 +00:00
|
|
|
ffs_blkrelease_finish(ump, key);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (lastblock < 0)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, look for a change in size of the
|
|
|
|
* last direct block; release any frags.
|
|
|
|
*/
|
2005-04-05 08:49:41 +00:00
|
|
|
bn = DIP(ip, i_db[lastblock]);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (bn != 0) {
|
|
|
|
long oldspace, newspace;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate amount of space we're giving
|
|
|
|
* back as old block size minus new block size.
|
|
|
|
*/
|
2005-04-05 08:49:41 +00:00
|
|
|
oldspace = blksize(fs, ip, lastblock);
|
|
|
|
ip->i_size = length;
|
|
|
|
DIP_SET(ip, i_size, length);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
|
2005-04-05 08:49:41 +00:00
|
|
|
newspace = blksize(fs, ip, lastblock);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (newspace == 0)
|
1994-08-03 08:19:35 +00:00
|
|
|
panic("ffs_truncate: newspace");
|
1994-05-24 10:09:53 +00:00
|
|
|
if (oldspace - newspace > 0) {
|
|
|
|
/*
|
|
|
|
* Block number of space to be free'd is
|
|
|
|
* the old block # plus the number of frags
|
|
|
|
* required for the storage we're keeping.
|
|
|
|
*/
|
|
|
|
bn += numfrags(fs, newspace);
|
2016-09-17 16:47:34 +00:00
|
|
|
ffs_blkfree(ump, fs, ump->um_devvp, bn,
|
2018-08-18 22:21:59 +00:00
|
|
|
oldspace - newspace, ip->i_number, vp->v_type,
|
|
|
|
NULL, SINGLETON_KEY);
|
1994-05-24 10:09:53 +00:00
|
|
|
blocksreleased += btodb(oldspace - newspace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
2007-11-08 17:21:51 +00:00
|
|
|
#ifdef INVARIANTS
|
1994-05-24 10:09:53 +00:00
|
|
|
for (level = SINGLE; level <= TRIPLE; level++)
|
2017-02-15 19:50:26 +00:00
|
|
|
if (newblks[UFS_NDADDR + level] != DIP(ip, i_ib[level]))
|
2019-03-11 23:53:56 +00:00
|
|
|
panic("ffs_truncate1: level %d newblks %jd != i_ib %jd",
|
|
|
|
level, (intmax_t)newblks[UFS_NDADDR + level],
|
|
|
|
(intmax_t)DIP(ip, i_ib[level]));
|
2017-02-15 19:50:26 +00:00
|
|
|
for (i = 0; i < UFS_NDADDR; i++)
|
2005-04-05 08:49:41 +00:00
|
|
|
if (newblks[i] != DIP(ip, i_db[i]))
|
2019-03-11 23:53:56 +00:00
|
|
|
panic("ffs_truncate2: blkno %d newblks %jd != i_db %jd",
|
|
|
|
i, (intmax_t)newblks[UFS_NDADDR + level],
|
|
|
|
(intmax_t)DIP(ip, i_ib[level]));
|
2008-03-22 09:15:16 +00:00
|
|
|
BO_LOCK(bo);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (length == 0 &&
|
2005-04-05 08:49:41 +00:00
|
|
|
(fs->fs_magic != FS_UFS2_MAGIC || ip->i_din2->di_extsize == 0) &&
|
2008-03-22 09:15:16 +00:00
|
|
|
(bo->bo_dirty.bv_cnt > 0 || bo->bo_clean.bv_cnt > 0))
|
2019-03-11 23:53:56 +00:00
|
|
|
panic("ffs_truncate3: vp = %p, buffers: dirty = %d, clean = %d",
|
|
|
|
vp, bo->bo_dirty.bv_cnt, bo->bo_clean.bv_cnt);
|
2008-03-22 09:15:16 +00:00
|
|
|
BO_UNLOCK(bo);
|
2007-11-08 17:21:51 +00:00
|
|
|
#endif /* INVARIANTS */
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Put back the real size.
|
|
|
|
*/
|
2005-04-05 08:49:41 +00:00
|
|
|
ip->i_size = length;
|
|
|
|
DIP_SET(ip, i_size, length);
|
2013-02-03 17:16:32 +00:00
|
|
|
if (DIP(ip, i_blocks) >= blocksreleased)
|
|
|
|
DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - blocksreleased);
|
|
|
|
else /* sanity */
|
2005-04-05 08:49:41 +00:00
|
|
|
DIP_SET(ip, i_blocks, 0);
|
2020-06-05 01:00:55 +00:00
|
|
|
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE);
|
1994-05-24 10:09:53 +00:00
|
|
|
#ifdef QUOTA
|
2019-07-31 22:44:58 +00:00
|
|
|
(void) chkdq(ip, -blocksreleased, NOCRED, FORCE);
|
1994-05-24 10:09:53 +00:00
|
|
|
#endif
|
2011-06-10 22:48:35 +00:00
|
|
|
return (allerror);
|
|
|
|
|
|
|
|
extclean:
|
|
|
|
if (journaltrunc)
|
|
|
|
softdep_journal_freeblocks(ip, cred, length, IO_EXT);
|
|
|
|
else
|
|
|
|
softdep_setup_freeblocks(ip, length, IO_EXT);
|
2016-09-08 17:40:40 +00:00
|
|
|
return (ffs_update(vp, waitforupdate));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release blocks associated with the inode ip and stored in the indirect
|
|
|
|
* block bn. Blocks are free'd in LIFO order up to (but not including)
|
|
|
|
* lastbn. If level is greater than SINGLE, the block is an indirect block
|
|
|
|
* and recursive calls to indirtrunc must be used to cleanse other indirect
|
|
|
|
* blocks.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
|
2002-05-13 09:22:31 +00:00
|
|
|
struct inode *ip;
|
2002-06-21 06:18:05 +00:00
|
|
|
ufs2_daddr_t lbn, lastbn;
|
|
|
|
ufs2_daddr_t dbn;
|
1994-05-24 10:09:53 +00:00
|
|
|
int level;
|
2002-06-21 06:18:05 +00:00
|
|
|
ufs2_daddr_t *countp;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
struct buf *bp;
|
2016-09-17 16:47:34 +00:00
|
|
|
struct fs *fs;
|
2018-08-18 22:21:59 +00:00
|
|
|
struct ufsmount *ump;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *vp;
|
2002-06-21 06:18:05 +00:00
|
|
|
caddr_t copy = NULL;
|
2018-08-18 22:21:59 +00:00
|
|
|
u_long key;
|
2018-08-18 21:21:06 +00:00
|
|
|
int i, nblocks, error = 0, allerror = 0;
|
2002-06-21 06:18:05 +00:00
|
|
|
ufs2_daddr_t nb, nlbn, last;
|
|
|
|
ufs2_daddr_t blkcount, factor, blocksreleased = 0;
|
|
|
|
ufs1_daddr_t *bap1 = NULL;
|
|
|
|
ufs2_daddr_t *bap2 = NULL;
|
2016-09-17 16:47:34 +00:00
|
|
|
#define BAP(ip, i) (I_IS_UFS1(ip) ? bap1[i] : bap2[i])
|
|
|
|
|
|
|
|
fs = ITOFS(ip);
|
2018-08-18 22:21:59 +00:00
|
|
|
ump = ITOUMP(ip);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate index in current block of last
|
|
|
|
* block to be kept. -1 indicates the entire
|
|
|
|
* block so we need not calculate the index.
|
|
|
|
*/
|
2010-11-11 11:35:42 +00:00
|
|
|
factor = lbn_offset(fs, level);
|
1994-05-24 10:09:53 +00:00
|
|
|
last = lastbn;
|
|
|
|
if (lastbn > 0)
|
|
|
|
last /= factor;
|
|
|
|
nblocks = btodb(fs->fs_bsize);
|
|
|
|
/*
|
|
|
|
* Get buffer of block pointers, zero those entries corresponding
|
|
|
|
* to blocks to be free'd, and update on disk copy first. Since
|
|
|
|
* double(triple) indirect before single(double) indirect, calls
|
2019-12-03 23:07:09 +00:00
|
|
|
* to VOP_BMAP() on these blocks will fail. However, we already
|
|
|
|
* have the on-disk address, so we just pass it to bread() instead
|
|
|
|
* of having bread() attempt to calculate it using VOP_BMAP().
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
vp = ITOV(ip);
|
This commit enables a UFS filesystem to do a forcible unmount when
the underlying media fails or becomes inaccessible. For example
when a USB flash memory card hosting a UFS filesystem is unplugged.
The strategy for handling disk I/O errors when soft updates are
enabled is to stop writing to the disk of the affected file system
but continue to accept I/O requests and report that all future
writes by the file system to that disk actually succeed. Then
initiate an asynchronous forced unmount of the affected file system.
There are two cases for disk I/O errors:
- ENXIO, which means that this disk is gone and the lower layers
of the storage stack already guarantee that no future I/O to
this disk will succeed.
- EIO (or most other errors), which means that this particular
I/O request has failed but subsequent I/O requests to this
disk might still succeed.
For ENXIO, we can just clear the error and continue, because we
know that the file system cannot affect the on-disk state after we
see this error. For EIO or other errors, we arrange for the geom_vfs
layer to reject all future I/O requests with ENXIO just like is
done when the geom_vfs is orphaned. In both cases, the file system
code can just clear the error and proceed with the forcible unmount.
This new treatment of I/O errors is needed for writes of any buffer
that is involved in a dependency. Most dependencies are described
by a structure attached to the buffer's b_dep field. But some are
created and processed as a result of the completion of the dependencies
attached to the buffer.
Clearing of some dependencies require a read. For example if there
is a dependency that requires an inode to be written, the disk block
containing that inode must be read, the updated inode copied into
place in that buffer, and the buffer then written back to disk.
Often the needed buffer is already in memory and can be used. But
if it needs to be read from the disk, the read will fail, so we
fabricate a buffer full of zeroes and pretend that the read succeeded.
This zero'ed buffer can be updated and written back to disk.
The only case where a buffer full of zeros causes the code to do
the wrong thing is when reading an inode buffer containing an inode
that still has an inode dependency in memory that will reinitialize
the effective link count (i_effnlink) based on the actual link count
(i_nlink) that we read. To handle this case we now store the i_nlink
value that we wrote in the inode dependency so that it can be
restored into the zero'ed buffer thus keeping the tracking of the
inode link count consistent.
Because applications depend on knowing when an attempt to write
their data to stable storage has failed, the fsync(2) and msync(2)
system calls need to return errors if data fails to be written to
stable storage. So these operations return ENXIO for every call
made on files in a file system where we have otherwise been ignoring
I/O errors.
Coauthered by: mckusick
Reviewed by: kib
Tested by: Peter Holm
Approved by: mckusick (mentor)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D24088
2020-05-25 23:47:31 +00:00
|
|
|
error = ffs_breadz(ump, vp, lbn, dbn, (int)fs->fs_bsize, NULL, NULL, 0,
|
2019-12-03 23:07:09 +00:00
|
|
|
NOCRED, 0, NULL, &bp);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error) {
|
|
|
|
*countp = 0;
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2016-09-17 16:47:34 +00:00
|
|
|
if (I_IS_UFS1(ip))
|
2002-06-21 06:18:05 +00:00
|
|
|
bap1 = (ufs1_daddr_t *)bp->b_data;
|
|
|
|
else
|
|
|
|
bap2 = (ufs2_daddr_t *)bp->b_data;
|
1996-11-05 08:19:40 +00:00
|
|
|
if (lastbn != -1) {
|
2008-10-23 15:53:51 +00:00
|
|
|
copy = malloc(fs->fs_bsize, M_TEMP, M_WAITOK);
|
2002-06-21 06:18:05 +00:00
|
|
|
bcopy((caddr_t)bp->b_data, copy, (u_int)fs->fs_bsize);
|
|
|
|
for (i = last + 1; i < NINDIR(fs); i++)
|
2016-09-17 16:47:34 +00:00
|
|
|
if (I_IS_UFS1(ip))
|
2004-07-28 06:41:27 +00:00
|
|
|
bap1[i] = 0;
|
|
|
|
else
|
|
|
|
bap2[i] = 0;
|
1999-07-13 18:20:13 +00:00
|
|
|
if (DOINGASYNC(vp)) {
|
2012-03-11 20:26:19 +00:00
|
|
|
bdwrite(bp);
|
1999-07-13 18:20:13 +00:00
|
|
|
} else {
|
1996-11-05 08:19:40 +00:00
|
|
|
error = bwrite(bp);
|
|
|
|
if (error)
|
|
|
|
allerror = error;
|
|
|
|
}
|
2016-09-17 16:47:34 +00:00
|
|
|
if (I_IS_UFS1(ip))
|
2002-06-21 06:18:05 +00:00
|
|
|
bap1 = (ufs1_daddr_t *)copy;
|
|
|
|
else
|
|
|
|
bap2 = (ufs2_daddr_t *)copy;
|
1995-12-11 04:58:34 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Recursively free totally unused blocks.
|
|
|
|
*/
|
2018-08-18 22:21:59 +00:00
|
|
|
key = ffs_blkrelease_start(ump, ITODEVVP(ip), ip->i_number);
|
1994-05-24 10:09:53 +00:00
|
|
|
for (i = NINDIR(fs) - 1, nlbn = lbn + 1 - i * factor; i > last;
|
|
|
|
i--, nlbn += factor) {
|
2002-06-21 06:18:05 +00:00
|
|
|
nb = BAP(ip, i);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (nb == 0)
|
|
|
|
continue;
|
|
|
|
if (level > SINGLE) {
|
1999-01-28 00:57:57 +00:00
|
|
|
if ((error = ffs_indirtrunc(ip, nlbn, fsbtodb(fs, nb),
|
2002-06-21 06:18:05 +00:00
|
|
|
(ufs2_daddr_t)-1, level - 1, &blkcount)) != 0)
|
1994-05-24 10:09:53 +00:00
|
|
|
allerror = error;
|
|
|
|
blocksreleased += blkcount;
|
|
|
|
}
|
2018-08-18 22:21:59 +00:00
|
|
|
ffs_blkfree(ump, fs, ITODEVVP(ip), nb, fs->fs_bsize,
|
|
|
|
ip->i_number, vp->v_type, NULL, key);
|
1994-05-24 10:09:53 +00:00
|
|
|
blocksreleased += nblocks;
|
|
|
|
}
|
2018-08-18 22:21:59 +00:00
|
|
|
ffs_blkrelease_finish(ump, key);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Recursively free last partial block.
|
|
|
|
*/
|
|
|
|
if (level > SINGLE && lastbn >= 0) {
|
|
|
|
last = lastbn % factor;
|
2002-06-21 06:18:05 +00:00
|
|
|
nb = BAP(ip, i);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (nb != 0) {
|
1994-10-10 01:04:55 +00:00
|
|
|
error = ffs_indirtrunc(ip, nlbn, fsbtodb(fs, nb),
|
|
|
|
last, level - 1, &blkcount);
|
|
|
|
if (error)
|
1994-05-24 10:09:53 +00:00
|
|
|
allerror = error;
|
|
|
|
blocksreleased += blkcount;
|
|
|
|
}
|
|
|
|
}
|
1996-11-05 08:19:40 +00:00
|
|
|
if (copy != NULL) {
|
2008-10-23 15:53:51 +00:00
|
|
|
free(copy, M_TEMP);
|
1996-11-05 08:19:40 +00:00
|
|
|
} else {
|
|
|
|
bp->b_flags |= B_INVAL | B_NOCACHE;
|
|
|
|
brelse(bp);
|
|
|
|
}
|
2002-06-21 06:18:05 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
*countp = blocksreleased;
|
|
|
|
return (allerror);
|
|
|
|
}
|
2008-09-16 10:59:35 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
ffs_rdonly(struct inode *ip)
|
|
|
|
{
|
|
|
|
|
2016-09-17 16:47:34 +00:00
|
|
|
return (ITOFS(ip)->fs_ronly != 0);
|
2008-09-16 10:59:35 +00:00
|
|
|
}
|
|
|
|
|