Changeset View
Changeset View
Standalone View
Standalone View
head/sys/ufs/ffs/ffs_softdep.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
#include <ufs/ffs/ffs_extern.h> | #include <ufs/ffs/ffs_extern.h> | ||||
#include <ufs/ufs/ufs_extern.h> | #include <ufs/ufs/ufs_extern.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/vm_object.h> | #include <vm/vm_object.h> | ||||
#include <geom/geom.h> | #include <geom/geom.h> | ||||
#include <geom/geom_vfs.h> | |||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#define KTR_SUJ 0 /* Define to KTR_SPARE. */ | #define KTR_SUJ 0 /* Define to KTR_SPARE. */ | ||||
#ifndef SOFTUPDATES | #ifndef SOFTUPDATES | ||||
int | int | ||||
▲ Show 20 Lines • Show All 1,349 Lines • ▼ Show 20 Lines | worklist_speedup(mp) | ||||
ump = VFSTOUFS(mp); | ump = VFSTOUFS(mp); | ||||
LOCK_OWNED(ump); | LOCK_OWNED(ump); | ||||
if ((ump->softdep_flags & (FLUSH_CLEANUP | FLUSH_EXIT)) == 0) | if ((ump->softdep_flags & (FLUSH_CLEANUP | FLUSH_EXIT)) == 0) | ||||
ump->softdep_flags |= FLUSH_CLEANUP; | ump->softdep_flags |= FLUSH_CLEANUP; | ||||
wakeup(&ump->softdep_flushtd); | wakeup(&ump->softdep_flushtd); | ||||
} | } | ||||
static void | |||||
softdep_send_speedup(struct ufsmount *ump, size_t shortage, u_int flags) | |||||
{ | |||||
struct buf *bp; | |||||
bp = malloc(sizeof(*bp), M_TRIM, M_WAITOK | M_ZERO); | |||||
bp->b_iocmd = BIO_SPEEDUP; | |||||
bp->b_ioflags = flags; | |||||
bp->b_bcount = shortage; | |||||
g_vfs_strategy(ump->um_bo, bp); | |||||
bufwait(bp); | |||||
free(bp, M_TRIM); | |||||
} | |||||
static int | static int | ||||
softdep_speedup(ump) | softdep_speedup(ump) | ||||
struct ufsmount *ump; | struct ufsmount *ump; | ||||
{ | { | ||||
struct ufsmount *altump; | struct ufsmount *altump; | ||||
struct mount_softdeps *sdp; | struct mount_softdeps *sdp; | ||||
LOCK_OWNED(ump); | LOCK_OWNED(ump); | ||||
▲ Show 20 Lines • Show All 11,896 Lines • ▼ Show 20 Lines | softdep_request_cleanup(fs, vp, cred, resource) | ||||
struct fs *fs; | struct fs *fs; | ||||
struct vnode *vp; | struct vnode *vp; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
int resource; | int resource; | ||||
{ | { | ||||
struct ufsmount *ump; | struct ufsmount *ump; | ||||
struct mount *mp; | struct mount *mp; | ||||
long starttime; | long starttime; | ||||
size_t resid; | |||||
ufs2_daddr_t needed; | ufs2_daddr_t needed; | ||||
int error, failed_vnode; | int error, failed_vnode; | ||||
/* | /* | ||||
* If we are being called because of a process doing a | * If we are being called because of a process doing a | ||||
* copy-on-write, then it is not safe to process any | * copy-on-write, then it is not safe to process any | ||||
* worklist items as we will recurse into the copyonwrite | * worklist items as we will recurse into the copyonwrite | ||||
* routine. This will result in an incoherent snapshot. | * routine. This will result in an incoherent snapshot. | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | printf("softdep_request_cleanup: Unknown resource type %d\n", | ||||
resource); | resource); | ||||
UFS_LOCK(ump); | UFS_LOCK(ump); | ||||
return (0); | return (0); | ||||
} | } | ||||
starttime = time_second; | starttime = time_second; | ||||
retry: | retry: | ||||
if (resource == FLUSH_BLOCKS_WAIT && | if (resource == FLUSH_BLOCKS_WAIT && | ||||
fs->fs_cstotal.cs_nbfree <= needed) | fs->fs_cstotal.cs_nbfree <= needed) | ||||
g_io_speedup(needed * fs->fs_bsize, BIO_SPEEDUP_TRIM, &resid, | softdep_send_speedup(ump, needed * fs->fs_bsize, | ||||
ump->um_cp); | BIO_SPEEDUP_TRIM); | ||||
if ((resource == FLUSH_BLOCKS_WAIT && ump->softdep_on_worklist > 0 && | if ((resource == FLUSH_BLOCKS_WAIT && ump->softdep_on_worklist > 0 && | ||||
fs->fs_cstotal.cs_nbfree <= needed) || | fs->fs_cstotal.cs_nbfree <= needed) || | ||||
(resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 && | (resource == FLUSH_INODES_WAIT && fs->fs_pendinginodes > 0 && | ||||
fs->fs_cstotal.cs_nifree <= needed)) { | fs->fs_cstotal.cs_nifree <= needed)) { | ||||
ACQUIRE_LOCK(ump); | ACQUIRE_LOCK(ump); | ||||
if (ump->softdep_on_worklist > 0 && | if (ump->softdep_on_worklist > 0 && | ||||
process_worklist_item(UFSTOVFS(ump), | process_worklist_item(UFSTOVFS(ump), | ||||
ump->softdep_on_worklist, LK_NOWAIT) != 0) | ump->softdep_on_worklist, LK_NOWAIT) != 0) | ||||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* If requested, try removing inode or removal dependencies. | * If requested, try removing inode or removal dependencies. | ||||
*/ | */ | ||||
static void | static void | ||||
check_clear_deps(mp) | check_clear_deps(mp) | ||||
struct mount *mp; | struct mount *mp; | ||||
{ | { | ||||
struct ufsmount *ump; | struct ufsmount *ump; | ||||
size_t resid; | |||||
/* | /* | ||||
* Tell the lower layers that any TRIM or WRITE transactions | * Tell the lower layers that any TRIM or WRITE transactions | ||||
* that have been delayed for performance reasons should | * that have been delayed for performance reasons should | ||||
* proceed to help alleviate the shortage faster. | * proceed to help alleviate the shortage faster. | ||||
*/ | */ | ||||
ump = VFSTOUFS(mp); | ump = VFSTOUFS(mp); | ||||
FREE_LOCK(ump); | FREE_LOCK(ump); | ||||
g_io_speedup(0, BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE, &resid, ump->um_cp); | softdep_send_speedup(ump, 0, BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE); | ||||
ACQUIRE_LOCK(ump); | ACQUIRE_LOCK(ump); | ||||
/* | /* | ||||
* If we are suspended, it may be because of our using | * If we are suspended, it may be because of our using | ||||
* too many inodedeps, so help clear them out. | * too many inodedeps, so help clear them out. | ||||
*/ | */ | ||||
if (MOUNTEDSUJ(mp) && VFSTOUFS(mp)->softdep_jblocks->jb_suspended) | if (MOUNTEDSUJ(mp) && VFSTOUFS(mp)->softdep_jblocks->jb_suspended) | ||||
▲ Show 20 Lines • Show All 948 Lines • Show Last 20 Lines |