ufs_vnops.c revision 9b5097ee22b7d249db813b466eda136ffc2c21fa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Portions of this source code were derived from Berkeley 4.3 BSD
* under license from the Regents of the University of California.
*/
#include <sys/sysmacros.h>
#include <sys/resource.h>
#include <sys/vfs_opreg.h>
#include <sys/pathname.h>
#include <sys/fssnap_if.h>
#include <vm/seg_kmem.h>
caller_context_t *);
struct caller_context *);
struct caller_context *);
int *, caller_context_t *);
caller_context_t *);
caller_context_t *);
caller_context_t *);
caller_context_t *, int *, pathname_t *);
caller_context_t *, vsecattr_t *);
caller_context_t *, int);
caller_context_t *, int);
struct cred *, caller_context_t *, int);
caller_context_t *, int);
caller_context_t *, int);
struct cred *, caller_context_t *, int);
caller_context_t *);
struct flk_callback *, struct cred *,
caller_context_t *);
cred_t *, caller_context_t *);
caller_context_t *);
caller_context_t *);
caller_context_t *);
caller_context_t *);
struct cred *, caller_context_t *);
daddr32_t *, int, int);
caller_context_t *);
caller_context_t *);
static int ufs_priv_access(void *, int, struct cred *);
struct vnode **);
/*
*
* XXX - ULOCKFS in fs_pathconf and ufs_ioctl is not inlined yet.
*/
struct vnodeops *ufs_vnodeops;
/* NOTE: "not blkd" below means that the operation isn't blocked by lockfs */
const fs_operation_def_t ufs_vnodeops_template[] = {
};
#define MAX_BACKFILE_COUNT 9999
/*
* Created by ufs_dumpctl() to store a file's disk block info into memory.
* Used by ufs_dump() to dump data to disk directly.
*/
struct dump {
};
/*
* Previously there was no special action required for ordinary files.
* (Devices are handled through the device file system.)
* Now we support Large Files and Large File API requires open to
* fail if file is large.
* We could take care to prevent data corruption
* by doing an atomic check of size and truncate if file is opened with
* layers. So taking care of truncation here is a change in the existing
* semantics of VOP_OPEN and therefore we chose not to implement any thing
* here. The check for the size of the file > 2GB is being done at the
* vfs layer in routine vn_open().
*/
/* ARGSUSED */
static int
{
return (0);
}
/*ARGSUSED*/
static int
{
/*
* Push partially filled cluster at last close.
* ``last close'' is approximated because the dnlc
* may have a hold on the vnode.
* Checking for VBAD here will also act as a forced umount check.
*/
if (ip->i_delaylen) {
ip->i_delaylen = 0;
}
}
return (0);
}
/*ARGSUSED*/
static int
struct caller_context *ct)
{
int error = 0;
int intrans = 0;
/*
* Mandatory locking needs to be done before ufs_lockfs_begin()
* and TRANS_BEGIN_SYNC() calls since mandatory locks can sleep.
*/
/*
* ufs_getattr ends up being called by chklock
*/
if (error)
goto out;
}
if (error)
goto out;
/*
* In the case that a directory is opened for reading as a file
* (eg "cat .") with the O_RSYNC, O_SYNC and O_DSYNC flags set.
* The locking order had to be changed to avoid a deadlock with
* an update taking place on that directory at the same time.
*/
if (error) {
if (ulp)
goto out;
}
TRANS_ISTRANS(ufsvfsp)) {
error);
}
} else {
/*
* Only transact reads to files opened for sync-read and
* sync-write on a file system that is not write locked.
*
* The ``not write locked'' check prevents problems with
* logging exists at the beginning of the read but does not
* at the end.
*
*/
TRANS_ISTRANS(ufsvfsp)) {
error);
intrans = 1;
}
if (intrans) {
}
}
if (ulp) {
}
out:
return (error);
}
extern int ufs_HW; /* high water mark */
extern int ufs_LW; /* low water mark */
int ufs_throttles = 0; /* throttling count */
static int
{
int shared_write;
/*
* If the FDSYNC flag is set then ignore the global
* ufs_allow_shared_writes in this case.
*/
/*
* Filter to determine if this request is suitable as a
* concurrent rewrite. This write must not allocate blocks
* by extending the file or filling in holes. No use trying
* through FSYNC descriptors as the inode will be synchronously
* updated after the write. The uio structure has not yet been
* checked for sanity, so assume nothing.
*/
}
/*ARGSUSED*/
static int
{
int retry = 1;
int directio_status;
int exclusive;
int rewriteflg;
/*
* Mandatory locking needs to be done before ufs_lockfs_begin()
* and TRANS_BEGIN_[A]SYNC() calls since mandatory locks can sleep.
* Check for forced unmounts normally done in ufs_lockfs_begin().
*/
goto out;
}
/*
* ufs_getattr ends up being called by chklock
*/
if (error)
goto out;
}
/* i_rwlock can change in chklock */
/*
* Check for fast-path special case of directio re-writes.
*/
!exclusive && rewriteflg) {
if (error)
goto out;
if (directio_status == DIRECTIO_SUCCESS) {
error = 0;
/*
* Special treatment of access times for re-writes.
* If IMOD is not already set, then convert it
* to IMODACC for this operation. This defers
* entering a delta into the log until the inode
* is flushed. This mimics what is done for read
* operations and inode access time.
*/
if ((i_flag_save & IMOD) == 0) {
}
if (ulp)
goto out;
}
if (ulp)
}
/*
* Mandatory locking could have been enabled
* after dropping the i_rwlock.
*/
goto retry_mandlock;
}
if (error)
goto out;
/*
* Amount of log space needed for this write
*/
/*
* Throttle writes.
*/
}
}
/*
* Enter Transaction
*
* If the write is a rewrite there is no need to open a transaction
* if the FDSYNC flag is set and not the FSYNC. In this case just
* set the IMODACC flag to modify do the update at a later time
* thus avoiding the overhead of the logging transaction that is
* not required.
*/
if (ulp) {
if (rewriteflg) {
if ((i_flag_save & IMOD) == 0) {
}
} else {
int terr = 0;
terr);
}
}
} else {
if (ulp)
}
/*
* Write the file
*/
/*
* In append mode start at end of file.
*/
}
/*
* Mild optimisation, don't call ufs_trans_write() unless we have to
* Also, suppress file system full messages if we will retry.
*/
if (retry)
if (resid) {
} else {
}
/*
* Leave Transaction
*/
if (ulp) {
if (!rewriteflg) {
int terr = 0;
resv);
if (error == 0)
}
} else {
}
}
out:
/*
* Any blocks tied up in pending deletes?
*/
retry = 0;
goto retry_mandlock;
}
error = 0;
return (error);
}
/*
* Don't cache write blocks to files with the sticky bit set.
* Used to keep swap files from blowing the page cache on a server.
*/
int stickyhack = 1;
/*
* Free behind hacks. The pager is busted.
* XXX - need to pass the information down to writedone() in a flag like B_SEQ
* or B_FREE_IF_TIGHT_ON_MEMORY.
*/
int freebehind = 1;
int smallfile = 0;
/*
* While we should, in most cases, cache the pages for write, we
* may also want to cache the pages for read as long as they are
* frequently re-usable.
*
* If cache_read_ahead = 1, the pages for read will go to the tail
* of the cache list when they are released, otherwise go to the head.
*/
int cache_read_ahead = 0;
/*
* Freebehind exists so that as we read large files sequentially we
* don't consume most of memory with pages from a few files. It takes
* longer to re-read from disk multiple small files as it does reading
* one large one sequentially. As system memory grows customers need
* to retain bigger chunks of files in memory. The advent of the
* cachelist opens up of the possibility freeing pages to the head or
* tail of the list.
*
* Not freeing a page is a bet that the page will be read again before
* it's segmap slot is needed for something else. If we loose the bet,
* it means some other thread is burdened with the page free we did
* not do. If we win we save a free and reclaim.
*
* Freeing it at the tail vs the head of cachelist is a bet that the
* page will survive until the next read. It's also saying that this
* page is more likely to be re-used than a page freed some time ago
* and never reclaimed.
*
* Freebehind maintains a range of file offset [smallfile1; smallfile2]
*
* 0 < offset < smallfile1 : pages are not freed.
* smallfile1 < offset < smallfile2 : pages freed to tail of cachelist.
* smallfile2 < offset : pages freed to head of cachelist.
*
* The range is computed at most once per second and depends on
* freemem and ncpus_online. Both parameters are bounded to be
* >= smallfile && >= smallfile64.
*
* smallfile1 = (free memory / ncpu) / 1000
* smallfile2 = (free memory / ncpu) / 10
*
* A few examples values:
*
* Free Mem (in Bytes) [smallfile1; smallfile2] [smallfile1; smallfile2]
* ncpus_online = 4 ncpus_online = 64
* ------------------ ----------------------- -----------------------
* 1G [256K; 25M] [32K; 1.5M]
* 10G [2.5M; 250M] [156K; 15M]
* 100G [25M; 2.5G] [1.5M; 150M]
*
*/
#define SMALLFILE1_D 1000
#define SMALLFILE2_D 10
/*
* wrip does the real work of write requests for ufs.
*/
int
{
long premove_resid; /* resid before uiomove() */
int newpage;
int iupdat_flag, directio_status;
int error, pagecreate;
int do_dqrwlock; /* drop/reacquire vfs_dqrwlock */
int new_iblocks;
/*
* ip->i_size is incremented before the uiomove
* is done on a write. If the move fails (bad user
* address) reset ip->i_size.
* The better way would be to increment ip->i_size
* only if the uiomove succeeds.
*/
int i_size_changed = 0;
int i_seq_needed = 0;
/*
* check for forced unmount - should not happen as
* the request passed the lockfs checks.
*/
return (EIO);
/* check for valid filetype */
return (EIO);
}
/*
* the actual limit of UFS file size
* is UFS_MAXOFFSET_T
*/
limit = MAXOFFSET_T;
mutex_enter(&p->p_lock);
p, RCA_UNSAFE_SIGINFO);
mutex_exit(&p->p_lock);
return (EFBIG);
}
/*
* if largefiles are disallowed, the limit is
* the pre-largefiles value of 2GB
*/
else
return (EINVAL);
}
return (0);
}
return (EFBIG);
iupdat_flag = 1;
}
/*
* Try to go direct
*/
/*
* If ufs_directio wrote to the file or set the flags,
* we need to update i_seq, but it may be deferred.
*/
i_seq_needed = 1;
}
if (directio_status == DIRECTIO_SUCCESS)
goto out;
}
/*
* Behavior with respect to dropping/reacquiring vfs_dqrwlock:
*
* o shadow inodes: vfs_dqrwlock is not held at all
* o quota updates: vfs_dqrwlock is read or write held
* o other updates: vfs_dqrwlock is read held
*
* The first case is the only one where we do not hold
* vfs_dqrwlock at all while entering wrip().
* have it as writer, i.e. if we are updating the quota inode.
* There is no potential deadlock scenario in this case as
* ufs_getpage() takes care of this and avoids reacquiring
* vfs_dqrwlock in that case.
*
* This check is done here since the above conditions do not change
* and we possibly loop below, so save a few cycles.
*/
do_dqrwlock = 0;
} else {
do_dqrwlock = 1;
}
/*
* Large Files: We cast MAXBMASK to offset_t
* inorder to mask out the higher bits. Since offset_t
* is a signed value, the high order bit set in MAXBMASK
* value makes it do the right thing by having all bits 1
* in the higher word. May be removed for _SOLARIS64_.
*/
do {
new_iblocks = 1;
goto out;
}
/*
* since uoff + n >= limit,
* therefore n >= limit - uoff, and n is an int
* so it is safe to cast it to an int
*/
}
/*
* We are extending the length of the file.
* bmap is used so that we are sure that
* if we need to allocate new blocks, that it
* is done here before we up the file size.
*/
/*
* bmap_write never drops i_contents so if
* the flags are set it changed the file.
*/
i_seq_needed = 1;
}
if (error)
break;
/*
* There is a window of vulnerability here.
* The sequence of operations: allocate file
* system blocks, uiomove the data into pages,
* and then update the size of the file in the
* inode, must happen atomically. However, due
* to current locking constraints, this can not
* be done.
*/
i_size_changed = 1;
/*
* If we are writing from the beginning of
* the mapping, we can just create the
* pages without having to read them.
*/
pagecreate = (mapon == 0);
} else if (n == MAXBSIZE) {
/*
* Going to do a whole mappings worth,
* so we can just create the pages w/o
* having to read them in. But before
* we do that, we need to make sure any
* needed blocks are allocated first.
*/
/*
* bmap_write never drops i_contents so if
* the flags are set it changed the file.
*/
i_seq_needed = 1;
}
if (error)
break;
pagecreate = 1;
/*
* check if the new created page needed the
* allocation of new disk blocks.
*/
new_iblocks = 0; /* no new blocks allocated */
} else {
pagecreate = 0;
/*
* In sync mode flush the indirect blocks which
* may have been allocated and not written on
* disk. In above cases bmap_write will allocate
* in sync mode.
*/
if (error)
break;
}
}
/*
* At this point we can enter ufs_getpage() in one
* of two ways:
* 1) segmap_getmapflt() calls ufs_getpage() when the
* forcefault parameter is true (pagecreate == 0)
* 2) uiomove() causes a page fault.
*
* We have to drop the contents lock to prevent the VM
* system from trying to reacquire it in ufs_getpage()
* should the uiomove cause a pagefault.
*
* We have to drop the reader vfs_dqrwlock here as well.
*/
if (do_dqrwlock) {
}
newpage = 0;
/*
* Touch the page and fault it in if it is not in core
* before segmap_getmapflt or vpm_data_copy can lock it.
* This is to avoid the deadlock if the buffer is mapped
* to the same file through mmap which we want to write.
*/
uio_prefaultpages((long)n, uio);
if (vpm_enable) {
/*
* Copy data. If new pages are created, part of
* the page that is not written will be initizliazed
* with zeros.
*/
} else {
/*
* segmap_pagecreate() returns 1 if it calls
* page_create_va() to allocate any pages.
*/
if (pagecreate)
(size_t)n, 0);
}
/*
* If "newpage" is set, then a new page was created and it
* does not contain valid data, so it needs to be initialized
* at this point.
* Otherwise the page contains old data, which was overwritten
* partially or as a whole in uiomove.
* If there is only one iovec structure within uio, then
* on error uiomove will not be able to update uio->uio_loffset
* and we would zero the whole page here!
*
* If uiomove fails because of an error, the old valid data
* is kept instead of filling the rest of the page with zero's.
*/
if (!vpm_enable && newpage &&
/*
* We created pages w/o initializing them completely,
* thus we need to zero the part that wasn't set up.
* This happens on most EOF write cases and if
* we had some sort of error during the uiomove.
*/
}
/*
* Unlock the pages allocated by page_create_va()
* in segmap_pagecreate()
*/
if (!vpm_enable && newpage)
/*
* If the size of the file changed, then update the
* size field in the inode now. This can't be done
* before the call to segmap_pageunlock or there is
* a potential deadlock with callers to ufs_putpage().
* They will be holding i_contents and trying to lock
* a page, while this thread is holding a page locked
* and trying to acquire i_contents.
*/
if (i_size_changed) {
/*
* file has grown larger than 2GB. Set flag
* in superblock to indicate this, if it
* is not already set.
*/
}
}
if (error) {
/*
* If we failed on a write, we may have already
* allocated file blocks as well as pages. It's
* hard to undo the block allocation, but we must
* be sure to invalidate any pages that may have
* been allocated.
*
* If the page was created without initialization
* then we must check if it should be possible
* to destroy the new page and to keep the old data
* on the disk.
*
* It is possible to destroy the page without
* having to write back its contents only when
* - the size of the file keeps unchanged
* - bmap_write() did not allocate new disk blocks
* it is possible to create big files using "seek" and
* write to the end of the file. A "write" to a
* position before the end of the file would not
* change the size of the file but it would allocate
* new disk blocks.
* - uiomove intended to overwrite the whole page.
* - a new page was created (newpage == 1).
*/
if (i_size_changed == 0 && new_iblocks == 0 &&
newpage) {
/* unwind what uiomove eventually last did */
/*
* destroy the page, do not write ambiguous
* data to the disk.
*/
flags = SM_DESTROY;
} else {
/*
* write the page back to the disk, if dirty,
* and remove the page from the cache.
*/
}
if (vpm_enable) {
/*
* Flush pages.
*/
} else {
}
} else {
flags = 0;
/*
* Force write back for synchronous write cases.
*/
/*
* If the sticky bit is set but the
* execute bit is not set, we do a
* synchronous write back and free
* the page when done. We set up swap
* files to be handled this way to
* prevent servers from keeping around
* the client's swap pages too long.
* XXX - there ought to be a better way.
*/
iupdat_flag = 0;
} else {
}
/*
* Have written a whole block.
* Start an asynchronous write and
* mark the buffer to indicate that
* it won't be needed again soon.
*/
}
if (vpm_enable) {
/*
* Flush pages.
*/
} else {
}
/*
* If the operation failed and is synchronous,
* then we need to unwind what uiomove() last
* did so we can potentially return an error to
* the caller. If this write operation was
* done in two pieces and the first succeeded,
* then we won't return an error for the second
* piece that failed. However, we only want to
* return a resid value that reflects what was
* really done.
*
* Failures for non-synchronous operations can
* be ignored since the page subsystem will
* retry the operation until it succeeds or the
* file system is unmounted.
*/
if (error) {
} else {
error = 0;
}
}
}
/*
* Re-acquire contents lock.
* If it was dropped, reacquire reader vfs_dqrwlock as well.
*/
if (do_dqrwlock)
/*
* If the uiomove() failed or if a synchronous
* page push failed, fix up i_size.
*/
if (error) {
if (i_size_changed) {
/*
* The uiomove failed, and we
* allocated blocks,so get rid
* of them.
*/
}
} else {
/*
* XXX - Can this be out of the loop?
*/
/*
* Only do one increase of i_seq for multiple
* pieces. Because we drop locks, record
* the fact that we changed the timestamp and
* are deferring the increase in case another thread
* pushes our timestamp update.
*/
i_seq_needed = 1;
if (i_size_changed)
(IEXEC >> 6))) != 0 &&
/*
* Clear Set-UID & Set-GID bits on
* successful write if not privileged
* and at least one of the execute bits
* is set. If we always clear Set-GID,
* mandatory file and record locking is
* unuseable.
*/
}
}
/*
* In the case the FDSYNC flag is set and this is a
* "rewrite" we won't log a delta.
* The FSYNC flag overrides all cases.
*/
}
out:
/*
* Make sure i_seq is increased at least once per write
*/
if (i_seq_needed) {
}
/*
* Inode is updated according to this table -
*
* FSYNC FDSYNC(posix.4)
* --------------------------
* always@ IATTCHG|IBDWRITE
*
* @ - If we are doing synchronous write the only time we should
* not be sync'ing the ip here is if we have the stickyhack
* activated, the file is marked with the sticky bit and
* no exec bit, the file length has not been changed and
* no new blocks have been allocated during this write.
*/
/*
* we have eliminated nosync
*/
}
}
/*
* If we've already done a partial-write, terminate
* the write but return no error unless the error is ENOSPC
* because the caller can detect this and free resources and
* try again.
*/
error = 0;
return (error);
}
/*
* rdip does the real work of read requests for ufs.
*/
int
{
int error = 0;
int doupdate = 1;
int dofree, directio_status;
return (EIO);
/* check for valid filetype */
return (EIO);
}
error = 0;
goto out;
}
return (EINVAL);
}
return (0);
}
(!ufsvfsp->vfs_noatime)) {
}
/*
* Try to go direct
*/
if (directio_status == DIRECTIO_SUCCESS)
goto out;
}
do {
error = 0;
goto out;
}
n = (int)diff;
/*
* We update smallfile2 and smallfile1 at most every second.
*/
now = ddi_get_lbolt();
if (now >= smallfile_update) {
}
dofree = freebehind &&
/*
* At this point we can enter ufs_getpage() in one of two
* ways:
* 1) segmap_getmapflt() calls ufs_getpage() when the
* forcefault parameter is true (value of 1 is passed)
* 2) uiomove() causes a page fault.
*
* We cannot hold onto an i_contents reader lock without
* risking deadlock in ufs_getpage() so drop a reader lock.
* The ufs_getpage() dolock logic already allows for a
* thread holding i_contents as writer to work properly
* so we keep a writer lock.
*/
if (vpm_enable) {
/*
* Copy data.
*/
} else {
}
flags = 0;
if (!error) {
/*
* If reading sequential we won't need this
* buffer again soon. For offsets in range
* [smallfile1, smallfile2] release the pages
* at the tail of the cache list, larger
* offsets are released at the head.
*/
if (dofree) {
if ((cache_read_ahead == 0) &&
(off > smallfile2))
flags |= SM_DONTNEED;
}
/*
* In POSIX SYNC (FSYNC and FDSYNC) read mode,
* we want to make sure that the page which has
* been read, is written on disk if it is dirty.
* And corresponding indirect blocks should also
* be flushed out.
*/
}
if (vpm_enable) {
} else {
}
} else {
if (vpm_enable) {
} else {
}
}
out:
/*
* Inode is updated according to this table if FRSYNC is set.
*
* FSYNC FDSYNC(posix.4)
* --------------------------
* always IATTCHG|IBDWRITE
*/
/*
* The inode is not updated if we're logging and the inode is a
* directory with FRSYNC, FSYNC and FDSYNC flags set.
*/
doupdate = 0;
}
if (doupdate) {
}
}
}
/*
* If we've already done a partial read, terminate
* the read but return no error.
*/
error = 0;
return (error);
}
/* ARGSUSED */
static int
int cmd,
int flag,
int *rvalp,
{
char *comment, *original_comment;
extern int maxphys;
int error;
int issync;
int trans_size;
/*
* forcibly unmounted
*/
return (EIO);
if (cmd == Q_QUOTACTL) {
if (error)
return (error);
if (ulp) {
}
if (ulp) {
}
return (error);
}
switch (cmd) {
case _FIOLFS:
/*
* file system locking
*/
return (EPERM);
sizeof (struct lockfs)))
return (EFAULT);
}
#ifdef _SYSCALL32_IMPL
else {
/* Translate ILP32 lockfs to LP64 lockfs */
sizeof (struct lockfs32)))
return (EFAULT);
}
#endif /* _SYSCALL32_IMPL */
return (ENAMETOOLONG);
comment =
return (EFAULT);
}
}
if ((flag & DATAMODEL_MASK) ==
sizeof (struct lockfs));
}
#ifdef _SYSCALL32_IMPL
else {
/* Translate LP64 to ILP32 lockfs */
sizeof (struct lockfs32));
}
#endif /* _SYSCALL32_IMPL */
} else {
}
return (error);
case _FIOLFSS:
/*
* get file system locking status
*/
sizeof (struct lockfs)))
return (EFAULT);
}
#ifdef _SYSCALL32_IMPL
else {
/* Translate ILP32 lockfs to LP64 lockfs */
sizeof (struct lockfs32)))
return (EFAULT);
}
#endif /* _SYSCALL32_IMPL */
return (error);
sizeof (struct lockfs)))
return (EFAULT);
}
#ifdef _SYSCALL32_IMPL
else {
/* Translate LP64 to ILP32 lockfs */
sizeof (struct lockfs32)))
return (EFAULT);
}
#endif /* _SYSCALL32_IMPL */
return (EFAULT);
return (0);
case _FIOSATIME:
/*
* set access time
*/
/*
* if mounted w/o atime, return quietly.
* I briefly thought about returning ENOSYS, but
* figured that most apps would consider this fatal
* but the idea is to make this as seamless as poss.
*/
if (ufsvfsp->vfs_noatime)
return (0);
if (error)
return (error);
if (ulp) {
}
if (ulp) {
}
return (error);
case _FIOSDIO:
/*
* set delayed-io
*/
case _FIOGDIO:
/*
* get delayed-io
*/
case _FIOIO:
/*
* inode open
*/
if (error)
return (error);
if (ulp) {
}
return (error);
case _FIOFFS:
/*
* file system flush (push w/invalidate)
*/
return (EINVAL);
case _FIOISBUSY:
/*
* Contract-private interface for Legato
* Purge this vnode from the DNLC and decide
* if this vnode is busy (*arg == 1) or not
* (*arg == 0)
*/
return (EPERM);
return (error);
case _FIODIRECTIO:
case _FIOTUNE:
/*
* Tune the file system (aka setting fs attributes)
*/
if (error)
return (error);
if (ulp)
return (error);
case _FIOLOGENABLE:
return (EPERM);
case _FIOLOGDISABLE:
return (EPERM);
case _FIOISLOG:
case _FIOSNAPSHOTCREATE_MULTI:
{
return (EFAULT);
return (EINVAL);
fcm_size = sizeof (struct fiosnapcreate_multi) +
fcp = (struct fiosnapcreate_multi *)
return (EFAULT);
}
/*
* Do copyout even if there is an error because
* the details of error is stored in fcp.
*/
return (error);
}
case _FIOSNAPSHOTDELETE:
{
struct fiosnapdelete fc;
return (EFAULT);
return (error);
}
case _FIOGETSUPERBLOCK:
return (EFAULT);
return (0);
case _FIOGETMAXPHYS:
return (EFAULT);
return (0);
/*
* The following 3 ioctls are for TSufs support
* although could potentially be used elsewhere
*/
case _FIO_SET_LUFS_DEBUG:
return (EPERM);
return (0);
case _FIO_SET_LUFS_ERROR:
return (EPERM);
return (0);
case _FIO_GET_TOP_STATS:
{
/* Copy stucture if statistics are being kept */
}
error = 0;
return (error);
}
case _FIO_SEEK_DATA:
case _FIO_SEEK_HOLE:
return (EFAULT);
if (error)
return (error);
return (EFAULT);
return (0);
case _FIO_COMPRESSED:
{
/*
* This is a project private ufs ioctl() to mark
* the inode as that belonging to a compressed
* file. This is used to mark individual
* compressed files in a miniroot archive.
* The files compressed in this manner are
* automatically decompressed by the dcfs filesystem
* (via an interception in ufs_lookup - see decompvp())
* which is layered on top of ufs on a system running
* This ioctl only marks the file as compressed - the
* actual compression is done by fiocompress (a
* userland utility) which invokes this ioctl().
*/
if (error)
return (error);
if (ulp) {
}
if (ulp) {
}
return (error);
}
default:
return (ENOTTY);
}
}
/* ARGSUSED */
static int
{
int err;
/*
* for performance, if only the size is requested don't bother
* with anything else.
*/
return (0);
}
/*
* inlined lockfs checks
*/
goto out;
}
/*
* Return all the attributes. This should be refined so
* that it only returns what's asked for.
*/
/*
* Copy from inode table.
*/
/*
* If there is an ACL and there is a mask entry, then do the
* extra work that completes the equivalent of an acltomode(3)
* call. According to POSIX P1003.1e, the acl mask should be
* returned in the group permissions field.
*
* - start with the original permission and mode bits (from above)
* - clear the group owner bits
* - add in the mask bits.
*/
}
else
case IFBLK:
break;
case IFCHR:
break;
default:
break;
}
err = 0;
out:
return (err);
}
/*
* Special wrapper to provide a callback for secpolicy_vnode_setattr().
* The i_contents lock is already held by the caller and we need to
* declare the inode as 'void *' argument.
*/
static int
{
}
/*ARGSUSED4*/
static int
int flags,
{
char *errmsg1;
char *errmsg2;
long blocks;
int issync;
int trans_size;
int dotrans;
int dorwlock;
int error;
int owner_change;
int dodqlock;
int retry = 1;
int indeadlock;
/*
* Cannot set these attributes.
*/
return (EINVAL);
/*
* check for forced unmount
*/
return (EIO);
return (EROFS);
dotrans = 0;
dorwlock = 0;
dodqlock = 0;
if (error)
goto out;
/*
* Acquire i_rwlock before TRANS_BEGIN_CSYNC() if this is a file.
* This follows the protocol for read()/write().
*/
/*
* ufs_tryirwlock uses rw_tryenter and checks for SLOCK to
* avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock) {
if (ulp)
goto again;
}
dorwlock = 1;
}
/*
* Truncate file. Must have write permission and not be a directory.
*/
goto update_inode;
}
goto update_inode;
if (error) {
goto update_inode;
}
}
if (ulp) {
++dotrans;
}
/*
* Acquire i_rwlock after TRANS_BEGIN_CSYNC() if this is a directory.
* This follows the protocol established by
*/
if (indeadlock)
goto again;
dorwlock = 1;
}
/*
* Grab quota lock if we are changing the file's owner.
*/
dodqlock = 1;
}
if (error)
goto update_inode;
/*
* Change file access modes.
*/
if (stickyhack) {
else
}
}
/*
* Don't change ownership of the quota inode.
*/
goto update_inode;
}
/*
* No real ownership change.
*/
blocks = 0;
owner_change = 0;
}
/*
* Remove the blocks and the file, from the old user's
* quota.
*/
else {
owner_change = 1;
}
/*
* There is a real ownership change.
*/
if (owner_change) {
/*
* Add the blocks and the file to the new
* user's quota.
*/
}
}
}
}
/*
* Change file access or modified times.
*/
/* Check that the time value is within ufs range */
goto update_inode;
}
/*
* if the "noaccess" mount option is set and only atime
* update is requested, do nothing. No error is returned.
*/
if ((ufsvfsp->vfs_noatime) &&
goto skip_atime;
}
gethrestime(&now);
/*
* In 2038, ctime sticks forever..
*/
} else {
}
}
}
/*
* The presence of a shadow inode may indicate an ACL, but does
* not imply an ACL. Future FSD types should be handled here too
* and check for the presence of the attribute-specific data
* before referencing it.
*/
/*
* XXX if ufs_iupdat is changed to sandbagged write fix
* ufs_acl_setattr to push ip to keep acls consistent
*
* Suppress out of inodes messages if we will retry.
*/
if (retry)
}
/*
* Setattr always increases the sequence number
*/
/*
* if nfsd and not logging; push synchronously
*/
} else {
}
if (dodqlock) {
}
if (dorwlock)
if (ulp) {
if (dotrans) {
int terr = 0;
if (error == 0)
}
}
out:
/*
* If out of inodes or blocks, see if we can free something
* up from the delete queue.
*/
retry = 0;
goto again;
}
}
}
return (error);
}
/*ARGSUSED*/
static int
{
return (EIO);
/*
* The ufs_iaccess function wants to be called with
* mode bits expressed as "ufs specific" bits.
* I.e., VWRITE|VREAD|VEXEC do not make sense to
* ufs_iaccess() but IWRITE|IREAD|IEXEC do.
* But since they're the same we just pass the vnode mode
* bit but just verify that assumption at compile time.
*/
#error "ufs_access needs to map Vmodes to Imodes"
#endif
}
/* ARGSUSED */
static int
{
int error;
int fastsymlink;
goto nolockout;
}
/*
* If the symbolic link is empty there is nothing to read.
* Fast-track these empty symbolic links
*/
error = 0;
goto nolockout;
}
if (error)
goto nolockout;
/*
* The ip->i_rwlock protects the data blocks used for FASTSYMLINK
*/
fastsymlink = 0;
(!ufsvfsp->vfs_noatime)) {
}
++fastsymlink;
}
}
if (!fastsymlink) {
long igen;
int tflag = 0; /* flag to indicate temp vars used */
goto again;
}
/* can this be a fast symlink and is it a user buffer? */
/*
* setup a kernel buffer to read link into. this
* is to fix a race condition where the user buffer
* got corrupted before copying it into the inode.
*/
tflag = 1;
}
goto out;
}
if (tflag == 0)
if (error == 0) {
/*
* free page
*/
} else {
int i;
/* error, clear garbage left behind */
for (i = 1; i < NDADDR; i++)
for (i = 0; i < NIADDR; i++)
}
}
if (tflag == 1) {
/* now, copy it into the user buffer */
}
}
out:
if (ulp) {
}
return (error);
}
/* ARGSUSED */
static int
{
int error;
if (error)
return (error);
if (TRANS_ISTRANS(ufsvfsp)) {
/*
* First push out any data pages
*/
if (error)
goto out;
}
/*
* Delta any delayed inode times updates
* and push inode to log.
* All other inode deltas will have already been delta'd
* and will be pushed during the commit.
*/
if (ulp) {
}
if (ulp) {
}
}
/*
* Commit the Moby transaction
*
* Deltas have already been made so we just need to
* commit them with a synchronous transaction.
* TRANS_BEGIN_SYNC() will return an error
* if there are no deltas to commit, for an
* empty transaction.
*/
if (ulp) {
error);
if (error) {
error = 0; /* commit wasn't needed */
goto out;
}
}
} else { /* not logging */
/* Just update the inode only */
error = 0;
/* Do data-synchronous writes */
else
/* Do synchronous writes */
if (!error)
}
out:
if (ulp) {
}
return (error);
}
/*ARGSUSED*/
static void
{
}
/*
* Unix file system operations having to do with directory manipulation.
*/
/* ARGSUSED */
static int
{
int error;
/*
* Check flags for type of lookup (regular file or attribute file)
*/
if (flags & LOOKUP_XATTR) {
/*
* If not mounted with XATTR support then return EINVAL
*/
return (EINVAL);
/*
* We don't allow recursive attributes...
* Maybe someday we will.
*/
return (EINVAL);
}
if (error) {
goto out;
}
}
/*
* Check accessibility of directory.
*/
if (vp == DNLC_NO_VNODE) {
goto out;
}
goto out;
}
return (0);
}
/*
* Check for a null component, which we should treat as
* looking at dvp from within it's parent, so we don't
* need a call to ufs_iaccess(), as it has already been
* done.
*/
if (nm[0] == 0) {
error = 0;
goto out;
}
/*
* Check for "." ie itself. this is a quick check and
* avoids adding "." into the dnlc (which have been seen
* to occupy >10% of the cache).
*/
/*
* Don't return without checking accessibility
* of the directory. We only need the lock if
* we are going to return it.
*/
}
goto out;
}
/*
* Fast path: Check the directory name lookup cache.
*/
/*
* Check accessibility of directory.
*/
goto out;
}
if (vp == DNLC_NO_VNODE) {
goto out;
}
goto fastpath;
}
/*
* Keep the idle queue from getting too long by
* idling two inodes before attempting to allocate another.
* This operation must be performed before entering
* lockfs or a transaction.
*/
}
/*
* Check accessibility of directory.
*/
goto out;
if (error)
goto out;
if (error == 0) {
/*
* If vnode is a device return special vnode instead.
*/
cr);
else
/*
* Compressed file, substitute dcfs vnode
*/
else
}
}
if (ulp) {
}
goto retry_lookup;
out:
return (error);
}
/*ARGSUSED*/
static int
{
int error;
int issync;
int truncflag;
int trans_size;
int noentry;
int defer_dip_seq_update = 0; /* need to defer update of dip->i_seq */
int retry = 1;
int indeadlock;
truncflag = 0;
if (error)
goto out;
if (ulp) {
}
if (*name == '\0') {
/*
* Null component name refers to the directory itself.
*/
/*
* Even though this is an error case, we need to grab the
* quota lock since the error handling code below is common.
*/
} else {
noentry = 0;
/*
* ufs_tryirwlock_trans uses rw_tryenter and checks for SLOCK
* to avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock)
goto again;
if (xvp == DNLC_NO_VNODE) {
noentry = 1;
}
if (xvp) {
} else {
}
} else {
/*
* Suppress file system full message if we will retry
*/
if (ulp) {
}
goto again;
}
}
}
}
/*
* If the file already exists and this is a non-exclusive create,
* check permissions and allow access for non-directories.
* Read-only create of an existing directory is also allowed.
* We fail an exclusive create of anything which already exists.
*/
else if (mode)
else
error = 0;
}
if (error) {
goto unlock;
}
/*
* If the error EEXIST was set, then i_seq can not
* have been updated. The sequence number interface
* is defined such that a non-error VOP_CREATE must
* increase the dir va_seq it by at least one. If we
* have cleared the error, increase i_seq. Note that
* we are increasing the dir i_seq and in rare cases
* ip may actually be from the dvp, so we already have
* the locks and it will not be subject to truncation.
* In case we have to update i_seq of the parent
* directory dip, we have to defer it till we have
* released our locks on ip due to lock ordering requirements.
*/
defer_dip_seq_update = 1;
else
/*
* Truncate regular files, if requested by caller.
* Grab i_rwlock to make sure no one else is
* currently writing to the file (we promised
* bmap we would do this).
* Must get the locks in the correct order.
*/
} else {
/*
* Large Files: Why this check here?
* Though we do it in vn_create() we really
* want to guarantee that we do not destroy
* Large file data by atomically checking
* the size while holding the contents
* lock.
*/
goto unlock;
}
if (TRANS_ISTRANS(ufsvfsp))
truncflag++;
else {
if (indeadlock) {
goto again;
}
cr);
}
}
if (error == 0) {
}
}
}
if (error) {
}
goto unlock;
}
/*
* If vnode is a device return special vnode instead.
*/
goto unlock;
}
truncflag = 0;
}
/*
* Do the deferred update of the parent directory's sequence
* number now.
*/
if (defer_dip_seq_update == 1) {
}
if (ulp) {
int terr = 0;
/*
* If we haven't had a more interesting failure
* already, then anything that might've happened
* here should be reported.
*/
if (error == 0)
}
if (indeadlock) {
if (ulp)
goto again;
}
}
if (ulp)
/*
* If no inodes available, try to free one up out of the
* pending delete queue.
*/
retry = 0;
goto again;
}
out:
return (error);
}
extern int ufs_idle_max;
/*ARGSUSED*/
static int
{
int indeadlock;
int error;
int issync;
int trans_size;
/*
* don't let the delete queue get too long
*/
goto out;
}
/* Only send the event if there were no errors */
if (error == 0)
}
if (error)
goto out;
if (ulp)
/*
* ufs_tryirwlock_trans uses rw_tryenter and checks for SLOCK
* to avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock)
goto retry_remove;
if (ulp) {
}
out:
return (error);
}
/*
* Link a file or a directory. Only privileged processes are allowed to
* make links to directories.
*/
/*ARGSUSED*/
static int
{
int error;
int issync;
int trans_size;
int isdev;
int indeadlock;
if (error)
goto out;
if (ulp)
/*
* Make sure link for extended attributes is valid
* We only support hard linking of attr in ATTRDIR to ATTRDIR
*
* Make certain we don't attempt to look at a device node as
* a ufs inode.
*/
goto unlock;
}
goto unlock;
}
/*
* ufs_tryirwlock_trans uses rw_tryenter and checks for SLOCK
* to avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock)
goto retry_link;
if (ulp) {
}
if (!error) {
}
out:
return (error);
}
/*
* Rename a file or directory.
* We are given the vnode and entry string of the source and the
* vnode and entry string of the place we want to move the source
* to (the target). The essential operation is:
* unlink(target);
* link(source, target);
* unlink(source);
* but "atomically". Can't do full commit without saving state in
* the inode on disk, which isn't feasible at this time. Best we
* can do is always guarantee that the TARGET exists.
*/
/*ARGSUSED*/
static int
char *snm, /* old (source) entry name */
char *tnm, /* new (target) entry name */
int flags)
{
int error;
int issync;
int trans_size;
/*
* Notify the target directory of the rename event
* if source and target directories are not the same.
*/
}
if (error)
goto out;
if (ulp)
/*
* We only allow renaming of attributes from ATTRDIR to ATTRDIR.
*/
goto unlock;
}
/*
* Check accessibility of directory.
*/
goto unlock;
/*
* Look up inode of file we're supposed to rename.
*/
gethrestime(&now);
if (ulp) {
}
goto retry_rename;
}
goto unlock;
}
/*
* Lock both the source and target directories (they may be
* the same) to provide the atomicity semantics that was
* previously provided by the per file system vfs_rename_lock
*
* with vfs_rename_lock removed to allow simultaneous renames
* within a file system, ufs_dircheckpath can deadlock while
* traversing back to ensure that source is not a parent directory
* of target parent directory. This is because we get into
* ufs_dircheckpath with the sdp and tdp locks held as RW_WRITER.
* If the tdp and sdp of the simultaneous renames happen to be
* in the path of each other, it can lead to a deadlock. This
* can be avoided by getting the locks as RW_READER here and then
* upgrading to RW_WRITER after completing the ufs_dircheckpath.
*
* We hold the target directory's i_rwlock after calling
* ufs_lockfs_begin but in many other operations (like ufs_readdir)
* VOP_RWLOCK is explicitly called by the filesystem independent code
* before calling the file system operation. In these cases the order
* is reversed (i.e i_rwlock is taken first and then ufs_lockfs_begin
* is called). This is fine as long as ufs_lockfs_begin acts as a VOP
* counter but with ufs_quiesce setting the SLOCK bit this becomes a
* synchronizing object which might lead to a deadlock. So we use
* rw_tryenter instead of rw_enter. If we fail to get this lock and
* find that SLOCK bit is set, we call ufs_lockfs_end and restart the
* operation.
*/
/*
* We didn't get the lock. Check if the SLOCK is set in the
* ufsvfs. If yes, we might be in a deadlock. Safer to give up
* and wait for SLOCK to be cleared.
*/
goto retry_rename;
} else {
/*
* SLOCK isn't set so this is a genuine synchronization
* case. Let's try again after giving them a breather.
*/
goto retry_firstlock;
}
}
/*
* Need to check if the tdp and sdp are same !!!
*/
/*
* We didn't get the lock. Check if the SLOCK is set in the
* ufsvfs. If yes, we might be in a deadlock. Safer to give up
* and wait for SLOCK to be cleared.
*/
goto retry_rename;
} else {
/*
* So we couldn't get the second level peer lock *and*
* the SLOCK bit isn't set. Too bad we can be
* contentding with someone wanting these locks otherway
* round. Reverse the locks in case there is a heavy
* contention for the second level lock.
*/
goto retry_firstlock;
}
}
goto errout;
}
/*
* Make sure we can delete the source entry. This requires
* write permission on the containing directory.
* Check for sticky directories.
*/
goto errout;
}
/*
* If this is a rename of a directory and the parent is
* different (".." must be changed), then the source
* directory must not be in the directory hierarchy
* above the target, as this would orphan everything
* below the source directory. Also the user must have
* write permission in the source so as to be able to
* change "..".
*/
goto errout;
}
/*
* If we got EAGAIN ufs_dircheckpath detected a
* potential deadlock and backed out. We need
* to retry the operation since sdp and tdp have
* to be released to avoid the deadlock.
*/
goto retry;
}
goto errout;
}
} else {
}
/*
* Check for renaming '.' or '..' or alias of '.'
*/
goto errout;
}
/*
* Simultaneous renames can deadlock in ufs_dircheckpath since it
* tries to traverse back the file tree with both tdp and sdp held
* as RW_WRITER. To avoid that we have to hold the tdp and sdp locks
* as RW_READERS till ufs_dircheckpath is done.
* Now that ufs_dircheckpath is done with, we can upgrade the locks
* to RW_WRITER.
*/
/*
* The upgrade failed. We got to give away the lock
* as to avoid deadlocking with someone else who is
* waiting for writer lock. With the lock gone, we
* cannot be sure the checks done above will hold
* good when we eventually get them back as writer.
* So if we can't upgrade we drop the locks and retry
* everything again.
*/
goto retry;
}
/*
* The upgrade failed. We got to give away the lock
* as to avoid deadlocking with someone else who is
* waiting for writer lock. With the lock gone, we
* cannot be sure the checks done above will hold
* good when we eventually get them back as writer.
* So if we can't upgrade we drop the locks and retry
* everything again.
*/
goto retry;
}
}
/*
* Now that all the locks are held check to make sure another thread
* didn't slip in and take out the sip.
*/
if (error) {
goto errout;
}
goto errout;
} else {
/*
* If the inode was found need to drop the v_count
* so as not to keep the filesystem from being
* unmounted at a later time.
*/
}
/*
* Release the slot.fbp that has the page mapped and
* locked SE_SHARED, and could be used in in
* ufs_direnter_lr() which needs to get the SE_EXCL lock
* on said page.
*/
}
}
/*
* Link source to the target.
*/
/*
* ESAME isn't really an error; it indicates that the
* operation should not be done because the source and target
* are the same file, but that no error should be reported.
*/
error = 0;
goto errout;
}
/*
* Unlink the source.
* Remove the source entry. ufs_dirremove() checks that the entry
* still reflects sip, and returns an error if it doesn't.
* If the entry has changed just forget about it. Release
* the source inode.
*/
error = 0;
}
if (ulp) {
}
out:
return (error);
}
/*ARGSUSED*/
static int
{
int error;
int issync;
int trans_size;
int indeadlock;
int retry = 1;
/*
* Can't make directory in attr hidden dir
*/
return (EINVAL);
if (error)
goto out;
if (ulp)
/*
* ufs_tryirwlock_trans uses rw_tryenter and checks for SLOCK
* to avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock)
goto again;
if (ulp) {
}
goto again;
}
if (error == 0) {
if (ulp) {
int terr = 0;
if (error == 0)
}
out:
retry = 0;
goto again;
}
return (error);
}
/*ARGSUSED*/
static int
{
int error;
int issync;
int trans_size;
int indeadlock;
/*
* don't let the delete queue get too long
*/
goto out;
}
/* Only send the event if there were no errors */
if (error == 0)
}
if (error)
goto out;
if (ulp)
/*
* ufs_tryirwlock_trans uses rw_tryenter and checks for SLOCK
* to avoid i_rwlock, ufs_lockfs_begin deadlock. If deadlock
* possible, retries the operation.
*/
if (indeadlock)
goto retry_rmdir;
if (ulp) {
}
out:
return (error);
}
/* ARGSUSED */
static int
int *eofp,
int flags)
{
int incount = 0;
int outcount = 0;
int error;
if (eofp)
*eofp = 1;
return (0);
}
/*
* Check if we have been called with a valid iov_len
* and bail out if not, otherwise we may potentially loop
* forever further down.
*/
goto out;
}
/*
* Large Files: When we come here we are guaranteed that
* uio_offset can be used safely. The high word is zero.
*/
if (error)
goto out;
/* Large Files: directory files should not be "large" */
/* Force offset to be valid (to guard against bogus lseek() values) */
/* Quit if at end of file or link count of zero (posix) */
if (eofp)
*eofp = 1;
error = 0;
goto unlock;
}
/*
* Get space to change directory entries into fs independent format.
* Do fast alloc for the most commonly used-request size (filesystem
* block size).
*/
} else {
}
/* Truncate request to file size */
/* Comply with MAXBSIZE boundary restrictions of fbread() */
/*
* Read in the next chunk.
* We are still holding the i_rwlock.
*/
if (error)
goto update_inode;
(!ufsvfsp->vfs_noatime)) {
}
incount = 0;
"fs = %s\n",
goto update_inode;
}
/* Transform to file-system independent format */
while (incount < bytes_wanted) {
/*
* If the current directory entry is mangled, then skip
* to the next block. It would be nice to set the FSBAD
* flag in the super-block so that a fsck is forced on
* next reboot, but locking is a problem.
*/
break;
}
/* Skip to requested offset and skip empty entries */
/* Buffer too small for any entries */
goto update_inode;
}
/* If would overrun the buffer, quit */
break;
}
/* Take this entry */
/* use strncpy(9f) to zero out uninitialized bytes */
}
} else {
break;
}
}
/* Release the chunk */
/* Read whole block, but got no entries, read another if not eof */
/*
* Large Files: casting i_size to int here is not a problem
* because directory sizes are always less than MAXOFF32_T.
* See assertion above.
*/
goto nextblk;
/* Copy out the entry data */
uiop)) == 0)
if (ulp) {
}
out:
return (error);
}
/*ARGSUSED*/
static int
char *linkname, /* name of symbolic link */
char *target, /* target path */
int flags)
{
int error;
int issync;
int trans_size;
int residual;
int ioflag;
int retry = 1;
/*
* No symlinks in attrdirs at this time
*/
return (EINVAL);
if (error)
goto out;
if (ulp)
/*
* We must create the inode before the directory entry, to avoid
* racing with readlink(). ufs_dirmakeinode requires that we
* hold the quota lock as reader, and directory locks as writer.
*/
/*
* Suppress any out of inodes messages if we will retry on
* ENOSP
*/
if (retry)
if (error)
goto unlock;
/*
* OK. The inode has been created. Write out the data of the
* symbolic link. Since symbolic links are metadata, and should
* remain consistent across a system crash, we need to force the
* data out synchronously.
*
* (This is a change from the semantics in earlier releases, which
* only created symbolic links synchronously if the semi-documented
* 'syncdir' option was set, or if we were being invoked by the NFS
* server, which requires symbolic links to be created synchronously.)
*
* We need to pass in a pointer for the residual length; otherwise
* ufs_rdwri() will always return EIO if it can't write the data,
* even if the error was really ENOSPC or EDQUOT.
*/
residual = 0;
/*
* Suppress file system full messages if we will retry
*/
if (retry)
if (error) {
goto remove;
}
/*
* If the link's data is small enough, we can cache it in the inode.
* This is a "fast symbolic link". We don't use the first direct
* block because that's actually used to point at the symbolic link's
* contents on disk; but we know that none of the other direct or
* indirect blocks can be used because symbolic links are restricted
* to be smaller than a file system block.
*/
} else {
int i;
/* error, clear garbage left behind */
for (i = 1; i < NDADDR; i++)
for (i = 0; i < NIADDR; i++)
}
}
/*
* OK. We've successfully created the symbolic link. All that
* remains is to insert it into the appropriate directory.
*/
/*
* Fall through into remove-on-error code. We're either done, or we
* need to remove the inode (if we couldn't insert it).
*/
}
if (ulp) {
int terr = 0;
if (error == 0)
}
/*
* We may have failed due to lack of an inode or of a block to
* store the target in. Try flushing the delete queue to free
* logically-available things up and try again.
*/
retry = 0;
goto again;
}
out:
return (error);
}
/*
* Ufs specific routine used to do ufs io.
*/
int
{
int error;
} else {
}
if (aresid) {
}
return (error);
}
/*ARGSUSED*/
static int
{
return (EIO);
return (ENOSPC);
}
return (0);
}
/* ARGSUSED2 */
static int
{
int forcedirectio;
/*
* Read case is easy.
*/
if (!write_lock) {
return (V_WRITELOCK_FALSE);
}
/*
* Caller has requested a writer lock, but that inhibits any
* concurrency in the VOPs that follow. Acquire the lock shared
* and defer exclusive access until it is known to be needed in
* other VOP handlers. Some cases can be determined here.
*/
/*
* If directio is not set, there is no chance of concurrency,
* so just acquire the lock exclusive. Beware of a forced
* unmount before looking at the mount option.
*/
return (V_WRITELOCK_TRUE);
}
/*
* Mandatory locking forces acquiring i_rwlock exclusive.
*/
return (V_WRITELOCK_TRUE);
}
/*
* Acquire the lock shared in case a concurrent write follows.
* Mandatory locking could have become enabled before the lock
* was acquired. Re-check and upgrade if needed.
*/
return (V_WRITELOCK_TRUE);
}
return (V_WRITELOCK_FALSE);
}
/*ARGSUSED*/
static void
{
}
/* ARGSUSED */
static int
{
}
/* ARGSUSED */
static int
{
return (EIO);
/*
* If file is being mapped, disallow frlock.
* XXX I am not holding tlock while checking i_mapcnt because the
* current locking strategy drops all locks before calling fs_frlock.
* So, mapcnt could change before we enter fs_frlock making is
* meaningless to have held tlock in the first place.
*/
return (EAGAIN);
}
/* ARGSUSED */
static int
{
int error;
if (error)
return (error);
if (error)
return (error);
} else
return (EINVAL); /* Command not handled here */
if (ulp)
}
return (error);
}
/*
* Used to determine if read ahead should be done. Also used to
* to determine when write back occurs.
*/
/*
* A faster version of ufs_getpage.
*
* We optimize by inlining the pvn_getpages iterator, eliminating
* calls to bmap_read if file doesn't have UFS holes, and avoiding
* the overhead of page_exists().
*
* When files has UFS_HOLES and ufs_getpage is called with S_READ,
* we set *protp to PROT_READ to avoid calling bmap_read. This approach
* victimizes performance when a file with UFS holes is faulted
* first in the S_READ mode, and then in the S_WRITE mode. We will get
* two MMU faults in this case.
*
* XXX - the inode fields which control the sequential mode are not
* protected by any mutex. The read ahead will act wild if
* multiple processes will access the file concurrently and
* some of them in sequential mode. One particulary bad case
* is if another thread will change the value of i_nextrio between
* the time this thread tests the i_nextrio value and then reads it
* again to use it as the offset for the read ahead.
*/
/*ARGSUSED*/
static int
{
int err;
int has_holes;
int beyond_eof;
int seqmode;
int dolock;
int do_qlock;
int trans_size;
if (protp)
/*
* Obey the lockfs protocol
*/
if (err)
goto out;
/*
* Try to start a transaction, will return if blocking is
* expected to occur and the address space is not the
* kernel address space.
*/
if (err == EWOULDBLOCK) {
/*
* Use EDEADLK here because the VM code
* can normally never see this error.
*/
goto out;
}
} else {
}
}
goto unlock;
}
/*
* If this thread owns the lock, i.e., this thread grabbed it
* as writer somewhere above, then we don't need to grab the
* lock as reader in this routine.
*/
if (dolock) {
/*
* Grab the quota lock if we need to call
* bmap_write() below (with i_contents as writer).
*/
}
/*
* We may be getting called as a side effect of a bmap using
* fbread() when the blocks might be being allocated and the
* size has not yet been up'ed. In this case we want to be
* able to return zero pages if we get back UFS_HOLE from
* calling bmap for a non write case here. We also might have
* to read some frags from the disk into a page if we are
* extending the number of frags for a given lbn in bmap().
* Large Files: The read of i_size here is atomic because
* i_contents is held here. If dolock is zero, the lock
* is held in bmap routines.
*/
if (dolock) {
}
goto unlock;
}
/*
* Must hold i_contents lock throughout the call to pvn_getpages
* since locked pages are returned from each call to ufs_getapage.
* Must *not* return locked pages and then try for contents lock
* due to lock ordering requirements (inode > page)
*/
int blk_size;
/*
* We must acquire the RW_WRITER lock in order to
* call bmap_write().
*/
/*
* Grab the quota lock before
* upgrading i_contents, but if we can't grab it
* don't wait here due to lock order:
* vfs_dqrwlock > i_contents.
*/
if (do_qlock &&
== 0) {
goto retrylock;
}
if (do_qlock)
goto retrylock;
}
}
/*
* May be allocating disk blocks for holes here as
* a result of mmap faults. write(2) does the bmap_write
* in this case.
*/
/*
* Large Files: We cast fs_bmask field to offset_t
* just as we do for MAXBMASK because uoff is a 64-bit
* data type. fs_bmask will still be a 32-bit type
* as we cannot change any ondisk data structures.
*/
if (err)
goto update_inode;
}
}
/*
* Can be a reader from now on.
*/
/*
* We can release vfs_dqrwlock early so do it, but make
* sure we don't try to release it again at the bottom.
*/
if (do_qlock) {
do_qlock = 0;
}
}
/*
* We remove PROT_WRITE in cases when the file has UFS holes
* because we don't want to call bmap_read() to check each
* page if it is backed with a disk block.
*/
*protp &= ~PROT_WRITE;
err = 0;
/*
* The loop looks up pages in the range [off, off + len).
* For each page, we first check if we should initiate an asynchronous
* read ahead before we call page_lookup (we may sleep in page_lookup
* for a previously initiated disk read).
*/
int retval;
/* Handle async getpage (faultahead) */
continue;
}
/*
* Check if we should initiate read ahead of next cluster.
* We call page_exists only when we need to confirm that
* we have the current page before we initiate the read ahead.
*/
if (seqmode &&
/*
* We always read ahead the next cluster of data
* starting from i_nextrio. If the page (vp,nextrio)
* is actually in core at this point, the routine
* ufs_getpage_ra() will stop pre-fetching data
* until we read that page in a synchronized manner
* through ufs_getpage_miss(). So, we should increase
* i_nextrio if the page (vp, nextrio) exists.
*/
}
}
/*
* We found the page in the page cache.
*/
} else {
/*
* We have to create the page, or read it from disk.
*/
goto error;
pl++;
}
}
}
/*
* Return pages up to plsz if they are in the page cache.
* We cannot return pages if there is a chance that they are
* backed with a UFS hole and rw is S_WRITE or S_CREATE.
*/
break;
}
}
if (plarr)
/*
* Release any pages we have locked.
*/
page_unlock(*--pl);
}
/*
* If the inode is not already marked for IACC (in rdip() for read)
* and the inode is not marked for no access time update (in wrip()
* for write) then update the inode access time and mod time now.
*/
(!ufsvfsp->vfs_noatime)) {
}
}
}
if (dolock) {
}
if (ulp) {
}
}
out:
return (err);
}
/*
* ufs_getpage_miss is called when ufs_getpage missed the page in the page
* cache. The page is either read from the disk, or it's created.
* A page is created (without disk read) if rw == S_CREATE, or if
* the page is not backed with a real disk block (UFS hole).
*/
/* ARGSUSED */
static int
{
int crpage = 0;
int err;
int contig;
/*
* Figure out whether the page can be created, or must be
* must be read from the disk.
*/
crpage = 1;
else {
contig = 0;
return (err);
/*
* If its also a fallocated block that hasn't been written to
* yet, we will treat it just like a UFS_HOLE and create
* a zero page for it
*/
crpage = 1;
}
if (crpage) {
"ufs_getpage_miss: page_create == NULL"));
}
} else {
/*
* If access is not in sequential order, we read from disk
* in bsize units.
*
* We limit the size of the transfer to bsize if we are reading
* from the beginning of the file. Note in this situation we
* will hedge our bets and initiate an async read ahead of
* the second block.
*/
/*
* Some other thread has entered the page.
* ufs_getpage will retry page_lookup.
*/
return (0);
}
/*
* Zero part of the page which we are not
* going to read from the disk.
*/
if (xlen != 0)
} else if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
/*
* If the file access is sequential, initiate read ahead
* of the next cluster.
*/
if (err) {
return (err);
}
}
return (0);
}
/*
* Read ahead a cluster from the disk. Returns the length in bytes.
*/
static int
{
int err;
int contig;
int xlen;
/*
* If the directio advisory is in effect on this file,
* then do not do buffered read ahead. Read ahead makes
* it more difficult on threads using directio as they
* will be forced to flush the pages from this vnode.
*/
return (0);
return (0);
/*
* Is this test needed?
*/
return (0);
contig = 0;
/*
* If its a UFS_HOLE or a fallocated block, do not perform
* any read ahead's since there probably is nothing to read ahead
*/
return (0);
/*
* Limit the transfer size to bsize if this is the 2nd block.
*/
return (0);
/*
* Zero part of page which we are not going to read from disk
*/
} else if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
return (io_len);
}
int ufs_delay = 1;
/*
* Flags are composed of {B_INVAL, B_FREE, B_DONTNEED, B_FORCE, B_ASYNC}
*
* LMXXX - the inode really ought to contain a pointer to one of these
* async args. Stuff gunk in there and just hand the whole mess off.
* This would replace i_delaylen, i_delayoff.
*/
/*ARGSUSED*/
static int
{
int err = 0;
}
/*
* XXX - Why should this check be made here?
*/
goto errout;
}
goto errout;
}
/*
* If nobody stalled, start a new cluster.
*/
if (ip->i_delaylen == 0) {
goto errout;
}
/*
* If we have a full cluster or they are not contig,
* then push last cluster and start over.
*/
/* LMXXX - flags are new val, not old */
goto errout;
}
/*
* There is something there, it's not full, and
* it is contig.
*/
goto errout;
}
/*
* Must have weird flags or we are not clustering.
*/
}
return (err);
}
/*
* If len == 0, do from off to EOF.
*
* The normal cases should be len == 0 & off == 0 (entire vp list),
* len == MAXBSIZE (from segmap_release actions), and len == PAGESIZE
* (from pageout).
*/
/*ARGSUSED*/
static int
int flags,
{
int err = 0;
int dolock;
/*
* any pages in this inode.
* The inode lock is held during i/o.
*/
if (len == 0) {
}
if (dolock) {
/*
* Must synchronize this thread and any possible thread
* operating in the window of vulnerability in wrip().
* It is dangerous to allow both a thread doing a putpage
* and a thread writing, so serialize them. The exception
* is when the thread in wrip() does something which causes
* a putpage operation. Then, the thread must be allowed
* to continue. It may encounter a bmap_read problem in
* ufs_putapage, but that is handled in ufs_putapage.
* Allow async writers to proceed, we don't want to block
* the pageout daemon.
*/
else {
for (;;) {
/*
* If there is no thread in the critical
* section of wrip(), then proceed.
* Otherwise, wait until there isn't one.
*/
break;
}
/*
* Bounce async writers when we have a writer
* working on this file so we don't deadlock
* the pageout daemon.
*/
return (0);
}
}
}
}
if (!vn_has_cached_data(vp)) {
if (dolock)
return (0);
}
if (len == 0) {
/*
* Search the entire vp list for pages >= off.
*/
} else {
/*
* Loop over all offsets in the range looking for
* pages to deal with.
*/
else
/*
* If we are not invalidating, synchronously
* freeing or writing pages, use the routine
* page_lookup_nowait() to prevent reclaiming
* them from the free list.
*/
} else {
}
else {
if (err != 0)
break;
/*
* "io_off" and "io_len" are returned as
* the range of pages we actually wrote.
* This allows us to skip ahead more quickly
* since several pages may've been dealt
* with by this iteration of the loop.
*/
}
}
}
/*
* We have just sync'ed back all the pages on
* the inode, turn off the IMODTIME flag.
*/
}
if (dolock)
return (err);
}
static void
{
if (ufs_WRITES)
} else {
}
}
/*
* Write out a single page, possibly klustering adjacent
* dirty pages. The inode lock must be held.
*
* LMXXX - bsize < pagesize not done.
*/
/*ARGSUSED*/
int
int flags,
{
int err;
int contig;
int dotrans;
goto out_trace;
}
/*
* If the modified time on the inode has not already been
* This gives us approximate modified times for mmap'ed files
* which are modified via stores in the user address space.
*/
}
/*
* Align the request to a block boundry (for old file systems),
* and go ask bmap() how contiguous things are for this file.
*/
contig = 0;
if (err)
goto out;
/*
* logging device is in error mode; simply return EIO
*/
if (TRANS_ISERROR(ufsvfsp)) {
goto out;
}
/*
* Oops, the thread in the window in wrip() did some
* sort of operation which caused a putpage in the bad
* range. In this case, just return an error which will
* cause the software modified bit on the page to set
* and the page will get written out again later.
*/
goto out;
}
/*
* If the pager is trying to push a page in the bad range
* just tell him to try again later when things are better.
*/
goto out;
}
goto out;
}
/*
* If it is an fallocate'd block, reverse the negativity since
* we are now writing to it
*/
if (err)
goto out;
}
/*
* Take the length (of contiguous bytes) passed back from bmap()
* and _try_ and get a set of pages covering that extent.
*/
/*
* May have run out of memory and not clustered backwards.
* off p_offset
* [ pp - 1 ][ pp ]
* [ block ]
* We told bmap off, so we have to adjust the bn accordingly.
*/
}
/*
* bmap was carefull to tell us the right size so use that.
* There might be unallocated frags at the end.
* LMXXX - bzero the end of the page? We must be writing after EOF.
*/
}
/*
* Handle the case where we are writing the last page after EOF.
*
* XXX - just a patch for i-mt3.
*/
if (io_len == 0) {
}
/*
* File contents of shadow or quota inodes are metadata, and updates
* to these need to be put into a logging transaction. All direct
* callers in UFS do that, but fsflush can come here _before_ the
* normal codepath. An example would be updating ACL information, for
* which the normal codepath would be:
* ufs_si_store()
* ufs_rdwri()
* wrip()
* segmap_release()
* VOP_PUTPAGE()
* Here, fsflush can pick up the dirty page before segmap_release()
* forces it out. If that happens, there's no transaction.
* We therefore need to test whether a transaction exists, and if not
* create one - for fsflush.
*/
dotrans =
(TRANS_ISTRANS(ufsvfsp)));
if (dotrans) {
}
if (TRANS_ISTRANS(ufsvfsp)) {
0, 0);
}
}
if (dotrans) {
}
/* write throttle */
} else if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
} else {
} else if (ufsvfsp->vfs_snapshot) {
} else {
(void) bdev_strategy(bp);
}
}
out:
if (offp)
if (lenp)
return (err);
}
/* ARGSUSED */
static int
{
struct segvn_crargs vn_a;
goto out;
}
goto out;
}
goto out;
}
/*
* If file is being locked, disallow mapping.
*/
goto out;
}
/*
* Note that if we are retrying (because ufs_lockfs_trybegin failed in
* the previous attempt), some other thread could have grabbed
* the same VA range if MAP_FIXED is set. In that case, choose_addr
* would unmap the valid VA range, that is ok.
*/
if (error != 0) {
goto out;
}
/*
* a_lock has to be acquired before entering the lockfs protocol
* because that is the order in which pagefault works. Also we cannot
* block on a_lock here because this waiting writer will prevent
* further readers like ufs_read from progressing and could cause
* pending.
*/
}
/*
* We can't hold as->a_lock and wait for lockfs to succeed because
* the proc tools might hang on a_lock, so call ufs_lockfs_trybegin()
* instead.
*/
/*
* ufs_lockfs_trybegin() did not succeed. It is safer to give up
* as->a_lock and wait for ulp->ul_fs_lock status to change.
*/
goto out;
} else {
return (EINTR);
}
}
}
goto retry_map;
}
if (ulp)
out:
return (error);
}
/* ARGSUSED */
static int
{
return (ENOSYS);
}
return (0);
}
/*ARGSUSED*/
static int
{
return (ENOSYS);
}
return (0);
}
/*
* Return the answer requested to poll() for non-device files
*/
struct pollhead ufs_pollhd;
/* ARGSUSED */
int
{
*revp = 0;
if (!ufsvfsp) {
goto out;
}
} else {
*revp |= POLLWRBAND;
if (ev & POLLRDNORM)
*revp |= POLLRDNORM;
if (ev & POLLRDBAND)
*revp |= POLLRDBAND;
}
out:
return (0);
}
/* ARGSUSED */
static int
{
int error;
int issync;
if (error)
return (error);
switch (cmd) {
/*
* Have to handle _PC_NAME_MAX here, because the normal way
* [fs_pathconf() -> VOP_STATVFS() -> ufs_statvfs()]
* results in a lock ordering reversal between
* ufs_lockfs_{begin,end}() and
* ufs_thread_{suspend,continue}().
*
* Keep in sync with ufs_statvfs().
*/
case _PC_NAME_MAX:
break;
case _PC_FILESIZEBITS:
else
*valp = 32;
break;
case _PC_XATTR_EXISTS:
error =
/* Start transaction */
if (ulp) {
}
/*
* Is directory empty
*/
if (ufs_xattrdirempty(sip,
*valp = 0;
} else
*valp = 1;
if (ulp) {
}
*valp = 0;
error = 0;
}
} else {
}
break;
case _PC_ACL_ENABLED:
break;
case _PC_MIN_HOLE_SIZE:
break;
case _PC_SATTR_ENABLED:
case _PC_SATTR_EXISTS:
break;
case _PC_TIMESTAMP_RESOLUTION:
/*
* UFS keeps only microsecond timestamp resolution.
* This is historical and will probably never change.
*/
*valp = 1000L;
break;
default:
break;
}
}
return (error);
}
/*ARGSUSED*/
static int
{
int err = 0;
int contig = 0;
int dolock;
int vmpss = 0;
vmpss = 1;
}
/*
* We need a better check. Ideally, we would use another
* vnodeops so that hlocked and forcibly unmounted file
* systems would return EIO where appropriate and w/o the
* need for these checks.
*/
return (EIO);
/*
* For vmpss (pp can be NULL) case respect the quiesce protocol.
* ul_lock must be taken before locking pages so we can't use it here
* if pp is non NULL because segvn already locked pages
* SE_EXCL. Instead we rely on the fact that a forced umount or
* applying a filesystem lock via ufs_fiolfs() will block in the
* implicit call to ufs_flush() until we unlock the pages after the
* return to segvn. Other ufs_quiesce() callers keep ufs_quiesce_pend
* above 0 until they are done. We have to be careful not to increment
* ul_vnops_cnt here after forceful unmount hlocks the file system.
*
* If pp is NULL use ul_lock to make sure we don't increment
* ul_vnops_cnt after forceful unmount hlocks the file system.
*/
}
}
if (ufs_quiesce_pend) {
}
}
if (dolock) {
/*
* segvn may call VOP_PAGEIO() instead of VOP_GETPAGE() to
* handle a fault against a segment that maps vnode pages with
* large mappings. Segvn creates pages and holds them locked
* SE_EXCL during VOP_PAGEIO() call. In this case we have to
* use rw_tryenter() to avoid a potential deadlock since in
* lock order i_contents needs to be taken first.
* Segvn will retry via VOP_GETPAGE() if VOP_PAGEIO() fails.
*/
if (!vmpss) {
return (EDEADLK);
}
}
/*
* Return an error to segvn because the pagefault request is beyond
* PAGESIZE rounded EOF.
*/
if (dolock)
return (EFAULT);
}
if (bmap_has_holes(ip)) {
} else {
}
if (dolock)
return (err);
}
/*
* Break the io request into chunks, one for each contiguous
* stretch of disk blocks in the target file.
*/
contig = 0;
break;
if (vmpss) {
break;
}
break;
}
/*
* Zero out a page beyond EOF, when the last block of
* a file is a UFS fragment so that ufs_pageio() can be used
* instead of ufs_getpage() to handle faults against
* segvn segments that use large pages.
*/
}
if (ufsvfsp->vfs_snapshot)
else
(void) bdev_strategy(bp);
else
else
/*
* If the request is not B_ASYNC, wait for i/o to complete
* and re-assemble the page list to return to the caller.
* If it is B_ASYNC we leave the page list in pieces and
* cleanup() will dispose of them.
*/
if (err)
break;
}
}
if (err) {
/* Cleanup unprocessed parts of list */
else
} else {
/* Re-assemble list and let caller clean up */
}
}
}
if (dolock)
return (err);
}
/*
* Called when the kernel is in a frozen state to dump data
* directly to the device. It uses a private dump data structure,
* set up by dump_ctl, to locate the correct disk block to which to dump.
*/
/*ARGSUSED*/
static int
{
int error = 0;
/*
* forced unmount case
*/
return (EIO);
/*
* Validate the inode that it has not been modified since
* the dump structure is allocated.
*/
return (-1);
}
/*
* See that the file has room for this write
*/
return (ENOSPC);
/*
* Find the physical disk block numbers from the dump
* private data structure directly and write out the data
* in contiguous block lumps
*/
nfsbs = 1;
nfsbs++;
}
}
return (error);
}
/*
* Prepare the file system before and after the dump operation.
*
* action = DUMP_ALLOC:
* Preparation before dump, allocate dump private data structure
* to hold all the direct and indirect block info for dump.
*
* action = DUMP_FREE:
* Clean up after dump, deallocate the dump private data structure.
*
* action = DUMP_SCAN:
* Scan dump_info for *blkp DEV_BSIZE blocks of contig fs space;
* if found, the starting file-relative DEV_BSIZE lbn is written
* to *bklp; that lbn is intended for use with VOP_DUMP()
*/
/*ARGSUSED*/
static int
{
int n, ncontig;
/*
* check for forced unmount
*/
return (EIO);
if (action == DUMP_ALLOC) {
/*
* alloc and record dump_info
*/
return (EINVAL);
if (bmap_has_holes(ip)) {
return (EFAULT);
}
/*
* calculate and allocate space needed according to i_size
*/
return (ENOMEM);
}
/* Start saving the info */
/* Direct Blocks */
/* Indirect Blocks */
for (i = 0; i < NIADDR; i++) {
int error = 0;
else {
}
if (error != 0) {
return (error);
}
}
/* and time stamp the information */
/*
* free dump_info
*/
return (EINVAL);
/*
* scan dump_info
*/
return (EINVAL);
/*
* scan dblk[] entries; contig fs space is found when:
* ((current blkno + frags per block) == next blkno)
*/
n = 0;
n++;
else
n = 0;
dblk++;
nextblk++;
}
/*
* index is where size bytes of contig space begins;
* conversion from index to the file's DEV_BSIZE lbn
* is equivalent to: (index * fs_bsize) / DEV_BSIZE
*/
if (n == ncontig) {
} else
return (EFAULT);
}
return (0);
}
/*
* Recursive helper function for ufs_dumpctl(). It follows the indirect file
* system blocks until it reaches the the disk block addresses, which are
* then stored into the given buffer, storeblk.
*/
static daddr32_t *
{
int i;
if (level == 0) {
break;
}
return (storeblk);
}
break;
return (NULL);
}
return (NULL);
}
return (storeblk);
}
/* ARGSUSED */
static int
{
/*
* Only grab locks if needed - they're not needed to check vsa_mask
* or if the mask contains no acl flags.
*/
if (vsa_mask != 0) {
return (err);
if (ulp)
}
return (err);
}
/* ARGSUSED */
static int
{
int err;
int haverwlock = 1;
int trans_size;
int donetrans = 0;
int retry = 1;
/* Abort now if the request is either empty or invalid. */
if ((vsa_mask == 0) ||
goto out;
}
/*
* Following convention, if this is a directory then we acquire the
* inode's i_rwlock after starting a UFS logging transaction;
* otherwise, we acquire it beforehand. Since we were called (and
* must therefore return) with the lock held, we will have to drop it,
* and later reacquire it, if operating on a directory.
*/
haverwlock = 0;
} else {
/* Upgrade the lock if required. */
}
}
retry = 0;
goto out;
}
/*
* Check that the file system supports this operation. Note that
* ufs_lockfs_begin() will have checked that the file system had
* not been forcibly unmounted.
*/
goto out;
}
if (ufsvfsp->vfs_nosetsec) {
goto out;
}
if (ulp) {
donetrans = 1;
}
haverwlock = 1;
}
/* Do the actual work. */
/*
* Suppress out of inodes messages if we will retry.
*/
if (retry)
out:
if (ulp) {
if (donetrans) {
/*
* top_end_async() can eventually call
* top_end_sync(), which can block. We must
* therefore observe the lock-ordering protocol
* here as well.
*/
haverwlock = 0;
}
}
}
/*
* If no inodes available, try scaring a logically-
* free one out of the delete queue to someplace
* that we can find it.
*/
retry = 0;
haverwlock = 0;
}
goto again;
}
/*
* If we need to reacquire the lock then it is safe to do so
* as a reader. This is because ufs_rwunlock(), which will be
* called by our caller after we return, does not differentiate
* between shared and exclusive locks.
*/
if (!haverwlock) {
}
return (err);
}
/*
* Locate the vnode to be used for an event notification. As this will
* be called prior to the name space change perform basic verification
* that the change will be allowed.
*/
static int
{
int namlen;
int error;
return (EINVAL);
if (nm[0] == '.') {
if (namlen == 1)
return (EINVAL);
return (EEXIST);
}
}
/*
* Check accessibility and write access of parent directory as we
* only want to post the event if we're able to make a change.
*/
return (error);
if (vp == DNLC_NO_VNODE) {
return (ENOENT);
}
return (0);
}
/*
* Keep the idle queue from getting too long by idling two
* inodes before attempting to allocate another.
* This operation must be performed before entering lockfs
* or a transaction.
*/
}
return (error);
}
if (ulp) {
}
goto retry_lookup;
return (error);
}